Re: Cached statements hold strong references to bind values

Peter Rabbitson <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
On Sat, Jan 26, 2013 at 12:31:23PM +0000, Tim Bunce wrote:
> On Sat, Jan 26, 2013 at 07:21:56PM +1100, Peter Rabbitson wrote:
> > On Fri, Jan 25, 2013 at 10:59:46PM +0000, Tim Bunce wrote:
> > > On Fri, Jan 25, 2013 at 09:40:07PM +1100, Peter Rabbitson wrote:
> > > > On Fri, Jan 25, 2013 at 10:17:11AM +0000, Tim Bunce wrote:
> > > > > Re https://rt.cpan.org/Public/Bug/Display.html?id=82942
> > > > > 
> > > > > The key question: is this a bug or a feature?
> > > > 
> > > > Can you walk me through your thought process on what makes this a feature?
> > > > Not trying to be difficult, I am just having trouble seeing the use-case ;)
> > > 
> > > A cache statement is cached because the user asked for it to be cached.
> > 
> > Perhaps there is a mismatch of understanding here. For me the only 
> > benefit of using a cached statement is to avoid a prepare. Executing the 
> > *same* statement with the *same* values *without* rebind does not seem 
> > to be possible in the first place (according to the docs at least):
> 
> I don't follow you here Peter. This should work fine:
> 
>     $sth = $dbh->prepare_cached($sql);
>     $sth->bind_param(1, $foo);
>     $sth->execute();
>     $sth->execute();
>     $sth->execute();
>     $sth->execute();

I was not aware this is even possible. I rescanned the docs - nothing 
seeems to claim it is. In any case - now we are on the same page, and 
the entanglement seems to be the only way forward. I saw you already 
stalled the ticket - keep it so.

> > > Bound values are meant to persist across finish(), so there are still risks.
> > 
> > Also undocumented ;)
> 
> Bound values are spec'd to persist in general. No need to mention finish().

I keep thinking I am overlooking something. I will look at things again 
later tonight.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.