Skip to content

Commit

Permalink
Make PramValues follow expectations
Browse files Browse the repository at this point in the history
1. The keys are expected (not guaranteed) to be integers starting at 1. They previously started at 0.
2. The values should be undef if not yet bound
  • Loading branch information
dveeden committed Oct 30, 2024
1 parent 0c8c2d3 commit 0bbd203
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions dbdimp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4026,9 +4026,17 @@ dbd_st_FETCH_internal(
I32 keylen;
for (n= 0; n < DBIc_NUM_PARAMS(imp_sth); n++)
{
keylen= sprintf(key, "%d", n);
(void)hv_store(pvhv, key,
keylen, newSVsv(imp_sth->params[n].value), 0);
// https://metacpan.org/pod/DBI#ParamValues says keys
// are typically integers starting at 1
// values should be undef if not yet bound
keylen= sprintf(key, "%d", n+1);
if (imp_sth->params[n].value) {
(void)hv_store(pvhv, key,
keylen, newSVsv(imp_sth->params[n].value), 0);
} else {
(void)hv_store(pvhv, key,
keylen, &PL_sv_undef, 0);
}
}
}
retsv= sv_2mortal(newRV_noinc((SV*)pvhv));
Expand Down

0 comments on commit 0bbd203

Please sign in to comment.