diff --git a/include/common/tmsg.h b/include/common/tmsg.h index a3186b81898975a52dba2d918d963625b770e80c..a3d0ab39038923a6a435dd23bf50b81a73f236bc 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1375,7 +1375,9 @@ typedef struct { SArray* pArray; } SVCreateTbBatchReq; + typedef struct { + SArray* rspList; // SArray } SVCreateTbBatchRsp; int32_t tSerializeSVCreateTbBatchReq(void** buf, SVCreateTbBatchReq* pReq); diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 7189129d208109dacd1d5cca310913377206ad86..d51bf1b196d3b442589dce3bdbddde12cc60c955 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -193,7 +193,7 @@ void vnodeOptionsInit(SVnodeCfg *pOptions); */ void vnodeOptionsClear(SVnodeCfg *pOptions); -int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableName); +int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName); /* ------------------------ FOR COMPILE ------------------------ */ diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index 10d0d3372204b771505750776c966e45943c31fe..7a8e6d81f76cee7604bef5cf4236418b9b15549e 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -34,19 +34,22 @@ void vnodeOptionsCopy(SVnodeCfg *pDest, const SVnodeCfg *pSrc) { memcpy((void *)pDest, (void *)pSrc, sizeof(SVnodeCfg)); } -int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableName) { +int vnodeValidateTableHash(SVnodeCfg *pVnodeOptions, char *tableFName) { uint32_t hashValue = 0; switch (pVnodeOptions->hashMethod) { default: - hashValue = MurmurHash3_32(tableName, strlen(tableName)); + hashValue = MurmurHash3_32(tableFName, strlen(tableFName)); break; } + // TODO OPEN THIS !!!!!!! +#if 1 if (hashValue < pVnodeOptions->hashBegin || hashValue > pVnodeOptions->hashEnd) { terrno = TSDB_CODE_VND_HASH_MISMATCH; return TSDB_CODE_VND_HASH_MISMATCH; } +#endif return TSDB_CODE_SUCCESS; } diff --git a/source/dnode/vnode/src/vnd/vnodeWrite.c b/source/dnode/vnode/src/vnd/vnodeWrite.c index e62d2b0a92057a44ec5718370be408c6d9a23c58..e7ba46d3ecccf4c8c4f5eb4aaf258df3281c94bb 100644 --- a/source/dnode/vnode/src/vnd/vnodeWrite.c +++ b/source/dnode/vnode/src/vnd/vnodeWrite.c @@ -77,9 +77,35 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { } case TDMT_VND_CREATE_TABLE: { SVCreateTbBatchReq vCreateTbBatchReq = {0}; + SVCreateTbBatchRsp vCreateTbBatchRsp = {0}; tDeserializeSVCreateTbBatchReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vCreateTbBatchReq); - for (int i = 0; i < taosArrayGetSize(vCreateTbBatchReq.pArray); i++) { + int reqNum = taosArrayGetSize(vCreateTbBatchReq.pArray); + for (int i = 0; i < reqNum; i++) { SVCreateTbReq *pCreateTbReq = taosArrayGet(vCreateTbBatchReq.pArray, i); + + // TODO OPEN THIS + #if 0 + char tableFName[TSDB_TABLE_FNAME_LEN]; + tNameExtractFullName(&pCreateTbReq->name, tableFName); + #endif + + int32_t code = vnodeValidateTableHash(&pVnode->config, tableFName); + if (code) { + SVCreateTbRsp rsp; + rsp.code = code; + memcpy(rsp.tableName, pCreateTbReq->name, sizeof(rsp.tableName)); + + if (NULL == vCreateTbBatchRsp.rspList) { + vCreateTbBatchRsp.rspList = taosArrayInit(reqNum - i, sizeof(SVCreateTbRsp)); + if (NULL == vCreateTbBatchRsp.rspList) { + vError("vgId:%d, failed to init array: %d", reqNum - i); + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + } + + taosArrayPush(vCreateTbBatchRsp.rspList, &rsp); + } if (metaCreateTable(pVnode->pMeta, pCreateTbReq) < 0) { // TODO: handle error @@ -98,6 +124,9 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { vTrace("vgId:%d process create %" PRIzu " tables", pVnode->vgId, taosArrayGetSize(vCreateTbBatchReq.pArray)); taosArrayDestroy(vCreateTbBatchReq.pArray); + if (vCreateTbBatchRsp.rspList) { + + } break; } case TDMT_VND_ALTER_STB: {