From: Jay Jacobs [mailto:[EMAIL PROTECTED]]
> On Tue, 15 Aug 2000, Tom Mornini wrote:
> 
> > It is my understanding of the DBI docs that you only need to call
> > $sth->finish when you DON'T fetch all the rows that the 
> $sth has ready to
> > return.
> > 
> 
> From "Writing Apache Modules with Perl and C":
>   "You should still call finish() at the end of each series 
> of fetches,
> even though you are going to reuse the statement handler.  
> Failure to do
> so can lead to memory leaks."
> 

You picked the wrong authority for this! The right place (tm) to look 
when discussing DBI is 'perldoc DBI'. The relevant quote is:

  finish
        $rc  = $sth->finish;

      Indicates that no more data will be fetched from this statement handle
      before it is either executed again or destroyed.  It is rarely needed
      but can sometimes be helpful in very specific situations in order to
      allow the server to free up resources currently being held (such as
      sort buffers).

      When all the data has been fetched from a select statement the driver
      should automatically call finish for you. So you should not normally
      need to call it explicitly.

Note the last sentence!


> If I remember correctly, it also frees up any resources used by the
> database (depending on db) for the query, like for sorting, joining,
> etc.  But I can't quote a source for that one.
There is no authoritative source for that fallacy - I hope!

> From my point of view, it never hurts to call finish()...
Quite true. Do you also undef all your variables just before they go
out of scope? Thats comparable. There are a *few* situations where finish
is needed (Michael Peppler has shown one, the DBI docs list another) but
must DBI programmers won't need finish ever.

Henrik

Reply via email to