fix: keep original udf file name when rename file error
This commit is contained in:
parent
c4d05af01a
commit
ba82f05d68
|
@ -241,7 +241,7 @@ typedef struct SUvUdfWork {
|
||||||
struct SUvUdfWork *pWorkNext;
|
struct SUvUdfWork *pWorkNext;
|
||||||
} SUvUdfWork;
|
} SUvUdfWork;
|
||||||
|
|
||||||
typedef enum { UDF_STATE_INIT = 0, UDF_STATE_LOADING, UDF_STATE_READY} EUdfState;
|
typedef enum { UDF_STATE_INIT = 0, UDF_STATE_LOADING, UDF_STATE_READY } EUdfState;
|
||||||
|
|
||||||
typedef struct SUdf {
|
typedef struct SUdf {
|
||||||
char name[TSDB_FUNC_NAME_LEN + 1];
|
char name[TSDB_FUNC_NAME_LEN + 1];
|
||||||
|
@ -509,15 +509,15 @@ int32_t udfdRenameUdfFile(SUdf *udf) {
|
||||||
char newPath[PATH_MAX];
|
char newPath[PATH_MAX];
|
||||||
if (udf->scriptType == TSDB_FUNC_SCRIPT_BIN_LIB) {
|
if (udf->scriptType == TSDB_FUNC_SCRIPT_BIN_LIB) {
|
||||||
snprintf(newPath, PATH_MAX, "%s/lib%s.so", tsTempDir, udf->name);
|
snprintf(newPath, PATH_MAX, "%s/lib%s.so", tsTempDir, udf->name);
|
||||||
taosRenameFile(udf->path, newPath);
|
|
||||||
sprintf(udf->path, "%s", newPath);
|
|
||||||
} else if (udf->scriptType == TSDB_FUNC_SCRIPT_PYTHON) {
|
} else if (udf->scriptType == TSDB_FUNC_SCRIPT_PYTHON) {
|
||||||
snprintf(newPath, PATH_MAX, "%s/%s.py", tsTempDir, udf->name);
|
snprintf(newPath, PATH_MAX, "%s/%s.py", tsTempDir, udf->name);
|
||||||
taosRenameFile(udf->path, newPath);
|
|
||||||
sprintf(udf->path, "%s", newPath);
|
|
||||||
} else {
|
} else {
|
||||||
return TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED;
|
return TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
int32_t code = taosRenameFile(udf->path, newPath);
|
||||||
|
if (code == 0) {
|
||||||
|
sprintf(udf->path, "%s", newPath);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,13 @@
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include "taosudf.h"
|
#include "taosudf.h"
|
||||||
|
|
||||||
|
DLL_EXPORT int32_t bit_and_init() { return 0; }
|
||||||
|
|
||||||
DLL_EXPORT int32_t bit_and_init() {
|
DLL_EXPORT int32_t bit_and_destroy() { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
DLL_EXPORT int32_t bit_and_destroy() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
DLL_EXPORT int32_t bit_and(SUdfDataBlock* block, SUdfColumn *resultCol) {
|
|
||||||
|
|
||||||
|
DLL_EXPORT int32_t bit_and(SUdfDataBlock* block, SUdfColumn* resultCol) {
|
||||||
if (block->numOfCols < 2) {
|
if (block->numOfCols < 2) {
|
||||||
return TSDB_CODE_UDF_INVALID_INPUT;
|
return TSDB_CODE_UDF_INVALID_INPUT;
|
||||||
}
|
}
|
||||||
|
@ -25,18 +19,9 @@ DLL_EXPORT int32_t bit_and(SUdfDataBlock* block, SUdfColumn *resultCol) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SUdfColumnMeta *meta = &resultCol->colMeta;
|
SUdfColumnData* resultData = &resultCol->colData;
|
||||||
meta->bytes = 4;
|
|
||||||
meta->type = TSDB_DATA_TYPE_INT;
|
|
||||||
meta->scale = 0;
|
|
||||||
meta->precision = 0;
|
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < block->numOfRows; ++i) {
|
||||||
SUdfColumnData *resultData = &resultCol->colData;
|
|
||||||
|
|
||||||
resultData->numOfRows = block->numOfRows;
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < resultData->numOfRows; ++i) {
|
|
||||||
if (udfColDataIsNull(block->udfCols[0], i)) {
|
if (udfColDataIsNull(block->udfCols[0], i)) {
|
||||||
udfColDataSetNull(resultCol, i);
|
udfColDataSetNull(resultCol, i);
|
||||||
continue;
|
continue;
|
||||||
|
@ -55,7 +40,8 @@ DLL_EXPORT int32_t bit_and(SUdfDataBlock* block, SUdfColumn *resultCol) {
|
||||||
if (j == block->numOfCols) {
|
if (j == block->numOfCols) {
|
||||||
udfColDataSet(resultCol, i, (char*)&result, false);
|
udfColDataSet(resultCol, i, (char*)&result, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
resultData->numOfRows = block->numOfRows;
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue