Re: Push down time-related SQLValue functions to foreign server - Mailing list pgsql-hackers

From Alexander Pyhalov
Subject Re: Push down time-related SQLValue functions to foreign server
Date
Msg-id 73605b4bb95180e6cff620b6e7ee130d@postgrespro.ru
Whole thread Raw
In response to Re: Push down time-related SQLValue functions to foreign server  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Push down time-related SQLValue functions to foreign server
List pgsql-hackers
Tom Lane писал 2022-01-18 23:01:
> I wrote:
>> Alexander Pyhalov <a.pyhalov@postgrespro.ru> writes:
>>> This means we'll translate something like
>>> explain select * from t where d > now() - '1 day'::interval;
>>> to
>>> select * from t where d > $1;
> 
>> Right.
> 
> After thinking about that a bit more, I see that this will result
> in a major redefinition of what is "shippable".  Right now, we do not
> consider the above WHERE clause to be shippable, not only because of
> now() but because the timestamptz-minus-interval operator is dependent
> on the timezone setting, which might be different at the remote.
> But if we evaluate that operator locally and send its result as a
> parameter, the objection vanishes.  In fact, I don't think we even
> need to require the subexpression to contain only built-in functions.
> Its result still has to be of a built-in type, but that's a much
> weaker restriction.
> 

Hi.
So far I have the following prototype. It seems to be working, but I 
think it can be enhanced.
At least, some sort of caching seems to be necessary for 
is_stable_expr().

1) Now expression can be either 'stable shippable' or 'shippable 
according to old rules'. We check if it's 'stable shippable' in 
foreign_expr_walker(),
is_foreign_param() and deparseExpr(). All such exprs are replaced by 
params while deparsing.
2) contain_mutable_functions() now is calculated only for current node, 
if node is not considered 'stable shippable'.

Is it step in the right direction or do I miss something?
-- 
Best regards,
Alexander Pyhalov,
Postgres Professional
Attachment

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: row filtering for logical replication
Next
From: Robert Haas
Date:
Subject: Re: removing datlastsysoid