fix: if not exists logic for topic/stream/table
This commit is contained in:
parent
92a7801d09
commit
a0a7c05faf
|
@ -860,11 +860,6 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
|||
SUserObj *pUser = NULL;
|
||||
SCreateDbReq createReq = {0};
|
||||
|
||||
if ((terrno = grantCheck(TSDB_GRANT_DB)) != 0) {
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (tDeserializeSCreateDbReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto _OVER;
|
||||
|
@ -903,6 +898,11 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
|
|||
}
|
||||
}
|
||||
|
||||
if ((terrno = grantCheck(TSDB_GRANT_DB)) != 0) {
|
||||
code = terrno;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if ((code = mndCheckDbEncryptKey(pMnode, &createReq)) != 0) {
|
||||
terrno = code;
|
||||
goto _OVER;
|
||||
|
|
|
@ -699,10 +699,6 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
int32_t sqlLen = 0;
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
|
||||
if ((terrno = grantCheck(TSDB_GRANT_STREAMS)) < 0) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
SCMCreateStreamReq createReq = {0};
|
||||
if (tDeserializeSCMCreateStreamReq(pReq->pCont, pReq->contLen, &createReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
|
@ -733,6 +729,10 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
if ((terrno = grantCheck(TSDB_GRANT_STREAMS)) < 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if (createReq.sql != NULL) {
|
||||
sqlLen = strlen(createReq.sql);
|
||||
sql = taosMemoryMalloc(sqlLen + 1);
|
||||
|
|
|
@ -561,15 +561,6 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
|
|||
SMqTopicObj *pTopic = NULL;
|
||||
SDbObj *pDb = NULL;
|
||||
SCMCreateTopicReq createTopicReq = {0};
|
||||
if (sdbGetSize(pMnode->pSdb, SDB_TOPIC) >= tmqMaxTopicNum){
|
||||
terrno = TSDB_CODE_TMQ_TOPIC_OUT_OF_RANGE;
|
||||
mError("topic num out of range");
|
||||
return code;
|
||||
}
|
||||
|
||||
if ((terrno = grantCheck(TSDB_GRANT_SUBSCRIPTION)) < 0) {
|
||||
return code;
|
||||
}
|
||||
|
||||
if (tDeserializeSCMCreateTopicReq(pReq->pCont, pReq->contLen, &createTopicReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
|
@ -609,6 +600,16 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
if (sdbGetSize(pMnode->pSdb, SDB_TOPIC) >= tmqMaxTopicNum){
|
||||
terrno = TSDB_CODE_TMQ_TOPIC_OUT_OF_RANGE;
|
||||
mError("topic num out of range");
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
if ((terrno = grantCheck(TSDB_GRANT_SUBSCRIPTION)) < 0) {
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
code = mndCreateTopic(pMnode, pReq, &createTopicReq, pDb, pReq->info.conn.user);
|
||||
if (code == 0) {
|
||||
code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
|
|
|
@ -887,6 +887,12 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
|
|||
|
||||
bool sysTbl = (pReq->type == TSDB_CHILD_TABLE) && metaTbInFilterCache(pMeta, pReq->ctb.stbName, 1);
|
||||
|
||||
if (!sysTbl) {
|
||||
if ((terrno = grantCheck(TSDB_GRANT_TIMESERIES)) < 0) {
|
||||
goto _err;
|
||||
}
|
||||
}
|
||||
|
||||
// build SMetaEntry
|
||||
SVnodeStats *pStats = &pMeta->pVnode->config.vndStats;
|
||||
me.version = ver;
|
||||
|
|
|
@ -1076,16 +1076,6 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq,
|
|||
pCreateReq = req.pReqs + iReq;
|
||||
memset(&cRsp, 0, sizeof(cRsp));
|
||||
|
||||
if ((terrno = grantCheck(TSDB_GRANT_TIMESERIES)) < 0) {
|
||||
rcode = -1;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if ((terrno = grantCheck(TSDB_GRANT_TABLE)) < 0) {
|
||||
rcode = -1;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
if (tsEnableAudit && tsEnableAuditCreateTable) {
|
||||
char *str = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN);
|
||||
if (str == NULL) {
|
||||
|
@ -1778,13 +1768,6 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t ver, void *pReq, in
|
|||
|
||||
// create table
|
||||
if (pSubmitTbData->pCreateTbReq) {
|
||||
// check (TODO: move check to create table)
|
||||
code = grantCheck(TSDB_GRANT_TIMESERIES);
|
||||
if (code) goto _exit;
|
||||
|
||||
code = grantCheck(TSDB_GRANT_TABLE);
|
||||
if (code) goto _exit;
|
||||
|
||||
// alloc if need
|
||||
if (pSubmitRsp->aCreateTbRsp == NULL &&
|
||||
(pSubmitRsp->aCreateTbRsp = taosArrayInit(TARRAY_SIZE(pSubmitReq->aSubmitTbData), sizeof(SVCreateTbRsp))) ==
|
||||
|
|
Loading…
Reference in New Issue