diff --git a/src/backend/pgxc/plan/planner.c b/src/backend/pgxc/plan/planner.c index 420a531..87a72e8 100644 --- a/src/backend/pgxc/plan/planner.c +++ b/src/backend/pgxc/plan/planner.c @@ -1622,7 +1622,7 @@ pgxc_shippability_walker(Node *node, Shippability_context *sc_context) * functions to the Datanode. We need a better way to see what * can be shipped to the Datanode and what can not be. */ - if (!is_immutable_func(funcexpr->funcid)) + if (func_volatile(funcexpr->funcid) != PROVOLATILE_IMMUTABLE) pgxc_set_shippability_reason(sc_context, SS_UNSHIPPABLE_EXPR); } break; @@ -1639,7 +1639,8 @@ pgxc_shippability_walker(Node *node, Shippability_context *sc_context) OpExpr *op_expr = (OpExpr *)node; Oid opfuncid = OidIsValid(op_expr->opfuncid) ? op_expr->opfuncid : get_opcode(op_expr->opno); - if (!OidIsValid(opfuncid) || !is_immutable_func(opfuncid)) + if (!OidIsValid(opfuncid) || + func_volatile(opfuncid) != PROVOLATILE_IMMUTABLE) pgxc_set_shippability_reason(sc_context, SS_UNSHIPPABLE_EXPR); } break; @@ -1653,7 +1654,8 @@ pgxc_shippability_walker(Node *node, Shippability_context *sc_context) ScalarArrayOpExpr *sao_expr = (ScalarArrayOpExpr *)node; Oid opfuncid = OidIsValid(sao_expr->opfuncid) ? sao_expr->opfuncid : get_opcode(sao_expr->opno); - if (!OidIsValid(opfuncid) || !is_immutable_func(opfuncid)) + if (!OidIsValid(opfuncid) || + func_volatile(opfuncid) != PROVOLATILE_IMMUTABLE) pgxc_set_shippability_reason(sc_context, SS_UNSHIPPABLE_EXPR); } break; @@ -1786,7 +1788,7 @@ pgxc_shippability_walker(Node *node, Shippability_context *sc_context) * be shipped to the datanodes. */ if (sc_context->sc_for_expr || - !is_immutable_func(winf->winfnoid)) + func_volatile(winf->winfnoid) != PROVOLATILE_IMMUTABLE) pgxc_set_shippability_reason(sc_context, SS_UNSHIPPABLE_EXPR); } break; diff --git a/src/backend/pgxc/pool/postgresql_fdw.c b/src/backend/pgxc/pool/postgresql_fdw.c index e8bb61b..133e4d3 100644 --- a/src/backend/pgxc/pool/postgresql_fdw.c +++ b/src/backend/pgxc/pool/postgresql_fdw.c @@ -31,38 +31,6 @@ #define DEBUG_FDW /* - * Check whether the function is IMMUTABLE. - */ -bool -is_immutable_func(Oid funcid) -{ - HeapTuple tp; - bool isnull; - Datum datum; - - tp = SearchSysCache(PROCOID, ObjectIdGetDatum(funcid), 0, 0, 0); - if (!HeapTupleIsValid(tp)) - elog(ERROR, "cache lookup failed for function %u", funcid); - -#ifdef DEBUG_FDW - /* print function name and its immutability */ - { - char *proname; - datum = SysCacheGetAttr(PROCOID, tp, Anum_pg_proc_proname, &isnull); - proname = pstrdup(DatumGetName(datum)->data); - elog(DEBUG1, "func %s(%u) is%s immutable", proname, funcid, - (DatumGetChar(datum) == PROVOLATILE_IMMUTABLE) ? "" : " not"); - pfree(proname); - } -#endif - - datum = SysCacheGetAttr(PROCOID, tp, Anum_pg_proc_provolatile, &isnull); - ReleaseSysCache(tp); - - return (DatumGetChar(datum) == PROVOLATILE_IMMUTABLE); -} - -/* * Check whether the ExprState node should be evaluated in foreign server. * * An expression which consists of expressions below will be evaluated in diff --git a/src/include/pgxc/postgresql_fdw.h b/src/include/pgxc/postgresql_fdw.h index 57ab2b7..0b75032 100644 --- a/src/include/pgxc/postgresql_fdw.h +++ b/src/include/pgxc/postgresql_fdw.h @@ -18,6 +18,5 @@ #include "postgres.h" #include "pgxc/execRemote.h" -bool is_immutable_func(Oid funcid); bool pgxc_is_expr_shippable(Expr *node, bool *has_aggs); #endif