[to #48891422] update PL C interface signature
This commit is contained in:
parent
aa50359fed
commit
ffb125d10e
@ -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 ¶m, ObObj &obj,
|
||||
ObPLExecCtx &) {
|
||||
return v(exec_ctx, param, obj);
|
||||
static int value(ObPLExecCtx &pl_exec_ctx, ParamStore ¶m, 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 ¶m, ObObj &obj,
|
||||
ObPLExecCtx &pl_exec_ctx) {
|
||||
return v(exec_ctx, param, obj, pl_exec_ctx);
|
||||
static int value(ObPLExecCtx &pl_exec_ctx, ParamStore ¶m, 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 ¶m, ObObj &obj) {
|
||||
return v(pl_exec_ctx, param, obj);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -137,7 +137,7 @@ namespace oceanbase
|
||||
namespace pl
|
||||
{
|
||||
|
||||
typedef int(*PL_C_INTERFACE_t)(ObExecContext&, ParamStore&, ObObj&, ObPLExecCtx&);
|
||||
typedef int(*PL_C_INTERFACE_t)(ObPLExecCtx&, ParamStore&, ObObj&);
|
||||
|
||||
enum ObPLInterfaceType
|
||||
{
|
||||
|
@ -4846,7 +4846,7 @@ int ObSPIService::spi_interface_impl(pl::ObPLExecCtx *ctx, const char *interface
|
||||
ObString name(interface_name);
|
||||
PL_C_INTERFACE_t fp = GCTX.pl_engine_->get_interface_service().get_entry(name);
|
||||
if (nullptr != fp) {
|
||||
ret = fp(*ctx->exec_ctx_, *ctx->params_, *ctx->result_, *ctx);
|
||||
ret = fp(*ctx, *ctx->params_, *ctx->result_);
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("Calling C interface which doesn't exist", K(interface_name), K(name));
|
||||
|
Loading…
x
Reference in New Issue
Block a user