From a9d47ded0ac786fa0cef55e96e05a8f7bc18fe52 Mon Sep 17 00:00:00 2001 From: slzhou Date: Sun, 24 Apr 2022 15:11:12 +0800 Subject: [PATCH] more udf info --- source/libs/function/inc/tudf.h | 3 ++- source/libs/function/src/udfd.c | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/source/libs/function/inc/tudf.h b/source/libs/function/inc/tudf.h index 247258ff9a..cb1fe320d8 100644 --- a/source/libs/function/inc/tudf.h +++ b/source/libs/function/inc/tudf.h @@ -36,7 +36,8 @@ extern "C" { enum { UDFC_CODE_STOPPING = -1, - UDFC_CODE_PIPE_READ_ERR = -3, + UDFC_CODE_PIPE_READ_ERR = -2, + UDF_CODE_LOAD_UDF_FAILURE = -3, }; typedef void *UdfcHandle; diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index ba1413f15d..220e1cd025 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -63,8 +63,13 @@ typedef struct SUdf { uv_mutex_t lock; uv_cond_t condReady; - char name[16]; - int8_t type; + char name[TSDB_FUNC_NAME_LEN]; + int8_t funcType; + int8_t scriptType; + int8_t outputType; + int32_t outputLen; + int32_t bufSize; + char path[PATH_MAX]; uv_lib_t lib; @@ -88,7 +93,7 @@ int32_t udfdLoadUdf(char *udfName, SEpSet *pEpSet, SUdf *udf) { int err = uv_dlopen(udf->path, &udf->lib); if (err != 0) { fnError("can not load library %s. error: %s", udf->path, uv_strerror(err)); - // TODO set error + return UDF_CODE_LOAD_UDF_FAILURE; } // TODO: find all the functions char normalFuncName[TSDB_FUNC_NAME_LEN] = {0}; @@ -416,9 +421,15 @@ int32_t udfdFillUdfInfoFromMNode(void *clientRpc, SEpSet *pEpSet, char *udfName, SFuncInfo *pFuncInfo = (SFuncInfo *)taosArrayGet(retrieveRsp.pFuncInfos, 0); + udf->funcType = pFuncInfo->funcType; + udf->scriptType = pFuncInfo->scriptType; + udf->outputType = pFuncInfo->funcType; + udf->outputLen = pFuncInfo->outputLen; + udf->bufSize = pFuncInfo->bufSize; + char path[PATH_MAX] = {0}; snprintf(path, sizeof(path), "%s/lib%s.so", "/tmp", udfName); - TdFilePtr file = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC); + TdFilePtr file = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL); // TODO check for failure of flush to disk taosWriteFile(file, pFuncInfo->pCode, pFuncInfo->codeSize); taosCloseFile(&file);