serialize show req
This commit is contained in:
parent
54584fd1e1
commit
a72fe7750b
|
@ -275,6 +275,7 @@ typedef struct {
|
|||
|
||||
int32_t tSerializeSMCreateStbReq(void** buf, SMCreateStbReq* pReq);
|
||||
void* tDeserializeSMCreateStbReq(void* buf, SMCreateStbReq* pReq);
|
||||
void tFreeSMCreateStbReq(SMCreateStbReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
char name[TSDB_TABLE_FNAME_LEN];
|
||||
|
@ -888,12 +889,16 @@ typedef struct {
|
|||
* payloadLen is the length of payload
|
||||
*/
|
||||
typedef struct {
|
||||
int8_t type;
|
||||
int32_t type;
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int16_t payloadLen;
|
||||
char payload[];
|
||||
int32_t payloadLen;
|
||||
char* payload;
|
||||
} SShowReq;
|
||||
|
||||
int32_t tSerializeSShowReq(void* buf, int32_t bufLen, SShowReq* pReq);
|
||||
int32_t tDeserializeSShowReq(void* buf, int32_t bufLen, SShowReq* pReq);
|
||||
void tFreeSShowReq(SShowReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
char db[TSDB_DB_FNAME_LEN];
|
||||
int32_t numOfVgroup;
|
||||
|
|
|
@ -440,6 +440,11 @@ void *tDeserializeSMCreateStbReq(void *buf, SMCreateStbReq *pReq) {
|
|||
return buf;
|
||||
}
|
||||
|
||||
void tFreeSMCreateStbReq(SMCreateStbReq *pReq) {
|
||||
taosArrayDestroy(pReq->pColumns);
|
||||
taosArrayDestroy(pReq->pTags);
|
||||
}
|
||||
|
||||
int32_t tSerializeSMDropStbReq(void **buf, SMDropStbReq *pReq) {
|
||||
int32_t tlen = 0;
|
||||
|
||||
|
@ -1469,4 +1474,43 @@ void tFreeSUseDbBatchRsp(SUseDbBatchRsp *pRsp) {
|
|||
}
|
||||
|
||||
taosArrayDestroy(pRsp->pArray);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t tSerializeSShowReq(void *buf, int32_t bufLen, SShowReq *pReq) {
|
||||
SCoder encoder = {0};
|
||||
tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER);
|
||||
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->type) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->db) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->payloadLen) < 0) return -1;
|
||||
if (pReq->payloadLen > 0) {
|
||||
if (tEncodeCStr(&encoder, pReq->payload) < 0) return -1;
|
||||
}
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
tCoderClear(&encoder);
|
||||
return tlen;
|
||||
}
|
||||
|
||||
int32_t tDeserializeSShowReq(void *buf, int32_t bufLen, SShowReq *pReq) {
|
||||
SCoder decoder = {0};
|
||||
tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER);
|
||||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->type) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->payloadLen) < 0) return -1;
|
||||
if (pReq->payloadLen > 0) {
|
||||
pReq->payload = malloc(pReq->payloadLen);
|
||||
if (pReq->payload == NULL) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->payload) < 0) return -1;
|
||||
}
|
||||
|
||||
tEndDecode(&decoder);
|
||||
tCoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tFreeSShowReq(SShowReq *pReq) { free(pReq->payload); }
|
||||
|
|
|
@ -80,12 +80,16 @@ SRpcMsg* Testbase::SendReq(tmsg_t msgType, void* pCont, int32_t contLen) {
|
|||
}
|
||||
|
||||
void Testbase::SendShowMetaReq(int8_t showType, const char* db) {
|
||||
int32_t contLen = sizeof(SShowReq);
|
||||
SShowReq* pShow = (SShowReq*)rpcMallocCont(contLen);
|
||||
pShow->type = showType;
|
||||
strcpy(pShow->db, db);
|
||||
SShowReq showReq = {0};
|
||||
showReq.type = showType;
|
||||
//strcpy(showReq.db, db);
|
||||
|
||||
SRpcMsg* pRsp = SendReq(TDMT_MND_SHOW, pShow, contLen);
|
||||
int32_t contLen = tSerializeSShowReq(NULL, 0, &showReq);
|
||||
char* pReq = (char*)rpcMallocCont(contLen);
|
||||
tSerializeSShowReq(pReq, contLen, &showReq);
|
||||
tFreeSShowReq(&showReq);
|
||||
|
||||
SRpcMsg* pRsp = SendReq(TDMT_MND_SHOW, pReq, contLen);
|
||||
SShowRsp* pShowRsp = (SShowRsp*)pRsp->pCont;
|
||||
|
||||
ASSERT(pShowRsp != nullptr);
|
||||
|
|
|
@ -118,27 +118,28 @@ static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove) {
|
|||
static int32_t mndProcessShowReq(SMnodeMsg *pReq) {
|
||||
SMnode *pMnode = pReq->pMnode;
|
||||
SShowMgmt *pMgmt = &pMnode->showMgmt;
|
||||
SShowReq *pShowReq = pReq->rpcMsg.pCont;
|
||||
int8_t type = pShowReq->type;
|
||||
int16_t payloadLen = htonl(pShowReq->payloadLen);
|
||||
int32_t code = -1;
|
||||
SShowReq showReq = {0};
|
||||
|
||||
if (type <= TSDB_MGMT_TABLE_START || type >= TSDB_MGMT_TABLE_MAX) {
|
||||
terrno = TSDB_CODE_MND_INVALID_MSG_TYPE;
|
||||
mError("failed to process show-meta req since %s", terrstr());
|
||||
return -1;
|
||||
if (tDeserializeSShowReq(pReq->rpcMsg.pCont, pReq->rpcMsg.contLen, &showReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto SHOW_OVER;
|
||||
}
|
||||
|
||||
ShowMetaFp metaFp = pMgmt->metaFps[type];
|
||||
if (showReq.type <= TSDB_MGMT_TABLE_START || showReq.type >= TSDB_MGMT_TABLE_MAX) {
|
||||
terrno = TSDB_CODE_MND_INVALID_MSG_TYPE;
|
||||
goto SHOW_OVER;
|
||||
}
|
||||
|
||||
ShowMetaFp metaFp = pMgmt->metaFps[showReq.type];
|
||||
if (metaFp == NULL) {
|
||||
terrno = TSDB_CODE_MND_INVALID_MSG_TYPE;
|
||||
mError("failed to process show-meta req:%s since %s", mndShowStr(type), terrstr());
|
||||
return -1;
|
||||
goto SHOW_OVER;
|
||||
}
|
||||
|
||||
SShowObj *pShow = mndCreateShowObj(pMnode, pShowReq);
|
||||
SShowObj *pShow = mndCreateShowObj(pMnode, &showReq);
|
||||
if (pShow == NULL) {
|
||||
mError("failed to process show-meta req:%s since %s", mndShowStr(type), terrstr());
|
||||
return -1;
|
||||
goto SHOW_OVER;
|
||||
}
|
||||
|
||||
int32_t size = sizeof(SShowRsp) + sizeof(SSchema) * TSDB_MAX_COLUMNS + TSDB_EXTRA_PAYLOAD_SIZE;
|
||||
|
@ -146,26 +147,30 @@ static int32_t mndProcessShowReq(SMnodeMsg *pReq) {
|
|||
if (pRsp == NULL) {
|
||||
mndReleaseShowObj(pShow, true);
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
mError("show:0x%" PRIx64 ", failed to process show-meta req:%s since malloc rsp error", pShow->id,
|
||||
mndShowStr(type));
|
||||
return -1;
|
||||
goto SHOW_OVER;
|
||||
}
|
||||
|
||||
int32_t code = (*metaFp)(pReq, pShow, &pRsp->tableMeta);
|
||||
mDebug("show:0x%" PRIx64 ", get meta finished, numOfRows:%d cols:%d type:%s, result:%s", pShow->id, pShow->numOfRows,
|
||||
pShow->numOfColumns, mndShowStr(type), tstrerror(code));
|
||||
code = (*metaFp)(pReq, pShow, &pRsp->tableMeta);
|
||||
mDebug("show:0x%" PRIx64 ", get meta finished, numOfRows:%d cols:%d showReq.type:%s, result:%s", pShow->id,
|
||||
pShow->numOfRows, pShow->numOfColumns, mndShowStr(showReq.type), tstrerror(code));
|
||||
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
pReq->contLen = sizeof(SShowRsp) + sizeof(SSchema) * pShow->numOfColumns;
|
||||
pReq->pCont = pRsp;
|
||||
pRsp->showId = htobe64(pShow->id);
|
||||
mndReleaseShowObj(pShow, false);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else {
|
||||
rpcFreeCont(pRsp);
|
||||
mndReleaseShowObj(pShow, true);
|
||||
return code;
|
||||
}
|
||||
|
||||
SHOW_OVER:
|
||||
if (code != 0) {
|
||||
mError("failed to process show-meta req since %s", terrstr());
|
||||
}
|
||||
|
||||
tFreeSShowReq(&showReq);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndProcessRetrieveReq(SMnodeMsg *pReq) {
|
||||
|
|
|
@ -56,10 +56,13 @@ TEST_F(MndTestAcct, 03_Drop_Acct) {
|
|||
}
|
||||
|
||||
TEST_F(MndTestAcct, 04_Show_Acct) {
|
||||
int32_t contLen = sizeof(SShowReq);
|
||||
SShowReq showReq = {0};
|
||||
showReq.type = TSDB_MGMT_TABLE_ACCT;
|
||||
|
||||
SShowReq* pReq = (SShowReq*)rpcMallocCont(contLen);
|
||||
pReq->type = TSDB_MGMT_TABLE_ACCT;
|
||||
int32_t contLen = tSerializeSShowReq(NULL, 0, &showReq);
|
||||
void* pReq = rpcMallocCont(contLen);
|
||||
tSerializeSShowReq(pReq, contLen, &showReq);
|
||||
tFreeSShowReq(&showReq);
|
||||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
|
|
|
@ -26,11 +26,13 @@ class MndTestShow : public ::testing::Test {
|
|||
Testbase MndTestShow::test;
|
||||
|
||||
TEST_F(MndTestShow, 01_ShowMsg_InvalidMsgMax) {
|
||||
int32_t contLen = sizeof(SShowReq);
|
||||
SShowReq showReq = {0};
|
||||
showReq.type = TSDB_MGMT_TABLE_MAX;
|
||||
|
||||
SShowReq* pReq = (SShowReq*)rpcMallocCont(contLen);
|
||||
pReq->type = TSDB_MGMT_TABLE_MAX;
|
||||
strcpy(pReq->db, "");
|
||||
int32_t contLen = tSerializeSShowReq(NULL, 0, &showReq);
|
||||
void* pReq = rpcMallocCont(contLen);
|
||||
tSerializeSShowReq(pReq, contLen, &showReq);
|
||||
tFreeSShowReq(&showReq);
|
||||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
|
@ -38,11 +40,13 @@ TEST_F(MndTestShow, 01_ShowMsg_InvalidMsgMax) {
|
|||
}
|
||||
|
||||
TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
|
||||
int32_t contLen = sizeof(SShowReq);
|
||||
SShowReq showReq = {0};
|
||||
showReq.type = TSDB_MGMT_TABLE_START;
|
||||
|
||||
SShowReq* pReq = (SShowReq*)rpcMallocCont(sizeof(SShowReq));
|
||||
pReq->type = TSDB_MGMT_TABLE_START;
|
||||
strcpy(pReq->db, "");
|
||||
int32_t contLen = tSerializeSShowReq(NULL, 0, &showReq);
|
||||
void* pReq = rpcMallocCont(contLen);
|
||||
tSerializeSShowReq(pReq, contLen, &showReq);
|
||||
tFreeSShowReq(&showReq);
|
||||
|
||||
SRpcMsg* pRsp = test.SendReq(TDMT_MND_SHOW, pReq, contLen);
|
||||
ASSERT_NE(pRsp, nullptr);
|
||||
|
|
|
@ -1,18 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TDENGINE_ASTTOMSG_H
|
||||
#define TDENGINE_ASTTOMSG_H
|
||||
|
||||
#include "parserInt.h"
|
||||
#include "tmsg.h"
|
||||
|
||||
|
||||
char* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen);
|
||||
char* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen);
|
||||
char* buildDropUserMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgLen);
|
||||
SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseContext* pParseCtx, SMsgBuf* pMsgBuf);
|
||||
char* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, int32_t *len, SParseContext *pCtx, SMsgBuf* pMsgBuf);
|
||||
char* buildCreateStbReq(SCreateTableSql* pCreateTableSql, int32_t* len, SParseContext* pParseCtx, SMsgBuf* pMsgBuf);
|
||||
char* buildDropStableReq(SSqlInfo* pInfo, int32_t* len, SParseContext* pParseCtx, SMsgBuf* pMsgBuf);
|
||||
char* buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf);
|
||||
char* buildDropDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf);
|
||||
char* buildShowMsg(SShowInfo* pShowInfo, int32_t* outputLen, SParseContext* pParseCtx, SMsgBuf* pMsgBuf);
|
||||
char* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, int32_t* outputLen, SParseContext* pCtx, SMsgBuf* pMsgBuf);
|
||||
char* buildCreateStbReq(SCreateTableSql* pCreateTableSql, int32_t* outputLen, SParseContext* pParseCtx, SMsgBuf* pMsgBuf);
|
||||
char* buildDropStableReq(SSqlInfo* pInfo, int32_t* outputLen, SParseContext* pParseCtx, SMsgBuf* pMsgBuf);
|
||||
char* buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* outputLen, SMsgBuf* pMsgBuf);
|
||||
char* buildDropDnodeMsg(SSqlInfo* pInfo, int32_t* outputLen, SMsgBuf* pMsgBuf);
|
||||
|
||||
#endif // TDENGINE_ASTTOMSG_H
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "astGenerator.h"
|
||||
#include "parserInt.h"
|
||||
#include "parserUtil.h"
|
||||
|
@ -11,7 +26,7 @@ char* buildUserManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id,
|
|||
createReq.superUser = (int8_t)pUser->type;
|
||||
|
||||
if (pUser->type == TSDB_ALTER_USER_PRIVILEGES) {
|
||||
// pMsg->privilege = (char)pCmd->count;
|
||||
// pMsg->privilege = (char)pCmd->count;
|
||||
} else {
|
||||
strncpy(createReq.pass, pUser->passwd.z, pUser->passwd.n);
|
||||
}
|
||||
|
@ -71,7 +86,7 @@ char* buildAcctManipulationMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id,
|
|||
return pReq;
|
||||
}
|
||||
|
||||
char* buildDropUserMsg(SSqlInfo* pInfo, int32_t* msgLen, int64_t id, char* msgBuf, int32_t msgBufLen) {
|
||||
char* buildDropUserMsg(SSqlInfo* pInfo, int32_t* outputLen, int64_t id, char* msgBuf, int32_t msgBufLen) {
|
||||
SDropUserReq dropReq = {0};
|
||||
|
||||
SToken* pName = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
||||
|
@ -89,30 +104,26 @@ char* buildDropUserMsg(SSqlInfo* pInfo, int32_t* msgLen, int64_t id, char* msgBu
|
|||
}
|
||||
|
||||
tSerializeSDropUserReq(pReq, tlen, &dropReq);
|
||||
*msgLen = tlen;
|
||||
*outputLen = tlen;
|
||||
return pReq;
|
||||
}
|
||||
|
||||
SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseContext* pCtx, SMsgBuf* pMsgBuf) {
|
||||
SShowReq* pShowMsg = calloc(1, sizeof(SShowReq));
|
||||
if (pShowMsg == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return pShowMsg;
|
||||
}
|
||||
char* buildShowMsg(SShowInfo* pShowInfo, int32_t* outputLen, SParseContext* pCtx, SMsgBuf* pMsgBuf) {
|
||||
SShowReq showReq = {.type = pShowInfo->showType};
|
||||
|
||||
pShowMsg->type = pShowInfo->showType;
|
||||
if (pShowInfo->showType != TSDB_MGMT_TABLE_VNODES) {
|
||||
SToken* pPattern = &pShowInfo->pattern;
|
||||
if (pPattern->type > 0) { // only show tables support wildcard query
|
||||
strncpy(pShowMsg->payload, pPattern->z, pPattern->n);
|
||||
pShowMsg->payloadLen = htons(pPattern->n);
|
||||
showReq.payloadLen = pPattern->n;
|
||||
showReq.payload = malloc(showReq.payloadLen);
|
||||
strncpy(showReq.payload, pPattern->z, pPattern->n);
|
||||
}
|
||||
} else {
|
||||
SToken* pEpAddr = &pShowInfo->prefix;
|
||||
assert(pEpAddr->n > 0 && pEpAddr->type > 0);
|
||||
|
||||
strncpy(pShowMsg->payload, pEpAddr->z, pEpAddr->n);
|
||||
pShowMsg->payloadLen = htons(pEpAddr->n);
|
||||
showReq.payloadLen = pEpAddr->n;
|
||||
showReq.payload = malloc(showReq.payloadLen);
|
||||
strncpy(showReq.payload, pEpAddr->z, pEpAddr->n);
|
||||
}
|
||||
|
||||
if (pShowInfo->showType == TSDB_MGMT_TABLE_STB || pShowInfo->showType == TSDB_MGMT_TABLE_VGROUP) {
|
||||
|
@ -121,22 +132,32 @@ SShowReq* buildShowMsg(SShowInfo* pShowInfo, SParseContext* pCtx, SMsgBuf* pMsgB
|
|||
if (pShowInfo->prefix.n > 0) {
|
||||
if (pShowInfo->prefix.n >= TSDB_DB_FNAME_LEN) {
|
||||
terrno = buildInvalidOperationMsg(pMsgBuf, "prefix name is too long");
|
||||
tfree(pShowMsg);
|
||||
tFreeSShowReq(&showReq);
|
||||
return NULL;
|
||||
}
|
||||
tNameSetDbName(&n, pCtx->acctId, pShowInfo->prefix.z, pShowInfo->prefix.n);
|
||||
} else if (pCtx->db == NULL || strlen(pCtx->db) == 0) {
|
||||
terrno = buildInvalidOperationMsg(pMsgBuf, "database is not specified");
|
||||
tfree(pShowMsg);
|
||||
tFreeSShowReq(&showReq);
|
||||
return NULL;
|
||||
} else {
|
||||
tNameSetDbName(&n, pCtx->acctId, pCtx->db, strlen(pCtx->db));
|
||||
}
|
||||
|
||||
tNameGetFullDbName(&n, pShowMsg->db);
|
||||
tNameGetFullDbName(&n, showReq.db);
|
||||
}
|
||||
|
||||
return pShowMsg;
|
||||
int32_t tlen = tSerializeSShowReq(NULL, 0, &showReq);
|
||||
void* pReq = malloc(tlen);
|
||||
if (pReq == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tSerializeSShowReq(pReq, tlen, &showReq);
|
||||
tFreeSShowReq(&showReq);
|
||||
*outputLen = tlen;
|
||||
return pReq;
|
||||
}
|
||||
|
||||
static int32_t setKeepOption(SCreateDbReq* pMsg, const SCreateDbInfo* pCreateDb, SMsgBuf* pMsgBuf) {
|
||||
|
@ -330,7 +351,7 @@ static int32_t doCheckDbOptions(SCreateDbReq* pCreate, SMsgBuf* pMsgBuf) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
char* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, int32_t* len, SParseContext* pCtx, SMsgBuf* pMsgBuf) {
|
||||
char* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, int32_t* outputLen, SParseContext* pCtx, SMsgBuf* pMsgBuf) {
|
||||
SCreateDbReq createReq = {0};
|
||||
|
||||
if (setDbOptions(&createReq, pCreateDbInfo, pMsgBuf) != TSDB_CODE_SUCCESS) {
|
||||
|
@ -360,11 +381,12 @@ char* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, int32_t* len, SParseContext
|
|||
}
|
||||
|
||||
tSerializeSCreateDbReq(pReq, tlen, &createReq);
|
||||
*len = tlen;
|
||||
*outputLen = tlen;
|
||||
return pReq;
|
||||
}
|
||||
|
||||
char* buildCreateStbReq(SCreateTableSql* pCreateTableSql, int32_t* len, SParseContext* pParseCtx, SMsgBuf* pMsgBuf) {
|
||||
char* buildCreateStbReq(SCreateTableSql* pCreateTableSql, int32_t* outputLen, SParseContext* pParseCtx,
|
||||
SMsgBuf* pMsgBuf) {
|
||||
SMCreateStbReq createReq = {0};
|
||||
createReq.igExists = pCreateTableSql->existCheck ? 1 : 0;
|
||||
createReq.pColumns = pCreateTableSql->colInfo.pColumns;
|
||||
|
@ -374,11 +396,13 @@ char* buildCreateStbReq(SCreateTableSql* pCreateTableSql, int32_t* len, SParseCo
|
|||
|
||||
SName n = {0};
|
||||
if (createSName(&n, &pCreateTableSql->name, pParseCtx, pMsgBuf) != 0) {
|
||||
tFreeSMCreateStbReq(&createReq);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (tNameExtractFullName(&n, createReq.name) != 0) {
|
||||
buildInvalidOperationMsg(pMsgBuf, "invalid table name or database not specified");
|
||||
tFreeSMCreateStbReq(&createReq);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -391,11 +415,12 @@ char* buildCreateStbReq(SCreateTableSql* pCreateTableSql, int32_t* len, SParseCo
|
|||
|
||||
void* pBuf = pReq;
|
||||
tSerializeSMCreateStbReq(&pBuf, &createReq);
|
||||
*len = tlen;
|
||||
tFreeSMCreateStbReq(&createReq);
|
||||
*outputLen = tlen;
|
||||
return pReq;
|
||||
}
|
||||
|
||||
char* buildDropStableReq(SSqlInfo* pInfo, int32_t* len, SParseContext* pParseCtx, SMsgBuf* pMsgBuf) {
|
||||
char* buildDropStableReq(SSqlInfo* pInfo, int32_t* outputLen, SParseContext* pParseCtx, SMsgBuf* pMsgBuf) {
|
||||
SToken* tableName = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
||||
|
||||
SName name = {0};
|
||||
|
@ -420,11 +445,11 @@ char* buildDropStableReq(SSqlInfo* pInfo, int32_t* len, SParseContext* pParseCtx
|
|||
|
||||
void* pBuf = pReq;
|
||||
tSerializeSMDropStbReq(&pBuf, &dropReq);
|
||||
*len = tlen;
|
||||
*outputLen = tlen;
|
||||
return pReq;
|
||||
}
|
||||
|
||||
char* buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf) {
|
||||
char* buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* outputLen, SMsgBuf* pMsgBuf) {
|
||||
const char* msg1 = "invalid host name (name too long, maximum length 128)";
|
||||
const char* msg2 = "dnode name can not be string";
|
||||
const char* msg3 = "port should be an integer that is less than 65535 and greater than 0";
|
||||
|
@ -469,11 +494,11 @@ char* buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf) {
|
|||
}
|
||||
|
||||
tSerializeSCreateDnodeReq(pReq, tlen, &createReq);
|
||||
*len = tlen;
|
||||
*outputLen = tlen;
|
||||
return pReq;
|
||||
}
|
||||
|
||||
char* buildDropDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf) {
|
||||
char* buildDropDnodeMsg(SSqlInfo* pInfo, int32_t* outputLen, SMsgBuf* pMsgBuf) {
|
||||
SDropDnodeReq dropReq = {0};
|
||||
|
||||
SToken* pzName = taosArrayGet(pInfo->pMiscInfo->a, 0);
|
||||
|
@ -494,6 +519,6 @@ char* buildDropDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMsgBuf) {
|
|||
}
|
||||
|
||||
tSerializeSDropDnodeReq(pReq, tlen, &dropReq);
|
||||
*len = tlen;
|
||||
*outputLen = tlen;
|
||||
return pReq;
|
||||
}
|
|
@ -114,12 +114,10 @@ static int32_t setShowInfo(SShowInfo* pShowInfo, SParseContext* pCtx, void** out
|
|||
}
|
||||
|
||||
*pEpSet = pCtx->mgmtEpSet;
|
||||
*output = buildShowMsg(pShowInfo, pCtx, pMsgBuf);
|
||||
*output = buildShowMsg(pShowInfo, outputLen, pCtx, pMsgBuf);
|
||||
if (*output == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
*outputLen = sizeof(SShowReq) /* + htons(pShowMsg->payloadLen)*/;
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
|
Loading…
Reference in New Issue