Hello,

I am sending small patch, that allows hooking transformation stage of parser.


Regards
Pavel Stehule
*** ./src/backend/parser/parse_expr.c.orig	2009-03-17 16:20:18.000000000 +0100
--- ./src/backend/parser/parse_expr.c	2009-03-17 16:24:43.000000000 +0100
***************
*** 36,41 ****
--- 36,44 ----
  
  bool		Transform_null_equals = false;
  
+ /* Hook for plugins to get control in transformExpr */
+ ParseExprTransform_hook_type ParseExprTransform_hook = NULL;
+ 
  static Node *transformParamRef(ParseState *pstate, ParamRef *pref);
  static Node *transformAExprOp(ParseState *pstate, A_Expr *a);
  static Node *transformAExprAnd(ParseState *pstate, A_Expr *a);
***************
*** 100,105 ****
--- 103,117 ----
  Node *
  transformExpr(ParseState *pstate, Node *expr)
  {
+ 	if (ParseExprTransform_hook)
+ 		return (*ParseExprTransform_hook) (pstate, expr);
+ 	else
+ 		return standard_transformExpr(pstate, expr);
+ }
+  
+ Node *
+ standard_transformExpr(ParseState *pstate, Node *expr)
+ {
  	Node	   *result = NULL;
  
  	if (expr == NULL)
*** ./src/include/parser/parse_expr.h.orig	2009-03-17 16:25:34.000000000 +0100
--- ./src/include/parser/parse_expr.h	2009-03-17 16:38:29.000000000 +0100
***************
*** 18,23 ****
--- 18,29 ----
  /* GUC parameters */
  extern bool Transform_null_equals;
  
+ /* Hook for parser plugin to get control in transformExpr */
+ typedef Node *(*ParseExprTransform_hook_type) (ParseState *pstate, Node *expr);
+ extern PGDLLIMPORT ParseExprTransform_hook_type ParseExprTransform_hook;
+ 
  extern Node *transformExpr(ParseState *pstate, Node *expr);
+ extern Node *standard_transformExpr(ParseState *pstate, Node *expr);
+ 
  
  #endif   /* PARSE_EXPR_H */
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to