Browse Source

ckdb/sql/php - add an optional address idname for users with multiple payment addressess

master
kanoi 9 years ago
parent
commit
f4db3e14bd
  1. 4
      pool/db.php
  2. 39
      pool/page_addrmgt.php
  3. 6
      pool/page_percent.php
  4. 4
      sql/ckdb.sql
  5. 26
      sql/v1.0.3-v1.0.4.sql
  6. 18
      src/ckdb.c
  7. 3
      src/ckdb.h
  8. 24
      src/ckdb_cmd.c
  9. 26
      src/ckdb_dbio.c

4
pool/db.php

@ -242,6 +242,7 @@ function userReg($user, $email, $pass)
# #
function userSettings($user, $email = null, $addr = null, $pass = null, $twofa = null) function userSettings($user, $email = null, $addr = null, $pass = null, $twofa = null)
{ {
global $fld_sep;
$tmo = false; $tmo = false;
$flds = array('username' => $user); $flds = array('username' => $user);
if ($email != null) if ($email != null)
@ -253,6 +254,9 @@ function userSettings($user, $email = null, $addr = null, $pass = null, $twofa =
foreach ($addr as $ar) foreach ($addr as $ar)
{ {
$flds['address:'.$i] = $ar['addr']; $flds['address:'.$i] = $ar['addr'];
// optional - missing = blank
if (isset($ar['payname']))
$flds['payname:'.$i] = str_replace($fld_sep, ' ', trim($ar['payname']));
// optional - missing = use default // optional - missing = use default
if (isset($ar['ratio'])) if (isset($ar['ratio']))
$flds['ratio:'.$i] = $ar['ratio']; $flds['ratio:'.$i] = $ar['ratio'];

39
pool/page_addrmgt.php

@ -11,6 +11,7 @@ function addrmgtuser($data, $user, $err)
$pg .= "<table callpadding=0 cellspacing=0 border=0>\n"; $pg .= "<table callpadding=0 cellspacing=0 border=0>\n";
$pg .= '<tr class=title>'; $pg .= '<tr class=title>';
$pg .= '<td class=dl>Address</td>'; $pg .= '<td class=dl>Address</td>';
$pg .= '<td class=dl>ID</td>';
$pg .= '<td class=dr>Ratio</td>'; $pg .= '<td class=dr>Ratio</td>';
$pg .= '<td class=dr>%</td>'; $pg .= '<td class=dr>%</td>';
$pg .= '</tr>'; $pg .= '</tr>';
@ -18,7 +19,10 @@ function addrmgtuser($data, $user, $err)
# new row template for '+' # new row template for '+'
$pg .= '<tr class=hid id=bs>'; $pg .= '<tr class=hid id=bs>';
$pg .= '<td class=dl>'; $pg .= '<td class=dl>';
$pg .= "<input type=text size=42 name='addr:' value=''>"; $pg .= "<input type=text size=36 name='addr:' value=''>";
$pg .= '</td>';
$pg .= '<td class=dl>';
$pg .= "<input type=text size=16 name='payname:' value=''>";
$pg .= '</td>'; $pg .= '</td>';
$pg .= '<td class=dr>'; $pg .= '<td class=dr>';
$pg .= "<input type=text size=6 name='ratio:' value='0' id=rat onchange='repc()'>"; $pg .= "<input type=text size=6 name='ratio:' value='0' id=rat onchange='repc()'>";
@ -45,7 +49,11 @@ function addrmgtuser($data, $user, $err)
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$addr = $ans['addr:'.$i]; $addr = $ans['addr:'.$i];
$pg .= '<td class=dl>'; $pg .= '<td class=dl>';
$pg .= "<input type=text size=42 name='addr:$i' value='$addr'>"; $pg .= "<input type=text size=36 name='addr:$i' value='$addr'>";
$pg .= '</td>';
$nam = htmlspecialchars($ans['payname:'.$i]);
$pg .= '<td class=dl>';
$pg .= "<input type=text size=16 name='payname:$i' value='$nam'>";
$pg .= '</td>'; $pg .= '</td>';
$ratio = intval($ans['ratio:'.$i]); $ratio = intval($ans['ratio:'.$i]);
$pg .= '<td class=dr>'; $pg .= '<td class=dr>';
@ -63,7 +71,7 @@ function addrmgtuser($data, $user, $err)
else else
$row = 'odd'; $row = 'odd';
$pg .= "<tr class=$row id=plus>"; $pg .= "<tr class=$row id=plus>";
$pg .= '<td colspan=3 class=dl>'; $pg .= '<td colspan=4 class=dl>';
$pg .= "<input type=button value='+' onclick='return adrw();'>"; $pg .= "<input type=button value='+' onclick='return adrw();'>";
$pg .= '</td></tr>'; $pg .= '</td></tr>';
@ -72,20 +80,21 @@ function addrmgtuser($data, $user, $err)
else else
$row = 'odd'; $row = 'odd';
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$pg .= '<td class=dr>'; $pg .= '<td class=dr>Password:</td>';
$pg .= 'Password: <input type=password name=pass size=20>'; $pg .= '<td class=dl><input type=password name=pass size=20></td>';
$pg .= '</td><td colspan=2>&nbsp;</td></tr>'; $pg .= '<td colspan=2>&nbsp;</td></tr>';
if ((($offset++) % 2) == 0) if ((($offset++) % 2) == 0)
$row = 'even'; $row = 'even';
else else
$row = 'odd'; $row = 'odd';
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$pg .= '<td class=dr>'; $pg .= '<td class=dr><span class=st1>*</span>2nd Authentication:</td>';
$pg .= '<span class=st1>*</span>2nd Authentication: <input type=password name=2fa size=10>'; $pg .= '<td class=dl><input type=password name=2fa size=10>';
$pg .= '</td><td colspan=2 class=dl><input type=submit name=OK value=Save></td></tr>'; $pg .= ' <input type=submit name=OK value=Save></td>';
$pg .= '<td colspan=3 class=dl>&nbsp;</td></tr>';
$pg .= "<tr><td colspan=3 class=dc><font size=-1>"; $pg .= "<tr><td colspan=4 class=dc><font size=-1>";
$pg .= "<span class=st1>*</span>Leave blank if you haven't enabled it<br>"; $pg .= "<span class=st1>*</span>Leave blank if you haven't enabled it<br>";
$pg .= 'You must enter your password to save changes<br>'; $pg .= 'You must enter your password to save changes<br>';
$pg .= 'A ratio of 0, will remove the address from the payouts</font></td></tr>'; $pg .= 'A ratio of 0, will remove the address from the payouts</font></td></tr>';
@ -97,8 +106,9 @@ function addrmgtuser($data, $user, $err)
$pg .= "var r=document.getElementById('rows');var c=parseInt(r.value);"; $pg .= "var r=document.getElementById('rows');var c=parseInt(r.value);";
$pg .= "var bs=document.getElementById('bs');var n=bs.cloneNode(true);n.id='z';"; $pg .= "var bs=document.getElementById('bs');var n=bs.cloneNode(true);n.id='z';";
$pg .= "n.className='odd';var ia=n.childNodes[0].firstChild;ia.name='addr:'+c;ia.value='';"; $pg .= "n.className='odd';var ia=n.childNodes[0].firstChild;ia.name='addr:'+c;ia.value='';";
$pg .= "var ir=n.childNodes[1].firstChild;ir.id='rat'+c;ir.name='ratio:'+c;ir.value='0';"; $pg .= "var ipn=n.childNodes[1].firstChild;ipn.name='payname:'+c;ipn.value='';";
$pg .= "var ip=n.childNodes[2].firstChild;ip.id='per'+c;ip.innerHTML='0.00%';"; $pg .= "var ir=n.childNodes[2].firstChild;ir.id='rat'+c;ir.name='ratio:'+c;ir.value='0';";
$pg .= "var ip=n.childNodes[3].firstChild;ip.id='per'+c;ip.innerHTML='0.00%';";
$pg .= "p.parentNode.insertBefore(n, p);"; $pg .= "p.parentNode.insertBefore(n, p);";
$pg .= "c++;r.value=c;return true}\n"; $pg .= "c++;r.value=c;return true}\n";
$pg .= "function repc(){var c=parseInt(document.getElementById('rows').value);"; $pg .= "function repc(){var c=parseInt(document.getElementById('rows').value);";
@ -127,9 +137,12 @@ function doaddrmgt($data, $user)
for ($i = 0; $i < $count; $i++) for ($i = 0; $i < $count; $i++)
{ {
$addr = getparam('addr:'.$i, false); $addr = getparam('addr:'.$i, false);
$nam = getparam('payname:'.$i, false);
if (nuem($nam))
$nam = '';
$ratio = getparam('ratio:'.$i, false); $ratio = getparam('ratio:'.$i, false);
if (!nuem($addr) && !nuem($ratio)) if (!nuem($addr) && !nuem($ratio))
$addrarr[] = array('addr' => $addr, 'ratio' => $ratio); $addrarr[] = array('addr' => $addr, 'payname' => $nam, 'ratio' => $ratio);
} }
$ans = userSettings($user, null, $addrarr, $pass, $twofa); $ans = userSettings($user, null, $addrarr, $pass, $twofa);
if ($ans['STATUS'] != 'ok') if ($ans['STATUS'] != 'ok')

6
pool/page_percent.php

@ -4,6 +4,7 @@ function pertitle($data, $user)
{ {
$pg = '<tr class=title>'; $pg = '<tr class=title>';
$pg .= '<td class=dl>Address</td>'; $pg .= '<td class=dl>Address</td>';
$pg .= '<td class=dl>ID</td>';
$pg .= '<td class=dr>Shares</td>'; $pg .= '<td class=dr>Shares</td>';
$pg .= '<td class=dr>Diff</td>'; $pg .= '<td class=dr>Diff</td>';
$pg .= '<td class=dr>Invalid</td>'; $pg .= '<td class=dr>Invalid</td>';
@ -40,6 +41,7 @@ function peruser($data, $user, &$offset, &$totshare, &$totdiff,
$all[] = array('payaddress' => $ans['payaddress:'.$i], $all[] = array('payaddress' => $ans['payaddress:'.$i],
'payratio' => $ans['payratio:'.$i], 'payratio' => $ans['payratio:'.$i],
'paypercent' => $ans['paypercent:'.$i], 'paypercent' => $ans['paypercent:'.$i],
'payname' => $ans['payname:'.$i],
'p_shareacc' => $ans['p_shareacc:'.$i], 'p_shareacc' => $ans['p_shareacc:'.$i],
'p_diffacc' => $ans['p_diffacc:'.$i], 'p_diffacc' => $ans['p_diffacc:'.$i],
'p_diffinv' => $ans['p_diffinv:'.$i], 'p_diffinv' => $ans['p_diffinv:'.$i],
@ -58,6 +60,7 @@ function peruser($data, $user, &$offset, &$totshare, &$totdiff,
$pg .= "<tr class=$row>"; $pg .= "<tr class=$row>";
$pg .= '<td class=dl>'.$all[$i]['payaddress'].'</td>'; $pg .= '<td class=dl>'.$all[$i]['payaddress'].'</td>';
$pg .= '<td class=dl>'.$all[$i]['payname'].'</td>';
$shareacc = number_format($all[$i]['p_shareacc'], 0); $shareacc = number_format($all[$i]['p_shareacc'], 0);
$totshare += $all[$i]['p_shareacc']; $totshare += $all[$i]['p_shareacc'];
@ -113,6 +116,7 @@ function pertotal($offset, $totshare, $totdiff, $totinvalid, $totrate, $blockacc
else else
$row = 'odd'; $row = 'odd';
$pg .= "<tr class=$row><td class=dl>Total:</td>"; $pg .= "<tr class=$row><td class=dl>Total:</td>";
$pg .= "<td class=dl>&nbsp;</td>";
$shareacc = number_format($totshare, 0); $shareacc = number_format($totshare, 0);
$pg .= "<td class=dr>$shareacc</td>"; $pg .= "<td class=dr>$shareacc</td>";
$diffacc = number_format($totdiff, 0); $diffacc = number_format($totdiff, 0);
@ -156,7 +160,7 @@ function dopercent($data, $user)
if ($blockacc > 0 && $blockreward > 0) if ($blockacc > 0 && $blockreward > 0)
{ {
$btc = btcfmt($totdiff / $blockacc * $blockreward); $btc = btcfmt($totdiff / $blockacc * $blockreward);
$pg .= '<tr><td colspan=8 class=dc>'; $pg .= '<tr><td colspan=9 class=dc>';
$pg .= "<br>Payout est if block found at 100%: ~$btc BTC"; $pg .= "<br>Payout est if block found at 100%: ~$btc BTC";
$pg .= '</td></tr>'; $pg .= '</td></tr>';
} }

4
sql/ckdb.sql

@ -75,6 +75,8 @@ CREATE TABLE paymentaddresses (
userid bigint NOT NULL, userid bigint NOT NULL,
payaddress character varying(256) DEFAULT ''::character varying NOT NULL, payaddress character varying(256) DEFAULT ''::character varying NOT NULL,
payratio integer DEFAULT 1000000 NOT NULL, payratio integer DEFAULT 1000000 NOT NULL,
payname character varying(64) DEFAULT ''::character varying NOT NULL,
status char DEFAULT ' ' NOT NULL,
createdate timestamp with time zone NOT NULL, createdate timestamp with time zone NOT NULL,
createby character varying(64) DEFAULT ''::character varying NOT NULL, createby character varying(64) DEFAULT ''::character varying NOT NULL,
createcode character varying(128) DEFAULT ''::character varying NOT NULL, createcode character varying(128) DEFAULT ''::character varying NOT NULL,
@ -468,4 +470,4 @@ CREATE TABLE version (
PRIMARY KEY (vlock) PRIMARY KEY (vlock)
); );
insert into version (vlock,version) values (1,'1.0.3'); insert into version (vlock,version) values (1,'1.0.4');

26
sql/v1.0.3-v1.0.4.sql

@ -0,0 +1,26 @@
SET SESSION AUTHORIZATION 'postgres';
BEGIN transaction;
DO $$
DECLARE ver TEXT;
BEGIN
UPDATE version set version='1.0.4' where vlock=1 and version='1.0.3';
IF found THEN
RETURN;
END IF;
SELECT version into ver from version
WHERE vlock=1;
RAISE EXCEPTION 'Wrong DB version - expect "1.0.3" - found "%"', ver;
END $$;
ALTER TABLE ONLY paymentaddresses
ADD COLUMN payname character varying(64) DEFAULT ''::character varying NOT NULL,
ADD COLUMN status char DEFAULT ' ' NOT NULL;
END transaction;

18
src/ckdb.c

@ -3112,8 +3112,10 @@ static void *summariser(__maybe_unused void *arg)
while (!everyone_die && !reload_queue_complete) while (!everyone_die && !reload_queue_complete)
cksleep_ms(42); cksleep_ms(42);
LOGWARNING("%s() Start processing...", __func__); if (!everyone_die) {
summariser_using_data = true; LOGWARNING("%s() Start processing...", __func__);
summariser_using_data = true;
}
while (!everyone_die) { while (!everyone_die) {
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
@ -3670,8 +3672,10 @@ static void *marker(__maybe_unused void *arg)
return NULL; return NULL;
} }
LOGWARNING("%s() Start processing...", __func__); if (!everyone_die) {
marker_using_data = true; LOGWARNING("%s() Start processing...", __func__);
marker_using_data = true;
}
while (!everyone_die) { while (!everyone_die) {
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
@ -3844,8 +3848,10 @@ static void *socketer(__maybe_unused void *arg)
while (!everyone_die && !db_users_complete) while (!everyone_die && !db_users_complete)
cksem_mswait(&socketer_sem, 420); cksem_mswait(&socketer_sem, 420);
LOGWARNING("%s() Start processing...", __func__); if (!everyone_die) {
socketer_using_data = true; LOGWARNING("%s() Start processing...", __func__);
socketer_using_data = true;
}
want_first = true; want_first = true;
while (!everyone_die) { while (!everyone_die) {

3
src/ckdb.h

@ -54,7 +54,7 @@
*/ */
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.3" #define DB_VERSION "1.0.4"
#define CKDB_VERSION DB_VERSION"-1.402" #define CKDB_VERSION DB_VERSION"-1.402"
#define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL " - from %s %s() line %d"
@ -1186,6 +1186,7 @@ typedef struct paymentaddresses {
int64_t userid; int64_t userid;
char payaddress[TXT_BIG+1]; char payaddress[TXT_BIG+1];
int32_t payratio; int32_t payratio;
char payname[TXT_SML+1];
HISTORYDATECONTROLFIELDS; HISTORYDATECONTROLFIELDS;
bool match; // non-DB field bool match; // non-DB field
} PAYMENTADDRESSES; } PAYMENTADDRESSES;

24
src/ckdb_cmd.c

@ -445,8 +445,8 @@ static char *cmd_userset(PGconn *conn, char *cmd, char *id,
__maybe_unused tv_t *notcd, K_TREE *trf_root) __maybe_unused tv_t *notcd, K_TREE *trf_root)
{ {
K_ITEM *i_username, *i_passwordhash, *i_2fa, *i_rows, *i_address; K_ITEM *i_username, *i_passwordhash, *i_2fa, *i_rows, *i_address;
K_ITEM *i_ratio, *i_email, *u_item, *pa_item, *old_pa_item; K_ITEM *i_ratio, *i_payname, *i_email, *u_item, *pa_item, *old_pa_item;
char *email, *address; char *email, *address, *payname;
char reply[1024] = ""; char reply[1024] = "";
size_t siz = sizeof(reply); size_t siz = sizeof(reply);
char tmp[1024]; char tmp[1024];
@ -507,6 +507,9 @@ static char *cmd_userset(PGconn *conn, char *cmd, char *id,
snprintf(tmp, sizeof(tmp), "ratio:%d=%d%c", snprintf(tmp, sizeof(tmp), "ratio:%d=%d%c",
rows, row->payratio, FLDSEP); rows, row->payratio, FLDSEP);
APPEND_REALLOC(answer, off, len, tmp); APPEND_REALLOC(answer, off, len, tmp);
snprintf(tmp, sizeof(tmp), "payname:%d=%s%c",
rows, row->payname, FLDSEP);
APPEND_REALLOC(answer, off, len, tmp);
rows++; rows++;
pa_item = prev_in_ktree(ctx); pa_item = prev_in_ktree(ctx);
@ -517,7 +520,7 @@ static char *cmd_userset(PGconn *conn, char *cmd, char *id,
snprintf(tmp, sizeof(tmp), "rows=%d%cflds=%s%c", snprintf(tmp, sizeof(tmp), "rows=%d%cflds=%s%c",
rows, FLDSEP, rows, FLDSEP,
"addr,ratio", FLDSEP); "addr,ratio,payname", FLDSEP);
APPEND_REALLOC(answer, off, len, tmp); APPEND_REALLOC(answer, off, len, tmp);
snprintf(tmp, sizeof(tmp), "arn=%s%carp=%s", snprintf(tmp, sizeof(tmp), "arn=%s%carp=%s",
"PaymentAddresses", FLDSEP, ""); "PaymentAddresses", FLDSEP, "");
@ -615,11 +618,20 @@ static char *cmd_userset(PGconn *conn, char *cmd, char *id,
} }
pa_item = pa_item->next; pa_item = pa_item->next;
} }
snprintf(tmp, sizeof(tmp), "payname:%d", i);
i_payname = optional_name(trf_root, tmp,
0, NULL,
reply, siz);
if (i_payname)
payname = transfer_data(i_payname);
else
payname = EMPTY;
pa_item = k_unlink_head(paymentaddresses_free); pa_item = k_unlink_head(paymentaddresses_free);
DATA_PAYMENTADDRESSES(row, pa_item); DATA_PAYMENTADDRESSES(row, pa_item);
bzero(row, sizeof(*row)); bzero(row, sizeof(*row));
STRNCPY(row->payaddress, address); STRNCPY(row->payaddress, address);
row->payratio = ratio; row->payratio = ratio;
STRNCPY(row->payname, payname);
k_add_head(pa_store, pa_item); k_add_head(pa_store, pa_item);
} }
K_WUNLOCK(paymentaddresses_free); K_WUNLOCK(paymentaddresses_free);
@ -1808,6 +1820,10 @@ static char *cmd_percent(char *cmd, char *id, tv_t *now, USERS *users)
rows, ratio * 100.0, FLDSEP); rows, ratio * 100.0, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp); APPEND_REALLOC(buf, off, len, tmp);
snprintf(tmp, sizeof(tmp), "payname:%d=%s%c",
rows, pa->payname, FLDSEP);
APPEND_REALLOC(buf, off, len, tmp);
snprintf(tmp, sizeof(tmp), "p_hashrate5m:%d=%.1f%c", rows, snprintf(tmp, sizeof(tmp), "p_hashrate5m:%d=%.1f%c", rows,
(double)t_hashrate5m * ratio, (double)t_hashrate5m * ratio,
FLDSEP); FLDSEP);
@ -1893,7 +1909,7 @@ static char *cmd_percent(char *cmd, char *id, tv_t *now, USERS *users)
snprintf(tmp, sizeof(tmp), snprintf(tmp, sizeof(tmp),
"rows=%d%cflds=%s%c", "rows=%d%cflds=%s%c",
rows, FLDSEP, rows, FLDSEP,
"payaddress,payratio,paypercent," "payaddress,payratio,paypercent,payname,"
"p_hashrate5m,p_hashrate1hr,p_hashrate24hr," "p_hashrate5m,p_hashrate1hr,p_hashrate24hr,"
"p_diffacc,p_diffinv," "p_diffacc,p_diffinv,"
"p_diffsta,p_diffdup,p_diffhi,p_diffrej," "p_diffsta,p_diffdup,p_diffhi,p_diffrej,"

26
src/ckdb_dbio.c

@ -1723,7 +1723,9 @@ bool paymentaddresses_set(PGconn *conn, int64_t userid, K_STORE *pa_store,
/* Since we are merging the changes in rather than just /* Since we are merging the changes in rather than just
* replacing the db contents, lock the data for the duration * replacing the db contents, lock the data for the duration
* of the update to ensure nothing else changes it */ * of the update to ensure nothing else changes it
* N.B. 'payname' isn't the start of the key
* thus 2 different addresses can have the same 'payname' */
K_WLOCK(paymentaddresses_free); K_WLOCK(paymentaddresses_free);
locked = true; locked = true;
@ -1741,7 +1743,8 @@ bool paymentaddresses_set(PGconn *conn, int64_t userid, K_STORE *pa_store,
while (match) { while (match) {
DATA_PAYMENTADDRESSES(pa, match); DATA_PAYMENTADDRESSES(pa, match);
if (strcmp(pa->payaddress, row->payaddress) == 0 && if (strcmp(pa->payaddress, row->payaddress) == 0 &&
pa->payratio == row->payratio) { pa->payratio == row->payratio &&
strcmp(pa->payname, row->payname) == 0) {
pa->match = true; // Don't store it pa->match = true; // Don't store it
matches++; matches++;
break; break;
@ -1791,8 +1794,8 @@ bool paymentaddresses_set(PGconn *conn, int64_t userid, K_STORE *pa_store,
// Second step - add the non-matching records to the DB // Second step - add the non-matching records to the DB
LOGDEBUG("%s(): Step 2", __func__); LOGDEBUG("%s(): Step 2", __func__);
ins = "insert into paymentaddresses " ins = "insert into paymentaddresses "
"(paymentaddressid,userid,payaddress,payratio" "(paymentaddressid,userid,payaddress,payratio,payname"
HISTORYDATECONTROL ") values (" PQPARAM9 ")"; HISTORYDATECONTROL ") values (" PQPARAM10 ")";
count = 0; count = 0;
match = pa_store->head; match = pa_store->head;
@ -1814,8 +1817,9 @@ bool paymentaddresses_set(PGconn *conn, int64_t userid, K_STORE *pa_store,
params[par++] = bigint_to_buf(row->userid, NULL, 0); params[par++] = bigint_to_buf(row->userid, NULL, 0);
params[par++] = str_to_buf(row->payaddress, NULL, 0); params[par++] = str_to_buf(row->payaddress, NULL, 0);
params[par++] = int_to_buf(row->payratio, NULL, 0); params[par++] = int_to_buf(row->payratio, NULL, 0);
params[par++] = str_to_buf(row->payname, NULL, 0);
HISTORYDATEPARAMS(params, par, row); HISTORYDATEPARAMS(params, par, row);
PARCHKVAL(par, 9, params); // As per PQPARAM9 above PARCHKVAL(par, 10, params); // As per PQPARAM10 above
res = PQexecParams(conn, ins, par, NULL, (const char **)params, res = PQexecParams(conn, ins, par, NULL, (const char **)params,
NULL, NULL, 0, CKPQ_WRITE); NULL, NULL, 0, CKPQ_WRITE);
@ -1864,7 +1868,8 @@ unparam:
while (match) { while (match) {
DATA_PAYMENTADDRESSES(pa, match); DATA_PAYMENTADDRESSES(pa, match);
if (strcmp(pa->payaddress, row->payaddress) == 0 && if (strcmp(pa->payaddress, row->payaddress) == 0 &&
pa->payratio == row->payratio) { pa->payratio == row->payratio &&
strcmp(pa->payname, row->payname) == 0) {
break; break;
} }
match = match->next; match = match->next;
@ -1917,13 +1922,13 @@ bool paymentaddresses_fill(PGconn *conn)
int n, i; int n, i;
char *field; char *field;
char *sel; char *sel;
int fields = 4; int fields = 5;
bool ok; bool ok;
LOGDEBUG("%s(): select", __func__); LOGDEBUG("%s(): select", __func__);
sel = "select " sel = "select "
"paymentaddressid,userid,payaddress,payratio" "paymentaddressid,userid,payaddress,payratio,payname"
HISTORYDATECONTROL HISTORYDATECONTROL
" from paymentaddresses"; " from paymentaddresses";
res = PQexec(conn, sel, CKPQ_READ); res = PQexec(conn, sel, CKPQ_READ);
@ -1976,6 +1981,11 @@ bool paymentaddresses_fill(PGconn *conn)
break; break;
TXT_TO_INT("payratio", field, row->payratio); TXT_TO_INT("payratio", field, row->payratio);
PQ_GET_FLD(res, i, "payname", field, ok);
if (!ok)
break;
TXT_TO_STR("payname", field, row->payname);
HISTORYDATEFLDS(res, i, row, ok); HISTORYDATEFLDS(res, i, row, ok);
if (!ok) if (!ok)
break; break;

Loading…
Cancel
Save