refact META 9
This commit is contained in:
parent
159f3acd3c
commit
89c8b768e1
|
@ -107,3 +107,4 @@ TAGS
|
|||
contrib/*
|
||||
!contrib/CMakeLists.txt
|
||||
!contrib/test
|
||||
sql
|
|
@ -269,6 +269,12 @@ typedef struct SSchema {
|
|||
#define SSCHMEA_BYTES(s) ((s)->bytes)
|
||||
#define SSCHMEA_NAME(s) ((s)->name)
|
||||
|
||||
typedef struct {
|
||||
int32_t nCols;
|
||||
int32_t sver;
|
||||
SSchema* pSchema;
|
||||
} SSchemaWrapper;
|
||||
|
||||
STSchema* tdGetSTSChemaFromSSChema(SSchema** pSchema, int32_t nCols);
|
||||
|
||||
typedef struct {
|
||||
|
@ -1498,15 +1504,12 @@ int tEncodeSRSmaParam(SCoder* pCoder, const SRSmaParam* pRSmaParam);
|
|||
int tDecodeSRSmaParam(SCoder* pCoder, SRSmaParam* pRSmaParam);
|
||||
|
||||
typedef struct SVCreateStbReq {
|
||||
const char* name;
|
||||
tb_uid_t suid;
|
||||
int8_t rollup;
|
||||
int16_t nCols;
|
||||
int16_t sver;
|
||||
SSchema* pSchema;
|
||||
int16_t nTags;
|
||||
SSchema* pSchemaTg;
|
||||
SRSmaParam pRSmaParam;
|
||||
const char* name;
|
||||
tb_uid_t suid;
|
||||
int8_t rollup;
|
||||
SSchemaWrapper schema;
|
||||
SSchemaWrapper schemaTag;
|
||||
SRSmaParam pRSmaParam;
|
||||
} SVCreateStbReq;
|
||||
|
||||
int tEncodeSVCreateStbReq(SCoder* pCoder, const SVCreateStbReq* pReq);
|
||||
|
@ -1532,9 +1535,7 @@ typedef struct SVCreateTbReq {
|
|||
const void* pTag;
|
||||
} ctb;
|
||||
struct {
|
||||
int16_t nCols;
|
||||
int16_t sver;
|
||||
SSchema* pSchema;
|
||||
SSchemaWrapper schema;
|
||||
} ntb;
|
||||
};
|
||||
} SVCreateTbReq;
|
||||
|
@ -2160,11 +2161,6 @@ int32_t tDecodeSMqOffset(SCoder* decoder, SMqOffset* pOffset);
|
|||
int32_t tEncodeSMqCMCommitOffsetReq(SCoder* encoder, const SMqCMCommitOffsetReq* pReq);
|
||||
int32_t tDecodeSMqCMCommitOffsetReq(SCoder* decoder, SMqCMCommitOffsetReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
uint32_t nCols;
|
||||
SSchema* pSchema;
|
||||
} SSchemaWrapper;
|
||||
|
||||
static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema) {
|
||||
int32_t tlen = 0;
|
||||
tlen += taosEncodeFixedI8(buf, pSchema->type);
|
||||
|
@ -2204,7 +2200,8 @@ static FORCE_INLINE int32_t tDecodeSSchema(SCoder* pDecoder, SSchema* pSchema) {
|
|||
|
||||
static FORCE_INLINE int32_t taosEncodeSSchemaWrapper(void** buf, const SSchemaWrapper* pSW) {
|
||||
int32_t tlen = 0;
|
||||
tlen += taosEncodeFixedU32(buf, pSW->nCols);
|
||||
tlen += taosEncodeVariantI32(buf, pSW->nCols);
|
||||
tlen += taosEncodeVariantI32(buf, pSW->sver);
|
||||
for (int32_t i = 0; i < pSW->nCols; i++) {
|
||||
tlen += taosEncodeSSchema(buf, &pSW->pSchema[i]);
|
||||
}
|
||||
|
@ -2212,7 +2209,8 @@ static FORCE_INLINE int32_t taosEncodeSSchemaWrapper(void** buf, const SSchemaWr
|
|||
}
|
||||
|
||||
static FORCE_INLINE void* taosDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pSW) {
|
||||
buf = taosDecodeFixedU32(buf, &pSW->nCols);
|
||||
buf = taosDecodeVariantI32(buf, &pSW->nCols);
|
||||
buf = taosDecodeVariantI32(buf, &pSW->sver);
|
||||
pSW->pSchema = (SSchema*)taosMemoryCalloc(pSW->nCols, sizeof(SSchema));
|
||||
if (pSW->pSchema == NULL) {
|
||||
return NULL;
|
||||
|
@ -2225,23 +2223,25 @@ static FORCE_INLINE void* taosDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pS
|
|||
}
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeSSchemaWrapper(SCoder* pEncoder, const SSchemaWrapper* pSW) {
|
||||
if (tEncodeU32(pEncoder, pSW->nCols) < 0) return -1;
|
||||
if (tEncodeI32v(pEncoder, pSW->nCols) < 0) return -1;
|
||||
if (tEncodeI32v(pEncoder, pSW->sver) < 0) return -1;
|
||||
for (int32_t i = 0; i < pSW->nCols; i++) {
|
||||
if (tEncodeSSchema(pEncoder, &pSW->pSchema[i]) < 0) return -1;
|
||||
}
|
||||
return pEncoder->pos;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeSSchemaWrapper(SCoder* pDecoder, SSchemaWrapper* pSW) {
|
||||
if (tDecodeU32(pDecoder, &pSW->nCols) < 0) return -1;
|
||||
void* ptr = taosMemoryRealloc(pSW->pSchema, pSW->nCols * sizeof(SSchema));
|
||||
if (ptr == NULL) {
|
||||
return -1;
|
||||
}
|
||||
pSW->pSchema = (SSchema*)ptr;
|
||||
if (tDecodeI32v(pDecoder, &pSW->nCols) < 0) return -1;
|
||||
if (tDecodeI32v(pDecoder, &pSW->sver) < 0) return -1;
|
||||
|
||||
pSW->pSchema = (SSchema*)TCODER_MALLOC(pDecoder, sizeof(SSchema) * pSW->nCols);
|
||||
if (pSW->pSchema == NULL) return -1;
|
||||
for (int32_t i = 0; i < pSW->nCols; i++) {
|
||||
if (tDecodeSSchema(pDecoder, &pSW->pSchema[i]) < 0) return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -3522,15 +3522,8 @@ int tEncodeSVCreateStbReq(SCoder *pCoder, const SVCreateStbReq *pReq) {
|
|||
if (tEncodeCStr(pCoder, pReq->name) < 0) return -1;
|
||||
if (tEncodeI64(pCoder, pReq->suid) < 0) return -1;
|
||||
if (tEncodeI8(pCoder, pReq->rollup) < 0) return -1;
|
||||
if (tEncodeI16v(pCoder, pReq->nCols) < 0) return -1;
|
||||
if (tEncodeI16v(pCoder, pReq->sver) < 0) return -1;
|
||||
for (int iCol = 0; iCol < pReq->nCols; iCol++) {
|
||||
if (tEncodeSSchema(pCoder, pReq->pSchema + iCol) < 0) return -1;
|
||||
}
|
||||
if (tEncodeI16v(pCoder, pReq->nTags) < 0) return -1;
|
||||
for (int iTag = 0; iTag < pReq->nTags; iTag++) {
|
||||
if (tEncodeSSchema(pCoder, pReq->pSchemaTg + iTag) < 0) return -1;
|
||||
}
|
||||
if (tEncodeSSchemaWrapper(pCoder, &pReq->schema) < 0) return -1;
|
||||
if (tEncodeSSchemaWrapper(pCoder, &pReq->schemaTag) < 0) return -1;
|
||||
// if (pReq->rollup) {
|
||||
// if (tEncodeSRSmaParam(pCoder, pReq->pRSmaParam) < 0) return -1;
|
||||
// }
|
||||
|
@ -3545,22 +3538,8 @@ int tDecodeSVCreateStbReq(SCoder *pCoder, SVCreateStbReq *pReq) {
|
|||
if (tDecodeCStr(pCoder, &pReq->name) < 0) return -1;
|
||||
if (tDecodeI64(pCoder, &pReq->suid) < 0) return -1;
|
||||
if (tDecodeI8(pCoder, &pReq->rollup) < 0) return -1;
|
||||
|
||||
if (tDecodeI16v(pCoder, &pReq->nCols) < 0) return -1;
|
||||
if (tDecodeI16v(pCoder, &pReq->sver) < 0) return -1;
|
||||
pReq->pSchema = (SSchema *)TCODER_MALLOC(pCoder, sizeof(SSchema) * pReq->nCols);
|
||||
if (pReq->pSchema == NULL) return -1;
|
||||
for (int iCol = 0; iCol < pReq->nCols; iCol++) {
|
||||
if (tDecodeSSchema(pCoder, pReq->pSchema + iCol) < 0) return -1;
|
||||
}
|
||||
|
||||
if (tDecodeI16v(pCoder, &pReq->nTags) < 0) return -1;
|
||||
pReq->pSchemaTg = (SSchema *)TCODER_MALLOC(pCoder, sizeof(SSchema) * pReq->nTags);
|
||||
if (pReq->pSchemaTg == NULL) return -1;
|
||||
pReq->pSchemaTg = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * pReq->nTags);
|
||||
for (int iTag = 0; iTag < pReq->nTags; iTag++) {
|
||||
if (tDecodeSSchema(pCoder, pReq->pSchemaTg + iTag) < 0) return -1;
|
||||
}
|
||||
if (tEncodeSSchemaWrapper(pCoder, &pReq->schema) < 0) return -1;
|
||||
if (tEncodeSSchemaWrapper(pCoder, &pReq->schemaTag) < 0) return -1;
|
||||
// if (pReq->rollup) {
|
||||
// if (tDecodeSRSmaParam(pCoder, pReq->pRSmaParam) < 0) return -1;
|
||||
// }
|
||||
|
@ -3607,12 +3586,7 @@ int tEncodeSVCreateTbReq(SCoder *pCoder, const SVCreateTbReq *pReq) {
|
|||
if (tEncodeI64(pCoder, pReq->ctb.suid) < 0) return -1;
|
||||
if (tEncodeBinary(pCoder, pReq->ctb.pTag, kvRowLen(pReq->ctb.pTag)) < 0) return -1;
|
||||
} else if (pReq->type == TSDB_NORMAL_TABLE) {
|
||||
if (tEncodeI16v(pCoder, pReq->ntb.nCols) < 0) return -1;
|
||||
if (tEncodeI16v(pCoder, pReq->ntb.sver) < 0) return -1;
|
||||
for (int iCol = 0; iCol < pReq->ntb.nCols; iCol++) {
|
||||
if (tEncodeSSchema(pCoder, pReq->ntb.pSchema + iCol) < 0) return -1;
|
||||
}
|
||||
|
||||
if (tEncodeSSchemaWrapper(pCoder, &pReq->ntb.schema) < 0) return -1;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -3635,13 +3609,7 @@ int tDecodeSVCreateTbReq(SCoder *pCoder, SVCreateTbReq *pReq) {
|
|||
if (tDecodeI64(pCoder, &pReq->ctb.suid) < 0) return -1;
|
||||
if (tDecodeBinary(pCoder, &pReq->ctb.pTag, NULL) < 0) return -1;
|
||||
} else if (pReq->type == TSDB_NORMAL_TABLE) {
|
||||
if (tDecodeI16v(pCoder, &pReq->ntb.nCols) < 0) return -1;
|
||||
if (tDecodeI16v(pCoder, &pReq->ntb.sver) < 0) return -1;
|
||||
pReq->ntb.pSchema = (SSchema *)TCODER_MALLOC(pCoder, sizeof(SSchema) * pReq->ntb.nCols);
|
||||
if (pReq->ntb.pSchema == NULL) return -1;
|
||||
for (int iCol = 0; iCol < pReq->ntb.nCols; iCol++) {
|
||||
if (tDecodeSSchema(pCoder, pReq->ntb.pSchema + iCol) < 0) return -1;
|
||||
}
|
||||
if (tDecodeSSchemaWrapper(pCoder, &pReq->ntb.schema) < 0) return -1;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
|
|
@ -407,15 +407,15 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
|
|||
req.name = (char *)tNameGetTableName(&name);
|
||||
req.suid = pStb->uid;
|
||||
req.rollup = pStb->aggregationMethod > -1 ? 1 : 0;
|
||||
req.nCols = pStb->numOfColumns;
|
||||
req.sver = 0; // TODO
|
||||
req.pSchema = pStb->pColumns;
|
||||
req.nTags = pStb->numOfTags;
|
||||
req.pSchemaTg = pStb->pTags;
|
||||
req.schema.nCols = pStb->numOfColumns;
|
||||
req.schema.sver = 0;
|
||||
req.schema.pSchema = pStb->pColumns;
|
||||
req.schemaTag.nCols = pStb->numOfTags;
|
||||
req.schemaTag.pSchema = pStb->pTags;
|
||||
|
||||
// TODO: remove here
|
||||
for (int iCol = 0; iCol < req.nCols; iCol++) {
|
||||
req.pSchema[iCol].flags = SCHEMA_SMA_ON;
|
||||
for (int iCol = 0; iCol < req.schema.nCols; iCol++) {
|
||||
req.schema.pSchema[iCol].flags = SCHEMA_SMA_ON;
|
||||
}
|
||||
|
||||
if (req.rollup) {
|
||||
|
|
|
@ -140,11 +140,8 @@ struct SMetaEntry {
|
|||
const char* name;
|
||||
union {
|
||||
struct {
|
||||
int16_t nCols;
|
||||
int16_t sver;
|
||||
SSchema* pSchema;
|
||||
int16_t nTags;
|
||||
SSchema* pSchemaTg;
|
||||
SSchemaWrapper schema;
|
||||
SSchemaWrapper schemaTag;
|
||||
} stbEntry;
|
||||
struct {
|
||||
int64_t ctime;
|
||||
|
@ -153,11 +150,9 @@ struct SMetaEntry {
|
|||
const void* pTags;
|
||||
} ctbEntry;
|
||||
struct {
|
||||
int64_t ctime;
|
||||
int32_t ttlDays;
|
||||
int16_t nCols;
|
||||
int16_t sver;
|
||||
SSchema* pSchema;
|
||||
int64_t ctime;
|
||||
int32_t ttlDays;
|
||||
SSchemaWrapper schema;
|
||||
} ntbEntry;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -23,16 +23,8 @@ int metaEncodeEntry(SCoder *pCoder, const SMetaEntry *pME) {
|
|||
if (tEncodeCStr(pCoder, pME->name) < 0) return -1;
|
||||
|
||||
if (pME->type == TSDB_SUPER_TABLE) {
|
||||
if (tEncodeI16v(pCoder, pME->stbEntry.nCols) < 0) return -1;
|
||||
if (tEncodeI16v(pCoder, pME->stbEntry.sver) < 0) return -1;
|
||||
for (int iCol = 0; iCol < pME->stbEntry.nCols; iCol++) {
|
||||
if (tEncodeSSchema(pCoder, pME->stbEntry.pSchema + iCol) < 0) return -1;
|
||||
}
|
||||
|
||||
if (tEncodeI16v(pCoder, pME->stbEntry.nTags) < 0) return -1;
|
||||
for (int iTag = 0; iTag < pME->stbEntry.nTags; iTag++) {
|
||||
if (tEncodeSSchema(pCoder, pME->stbEntry.pSchemaTg + iTag) < 0) return -1;
|
||||
}
|
||||
if (tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schema) < 0) return -1;
|
||||
if (tEncodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag) < 0) return -1;
|
||||
} else if (pME->type == TSDB_CHILD_TABLE) {
|
||||
if (tEncodeI64(pCoder, pME->ctbEntry.ctime) < 0) return -1;
|
||||
if (tEncodeI32(pCoder, pME->ctbEntry.ttlDays) < 0) return -1;
|
||||
|
@ -41,11 +33,7 @@ int metaEncodeEntry(SCoder *pCoder, const SMetaEntry *pME) {
|
|||
} else if (pME->type == TSDB_NORMAL_TABLE) {
|
||||
if (tEncodeI64(pCoder, pME->ntbEntry.ctime) < 0) return -1;
|
||||
if (tEncodeI32(pCoder, pME->ntbEntry.ttlDays) < 0) return -1;
|
||||
if (tEncodeI16v(pCoder, pME->ntbEntry.nCols) < 0) return -1;
|
||||
if (tEncodeI16v(pCoder, pME->ntbEntry.sver) < 0) return -1;
|
||||
for (int iCol = 0; iCol < pME->ntbEntry.nCols; iCol++) {
|
||||
if (tEncodeSSchema(pCoder, pME->ntbEntry.pSchema + iCol) < 0) return -1;
|
||||
}
|
||||
if (tEncodeSSchemaWrapper(pCoder, &pME->ntbEntry.schema) < 0) return -1;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
@ -62,26 +50,8 @@ int metaDecodeEntry(SCoder *pCoder, SMetaEntry *pME) {
|
|||
if (tDecodeCStr(pCoder, &pME->name) < 0) return -1;
|
||||
|
||||
if (pME->type == TSDB_SUPER_TABLE) {
|
||||
if (tDecodeI16v(pCoder, &pME->stbEntry.nCols) < 0) return -1;
|
||||
if (tDecodeI16v(pCoder, &pME->stbEntry.sver) < 0) return -1;
|
||||
pME->stbEntry.pSchema = (SSchema *)TCODER_MALLOC(pCoder, sizeof(SSchema) * pME->stbEntry.nCols);
|
||||
if (pME->stbEntry.pSchema == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
for (int iCol = 0; iCol < pME->stbEntry.nCols; iCol++) {
|
||||
if (tDecodeSSchema(pCoder, pME->stbEntry.pSchema + iCol) < 0) return -1;
|
||||
}
|
||||
|
||||
if (tDecodeI16v(pCoder, &pME->stbEntry.nTags) < 0) return -1;
|
||||
pME->stbEntry.pSchemaTg = (SSchema *)TCODER_MALLOC(pCoder, sizeof(SSchema) * pME->stbEntry.nTags);
|
||||
if (pME->stbEntry.pSchemaTg == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
for (int iTag = 0; iTag < pME->stbEntry.nTags; iTag++) {
|
||||
if (tDecodeSSchema(pCoder, pME->stbEntry.pSchemaTg + iTag) < 0) return -1;
|
||||
}
|
||||
if (tDecodeSSchemaWrapper(pCoder, &pME->stbEntry.schema) < 0) return -1;
|
||||
if (tDecodeSSchemaWrapper(pCoder, &pME->stbEntry.schemaTag) < 0) return -1;
|
||||
} else if (pME->type == TSDB_CHILD_TABLE) {
|
||||
if (tDecodeI64(pCoder, &pME->ctbEntry.ctime) < 0) return -1;
|
||||
if (tDecodeI32(pCoder, &pME->ctbEntry.ttlDays) < 0) return -1;
|
||||
|
@ -90,16 +60,7 @@ int metaDecodeEntry(SCoder *pCoder, SMetaEntry *pME) {
|
|||
} else if (pME->type == TSDB_NORMAL_TABLE) {
|
||||
if (tDecodeI64(pCoder, &pME->ntbEntry.ctime) < 0) return -1;
|
||||
if (tDecodeI32(pCoder, &pME->ntbEntry.ttlDays) < 0) return -1;
|
||||
if (tDecodeI16v(pCoder, &pME->ntbEntry.nCols) < 0) return -1;
|
||||
if (tDecodeI16v(pCoder, &pME->ntbEntry.sver) < 0) return -1;
|
||||
pME->ntbEntry.pSchema = (SSchema *)TCODER_MALLOC(pCoder, sizeof(SSchema) * pME->ntbEntry.nCols);
|
||||
if (pME->ntbEntry.pSchema == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
for (int iCol = 0; iCol < pME->ntbEntry.nCols; iCol++) {
|
||||
if (tEncodeSSchema(pCoder, pME->ntbEntry.pSchema + iCol) < 0) return -1;
|
||||
}
|
||||
if (tDecodeSSchemaWrapper(pCoder, &pME->ntbEntry.schema) < 0) return -1;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ static int metaCreateChildTable(SMeta *pMeta, int64_t version, SMetaEntry *pME);
|
|||
static int metaUpdateTtlIdx(SMeta *pMeta, int64_t dtime, tb_uid_t uid);
|
||||
|
||||
int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
||||
SSkmDbKey skmDbKey = {0};
|
||||
SMetaEntry me = {0};
|
||||
int kLen = 0;
|
||||
int vLen = 0;
|
||||
|
@ -42,14 +41,8 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
me.type = TSDB_SUPER_TABLE;
|
||||
me.uid = pReq->suid;
|
||||
me.name = pReq->name;
|
||||
me.stbEntry.nCols = pReq->nCols;
|
||||
me.stbEntry.sver = pReq->sver;
|
||||
me.stbEntry.pSchema = pReq->pSchema;
|
||||
me.stbEntry.nTags = pReq->nTags;
|
||||
me.stbEntry.pSchemaTg = pReq->pSchemaTg;
|
||||
|
||||
skmDbKey.uid = pReq->suid;
|
||||
skmDbKey.sver = 0; // (TODO)
|
||||
me.stbEntry.schema = pReq->schema;
|
||||
me.stbEntry.schemaTag = pReq->schemaTag;
|
||||
|
||||
// save to table.db
|
||||
if (metaSaveToTbDb(pMeta, version, &me) < 0) goto _err;
|
||||
|
@ -108,9 +101,7 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq) {
|
|||
} else {
|
||||
me.ntbEntry.ctime = pReq->ctime;
|
||||
me.ntbEntry.ttlDays = pReq->ttl;
|
||||
me.ntbEntry.nCols = pReq->ntb.nCols;
|
||||
me.ntbEntry.sver = pReq->ntb.sver;
|
||||
me.ntbEntry.pSchema = pReq->ntb.pSchema;
|
||||
me.ntbEntry.schema = pReq->ntb.schema;
|
||||
}
|
||||
|
||||
// save table
|
||||
|
|
|
@ -65,35 +65,35 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
metaRsp.tuid = meReader1.me.uid;
|
||||
if (meReader1.me.type == TSDB_SUPER_TABLE) {
|
||||
strcpy(metaRsp.stbName, meReader1.me.name);
|
||||
metaRsp.numOfTags = meReader1.me.stbEntry.nTags;
|
||||
metaRsp.numOfColumns = meReader1.me.stbEntry.nCols;
|
||||
metaRsp.numOfTags = meReader1.me.stbEntry.schemaTag.nCols;
|
||||
metaRsp.numOfColumns = meReader1.me.stbEntry.schema.nCols;
|
||||
metaRsp.suid = meReader1.me.uid;
|
||||
metaRsp.pSchemas = taosMemoryMalloc((metaRsp.numOfTags + metaRsp.numOfColumns) * sizeof(SSchema));
|
||||
if (metaRsp.pSchemas == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
memcpy(metaRsp.pSchemas, meReader1.me.stbEntry.pSchema, sizeof(SSchema) * metaRsp.numOfColumns);
|
||||
memcpy(metaRsp.pSchemas + metaRsp.numOfColumns, meReader1.me.stbEntry.pSchemaTg,
|
||||
memcpy(metaRsp.pSchemas, meReader1.me.stbEntry.schema.pSchema, sizeof(SSchema) * metaRsp.numOfColumns);
|
||||
memcpy(metaRsp.pSchemas + metaRsp.numOfColumns, meReader1.me.stbEntry.schemaTag.pSchema,
|
||||
sizeof(SSchema) * metaRsp.numOfTags);
|
||||
} else if (meReader1.me.type == TSDB_CHILD_TABLE) {
|
||||
strcpy(metaRsp.stbName, meReader2.me.name);
|
||||
metaRsp.numOfTags = meReader2.me.stbEntry.nTags;
|
||||
metaRsp.numOfColumns = meReader2.me.stbEntry.nCols;
|
||||
metaRsp.numOfTags = meReader2.me.stbEntry.schemaTag.nCols;
|
||||
metaRsp.numOfColumns = meReader2.me.stbEntry.schema.nCols;
|
||||
metaRsp.suid = meReader2.me.uid;
|
||||
metaRsp.pSchemas = taosMemoryMalloc((metaRsp.numOfTags + metaRsp.numOfColumns) * sizeof(SSchema));
|
||||
if (metaRsp.pSchemas == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
memcpy(metaRsp.pSchemas, meReader2.me.stbEntry.pSchema, sizeof(SSchema) * metaRsp.numOfColumns);
|
||||
memcpy(metaRsp.pSchemas + metaRsp.numOfColumns, meReader2.me.stbEntry.pSchemaTg,
|
||||
memcpy(metaRsp.pSchemas, meReader2.me.stbEntry.schema.pSchema, sizeof(SSchema) * metaRsp.numOfColumns);
|
||||
memcpy(metaRsp.pSchemas + metaRsp.numOfColumns, meReader2.me.stbEntry.schemaTag.pSchema,
|
||||
sizeof(SSchema) * metaRsp.numOfTags);
|
||||
} else if (meReader1.me.type == TSDB_NORMAL_TABLE) {
|
||||
metaRsp.numOfTags = 0;
|
||||
metaRsp.numOfColumns = meReader1.me.ntbEntry.nCols;
|
||||
metaRsp.numOfColumns = meReader1.me.ntbEntry.schema.nCols;
|
||||
metaRsp.suid = 0;
|
||||
metaRsp.pSchemas = meReader1.me.ntbEntry.pSchema;
|
||||
metaRsp.pSchemas = meReader1.me.ntbEntry.schema.pSchema;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
|
|
|
@ -3158,7 +3158,7 @@ typedef struct SVgroupTablesBatch {
|
|||
|
||||
static void destroyCreateTbReq(SVCreateTbReq* pReq) {
|
||||
taosMemoryFreeClear(pReq->name);
|
||||
taosMemoryFreeClear(pReq->ntb.pSchema);
|
||||
taosMemoryFreeClear(pReq->ntb.schema.pSchema);
|
||||
}
|
||||
|
||||
static int32_t buildSmaParam(STableOptions* pOptions, SVCreateTbReq* pReq) {
|
||||
|
@ -3196,17 +3196,17 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
|
|||
SVCreateTbReq req = {0};
|
||||
req.type = TD_NORMAL_TABLE;
|
||||
req.name = strdup(pStmt->tableName);
|
||||
req.ntb.nCols = LIST_LENGTH(pStmt->pCols);
|
||||
req.ntb.sver = 0;
|
||||
req.ntb.pSchema = taosMemoryCalloc(req.ntb.nCols, sizeof(SSchema));
|
||||
if (NULL == req.name || NULL == req.ntb.pSchema) {
|
||||
req.ntb.schema.nCols = LIST_LENGTH(pStmt->pCols);
|
||||
req.ntb.schema.sver = 0;
|
||||
req.ntb.schema.pSchema = taosMemoryCalloc(req.ntb.schema.nCols, sizeof(SSchema));
|
||||
if (NULL == req.name || NULL == req.ntb.schema.pSchema) {
|
||||
destroyCreateTbReq(&req);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
SNode* pCol;
|
||||
col_id_t index = 0;
|
||||
FOREACH(pCol, pStmt->pCols) {
|
||||
toSchema((SColumnDefNode*)pCol, index + 1, req.ntb.pSchema + index);
|
||||
toSchema((SColumnDefNode*)pCol, index + 1, req.ntb.schema.pSchema + index);
|
||||
++index;
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS != buildSmaParam(pStmt->pOptions, &req)) {
|
||||
|
@ -3264,7 +3264,7 @@ static void destroyCreateTbReqBatch(SVgroupTablesBatch* pTbBatch) {
|
|||
taosMemoryFreeClear(pTableReq->name);
|
||||
|
||||
if (pTableReq->type == TSDB_NORMAL_TABLE) {
|
||||
taosMemoryFreeClear(pTableReq->ntb.pSchema);
|
||||
taosMemoryFreeClear(pTableReq->ntb.schema.pSchema);
|
||||
} else if (pTableReq->type == TSDB_CHILD_TABLE) {
|
||||
taosMemoryFreeClear(pTableReq->ctb.pTag);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue