提交 6b68a373 编写于 作者: S shenglian zhou

fix: when update func, set createdtime to original time

上级 765c09d5
...@@ -145,8 +145,8 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) { ...@@ -145,8 +145,8 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) {
goto _OVER; goto _OVER;
} }
SDB_GET_BINARY(pRaw, dataPos, pFunc->pCode, pFunc->codeSize, _OVER) SDB_GET_BINARY(pRaw, dataPos, pFunc->pCode, pFunc->codeSize, _OVER)
if(sver >= 2){ if (sver >= 2) {
SDB_GET_INT32(pRaw, dataPos, &pFunc->funcVersion, _OVER) SDB_GET_INT32(pRaw, dataPos, &pFunc->funcVersion, _OVER)
} }
...@@ -181,7 +181,7 @@ static int32_t mndFuncActionDelete(SSdb *pSdb, SFuncObj *pFunc) { ...@@ -181,7 +181,7 @@ static int32_t mndFuncActionDelete(SSdb *pSdb, SFuncObj *pFunc) {
static int32_t mndFuncActionUpdate(SSdb *pSdb, SFuncObj *pOld, SFuncObj *pNew) { static int32_t mndFuncActionUpdate(SSdb *pSdb, SFuncObj *pOld, SFuncObj *pNew) {
mTrace("func:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew); mTrace("func:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew);
taosWLockLatch(&pOld->lock); taosWLockLatch(&pOld->lock);
pOld->align = pNew->align; pOld->align = pNew->align;
...@@ -194,21 +194,21 @@ static int32_t mndFuncActionUpdate(SSdb *pSdb, SFuncObj *pOld, SFuncObj *pNew) { ...@@ -194,21 +194,21 @@ static int32_t mndFuncActionUpdate(SSdb *pSdb, SFuncObj *pOld, SFuncObj *pNew) {
pOld->outputLen = pNew->outputLen; pOld->outputLen = pNew->outputLen;
pOld->outputType = pNew->outputType; pOld->outputType = pNew->outputType;
if(pOld->pComment != NULL){ if (pOld->pComment != NULL) {
taosMemoryFree(pOld->pComment); taosMemoryFree(pOld->pComment);
pOld->pComment = NULL; pOld->pComment = NULL;
} }
if(pNew->commentSize > 0 && pNew->pComment != NULL){ if (pNew->commentSize > 0 && pNew->pComment != NULL) {
pOld->commentSize = pNew->commentSize; pOld->commentSize = pNew->commentSize;
pOld->pComment = taosMemoryMalloc(pOld->commentSize); pOld->pComment = taosMemoryMalloc(pOld->commentSize);
memcpy(pOld->pComment, pNew->pComment, pOld->commentSize); memcpy(pOld->pComment, pNew->pComment, pOld->commentSize);
} }
if(pOld->pCode != NULL){ if (pOld->pCode != NULL) {
taosMemoryFree(pOld->pCode); taosMemoryFree(pOld->pCode);
pOld->pCode = NULL; pOld->pCode = NULL;
} }
if(pNew->codeSize > 0 && pNew->pCode != NULL){ if (pNew->codeSize > 0 && pNew->pCode != NULL) {
pOld->codeSize = pNew->codeSize; pOld->codeSize = pNew->codeSize;
pOld->pCode = taosMemoryMalloc(pOld->codeSize); pOld->pCode = taosMemoryMalloc(pOld->codeSize);
memcpy(pOld->pCode, pNew->pCode, pOld->codeSize); memcpy(pOld->pCode, pNew->pCode, pOld->codeSize);
...@@ -216,7 +216,7 @@ static int32_t mndFuncActionUpdate(SSdb *pSdb, SFuncObj *pOld, SFuncObj *pNew) { ...@@ -216,7 +216,7 @@ static int32_t mndFuncActionUpdate(SSdb *pSdb, SFuncObj *pOld, SFuncObj *pNew) {
pOld->scriptType = pNew->scriptType; pOld->scriptType = pNew->scriptType;
pOld->signature = pNew->signature; pOld->signature = pNew->signature;
taosWUnLockLatch(&pOld->lock); taosWUnLockLatch(&pOld->lock);
return 0; return 0;
...@@ -268,14 +268,15 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre ...@@ -268,14 +268,15 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
memcpy(func.pComment, pCreate->pComment, func.commentSize); memcpy(func.pComment, pCreate->pComment, func.commentSize);
} }
memcpy(func.pCode, pCreate->pCode, func.codeSize); memcpy(func.pCode, pCreate->pCode, func.codeSize);
pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-func"); pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-func");
if (pTrans == NULL) goto _OVER; if (pTrans == NULL) goto _OVER;
mInfo("trans:%d, used to create func:%s", pTrans->id, pCreate->name); mInfo("trans:%d, used to create func:%s", pTrans->id, pCreate->name);
SFuncObj *oldFunc = mndAcquireFunc(pMnode, pCreate->name); SFuncObj *oldFunc = mndAcquireFunc(pMnode, pCreate->name);
if(pCreate->orReplace == 1 && oldFunc != NULL){ if (pCreate->orReplace == 1 && oldFunc != NULL) {
func.funcVersion = oldFunc->funcVersion + 1; func.funcVersion = oldFunc->funcVersion + 1;
func.createdTime = oldFunc->createdTime;
SSdbRaw *pRedoRaw = mndFuncActionEncode(oldFunc); SSdbRaw *pRedoRaw = mndFuncActionEncode(oldFunc);
if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER; if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER;
...@@ -288,8 +289,7 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre ...@@ -288,8 +289,7 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
SSdbRaw *pCommitRaw = mndFuncActionEncode(&func); SSdbRaw *pCommitRaw = mndFuncActionEncode(&func);
if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER; if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER;
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) goto _OVER; if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) goto _OVER;
} } else {
else{
SSdbRaw *pRedoRaw = mndFuncActionEncode(&func); SSdbRaw *pRedoRaw = mndFuncActionEncode(&func);
if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER; if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER;
if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING) != 0) goto _OVER; if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING) != 0) goto _OVER;
...@@ -308,7 +308,7 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre ...@@ -308,7 +308,7 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
code = 0; code = 0;
_OVER: _OVER:
if(oldFunc != NULL){ if (oldFunc != NULL) {
mndReleaseFunc(pMnode, oldFunc); mndReleaseFunc(pMnode, oldFunc);
} }
...@@ -628,7 +628,7 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl ...@@ -628,7 +628,7 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->bufSize, false); colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->bufSize, false);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
char* language = ""; char *language = "";
if (pFunc->scriptType == TSDB_FUNC_SCRIPT_BIN_LIB) { if (pFunc->scriptType == TSDB_FUNC_SCRIPT_BIN_LIB) {
language = "C"; language = "C";
} else if (pFunc->scriptType == TSDB_FUNC_SCRIPT_PYTHON) { } else if (pFunc->scriptType == TSDB_FUNC_SCRIPT_PYTHON) {
...@@ -640,15 +640,17 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl ...@@ -640,15 +640,17 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
colDataSetVal(pColInfo, numOfRows, (const char *)varLang, false); colDataSetVal(pColInfo, numOfRows, (const char *)varLang, false);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
int32_t varCodeLen = (pFunc->codeSize + VARSTR_HEADER_SIZE) > TSDB_MAX_BINARY_LEN ? TSDB_MAX_BINARY_LEN : pFunc->codeSize + VARSTR_HEADER_SIZE; int32_t varCodeLen = (pFunc->codeSize + VARSTR_HEADER_SIZE) > TSDB_MAX_BINARY_LEN
char *b4 = taosMemoryMalloc(varCodeLen); ? TSDB_MAX_BINARY_LEN
: pFunc->codeSize + VARSTR_HEADER_SIZE;
char *b4 = taosMemoryMalloc(varCodeLen);
memcpy(varDataVal(b4), pFunc->pCode, varCodeLen - VARSTR_HEADER_SIZE); memcpy(varDataVal(b4), pFunc->pCode, varCodeLen - VARSTR_HEADER_SIZE);
varDataSetLen(b4, varCodeLen - VARSTR_HEADER_SIZE); varDataSetLen(b4, varCodeLen - VARSTR_HEADER_SIZE);
colDataSetVal(pColInfo, numOfRows, (const char*)b4, false); colDataSetVal(pColInfo, numOfRows, (const char *)b4, false);
taosMemoryFree(b4); taosMemoryFree(b4);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataSetVal(pColInfo, numOfRows, (const char*)&pFunc->funcVersion, false); colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->funcVersion, false);
numOfRows++; numOfRows++;
sdbRelease(pSdb, pFunc); sdbRelease(pSdb, pFunc);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册