Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-03 Thread Vlad
Greg, thanks for the suggestion. looking into other thread on the list, it looks like setting $dbh->{pg_server_prepare} = 0; would solve my problem as well. With this setting will dbd::pg behave in old-style (i.e. prepare_cached prepared and stored on dbd::pg side), or it won't cache anything at

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 >> Which is why Vlad should use prepare() instead of prepare_cached(). > in our web application similar SQL queries (like load an object) > executed over and over again with high frequency. So it's very > desirable to use prepare_cached. I think we

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 2, 2005, at 11:51 , Vlad wrote: in our web application similar SQL queries (like load an object) executed over and over again with high frequency. So it's very desirable to use prepare_cached. I think we are going to adjust our ORM (object relation mapper) to always use full path to referenc

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread Vlad
> > The docs for prepare_cached() are littered with "Don't do this unless > > you understand the implications" warnings, as well as some kludges to > > differentiate different cases. > > Which is why Vlad should use prepare() instead of prepare_cached(). in our web application similar SQL queries

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 2, 2005, at 09:34 , Tom Lane wrote: I think you could demonstrate that if the spec is "make it look like the original query was retyped as source each time", then *every* DDL change in the database potentially requires invalidating every cached plan. I don't find that a desirable spec. I

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 1, 2005, at 23:16 , Steve Atkins wrote: Isn't this behaving as documented? prepare_cached() is supposed to return the original statement handle when you pass it the same string a second time. Yes. The docs for prepare_cached() are littered with "Don't do this unless you understand the implic

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread Tom Lane
David Wheeler <[EMAIL PROTECTED]> writes: > On May 1, 2005, at 21:30 , Neil Conway wrote: >> An alternative would be to flush dependent plans when the schema >> search path is changed. In effect this would mean flushing *all* >> prepared plans whenever the search path changes: we could perhaps

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 1, 2005, at 21:30 , Neil Conway wrote: An alternative would be to flush dependent plans when the schema search path is changed. In effect this would mean flushing *all* prepared plans whenever the search path changes: we could perhaps keep plans that only contain explicit namespace ref

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 2, 2005, at 06:40 , Andrew Dunstan wrote: I am not sure this is reasonably fixable. Invalidating the cache is not a pleasant solution - the query might not be affected by the change in search path at all. I'd be inclined to say that this is just a limitation of prepare_cached() which s

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 2, 2005, at 06:36 , Vlad wrote: as I understood Tom's message, he's not advising dbd::pg driver to rely on the fact that earlier prepared query is still valid. That's not going to change. It's your responsibility, as the programmer, to know when you need to expire the cache: $dbh->do("SET

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 2, 2005, at 06:14 , Neil Conway wrote: I'm not sure I quite follow you -- in some future version of the backend in which prepared queries are invalidated, this would be invisible to the client. The client wouldn't need to explicitly check for the "liveness" of the prepared query, they

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread David Wheeler
On May 1, 2005, at 22:44 , Tom Lane wrote: I am not claiming that the backend handles all these cases nicely today: it certainly doesn't. But we understand in principle how to fix these problems by invalidating plans inside the backend. I don't see how the DBD::Pg driver can hope to deal with any

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread Andrew Dunstan
Andrew Dunstan wrote: Vlad wrote: i.e. the following perl code won't work correctly with DBD::Pg 1.40+ $dbh->do("SET search_path TO one"); my $sth1 = $dbh->prepare_cached("SELECT * FROM test WHERE item = ?"); $sth1->execute("one"); $dbh->do("set search_path to two"); my $sth2 = $dbh->prepare_cach

Re: [Dbdpg-general] Re: [GENERAL] 'prepare' is not quite schema-safe

2005-05-02 Thread Andrew Dunstan
Vlad wrote: i.e. the following perl code won't work correctly with DBD::Pg 1.40+ $dbh->do("SET search_path TO one"); my $sth1 = $dbh->prepare_cached("SELECT * FROM test WHERE item = ?"); $sth1->execute("one"); $dbh->do("set search_path to two"); my $sth2 = $dbh->prepare_cached("SELECT * FROM test