Skip to content

Commit 47633ba

Browse files
committed
get rid of ugly ExecEvalExprCompat() macro
1 parent 0feb47b commit 47633ba

File tree

4 files changed

+11
-30
lines changed

4 files changed

+11
-30
lines changed

src/compat/pg_compat.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,6 @@ create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
118118
#endif
119119

120120

121-
/*
122-
* ExecEvalExpr
123-
*
124-
* global variables for macro wrapper evaluation
125-
*/
126-
#if PG_VERSION_NUM >= 90500 && PG_VERSION_NUM < 100000
127-
Datum exprResult;
128-
ExprDoneCond isDone;
129-
#endif
130-
131-
132121
/*
133122
* get_all_actual_clauses
134123
*/

src/include/compat/pg_compat.h

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -367,26 +367,20 @@ extern void create_plain_partial_paths(PlannerInfo *root,
367367
* NOTE: 'errmsg' specifies error string when ExecEvalExpr returns multiple values.
368368
*/
369369
#if PG_VERSION_NUM >= 100000
370-
#define ExecEvalExprCompat(expr, econtext, isNull, errHandler) \
370+
#define ExecEvalExprCompat(expr, econtext, isNull) \
371371
ExecEvalExpr((expr), (econtext), (isNull))
372372
#elif PG_VERSION_NUM >= 90500
373+
static inline Datum
374+
ExecEvalExprCompat(ExprState *expr, ExprContext *econtext, bool *isnull)
375+
{
376+
ExprDoneCond isdone;
377+
Datum result = ExecEvalExpr(expr, econtext, isnull, &isdone);
373378

374-
/* Variables for ExecEvalExprCompat() */
375-
extern Datum exprResult;
376-
extern ExprDoneCond isDone;
379+
if (isdone != ExprSingleResult)
380+
elog(ERROR, "expression should return single value");
377381

378-
/* Error handlers */
379-
static inline void mult_result_handler()
380-
{
381-
elog(ERROR, "partitioning expression should return single value");
382+
return result;
382383
}
383-
384-
#define ExecEvalExprCompat(expr, econtext, isNull, errHandler) \
385-
( \
386-
exprResult = ExecEvalExpr((expr), (econtext), (isNull), &isDone), \
387-
(isDone != ExprSingleResult) ? (errHandler)() : (0), \
388-
exprResult \
389-
)
390384
#endif
391385

392386

src/partition_filter.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,7 @@ select_partition_for_insert(ResultPartsStorage *parts_storage,
519519
expr_context->ecxt_scantuple = slot;
520520

521521
/* Execute expression */
522-
value = ExecEvalExprCompat(expr_state, expr_context,
523-
&isnull, mult_result_handler);
522+
value = ExecEvalExprCompat(expr_state, expr_context, &isnull);
524523

525524
if (isnull)
526525
elog(ERROR, ERR_PART_ATTR_NULL);

src/pg_pathman.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ ExtractConst(Node *node, const WalkerContext *context)
202202

203203
/* Evaluate expression */
204204
estate = ExecInitExpr((Expr *) node, NULL);
205-
value = ExecEvalExprCompat(estate, econtext, &isnull,
206-
mult_result_handler);
205+
value = ExecEvalExprCompat(estate, econtext, &isnull);
207206

208207
#if PG_VERSION_NUM >= 100000
209208
/* Free temp econtext if needed */

0 commit comments

Comments
 (0)