more alter table
This commit is contained in:
parent
9d70acdcc5
commit
6454a205a8
|
@ -196,6 +196,8 @@ struct SMetaEntry {
|
||||||
STSma *tsma;
|
STSma *tsma;
|
||||||
} smaEntry;
|
} smaEntry;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uint8_t *pBuf;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMetaReader {
|
struct SMetaReader {
|
||||||
|
|
|
@ -523,7 +523,8 @@ _err:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq) {
|
static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq) {
|
||||||
SMetaEntry entry = {0};
|
SMetaEntry ctbEntry = {0};
|
||||||
|
SMetaEntry stbEntry = {0};
|
||||||
void *pVal = NULL;
|
void *pVal = NULL;
|
||||||
int nVal = 0;
|
int nVal = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -556,34 +557,45 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
||||||
|
|
||||||
// search table.db
|
// search table.db
|
||||||
TDBC *pTbDbc = NULL;
|
TDBC *pTbDbc = NULL;
|
||||||
|
SDecoder dc = {0};
|
||||||
|
|
||||||
|
/* get ctbEntry */
|
||||||
tdbDbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn);
|
tdbDbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn);
|
||||||
tdbDbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
tdbDbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
|
||||||
ASSERT(c == 0);
|
ASSERT(c == 0);
|
||||||
tdbDbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
tdbDbcGet(pTbDbc, NULL, NULL, &pData, &nData);
|
||||||
|
|
||||||
// get table entry
|
ctbEntry.pBuf = taosMemoryMalloc(nData);
|
||||||
SDecoder dc = {0};
|
memcpy(ctbEntry.pBuf, pData, nData);
|
||||||
tDecoderInit(&dc, pData, nData);
|
tDecoderInit(&dc, ctbEntry.pBuf, nData);
|
||||||
metaDecodeEntry(&dc, &entry);
|
metaDecodeEntry(&dc, &ctbEntry);
|
||||||
|
|
||||||
if (entry.type != TSDB_CHILD_TABLE) {
|
|
||||||
terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION;
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
// do actual job
|
|
||||||
{
|
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
|
|
||||||
|
/* get stbEntry*/
|
||||||
|
|
||||||
|
{
|
||||||
|
// get table entry
|
||||||
|
// SDecoder dc = {0};
|
||||||
|
// tDecoderInit(&dc, pData, nData);
|
||||||
|
// metaDecodeEntry(&dc, &ctbEntry);
|
||||||
|
|
||||||
|
// if (ctbEntry.type != TSDB_CHILD_TABLE) {
|
||||||
|
// terrno = TSDB_CODE_VND_INVALID_TABLE_ACTION;
|
||||||
|
// goto _err;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // do actual job
|
||||||
|
// {
|
||||||
|
// // TODO
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
// tDecoderClear(&dc);
|
||||||
tdbDbcClose(pTbDbc);
|
tdbDbcClose(pTbDbc);
|
||||||
tdbDbcClose(pUidIdxc);
|
tdbDbcClose(pUidIdxc);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tDecoderClear(&dc);
|
|
||||||
tdbDbcClose(pTbDbc);
|
tdbDbcClose(pTbDbc);
|
||||||
tdbDbcClose(pUidIdxc);
|
tdbDbcClose(pUidIdxc);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -462,7 +462,11 @@ _exit:
|
||||||
|
|
||||||
static int vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
static int vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pReq, int32_t len, SRpcMsg *pRsp) {
|
||||||
SVAlterTbReq vAlterTbReq = {0};
|
SVAlterTbReq vAlterTbReq = {0};
|
||||||
|
SVAlterTbRsp vAlterTbRsp = {0};
|
||||||
SDecoder dc = {0};
|
SDecoder dc = {0};
|
||||||
|
int rcode = 0;
|
||||||
|
int ret;
|
||||||
|
SEncoder ec = {0};
|
||||||
|
|
||||||
pRsp->msgType = TDMT_VND_ALTER_TABLE_RSP;
|
pRsp->msgType = TDMT_VND_ALTER_TABLE_RSP;
|
||||||
pRsp->pCont = NULL;
|
pRsp->pCont = NULL;
|
||||||
|
@ -473,19 +477,27 @@ static int vnodeProcessAlterTbReq(SVnode *pVnode, int64_t version, void *pReq, i
|
||||||
|
|
||||||
// decode
|
// decode
|
||||||
if (tDecodeSVAlterTbReq(&dc, &vAlterTbReq) < 0) {
|
if (tDecodeSVAlterTbReq(&dc, &vAlterTbReq) < 0) {
|
||||||
pRsp->code = TSDB_CODE_INVALID_MSG;
|
vAlterTbRsp.code = TSDB_CODE_INVALID_MSG;
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
return -1;
|
rcode = -1;
|
||||||
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// process
|
// process
|
||||||
if (metaAlterTable(pVnode->pMeta, version, &vAlterTbReq) < 0) {
|
if (metaAlterTable(pVnode->pMeta, version, &vAlterTbReq) < 0) {
|
||||||
pRsp->code = terrno;
|
vAlterTbRsp.code = TSDB_CODE_INVALID_MSG;
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
return -1;
|
rcode = -1;
|
||||||
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
tDecoderClear(&dc);
|
tDecoderClear(&dc);
|
||||||
|
|
||||||
|
_exit:
|
||||||
|
tEncodeSize(tEncodeSVAlterTbRsp, &vAlterTbRsp, pRsp->contLen, ret);
|
||||||
|
pRsp->pCont = rpcMallocCont(pRsp->contLen);
|
||||||
|
tEncoderInit(&ec, pRsp->pCont, pRsp->contLen);
|
||||||
|
tEncodeSVAlterTbRsp(&ec, &vAlterTbRsp);
|
||||||
|
tEncoderClear(&ec);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue