diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-03-17 01:02:24 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-03-17 01:02:24 +0000 |
commit | c1352052ef1d4eeb2eb1d822a207ddc2d106cb13 (patch) | |
tree | cc396212df36959c1220a953a009636477c615b2 /src/include/executor/executor.h | |
parent | 2c7e47343449e2a4f7694d04a5a4284d89246699 (diff) |
Replace the switching function ExecEvalExpr() with a macro that jumps
directly to the appropriate per-node execution function, using a function
pointer stored by ExecInitExpr. This speeds things up by eliminating one
level of function call. The function-pointer technique also enables further
small improvements such as only making one-time tests once (and then
changing the function pointer). Overall this seems to gain about 10%
on evaluation of simple expressions, which isn't earthshaking but seems
a worthwhile gain for a relatively small hack. Per recent discussion
on pghackers.
Diffstat (limited to 'src/include/executor/executor.h')
-rw-r--r-- | src/include/executor/executor.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index cc2e49efafc..1eb158440b1 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.107 2004/03/02 18:56:15 tgl Exp $ + * $PostgreSQL: pgsql/src/include/executor/executor.h,v 1.108 2004/03/17 01:02:24 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -17,17 +17,26 @@ #include "executor/execdesc.h" -/* ---------------- - * TupIsNull +/* + * TupIsNull * * This is used mainly to detect when there are no more * tuples to process. - * ---------------- */ /* return: true if tuple in slot is NULL, slot is slot to test */ #define TupIsNull(slot) \ ((slot) == NULL || (slot)->val == NULL) + +/* + * ExecEvalExpr was formerly a function containing a switch statement; + * now it's just a macro invoking the function pointed to by an ExprState + * node. Beware of double evaluation of the ExprState argument! + */ +#define ExecEvalExpr(expr, econtext, isNull, isDone) \ + ((*(expr)->evalfunc) (expr, econtext, isNull, isDone)) + + /* * prototypes from functions in execAmi.c */ @@ -125,8 +134,6 @@ extern Tuplestorestate *ExecMakeTableFunctionResult(ExprState *funcexpr, ExprContext *econtext, TupleDesc expectedDesc, TupleDesc *returnDesc); -extern Datum ExecEvalExpr(ExprState *expression, ExprContext *econtext, - bool *isNull, ExprDoneCond *isDone); extern Datum ExecEvalExprSwitchContext(ExprState *expression, ExprContext *econtext, bool *isNull, ExprDoneCond *isDone); extern ExprState *ExecInitExpr(Expr *node, PlanState *parent); |