Skip to content

Commit

Permalink
refact error code
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon9997 committed Jan 24, 2025
1 parent 3cdeaf7 commit 7971e8b
Show file tree
Hide file tree
Showing 102 changed files with 252,374 additions and 964 deletions.
8 changes: 4 additions & 4 deletions Jenkinsfile2
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ def pre_test(){
script {
sh '''
cd ${WK}
git checkout ''' + env.CHANGE_TARGET + '''
git checkout feat/3.0/TS-4897
cd ${WKC}
git checkout ''' + env.CHANGE_TARGET + '''
git checkout feat/3.0/TS-4897
'''
}
if (env.CHANGE_URL =~ /\/TDengine\//) {
Expand Down Expand Up @@ -274,11 +274,11 @@ def pre_test_win(){
script {
bat '''
cd %WIN_INTERNAL_ROOT%
git checkout ''' + env.CHANGE_TARGET + '''
git checkout feat/3.0/TS-4897
'''
bat '''
cd %WIN_COMMUNITY_ROOT%
git checkout ''' + env.CHANGE_TARGET + '''
git checkout feat/3.0/TS-4897
'''
}
script {
Expand Down
198 changes: 106 additions & 92 deletions docs/zh/14-reference/09-error-code.md

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions include/common/tmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ static FORCE_INLINE int32_t tInitDefaultSColRefWrapperByCols(SColRefWrapper* pRe
pRef->nCols = nCols;
for (int32_t i = 0; i < nCols; i++) {
pRef->pColRef[i].hasRef = false;
pRef->pColRef[i].id = (col_id_t)(i + 1);
}
return 0;
}
Expand Down Expand Up @@ -900,8 +901,8 @@ static FORCE_INLINE int32_t tDecodeSSchemaExt(SDecoder* pDecoder, SSchemaExt* pS

static FORCE_INLINE int32_t tEncodeSColRef(SEncoder* pEncoder, const SColRef* pColRef) {
TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pColRef->hasRef));
TAOS_CHECK_RETURN(tEncodeI16(pEncoder, pColRef->id));
if (pColRef->hasRef) {
TAOS_CHECK_RETURN(tEncodeI16(pEncoder, pColRef->id));
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pColRef->refTableName));
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pColRef->refColName));
}
Expand All @@ -910,8 +911,8 @@ static FORCE_INLINE int32_t tEncodeSColRef(SEncoder* pEncoder, const SColRef* pC

static FORCE_INLINE int32_t tDecodeSColRef(SDecoder* pDecoder, SColRef* pColRef) {
TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t*)&pColRef->hasRef));
TAOS_CHECK_RETURN(tDecodeI16(pDecoder, &pColRef->id));
if (pColRef->hasRef) {
TAOS_CHECK_RETURN(tDecodeI16(pDecoder, &pColRef->id));
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pColRef->refTableName));
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pColRef->refColName));
}
Expand Down Expand Up @@ -3265,6 +3266,7 @@ typedef struct SVCreateStbReq {
int8_t source;
int8_t colCmpred;
SColCmprWrapper colCmpr;
int8_t virtualStb;
} SVCreateStbReq;

int tEncodeSVCreateStbReq(SEncoder* pCoder, const SVCreateStbReq* pReq);
Expand Down Expand Up @@ -3320,12 +3322,12 @@ static FORCE_INLINE void tdDestroySVCreateTbReq(SVCreateTbReq* req) {
taosMemoryFreeClear(req->sql);
taosMemoryFreeClear(req->name);
taosMemoryFreeClear(req->comment);
if (req->type == TSDB_CHILD_TABLE) {
if (req->type == TSDB_CHILD_TABLE || req->type == TSDB_VIRTUAL_CHILD_TABLE) {
taosMemoryFreeClear(req->ctb.pTag);
taosMemoryFreeClear(req->ctb.stbName);
taosArrayDestroy(req->ctb.tagName);
req->ctb.tagName = NULL;
} else if (req->type == TSDB_NORMAL_TABLE) {
} else if (req->type == TSDB_NORMAL_TABLE || req->type == TSDB_VIRTUAL_TABLE) {
taosMemoryFreeClear(req->ntb.schemaRow.pSchema);
}
taosMemoryFreeClear(req->colCmpr.pColCmpr);
Expand Down
4 changes: 4 additions & 0 deletions include/libs/nodes/plannodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ typedef struct SJoinLogicNode {

typedef struct SVirtualScanLogicNode {
SLogicNode node;
bool scanAllCols;
SNodeList* pScanCols;
SNodeList* pScanPseudoCols;
int8_t tableType;
Expand Down Expand Up @@ -469,6 +470,9 @@ typedef SScanPhysiNode SBlockDistScanPhysiNode;

typedef struct SVirtualScanPhysiNode {
SScanPhysiNode scan;
SNodeList* pGroupTags;
bool groupSort;
bool scanAllCols;
SNodeList* pTargets;
}SVirtualScanPhysiNode;

Expand Down
2 changes: 1 addition & 1 deletion include/libs/qcom/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ void* getTaskPoolWorkerCb();

#define SET_META_TYPE_NULL(t) (t) = META_TYPE_NULL_TABLE
#define SET_META_TYPE_CTABLE(t) (t) = META_TYPE_CTABLE
#define SET_META_TYPE_VCTABLE(t) (t) = META_TYPE_CTABLE
#define SET_META_TYPE_VCTABLE(t) (t) = META_TYPE_VCTABLE
#define SET_META_TYPE_TABLE(t) (t) = META_TYPE_TABLE
#define SET_META_TYPE_BOTH_TABLE(t) (t) = META_TYPE_BOTH_TABLE
#define SET_META_TYPE_BOTH_VTABLE(t) (t) = META_TYPE_BOTH_VTABLE
Expand Down
5 changes: 2 additions & 3 deletions include/util/taoserror.h
Original file line number Diff line number Diff line change
Expand Up @@ -911,8 +911,7 @@ int32_t taosGetErrSize();
#define TSDB_CODE_PAR_INVALID_REF_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2687)
#define TSDB_CODE_PAR_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x2688)
#define TSDB_CODE_PAR_INVALID_REF_COLUMN_TYPE TAOS_DEF_ERROR_CODE(0, 0x2689)
#define TSDB_CODE_PAR_COLUMN_HAS_REF TAOS_DEF_ERROR_CODE(0, 0x268A)
#define TSDB_CODE_PAR_MISMATCH_STABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x268B)
#define TSDB_CODE_PAR_MISMATCH_STABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x268A)
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF)

//planner
Expand Down Expand Up @@ -1046,7 +1045,7 @@ int32_t taosGetErrSize();
#define TSDB_CODE_AUDIT_FAIL_GENERATE_JSON TAOS_DEF_ERROR_CODE(0, 0x6102)

// VTABLE
#define TSDB_CODE_VTABLE_SCAN_UNMATCHED_COLUMN TAOS_DEF_ERROR_CODE(0, 0x6200)
#define TSDB_CODE_VTABLE_SCAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x6200)
#define TSDB_CODE_VTABLE_SCAN_INVALID_DOWNSTREAM TAOS_DEF_ERROR_CODE(0, 0x6201)
#define TSDB_CODE_VTABLE_PRIMTS_HAS_REF TAOS_DEF_ERROR_CODE(0, 0x6202)
#define TSDB_CODE_VTABLE_NOT_VIRTUAL_SUPER_TABLE TAOS_DEF_ERROR_CODE(0, 0x6203)
Expand Down
16 changes: 10 additions & 6 deletions source/common/src/msg/tmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -10297,8 +10297,8 @@ int32_t tEncodeSColRefWrapper(SEncoder *pCoder, const SColRefWrapper *pWrapper)
for (int32_t i = 0; i < pWrapper->nCols; i++) {
SColRef *p = &pWrapper->pColRef[i];
TAOS_CHECK_EXIT(tEncodeI8(pCoder, p->hasRef));
TAOS_CHECK_EXIT(tEncodeI16v(pCoder, p->id));
if (p->hasRef) {
TAOS_CHECK_EXIT(tEncodeI16v(pCoder, p->id));
TAOS_CHECK_EXIT(tEncodeCStr(pCoder, p->refColName));
TAOS_CHECK_EXIT(tEncodeCStr(pCoder, p->refTableName));
}
Expand All @@ -10323,8 +10323,8 @@ int32_t tDecodeSColRefWrapperEx(SDecoder *pDecoder, SColRefWrapper *pWrapper) {
for (int i = 0; i < pWrapper->nCols; i++) {
SColRef *p = &pWrapper->pColRef[i];
TAOS_CHECK_EXIT(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
TAOS_CHECK_EXIT(tDecodeI16v(pDecoder, &p->id));
if (p->hasRef) {
TAOS_CHECK_EXIT(tDecodeI16v(pDecoder, &p->id));
TAOS_CHECK_EXIT(tDecodeCStrTo(pDecoder, p->refColName));
TAOS_CHECK_EXIT(tDecodeCStrTo(pDecoder, p->refTableName));
}
Expand Down Expand Up @@ -10401,6 +10401,7 @@ int tEncodeSVCreateStbReq(SEncoder *pCoder, const SVCreateStbReq *pReq) {

TAOS_CHECK_EXIT(tEncodeI8(pCoder, pReq->colCmpred));
TAOS_CHECK_EXIT(tEncodeSColCmprWrapper(pCoder, &pReq->colCmpr));
TAOS_CHECK_EXIT(tEncodeI8(pCoder, pReq->virtualStb));
tEndEncode(pCoder);

_exit:
Expand Down Expand Up @@ -10436,6 +10437,9 @@ int tDecodeSVCreateStbReq(SDecoder *pCoder, SVCreateStbReq *pReq) {
TAOS_CHECK_EXIT(tDecodeSColCmprWrapperEx(pCoder, &pReq->colCmpr));
}
}
if (!tDecodeIsEnd(pCoder)) {
TAOS_CHECK_EXIT(tDecodeI8(pCoder, &pReq->virtualStb));
}
tEndDecode(pCoder);

_exit:
Expand Down Expand Up @@ -10567,20 +10571,20 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) {
void tDestroySVCreateTbReq(SVCreateTbReq *pReq, int32_t flags) {
if (pReq == NULL) return;

// TODO(smj) : free virtual table stuff
if (flags & TSDB_MSG_FLG_ENCODE) {
// TODO
} else if (flags & TSDB_MSG_FLG_DECODE) {
taosMemoryFreeClear(pReq->comment);

if (pReq->type == TSDB_CHILD_TABLE) {
if (pReq->type == TSDB_CHILD_TABLE || pReq->type == TSDB_VIRTUAL_CHILD_TABLE) {
taosArrayDestroy(pReq->ctb.tagName);
} else if (pReq->type == TSDB_NORMAL_TABLE) {
} else if (pReq->type == TSDB_NORMAL_TABLE || pReq->type == TSDB_VIRTUAL_TABLE) {
taosMemoryFreeClear(pReq->ntb.schemaRow.pSchema);
}
}

taosMemoryFreeClear(pReq->colCmpr.pColCmpr);
taosMemoryFreeClear(pReq->colRef.pColRef);
taosMemoryFreeClear(pReq->sql);
}

Expand Down Expand Up @@ -10624,7 +10628,7 @@ void tDeleteSVCreateTbBatchReq(SVCreateTbBatchReq *pReq) {
SVCreateTbReq *pCreateReq = pReq->pReqs + iReq;
taosMemoryFreeClear(pCreateReq->sql);
taosMemoryFreeClear(pCreateReq->comment);
if (pCreateReq->type == TSDB_CHILD_TABLE) {
if (pCreateReq->type == TSDB_CHILD_TABLE || pCreateReq->type == TSDB_VIRTUAL_CHILD_TABLE) {
taosArrayDestroy(pCreateReq->ctb.tagName);
pCreateReq->ctb.tagName = NULL;
}
Expand Down
1 change: 1 addition & 0 deletions source/dnode/mnode/impl/src/mndStb.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStb, int3
req.alterOriData = alterOriData;
req.alterOriDataLen = alterOriDataLen;
req.source = pStb->source;
req.virtualStb = pStb->virtualStb;
// todo
req.schemaRow.nCols = pStb->numOfColumns;
req.schemaRow.version = pStb->colVer;
Expand Down
15 changes: 11 additions & 4 deletions source/dnode/vnode/src/meta/metaEntry.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ int meteEncodeColRefEntry(SEncoder *pCoder, const SMetaEntry *pME) {
for (int32_t i = 0; i < pw->nCols; i++) {
SColRef *p = &pw->pColRef[i];
TAOS_CHECK_RETURN(tEncodeI8(pCoder, p->hasRef));
TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
if (p->hasRef) {
TAOS_CHECK_RETURN(tEncodeI16v(pCoder, p->id));
TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refTableName));
TAOS_CHECK_RETURN(tEncodeCStr(pCoder, p->refColName));
}
Expand All @@ -50,8 +50,8 @@ int meteDecodeColRefEntry(SDecoder *pDecoder, SMetaEntry *pME) {
for (int i = 0; i < pWrapper->nCols; i++) {
SColRef *p = &pWrapper->pColRef[i];
TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&p->hasRef));
TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
if (p->hasRef) {
TAOS_CHECK_RETURN(tDecodeI16v(pDecoder, &p->id));
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refTableName));
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, p->refColName));
}
Expand Down Expand Up @@ -151,6 +151,12 @@ static int32_t metaCloneColCmpr(const SColCmprWrapper *pSrc, SColCmprWrapper *pD
return 0;
}

static void metaCloneColRefFree(SColRefWrapper *pColRef) {
if (pColRef) {
taosMemoryFreeClear(pColRef->pColRef);
}
}

static void metaCloneColCmprFree(SColCmprWrapper *pCmpr) {
if (pCmpr) {
taosMemoryFreeClear(pCmpr->pColCmpr);
Expand Down Expand Up @@ -334,16 +340,17 @@ void metaCloneEntryFree(SMetaEntry **ppEntry) {
if (TSDB_SUPER_TABLE == (*ppEntry)->type) {
metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaRow);
metaCloneSchemaFree(&(*ppEntry)->stbEntry.schemaTag);
} else if (TSDB_CHILD_TABLE == (*ppEntry)->type) {
} else if (TSDB_CHILD_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_CHILD_TABLE == (*ppEntry)->type) {
taosMemoryFreeClear((*ppEntry)->ctbEntry.comment);
taosMemoryFreeClear((*ppEntry)->ctbEntry.pTags);
} else if (TSDB_NORMAL_TABLE == (*ppEntry)->type) {
} else if (TSDB_NORMAL_TABLE == (*ppEntry)->type || TSDB_VIRTUAL_TABLE == (*ppEntry)->type) {
metaCloneSchemaFree(&(*ppEntry)->ntbEntry.schemaRow);
taosMemoryFreeClear((*ppEntry)->ntbEntry.comment);
} else {
return;
}
metaCloneColCmprFree(&(*ppEntry)->colCmpr);
metaCloneColRefFree(&(*ppEntry)->colRef);

taosMemoryFreeClear(*ppEntry);
return;
Expand Down
40 changes: 7 additions & 33 deletions source/dnode/vnode/src/meta/metaEntry2.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,30 +374,14 @@ static int32_t metaAddOrDropColumnIndexOfVirtualSuperTable(SMeta *pMeta, const S

const SMetaEntry *pEntry = pParam->pEntry;
const SMetaEntry *pOldEntry = pParam->pOldEntry;
enum { ADD_INDEX, DROP_INDEX } action;
enum { ADD_COLUMN, DROP_COLUMN } action;

if (pOldColumn && pNewColumn) {
if (IS_IDX_ON(pOldColumn) && IS_IDX_ON(pNewColumn)) {
return TSDB_CODE_SUCCESS;
} else if (IS_IDX_ON(pOldColumn) && !IS_IDX_ON(pNewColumn)) {
action = DROP_INDEX;
} else if (!IS_IDX_ON(pOldColumn) && IS_IDX_ON(pNewColumn)) {
action = ADD_INDEX;
} else {
return TSDB_CODE_SUCCESS;
}
return TSDB_CODE_SUCCESS;
} else if (pOldColumn) {
if (IS_IDX_ON(pOldColumn)) {
action = DROP_INDEX;
} else {
return TSDB_CODE_SUCCESS;
}
action = DROP_COLUMN;
} else {
if (IS_IDX_ON(pNewColumn)) {
action = ADD_INDEX;
} else {
return TSDB_CODE_SUCCESS;
}
action = ADD_COLUMN;
}

// fetch all child tables
Expand Down Expand Up @@ -425,7 +409,7 @@ static int32_t metaAddOrDropColumnIndexOfVirtualSuperTable(SMeta *pMeta, const S
.pEntry = pChildEntry
};

if (action == ADD_INDEX) {
if (action == ADD_COLUMN) {
code = updataTableColRef(&pChildEntry->colRef, pNewColumn, 1, NULL);
if (code) {
metaErr(TD_VID(pMeta->pVnode), code);
Expand Down Expand Up @@ -1507,6 +1491,8 @@ static int32_t metaHandleVirtualChildTableCreate(SMeta *pMeta, const SMetaEntry
} else {
metaErr(TD_VID(pMeta->pVnode), code);
}

metaFetchEntryFree(&pSuperEntry);
return code;
}

Expand Down Expand Up @@ -1854,18 +1840,6 @@ static int32_t metaHandleVirtualChildTableDrop(SMeta *pMeta, const SMetaEntry *p
return code;
}

#if 0
if (tbUids) {
if (taosArrayPush(tbUids, &uid) == NULL) {
rc = terrno;
goto _exit;
}
}

if ((type == TSDB_CHILD_TABLE) && tbUid) {
*tbUid = uid;
}
#endif
metaFetchEntryFree(&pChild);
metaFetchEntryFree(&pSuper);
return code;
Expand Down
17 changes: 12 additions & 5 deletions source/dnode/vnode/src/meta/metaTable.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,29 @@ int32_t updataTableColRef(SColRefWrapper *pWp, const SSchema *pSchema, int8_t ad
SColRef *pCol = p + nCols;
if (NULL == pColRef) {
pCol->hasRef = false;
pCol->id = pSchema->colId;
} else {
pCol->hasRef = pColRef->hasRef;
pCol->id = pSchema->colId;
if (pCol->hasRef) {
pCol->id = pSchema->colId;
tstrncpy(pCol->refTableName, pColRef->refTableName, TSDB_TABLE_NAME_LEN);
tstrncpy(pCol->refColName, pColRef->refColName, TSDB_COL_NAME_LEN);
}
}
pWp->nCols = nCols + 1;
pWp->version = ver;
} else {
int32_t left = (nCols - pSchema->colId) * sizeof(SColRef);
if (left) {
memmove(pWp->pColRef + pSchema->colId, pWp->pColRef + pSchema->colId + 1, left);
for (int32_t i = 0; i < nCols; i++) {
SColRef *pOColRef = &pWp->pColRef[i];
if (pOColRef->id == pSchema->colId) {
int32_t left = (nCols - i - 1) * sizeof(SColCmpr);
if (left) {
memmove(pWp->pColRef + i, pWp->pColRef + i + 1, left);
}
nCols--;
break;
}
}
nCols--;
pWp->nCols = nCols;
pWp->version = ver;
}
Expand Down
Loading

0 comments on commit 7971e8b

Please sign in to comment.