1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-17 06:41:09 +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:
Tom Lane
2016-08-16 20:33:01 -04:00
parent 4bc4cfe3bd
commit 0bb51aa967
24 changed files with 626 additions and 168 deletions

View File

@ -1041,6 +1041,22 @@ _readMinMaxExpr(void)
READ_DONE();
}
/*
* _readSQLValueFunction
*/
static SQLValueFunction *
_readSQLValueFunction(void)
{
READ_LOCALS(SQLValueFunction);
READ_ENUM_FIELD(op, SQLValueFunctionOp);
READ_OID_FIELD(type);
READ_INT_FIELD(typmod);
READ_LOCATION_FIELD(location);
READ_DONE();
}
/*
* _readXmlExpr
*/
@ -2348,6 +2364,8 @@ parseNodeString(void)
return_value = _readCoalesceExpr();
else if (MATCH("MINMAX", 6))
return_value = _readMinMaxExpr();
else if (MATCH("SQLVALUEFUNCTION", 16))
return_value = _readSQLValueFunction();
else if (MATCH("XMLEXPR", 7))
return_value = _readXmlExpr();
else if (MATCH("NULLTEST", 8))