From b1d1047321b1dafd41742a333b678288c3d9f5c8 Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Wed, 12 Sep 2012 03:21:10 +0000 Subject: [PATCH] applied a patch from VOVKASM (#79576) --- dbdimp.c | 2 +- t/19_bindparam.t | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dbdimp.c b/dbdimp.c index 5a009a7..e135add 100644 --- a/dbdimp.c +++ b/dbdimp.c @@ -1197,7 +1197,7 @@ sqlite_bind_ph(SV *sth, imp_sth_t *imp_sth, pos = 2 * (SvIV(param) - 1); } sqlite_trace(sth, imp_sth, 3, form("bind into 0x%p: %"IVdf" => %s (%"IVdf") pos %d", imp_sth->params, SvIV(param), SvPV_nolen_undef_ok(value), sql_type, pos)); - av_store(imp_sth->params, pos, SvREFCNT_inc(value)); + av_store(imp_sth->params, pos, newSVsv(value)); if (sql_type) { av_store(imp_sth->params, pos+1, newSViv(sql_type)); } diff --git a/t/19_bindparam.t b/t/19_bindparam.t index 955663d..025f8af 100644 --- a/t/19_bindparam.t +++ b/t/19_bindparam.t @@ -7,7 +7,7 @@ BEGIN { } use t::lib::Test; -use Test::More tests => 33; +use Test::More tests => 39; use Test::NoWarnings; use DBI ':sql_types'; @@ -48,6 +48,13 @@ SCOPE: { ok( $sth->bind_param(1, 5, SQL_INTEGER), 'bind 3' ); ok( $sth->bind_param(2, undef), 'bind 4' ); ok( $sth->execute, '->execute' ); + + # Works with PADTMPs? + my @values = (6, "Larry"); + for (my $i=0; $i<2; $i++) { + ok( $sth->bind_param($i+1, "$values[$i]"), 'bind '.($i+5) ); + } + ok( $sth->execute, '->execute' ); } # Reconnect @@ -75,4 +82,7 @@ SCOPE: { ok( $sth->fetch, '->fetch' ); is( $id, 5, 'id = 5' ); is( $name, undef, 'name = undef' ); + ok( $sth->fetch, '->fetch' ); + is( $id, 6, 'id = 6' ); + is( $name, 'Larry', 'name = Larry' ); }