[to #48891422] update PL C interface signature

This commit is contained in:
0xacc
2023-04-26 15:02:30 +00:00
committed by ob-robot
parent aa50359fed
commit ffb125d10e
3 changed files with 20 additions and 13 deletions

View File

@ -16,6 +16,7 @@
#include "share/ob_errno.h"
#include "lib/utility/ob_macro_utils.h"
#include "lib/oblog/ob_log_module.h"
#include "pl/ob_pl.h"
namespace oceanbase
{
@ -24,7 +25,6 @@ using namespace common;
namespace pl
{
class ObPlExecCtx;
struct ObPLInterface {
const char* name;
PL_C_INTERFACE_t entry;
@ -33,28 +33,35 @@ struct ObPLInterface {
template <typename U, U func>
struct interface_checker {
// only these types are allowed for PL C interfaces.
// T3 is for compatibility and deprecated.
// using T4 as interface signature is encouraged.
// T3, T4 is for compatibility and deprecated.
// using T_INTERFACE as interface signature is encouraged.
// any other signature will yield a compile-time error.
using T3 = int (&)(ObExecContext &, ParamStore &, ObObj &);
using T4 = int (&)(ObExecContext &, ParamStore &, ObObj &, ObPLExecCtx &);
using T3 = int(&)(ObExecContext &, ParamStore &, ObObj &);
using T4 = int(&)(ObExecContext &, ParamStore &, ObObj &, ObPLExecCtx &);
using T_INTERFACE = int(&)(ObPLExecCtx &, ParamStore &, ObObj&);
template <typename T, T v>
struct interface_checker_helper {}; // dummy type
template <T3 v>
struct interface_checker_helper<T3, v> {
static int value(ObExecContext &exec_ctx, ParamStore &param, ObObj &obj,
ObPLExecCtx &) {
return v(exec_ctx, param, obj);
static int value(ObPLExecCtx &pl_exec_ctx, ParamStore &param, ObObj &obj) {
return v(*pl_exec_ctx.exec_ctx_, param, obj);
}
};
template <T4 v>
struct interface_checker_helper<T4, v> {
static int value(ObExecContext &exec_ctx, ParamStore &param, ObObj &obj,
ObPLExecCtx &pl_exec_ctx) {
return v(exec_ctx, param, obj, pl_exec_ctx);
static int value(ObPLExecCtx &pl_exec_ctx, ParamStore &param, ObObj &obj) {
return v(*pl_exec_ctx.exec_ctx_, param, obj, pl_exec_ctx);
}
};
template <T_INTERFACE v>
struct interface_checker_helper<T_INTERFACE, v>{
static_assert(std::is_same<decltype(&v),PL_C_INTERFACE_t>::value, "T_INTERFACE and PL_C_INTERFACE_t do not match");
static int value(ObPLExecCtx &pl_exec_ctx, ParamStore &param, ObObj &obj) {
return v(pl_exec_ctx, param, obj);
}
};