Merge pull request #13071 from taosdata/fix/hzcheng_3.0
fix: vnode pre-process
This commit is contained in:
commit
8571614bdc
|
@ -1729,9 +1729,9 @@ int32_t tDecodeSVDropStbReq(SDecoder* pCoder, SVDropStbReq* pReq);
|
|||
#define TD_CREATE_IF_NOT_EXISTS 0x1
|
||||
typedef struct SVCreateTbReq {
|
||||
int32_t flags;
|
||||
char* name;
|
||||
tb_uid_t uid;
|
||||
int64_t ctime;
|
||||
char* name;
|
||||
int32_t ttl;
|
||||
int8_t type;
|
||||
union {
|
||||
|
|
|
@ -3861,10 +3861,9 @@ int tEncodeSVCreateTbReq(SEncoder *pCoder, const SVCreateTbReq *pReq) {
|
|||
if (tStartEncode(pCoder) < 0) return -1;
|
||||
|
||||
if (tEncodeI32v(pCoder, pReq->flags) < 0) return -1;
|
||||
if (tEncodeCStr(pCoder, pReq->name) < 0) return -1;
|
||||
if (tEncodeI64(pCoder, pReq->uid) < 0) return -1;
|
||||
if (tEncodeI64(pCoder, pReq->ctime) < 0) return -1;
|
||||
|
||||
if (tEncodeCStr(pCoder, pReq->name) < 0) return -1;
|
||||
if (tEncodeI32(pCoder, pReq->ttl) < 0) return -1;
|
||||
if (tEncodeI8(pCoder, pReq->type) < 0) return -1;
|
||||
|
||||
|
@ -3887,10 +3886,9 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) {
|
|||
if (tStartDecode(pCoder) < 0) return -1;
|
||||
|
||||
if (tDecodeI32v(pCoder, &pReq->flags) < 0) return -1;
|
||||
if (tDecodeCStr(pCoder, &pReq->name) < 0) return -1;
|
||||
if (tDecodeI64(pCoder, &pReq->uid) < 0) return -1;
|
||||
if (tDecodeI64(pCoder, &pReq->ctime) < 0) return -1;
|
||||
|
||||
if (tDecodeCStr(pCoder, &pReq->name) < 0) return -1;
|
||||
if (tDecodeI32(pCoder, &pReq->ttl) < 0) return -1;
|
||||
if (tDecodeI8(pCoder, &pReq->type) < 0) return -1;
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ int metaAlterTable(SMeta* pMeta, int64_t version, SVAlterTbReq* pReq
|
|||
SSchemaWrapper* metaGetTableSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver, bool isinline);
|
||||
STSchema* metaGetTbTSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver);
|
||||
int metaGetTableEntryByName(SMetaReader* pReader, const char* name);
|
||||
tb_uid_t metaGetTableEntryUidByName(SMeta* pMeta, const char* name);
|
||||
int metaGetTbNum(SMeta* pMeta);
|
||||
SMCtbCursor* metaOpenCtbCursor(SMeta* pMeta, tb_uid_t uid);
|
||||
void metaCloseCtbCursor(SMCtbCursor* pCtbCur);
|
||||
|
|
|
@ -81,6 +81,19 @@ int metaGetTableEntryByName(SMetaReader *pReader, const char *name) {
|
|||
return metaGetTableEntryByUid(pReader, uid);
|
||||
}
|
||||
|
||||
tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name) {
|
||||
void *pData = NULL;
|
||||
int nData = 0;
|
||||
tb_uid_t uid = 0;
|
||||
|
||||
if (tdbTbGet(pMeta->pNameIdx, name, strlen(name) + 1, &pData, &nData) == 0) {
|
||||
uid = *(tb_uid_t *)pData;
|
||||
tdbFree(pData);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int metaReadNext(SMetaReader *pReader) {
|
||||
SMeta *pMeta = pReader->pMeta;
|
||||
|
||||
|
|
|
@ -38,9 +38,11 @@ int32_t vnodePreprocessReq(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
tDecodeI32v(&dc, &nReqs);
|
||||
for (int32_t iReq = 0; iReq < nReqs; iReq++) {
|
||||
tb_uid_t uid = tGenIdPI64();
|
||||
char *name = NULL;
|
||||
tStartDecode(&dc);
|
||||
|
||||
tDecodeI32v(&dc, NULL);
|
||||
tDecodeCStr(&dc, &name);
|
||||
*(int64_t *)(dc.data + dc.pos) = uid;
|
||||
*(int64_t *)(dc.data + dc.pos + 8) = ctime;
|
||||
|
||||
|
@ -64,12 +66,18 @@ int32_t vnodePreprocessReq(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
if (pBlock == NULL) break;
|
||||
|
||||
if (msgIter.schemaLen > 0) {
|
||||
uid = tGenIdPI64();
|
||||
char *name = NULL;
|
||||
|
||||
tDecoderInit(&dc, pBlock->data, msgIter.schemaLen);
|
||||
tStartDecode(&dc);
|
||||
|
||||
tDecodeI32v(&dc, NULL);
|
||||
tDecodeCStr(&dc, &name);
|
||||
|
||||
uid = metaGetTableEntryUidByName(pVnode->pMeta, name);
|
||||
if (uid == 0) {
|
||||
uid = tGenIdPI64();
|
||||
}
|
||||
*(int64_t *)(dc.data + dc.pos) = uid;
|
||||
*(int64_t *)(dc.data + dc.pos + 8) = ctime;
|
||||
pBlock->uid = htobe64(uid);
|
||||
|
|
|
@ -55,8 +55,8 @@ typedef u32 SPgno;
|
|||
#define TDB_PUT_U24(p, v) \
|
||||
do { \
|
||||
int tv = (v); \
|
||||
(p)[2] = tv & 0xff; \
|
||||
(p)[1] = (tv >> 8) & 0xff; \
|
||||
(p)[1] = tv & 0xff; \
|
||||
(p)[2] = (tv >> 8) & 0xff; \
|
||||
(p)[0] = (tv >> 16) & 0xff; \
|
||||
} while (0)
|
||||
|
||||
|
|
Loading…
Reference in New Issue