feat: support uniq grant
This commit is contained in:
parent
a9316c3710
commit
6cf7809e8d
|
@ -232,7 +232,7 @@ struct SConfig *taosGetCfg();
|
|||
void taosSetAllDebugFlag(int32_t flag);
|
||||
void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal);
|
||||
void taosLocalCfgForbiddenToChange(char *name, bool *forbidden);
|
||||
int8_t taosGranted();
|
||||
int8_t taosGranted(int8_t type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -92,8 +92,6 @@ typedef struct SScanLogicNode {
|
|||
STimeWindow scanRange;
|
||||
SName tableName;
|
||||
bool showRewrite;
|
||||
bool isView;
|
||||
bool isAudit;
|
||||
double ratio;
|
||||
SNodeList* pDynamicScanFuncs;
|
||||
int32_t dataRequired;
|
||||
|
|
|
@ -517,8 +517,6 @@ typedef struct SQuery {
|
|||
SArray* pTableList;
|
||||
SArray* pDbList;
|
||||
bool showRewrite;
|
||||
// bool isView;
|
||||
// bool isAudit;
|
||||
int32_t placeholderNum;
|
||||
SArray* pPlaceholderValues;
|
||||
SNode* pPrepareRoot;
|
||||
|
|
|
@ -70,7 +70,7 @@ typedef enum {
|
|||
#define QUERY_MSG_MASK_AUDIT() (1 << 2)
|
||||
#define TEST_SHOW_REWRITE_MASK(m) (((m)&QUERY_MSG_MASK_SHOW_REWRITE()) != 0)
|
||||
#define TEST_VIEW_MASK(m) (((m)&QUERY_MSG_MASK_VIEW()) != 0)
|
||||
#define TEST_AUDIT_MASK(m) (((m)&QUERY_MSG_MASK_MASK()) != 0)
|
||||
#define TEST_AUDIT_MASK(m) (((m)&QUERY_MSG_MASK_AUDIT()) != 0)
|
||||
|
||||
|
||||
typedef struct STableComInfo {
|
||||
|
|
|
@ -458,8 +458,6 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra
|
|||
.mgmtEpSet = getEpSet_s(&pAppInfo->mgmtEp),
|
||||
.pAstRoot = pQuery->pRoot,
|
||||
.showRewrite = pQuery->showRewrite,
|
||||
.isView = pQuery->isView;
|
||||
.isAudit = pQuery->isAudit;
|
||||
.pMsg = pRequest->msgBuf,
|
||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||
.pUser = pRequest->pTscObj->user,
|
||||
|
|
|
@ -1801,4 +1801,17 @@ void taosSetAllDebugFlag(int32_t flag) {
|
|||
if (terrno == TSDB_CODE_CFG_NOT_FOUND) terrno = TSDB_CODE_SUCCESS; // ignore not exist
|
||||
}
|
||||
|
||||
int8_t taosGranted() { return atomic_load_8(&tsGrant); }
|
||||
int8_t taosGranted(int8_t type) {
|
||||
switch (type) {
|
||||
case TSDB_GRANT_ALL:
|
||||
return atomic_load_8(&tsGrant) & GRANT_ALL_FLAG;
|
||||
case TSDB_GRANT_AUDIT:
|
||||
return atomic_load_8(&tsGrant) & GRANT_AUDIT_FLAG;
|
||||
case TSDB_GRANT_VIEW:
|
||||
return atomic_load_8(&tsGrant) & GRANT_VIEW_FLAG;
|
||||
default:
|
||||
ASSERTS(0, "undefined grant type:%" PRIi8, type);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -43,8 +43,8 @@ typedef struct STranslateContext {
|
|||
bool createStream;
|
||||
bool stableQuery;
|
||||
bool showRewrite;
|
||||
bool isView;
|
||||
bool isAudit;
|
||||
// bool isView;
|
||||
// bool isAudit;
|
||||
SNode* pPrevRoot;
|
||||
SNode* pPostRoot;
|
||||
} STranslateContext;
|
||||
|
|
|
@ -2164,6 +2164,8 @@ static SSubplan* makeSubplan(SPhysiPlanContext* pCxt, SLogicSubplan* pLogicSubpl
|
|||
pSubplan->level = pLogicSubplan->level;
|
||||
pSubplan->rowsThreshold = 4096;
|
||||
pSubplan->dynamicRowThreshold = false;
|
||||
pSubplan->isView = pCxt->pPlanCxt->isView;
|
||||
pSubplan->isAudit = pCxt->pPlanCxt->isAudit;
|
||||
if (NULL != pCxt->pPlanCxt->pUser) {
|
||||
snprintf(pSubplan->user, sizeof(pSubplan->user), "%s", pCxt->pPlanCxt->pUser);
|
||||
}
|
||||
|
|
|
@ -360,10 +360,24 @@ int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg, bool chkGran
|
|||
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
}
|
||||
|
||||
if (chkGrant && (!TEST_SHOW_REWRITE_MASK(msg.msgMask)) && !taosGranted()) {
|
||||
QW_ELOG("query failed cause of grant expired, msgMask:%d", msg.msgMask);
|
||||
tFreeSSubQueryMsg(&msg);
|
||||
QW_ERR_RET(TSDB_CODE_GRANT_EXPIRED);
|
||||
if (chkGrant) {
|
||||
if ((!TEST_SHOW_REWRITE_MASK(msg.msgMask)) && !taosGranted(TSDB_GRANT_ALL)) {
|
||||
QW_ELOG("query failed cause of grant expired, msgMask:%d", msg.msgMask);
|
||||
tFreeSSubQueryMsg(&msg);
|
||||
QW_ERR_RET(TSDB_CODE_GRANT_EXPIRED);
|
||||
}
|
||||
|
||||
if ((TEST_VIEW_MASK(msg.msgMask)) && !taosGranted(TSDB_GRANT_VIEW)) {
|
||||
QW_ELOG("query failed cause of view grant expired, msgMask:%d", msg.msgMask);
|
||||
tFreeSSubQueryMsg(&msg);
|
||||
QW_ERR_RET(TSDB_CODE_GRANT_EXPIRED);
|
||||
}
|
||||
|
||||
if ((TEST_AUDIT_MASK(msg.msgMask)) && !taosGranted(TSDB_GRANT_AUDIT)) {
|
||||
QW_ELOG("query failed cause of audit grant expired, msgMask:%d", msg.msgMask);
|
||||
tFreeSSubQueryMsg(&msg);
|
||||
QW_ERR_RET(TSDB_CODE_GRANT_EXPIRED);
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t sId = msg.sId;
|
||||
|
|
Loading…
Reference in New Issue