-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make ParamValues follow expectations #449
Conversation
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
I am not an experienced XS developer, sorry I am perhaps not sufficiently qualified to review this change. The other you mention "The values should be undef if not yet bound", and my understanding of the code in this commit, suggests to me there is a misunderstanding. My reading of DBI docs are that, before any values are bound or given to As for the third problem in issue #447 -- the segfault -- we need a test to reproduce it so that you can find a root cause. I'll try to provide something useful in this regard. |
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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I read this correctly, the return value here is always a hashref. When there are no params saved yet, the return should simply be undef -- if I understand the DBI docs correctly 😛
Feel free to consider the XS stuff a black box and just verify if the behavior from it matches what you want it to do.
"If the driver supports How I read this, the driver is expected to return a hash with the keys, but values set to This seems to match DBD::SQLite: #!/bin/perl
use v5.36;
use DBI;
use Data::Dumper;
my $dbh = DBI->connect('dbi:SQLite:dbname=:memory:','','');
my $sth = $dbh->prepare('SELECT ?');
say "after prepare:\n" . Dumper($sth->{ParamValues});
$sth->execute(1);
say "after execute:\n" . Dumper($sth->{ParamValues});
while (my @row = $sth->fetchrow_array()) {
say "result: " . $row[0];
}
Thanks |
You are correct, I was mistaken about the expected behavior. I was misled by
And
but that is the default expectation for all attributes, and this one is specially described!. Sorry for my confusion. Thanks for your patience. I will update my tests. |
Closes #447