From c8e05226ceee05a2d5c239f0889f67e04b05b28e Mon Sep 17 00:00:00 2001 From: slzhou Date: Sun, 12 Mar 2023 09:40:49 +0800 Subject: [PATCH] fix: unknown error prompt --- include/util/taoserror.h | 2 +- source/libs/function/src/udfd.c | 19 ++++++++++++------- source/util/src/terror.c | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 0d959271c0..3ffbd02e97 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -713,7 +713,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_UDF_INVALID_BUFSIZE TAOS_DEF_ERROR_CODE(0, 0x2909) #define TSDB_CODE_UDF_INVALID_OUTPUT_TYPE TAOS_DEF_ERROR_CODE(0, 0x290A) #define TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED TAOS_DEF_ERROR_CODE(0, 0x290B) -#define TSDB_CODE_UDF_FUNC_NOT_IMPLEMENTED TAOS_DEF_ERROR_CODE(0, 0x290C) +#define TSDB_CODE_UDF_FUNC_EXEC_FAILURE TAOS_DEF_ERROR_CODE(0, 0x290C) // sml #define TSDB_CODE_SML_INVALID_PROTOCOL_TYPE TAOS_DEF_ERROR_CODE(0, 0x3000) diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 4bfa5ceb3b..f67b352cc0 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -127,7 +127,8 @@ int32_t udfdCPluginUdfScalarProc(SUdfDataBlock *block, SUdfColumn *resultCol, vo if (ctx->scalarProcFunc) { return ctx->scalarProcFunc(block, resultCol); } else { - return TSDB_CODE_UDF_FUNC_NOT_IMPLEMENTED; + fnError("udfd c plugin scalar proc not implemented"); + return TSDB_CODE_UDF_FUNC_EXEC_FAILURE; } } @@ -136,7 +137,8 @@ int32_t udfdCPluginUdfAggStart(SUdfInterBuf *buf, void *udfCtx) { if (ctx->aggStartFunc) { return ctx->aggStartFunc(buf); } else { - return TSDB_CODE_UDF_FUNC_NOT_IMPLEMENTED; + fnError("udfd c plugin aggregation start not implemented"); + return TSDB_CODE_UDF_FUNC_EXEC_FAILURE; } return 0; } @@ -146,7 +148,8 @@ int32_t udfdCPluginUdfAggProc(SUdfDataBlock *block, SUdfInterBuf *interBuf, SUdf if (ctx->aggProcFunc) { return ctx->aggProcFunc(block, interBuf, newInterBuf); } else { - return TSDB_CODE_UDF_FUNC_NOT_IMPLEMENTED; + fnError("udfd c plugin aggregation process not implemented"); + return TSDB_CODE_UDF_FUNC_EXEC_FAILURE; } } @@ -156,7 +159,8 @@ int32_t udfdCPluginUdfAggMerge(SUdfInterBuf *inputBuf1, SUdfInterBuf *inputBuf2, if (ctx->aggMergeFunc) { return ctx->aggMergeFunc(inputBuf1, inputBuf2, outputBuf); } else { - return TSDB_CODE_UDF_FUNC_NOT_IMPLEMENTED; + fnError("udfd c plugin aggregation merge not implemented"); + return TSDB_CODE_UDF_FUNC_EXEC_FAILURE; } } @@ -165,7 +169,8 @@ int32_t udfdCPluginUdfAggFinish(SUdfInterBuf *buf, SUdfInterBuf *resultData, voi if (ctx->aggFinishFunc) { return ctx->aggFinishFunc(buf, resultData); } else { - return TSDB_CODE_UDF_FUNC_NOT_IMPLEMENTED; + fnError("udfd c plugin aggregation finish not implemented"); + return TSDB_CODE_UDF_FUNC_EXEC_FAILURE; } return 0; } @@ -618,7 +623,7 @@ void udfdProcessSetupRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { SUdfResponse rsp; rsp.seqNum = request->seqNum; rsp.type = request->type; - rsp.code = code; + rsp.code = (code != 0) ? TSDB_CODE_UDF_FUNC_EXEC_FAILURE : 0; rsp.setupRsp.udfHandle = (int64_t)(handle); rsp.setupRsp.outputType = udf->outputType; rsp.setupRsp.bytes = udf->outputLen; @@ -701,7 +706,7 @@ void udfdProcessCallRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { rsp->seqNum = request->seqNum; rsp->type = request->type; - rsp->code = code; + rsp->code = (code != 0) ? TSDB_CODE_UDF_FUNC_EXEC_FAILURE : 0; subRsp->callType = call->callType; int32_t len = encodeUdfResponse(NULL, rsp); diff --git a/source/util/src/terror.c b/source/util/src/terror.c index b5890d7083..cb0ccc75df 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -584,7 +584,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_UDF_NO_FUNC_HANDLE, "udf no function han TAOS_DEFINE_ERROR(TSDB_CODE_UDF_INVALID_BUFSIZE, "udf invalid bufsize") TAOS_DEFINE_ERROR(TSDB_CODE_UDF_INVALID_OUTPUT_TYPE, "udf invalid output type") TAOS_DEFINE_ERROR(TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED, "udf program language not supported") -TAOS_DEFINE_ERROR(TSDB_CODE_UDF_FUNC_NOT_IMPLEMENTED, "udf function not implemented") +TAOS_DEFINE_ERROR(TSDB_CODE_UDF_FUNC_EXEC_FAILURE, "udf function execution failure") //schemaless TAOS_DEFINE_ERROR(TSDB_CODE_SML_INVALID_PROTOCOL_TYPE, "Invalid line protocol type") -- GitLab