1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

Code review for protransform patches.

Fix loss of previous expression-simplification work when a transform
function fires: we must not simply revert to untransformed input tree.
Instead build a dummy FuncExpr node to pass to the transform function.
This has the additional advantage of providing a simpler, more uniform
API for transform functions.

Move documentation to a somewhat less buried spot, relocate some
poorly-placed code, be more wary of null constants and invalid typmod
values, add an opr_sanity check on protransform function signatures,
and some other minor cosmetic adjustments.

Note: although this patch touches pg_proc.h, no need for catversion
bump, because the changes are cosmetic and don't actually change the
intended catalog contents.
This commit is contained in:
Tom Lane
2012-03-23 17:29:57 -04:00
parent e08b4101e1
commit 0339047bc9
15 changed files with 205 additions and 172 deletions

View File

@ -2271,25 +2271,3 @@ transformFrameOffset(ParseState *pstate, int frameOptions, Node *clause)
return node;
}
/*
* relabel_to_typmod
* Add a RelabelType node that changes just the typmod, and remove all
* now-superfluous RelabelType nodes beneath it.
*/
Node *
relabel_to_typmod(Node *expr, int32 typmod)
{
Oid type = exprType(expr);
Oid coll = exprCollation(expr);
/*
* Strip any existing RelabelType, then add one. This is to preserve the
* invariant of no redundant RelabelTypes.
*/
while (IsA(expr, RelabelType))
expr = (Node *) ((RelabelType *) expr)->arg;
return (Node *) makeRelabelType((Expr *) expr, type, typmod, coll,
COERCE_DONTCARE);
}