is necessary to recheck cached data in fn_extra?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

is necessary to recheck cached data in fn_extra?

Pavel Stehule
Hi

I should to use a cache accessed via fn_extra. There will be stored data about function parameters (types). If I understand correctly, these data should be stable in query, and then recheck is not necessary. Is it true?

Regards

Pavel
Reply | Threaded
Open this post in threaded view
|

Re: is necessary to recheck cached data in fn_extra?

Tom Lane-2
Pavel Stehule <[hidden email]> writes:
> I should to use a cache accessed via fn_extra. There will be stored data
> about function parameters (types). If I understand correctly, these data
> should be stable in query, and then recheck is not necessary. Is it true?

I wouldn't trust that.  You don't really know what the lifespan of
a fn_extra cache is.

                        regards, tom lane


Reply | Threaded
Open this post in threaded view
|

Re: is necessary to recheck cached data in fn_extra?

Chapman Flack
On 08/07/19 11:39, Tom Lane wrote:
> Pavel Stehule <[hidden email]> writes:
>> I should to use a cache accessed via fn_extra. There will be stored data
>> about function parameters (types). If I understand correctly, these data
>> should be stable in query, and then recheck is not necessary. Is it true?
>
> I wouldn't trust that.  You don't really know what the lifespan of
> a fn_extra cache is.

It is going to be either the last thing I put there, or NULL, right?
So a null check is sufficient?

Other than when the SRF_* api has commandeered it for other purposes?

Regards,
-Chap


Reply | Threaded
Open this post in threaded view
|

Re: is necessary to recheck cached data in fn_extra?

Pavel Stehule
In reply to this post by Tom Lane-2


st 7. 8. 2019 v 17:39 odesílatel Tom Lane <[hidden email]> napsal:
Pavel Stehule <[hidden email]> writes:
> I should to use a cache accessed via fn_extra. There will be stored data
> about function parameters (types). If I understand correctly, these data
> should be stable in query, and then recheck is not necessary. Is it true?

I wouldn't trust that.  You don't really know what the lifespan of
a fn_extra cache is.

fn_extra cache cannot be longer than query. And if I understand well, then is not possible to change parameter types inside query?

Pavel


                        regards, tom lane
Reply | Threaded
Open this post in threaded view
|

Re: is necessary to recheck cached data in fn_extra?

Tom Lane-2
Pavel Stehule <[hidden email]> writes:
> st 7. 8. 2019 v 17:39 odesílatel Tom Lane <[hidden email]> napsal:
>> I wouldn't trust that.  You don't really know what the lifespan of
>> a fn_extra cache is.

> fn_extra cache cannot be longer than query.

There are fn_extra caches that are not tied to queries.  Admittedly
they're for special purposes like I/O functions and index support
functions, and maybe you can assume that your function can't be
used in such ways.  I don't think it's a great programming model
though.

> And if I understand well, then
> is not possible to change parameter types inside query?

Most places dealing with composite types assume that the rowtype *could*
change intraquery.  I believe this was a live possibility in the past,
though it might not be today.  (The issue was inheritance queries, but
I think we now force tuples from child tables to be converted to the
parent rowtype.  Whether that's 100% bulletproof is unclear.)  If you're
not dealing with composites then it's an okay assumption.  I think.

                        regards, tom lane


Reply | Threaded
Open this post in threaded view
|

Re: is necessary to recheck cached data in fn_extra?

Pavel Stehule


st 7. 8. 2019 v 18:39 odesílatel Tom Lane <[hidden email]> napsal:
Pavel Stehule <[hidden email]> writes:
> st 7. 8. 2019 v 17:39 odesílatel Tom Lane <[hidden email]> napsal:
>> I wouldn't trust that.  You don't really know what the lifespan of
>> a fn_extra cache is.

> fn_extra cache cannot be longer than query.

There are fn_extra caches that are not tied to queries.  Admittedly
they're for special purposes like I/O functions and index support
functions, and maybe you can assume that your function can't be
used in such ways.  I don't think it's a great programming model
though.

> And if I understand well, then
> is not possible to change parameter types inside query?

Most places dealing with composite types assume that the rowtype *could*
change intraquery.  I believe this was a live possibility in the past,
though it might not be today.  (The issue was inheritance queries, but
I think we now force tuples from child tables to be converted to the
parent rowtype.  Whether that's 100% bulletproof is unclear.)  If you're
not dealing with composites then it's an okay assumption.  I think.

ok, thank you for your reply.

Regards

Pavel


                        regards, tom lane