mirror of
https://github.com/postgres/postgres.git
synced 2025-08-19 23:22:23 +03:00
Improve parsetree representation of special functions such as CURRENT_DATE.
We implement a dozen or so parameterless functions that the SQL standard defines special syntax for. Up to now, that was done by converting them into more or less ad-hoc constructs such as "'now'::text::date". That's messy for multiple reasons: it exposes what should be implementation details to users, and performance is worse than it needs to be in several cases. To improve matters, invent a new expression node type SQLValueFunction that can represent any of these parameterless functions. Bump catversion because this changes stored parsetrees for rules. Discussion: <30058.1463091294@sss.pgh.pa.us>
This commit is contained in:
@@ -1050,6 +1050,45 @@ typedef struct MinMaxExpr
|
||||
int location; /* token location, or -1 if unknown */
|
||||
} MinMaxExpr;
|
||||
|
||||
/*
|
||||
* SQLValueFunction - parameterless functions with special grammar productions
|
||||
*
|
||||
* The SQL standard categorizes some of these as <datetime value function>
|
||||
* and others as <general value specification>. We call 'em SQLValueFunctions
|
||||
* for lack of a better term. We store type and typmod of the result so that
|
||||
* some code doesn't need to know each function individually, and because
|
||||
* we would need to store typmod anyway for some of the datetime functions.
|
||||
* Note that currently, all variants return non-collating datatypes, so we do
|
||||
* not need a collation field; also, all these functions are stable.
|
||||
*/
|
||||
typedef enum SQLValueFunctionOp
|
||||
{
|
||||
SVFOP_CURRENT_DATE,
|
||||
SVFOP_CURRENT_TIME,
|
||||
SVFOP_CURRENT_TIME_N,
|
||||
SVFOP_CURRENT_TIMESTAMP,
|
||||
SVFOP_CURRENT_TIMESTAMP_N,
|
||||
SVFOP_LOCALTIME,
|
||||
SVFOP_LOCALTIME_N,
|
||||
SVFOP_LOCALTIMESTAMP,
|
||||
SVFOP_LOCALTIMESTAMP_N,
|
||||
SVFOP_CURRENT_ROLE,
|
||||
SVFOP_CURRENT_USER,
|
||||
SVFOP_USER,
|
||||
SVFOP_SESSION_USER,
|
||||
SVFOP_CURRENT_CATALOG,
|
||||
SVFOP_CURRENT_SCHEMA
|
||||
} SQLValueFunctionOp;
|
||||
|
||||
typedef struct SQLValueFunction
|
||||
{
|
||||
Expr xpr;
|
||||
SQLValueFunctionOp op; /* which function this is */
|
||||
Oid type; /* result type/typmod */
|
||||
int32 typmod;
|
||||
int location; /* token location, or -1 if unknown */
|
||||
} SQLValueFunction;
|
||||
|
||||
/*
|
||||
* XmlExpr - various SQL/XML functions requiring special grammar productions
|
||||
*
|
||||
|
Reference in New Issue
Block a user