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