From 2870fe0a8e12aa9e4043532308b1e5751c3a0e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Wed, 30 Oct 2024 20:32:00 +0100 Subject: [PATCH] Make ParamValues follow expectations 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 --- dbdimp.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dbdimp.c b/dbdimp.c index 8bf05c6a..27d05570 100644 --- a/dbdimp.c +++ b/dbdimp.c @@ -4026,9 +4026,16 @@ 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));