From 0bbd2031df5bc928beac5cc59820f0ebb19efe9d 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 PramValues 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 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dbdimp.c b/dbdimp.c index 8bf05c6a..38a26442 100644 --- a/dbdimp.c +++ b/dbdimp.c @@ -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));