From 7356bf397c6fa84a9044b70119e63c7d830b2535 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 20 Oct 2021 10:09:34 +0800 Subject: [PATCH] fix union all issue --- src/client/src/tscSQLParser.c | 1 + src/query/inc/qUdf.h | 1 + src/query/src/qExecutor.c | 13 ++++++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 6116b68be1..ef5bb7c501 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -8568,6 +8568,7 @@ int32_t loadAllTableMeta(SSqlObj* pSql, struct SSqlInfo* pInfo) { if (functionId < 0) { struct SUdfInfo info = {0}; info.name = strndup(t->z, t->n); + info.keep = true; if (pQueryInfo->pUdfInfo == NULL) { pQueryInfo->pUdfInfo = taosArrayInit(4, sizeof(struct SUdfInfo)); } else if (taosArrayGetSize(pQueryInfo->pUdfInfo) > 0) { diff --git a/src/query/inc/qUdf.h b/src/query/inc/qUdf.h index 1083b1e698..77da4b668a 100644 --- a/src/query/inc/qUdf.h +++ b/src/query/inc/qUdf.h @@ -51,6 +51,7 @@ typedef struct SUdfInfo { SUdfInit init; char *content; char *path; + bool keep; } SUdfInfo; //script diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index ae17e13ef1..483138db45 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -8075,10 +8075,21 @@ int32_t initUdfInfo(SUdfInfo* pUdfInfo) { // TODO check for failure of flush to disk /*size_t t = */ fwrite(pUdfInfo->content, pUdfInfo->contLen, 1, file); fclose(file); - tfree(pUdfInfo->content); + if (!pUdfInfo->keep) { + tfree(pUdfInfo->content); + } + if (pUdfInfo->path) { + unlink(pUdfInfo->path); + } + + tfree(pUdfInfo->path); pUdfInfo->path = strdup(path); + if (pUdfInfo->handle) { + taosCloseDll(pUdfInfo->handle); + } + pUdfInfo->handle = taosLoadDll(path); if (NULL == pUdfInfo->handle) { -- GitLab