mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Create the infrastructure for planner support functions.
Rename/repurpose pg_proc.protransform as "prosupport". The idea is still that it names an internal function that provides knowledge to the planner about the behavior of the function it's attached to; but redesign the API specification so that it's not limited to doing just one thing, but can support an extensible set of requests. The original purpose of simplifying a function call is handled by the first request type to be invented, SupportRequestSimplify. Adjust all the existing transform functions to handle this API, and rename them fron "xxx_transform" to "xxx_support" to reflect the potential generalization of what they do. (Since we never previously provided any way for extensions to add transform functions, this change doesn't create an API break for them.) Also add DDL and pg_dump support for attaching a support function to a user-defined function. Unfortunately, DDL access has to be restricted to superusers, at least for now; but seeing that support functions will pretty much have to be written in C, that limitation is just theoretical. (This support is untested in this patch, but a follow-on patch will add cases that exercise it.) Discussion: https://postgr.es/m/15193.1548028093@sss.pgh.pa.us
This commit is contained in:
@ -4462,16 +4462,23 @@ CheckDateTokenTables(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Common code for temporal protransform functions. Types time, timetz,
|
||||
* timestamp and timestamptz each have a range of allowed precisions. An
|
||||
* unspecified precision is rigorously equivalent to the highest specifiable
|
||||
* precision.
|
||||
* Common code for temporal prosupport functions: simplify, if possible,
|
||||
* a call to a temporal type's length-coercion function.
|
||||
*
|
||||
* Types time, timetz, timestamp and timestamptz each have a range of allowed
|
||||
* precisions. An unspecified precision is rigorously equivalent to the
|
||||
* highest specifiable precision. We can replace the function call with a
|
||||
* no-op RelabelType if it is coercing to the same or higher precision as the
|
||||
* input is known to have.
|
||||
*
|
||||
* The input Node is always a FuncExpr, but to reduce the #include footprint
|
||||
* of datetime.h, we declare it as Node *.
|
||||
*
|
||||
* Note: timestamp_scale throws an error when the typmod is out of range, but
|
||||
* we can't get there from a cast: our typmodin will have caught it already.
|
||||
*/
|
||||
Node *
|
||||
TemporalTransform(int32 max_precis, Node *node)
|
||||
TemporalSimplify(int32 max_precis, Node *node)
|
||||
{
|
||||
FuncExpr *expr = castNode(FuncExpr, node);
|
||||
Node *ret = NULL;
|
||||
|
Reference in New Issue
Block a user