mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21:12 +03:00
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.
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user