fix: correct udf body file name and correct createdtime

This commit is contained in:
slzhou 2023-04-08 11:36:09 +08:00
parent 0be6bb735a
commit 55ffb0bc6d
2 changed files with 13 additions and 12 deletions

View File

@ -475,7 +475,7 @@ static int32_t mndProcessRetrieveFuncReq(SRpcMsg *pReq) {
SFuncExtraInfo extraInfo = {0}; SFuncExtraInfo extraInfo = {0};
extraInfo.funcVersion = pFunc->funcVersion; extraInfo.funcVersion = pFunc->funcVersion;
extraInfo.funcCreatedTime = pFunc->createdTime; extraInfo.funcCreatedTime = pFunc->createdTime;
taosArrayPush(retrieveRsp.pFuncExtraInfos, &pFunc->funcVersion); taosArrayPush(retrieveRsp.pFuncExtraInfos, &extraInfo);
mndReleaseFunc(pMnode, pFunc); mndReleaseFunc(pMnode, pFunc);
} }

View File

@ -336,7 +336,8 @@ static int32_t udfdRun();
static void udfdConnectMnodeThreadFunc(void *args); static void udfdConnectMnodeThreadFunc(void *args);
SUdf *udfdNewUdf(const char *udfName); SUdf *udfdNewUdf(const char *udfName);
void udfdGetFuncBodyPath(const SUdf *udf, const char *path); void udfdGetFuncBodyPath(const SUdf *udf, char *path);
void udfdInitializeCPlugin(SUdfScriptPlugin *plugin) { void udfdInitializeCPlugin(SUdfScriptPlugin *plugin) {
plugin->scriptType = TSDB_FUNC_SCRIPT_BIN_LIB; plugin->scriptType = TSDB_FUNC_SCRIPT_BIN_LIB;
plugin->openFunc = udfdCPluginOpen; plugin->openFunc = udfdCPluginOpen;
@ -811,25 +812,25 @@ void udfdProcessTeardownRequest(SUvUdfWork *uvUdf, SUdfRequest *request) {
} }
void udfdGetFuncBodyPath(const SUdf *udf, const char *path) { void udfdGetFuncBodyPath(const SUdf *udf, char *path) {
if (udf->scriptType == TSDB_FUNC_SCRIPT_BIN_LIB) { if (udf->scriptType == TSDB_FUNC_SCRIPT_BIN_LIB) {
#ifdef WINDOWS #ifdef WINDOWS
snprintf(path, sizeof(path), "%s%s_%d_%" PRIx64 ".dll", tsDataDir, udf->name, udf->version, udf->createdTime); snprintf(path, PATH_MAX, "%s%s_%d_%" PRIx64 ".dll", tsDataDir, udf->name, udf->version, udf->createdTime);
#else #else
snprintf(path, sizeof(path), "%s/lib%s_%d_%" PRIx64 ".so", tsDataDir, udf->name, udf->version, snprintf(path, PATH_MAX, "%s/lib%s_%d_%" PRIx64 ".so", tsDataDir, udf->name, udf->version,
udf->createdTime); udf->createdTime);
#endif #endif
} else if (udf->scriptType == TSDB_FUNC_SCRIPT_PYTHON) { } else if (udf->scriptType == TSDB_FUNC_SCRIPT_PYTHON) {
#ifdef WINDOWS #ifdef WINDOWS
snprintf(path, sizeof(path), "%s%s_%d_%" PRIx64 ".py", tsDataDir, udf->name, udf->version, udf->createdTime); snprintf(path, PATH_MAX, "%s%s_%d_%" PRIx64 ".py", tsDataDir, udf->name, udf->version, udf->createdTime);
#else #else
snprintf(path, sizeof(path), "%s/%s_%d_%" PRIx64 ".py", tsDataDir, udf->name, udf->version, udf->createdTime); snprintf(path, PATH_MAX, "%s/%s_%d_%" PRIx64 ".py", tsDataDir, udf->name, udf->version, udf->createdTime);
#endif #endif
} else { } else {
#ifdef WINDOWS #ifdef WINDOWS
snprintf(path, sizeof(path), "%s%s_%d_%" PRIx64, tsDataDir, udf->name, udf->version, udf->createdTime); snprintf(path, PATH_MAX, "%s%s_%d_%" PRIx64, tsDataDir, udf->name, udf->version, udf->createdTime);
#else #else
snprintf(path, sizeof(path), "%s/lib%s_%d_%" PRIx64, tsDataDir, udf->name, udf->version, udf->createdTime); snprintf(path, PATH_MAX, "%s/lib%s_%d_%" PRIx64, tsDataDir, udf->name, udf->version, udf->createdTime);
#endif #endif
} }
} }
@ -849,7 +850,7 @@ int32_t udfdSaveFuncBodyToFile(SFuncInfo *pFuncInfo, SUdf *udf) {
TdFilePtr file = taosOpenFile(path, TD_FILE_READ); TdFilePtr file = taosOpenFile(path, TD_FILE_READ);
int64_t size = 0; int64_t size = 0;
taosFStatFile(file, &size, NULL); taosFStatFile(file, &size, NULL);
taosCloseFile(file); taosCloseFile(&file);
if (size == pFuncInfo->codeSize) { if (size == pFuncInfo->codeSize) {
strncpy(udf->path, path, PATH_MAX); strncpy(udf->path, path, PATH_MAX);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
@ -918,8 +919,8 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
udf->outputType = pFuncInfo->outputType; udf->outputType = pFuncInfo->outputType;
udf->outputLen = pFuncInfo->outputLen; udf->outputLen = pFuncInfo->outputLen;
udf->bufSize = pFuncInfo->bufSize; udf->bufSize = pFuncInfo->bufSize;
SFuncExtraInfo *pFuncExtraInfo = (SFuncExtraInfo *)taosArrayGet(retrieveRsp.pFuncExtraInfos, 0);
SFuncExtraInfo *pFuncExtraInfo = (SFuncExtraInfo *)taosArrayGet(retrieveRsp.pFuncExtraInfos, 0);
udf->version = pFuncExtraInfo->funcVersion; udf->version = pFuncExtraInfo->funcVersion;
udf->createdTime = pFuncExtraInfo->funcCreatedTime; udf->createdTime = pFuncExtraInfo->funcCreatedTime;
msgInfo->code = udfdSaveFuncBodyToFile(pFuncInfo, udf); msgInfo->code = udfdSaveFuncBodyToFile(pFuncInfo, udf);