Brett, you are absolutely correct. Thanks for the find and the
analysis. I've checked in the fix and checked in some tests to work the
usePreparedStatement option a little bit.
Brett Rann wrote:
>
> Log4perl/Appender/DBI.pm (exists in v0.37)
>
> PROBLEM:
> When a database appender is used and preparedStatement is set, Appender/DBI.pm incorrectly warns that bufferSize has been specified when it has not. Happens also if bufferSize is set to 1, 0 or <blank> (guesses at sensible values), but that is reasonable.
>
> ANALASYS:
> Incorrect logic for checking if bufferSize has been set:
>
> Pasted from about line 33.
> --------------
> * $self->{BUFFERSIZE} = $p{bufferSize} || 1;_
>
> if ($p{usePreparedStmt}) {
> $self->{sth} = $self->create_statement($p{sql});
> ** $self->{usePreparedStmt} = 1;
> }else{
> $self->{layout} = Log::Log4perl::Layout::PatternLayout->new(
> {ConversionPattern => {value => $p{sql}}});
> }
>
> *** if ($self->{usePreparedStmt} && $self->{BUFFERSIZE}){
> warn "Log4perl: you've defined both usePreparedStmt and bufferSize \n".
> "in your appender '$p{name}'--\n".
> "I'm going to ignore bufferSize and just use a prepared stmt\n";
> }
>
> return $self;
> }
> -------------
>
> The warning at line *** will always print if usePreparedStmt has been set, because, in the || at line *, $self->{BUFFERSIZE} gets defaulted to 1 if it is undefined, zero or otherwise false.
>
> PATCH:
> Change *** to read
> If ($self->{usePreparedStmt} && $p{bufferSize}) {
>
> Or possibly unset BUFFERSIZE after line **. I have gone with the first change though because it fixes the problem without making other assumptions (that unsetting it will not break countless bits of code elsewhere).
>
> Regards,
> Brett
> --
>
> --
> __________________________________________________________
> Sign-up for your own personalized E-mail at Mail.com
> http://www.mail.com/?sr=signup
>
> CareerBuilder.com has over 400,000 jobs. Be smarter about your job search
> http://corp.mail.com/careers
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> log4perl-devel mailing list
> log...@li...
> https://lists.sourceforge.net/lists/listinfo/log4perl-devel
--
Happy Trails. . .
Kevin M. Goess
(and Anne and Frank)
904 Carmel Ave.
Albany, CA 94706
(510)525-5217
|