From: Mark B. <ma...@ex...> - 2007-12-13 15:47:20
|
Hi, In the Appender::DBI man page, we see the following sentence, "If there are more '?' placeholders than there are values in your message, it will use undef for the rest." However, I was unable to observe this behaviour with my configuration. I used the following tiny patch to Appender::DBI.pm to get the described behaviour and it may be of general interest. It does rely on the DBI statement handle attribute NUM_OF_PARAMS which is driver dependent, however I can't currently see any other way of achieving this. --- ./original/Log/Log4perl/Appender/DBI.pm 2007-03-15 07:53:47.000000000 +0000 +++ ./patched/Log/Log4perl/Appender/DBI.pm 2007-12-13 15:00:48.000000000 +0000 @@ -134,6 +134,13 @@ for my $attempt (0..$self->{reconnect_attempts}) { #warn "Exe: @qmarks"; # TODO + + # if we're short of bind variables, fill in the remainder with undef + if( $sth->{NUM_OF_PARAMS}-1 > $#qmarks ){ + # use the old "assign past the end of array to extend it" thing. + undef $qmarks[$sth->{NUM_OF_PARAMS}-1]; + } + if(! $sth->execute(@qmarks)) { # Exe failed # warn "Log4perl: DBI->execute failed $DBI::errstr, \n". - Mark |