fix: union all view issue
This commit is contained in:
parent
ab98f7623c
commit
dbbceae061
|
@ -56,7 +56,7 @@ typedef struct SParseSqlRes {
|
||||||
};
|
};
|
||||||
} SParseSqlRes;
|
} SParseSqlRes;
|
||||||
|
|
||||||
typedef int32_t (*parseSqlFn)(void*, const char*, bool, const char*, SParseSqlRes*);
|
typedef int32_t (*parseSqlFn)(void*, const char*, const char*, bool, const char*, SParseSqlRes*);
|
||||||
|
|
||||||
typedef struct SParseCsvCxt {
|
typedef struct SParseCsvCxt {
|
||||||
TdFilePtr fp; // last parsed file
|
TdFilePtr fp; // last parsed file
|
||||||
|
|
|
@ -308,7 +308,7 @@ void taosAsyncQueryImpl(uint64_t connId, const char* sql, __taos_async_fn_t fp,
|
||||||
void taosAsyncQueryImplWithReqid(uint64_t connId, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly,
|
void taosAsyncQueryImplWithReqid(uint64_t connId, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly,
|
||||||
int64_t reqid);
|
int64_t reqid);
|
||||||
void taosAsyncFetchImpl(SRequestObj *pRequest, __taos_async_fn_t fp, void *param);
|
void taosAsyncFetchImpl(SRequestObj *pRequest, __taos_async_fn_t fp, void *param);
|
||||||
int32_t clientParseSql(void* param, const char* sql, bool parseOnly, const char* effectiveUser, SParseSqlRes* pRes);
|
int32_t clientParseSql(void* param, const char* dbName, const char* sql, bool parseOnly, const char* effectiveUser, SParseSqlRes* pRes);
|
||||||
void syncQueryFn(void* param, void* res, int32_t code);
|
void syncQueryFn(void* param, void* res, int32_t code);
|
||||||
|
|
||||||
int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols);
|
int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols);
|
||||||
|
@ -423,7 +423,7 @@ void stopAllQueries(SRequestObj *pRequest);
|
||||||
void freeQueryParam(SSyncQueryParam* param);
|
void freeQueryParam(SSyncQueryParam* param);
|
||||||
|
|
||||||
#ifdef TD_ENTERPRISE
|
#ifdef TD_ENTERPRISE
|
||||||
int32_t clientParseSqlImpl(void* param, const char* sql, bool parseOnly, const char* effeciveUser, SParseSqlRes* pRes);
|
int32_t clientParseSqlImpl(void* param, const char* dbName, const char* sql, bool parseOnly, const char* effeciveUser, SParseSqlRes* pRes);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -2623,11 +2623,11 @@ void taosAsyncFetchImpl(SRequestObj* pRequest, __taos_async_fn_t fp, void* param
|
||||||
schedulerFetchRows(pRequest->body.queryJob, &req);
|
schedulerFetchRows(pRequest->body.queryJob, &req);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t clientParseSql(void* param, const char* sql, bool parseOnly, const char* effectiveUser, SParseSqlRes* pRes) {
|
int32_t clientParseSql(void* param, const char* dbName, const char* sql, bool parseOnly, const char* effectiveUser, SParseSqlRes* pRes) {
|
||||||
#ifndef TD_ENTERPRISE
|
#ifndef TD_ENTERPRISE
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
#else
|
#else
|
||||||
return clientParseSqlImpl(param, sql, parseOnly, effectiveUser, pRes);
|
return clientParseSqlImpl(param, dbName, sql, parseOnly, effectiveUser, pRes);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1977,21 +1977,21 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs
|
||||||
char db[TSDB_DB_FNAME_LEN] = {0};
|
char db[TSDB_DB_FNAME_LEN] = {0};
|
||||||
if (tDecodeCStrTo(pDecoder, db) < 0) goto _err;
|
if (tDecodeCStrTo(pDecoder, db) < 0) goto _err;
|
||||||
int32_t len = strlen(db);
|
int32_t len = strlen(db);
|
||||||
taosHashPut(pRsp->createdDbs, db, len, db, len + 1);
|
taosHashPut(pRsp->createdDbs, db, len + 1, db, len + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfReadDbs; ++i) {
|
for (int32_t i = 0; i < numOfReadDbs; ++i) {
|
||||||
char db[TSDB_DB_FNAME_LEN] = {0};
|
char db[TSDB_DB_FNAME_LEN] = {0};
|
||||||
if (tDecodeCStrTo(pDecoder, db) < 0) goto _err;
|
if (tDecodeCStrTo(pDecoder, db) < 0) goto _err;
|
||||||
int32_t len = strlen(db);
|
int32_t len = strlen(db);
|
||||||
taosHashPut(pRsp->readDbs, db, len, db, len + 1);
|
taosHashPut(pRsp->readDbs, db, len + 1, db, len + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfWriteDbs; ++i) {
|
for (int32_t i = 0; i < numOfWriteDbs; ++i) {
|
||||||
char db[TSDB_DB_FNAME_LEN] = {0};
|
char db[TSDB_DB_FNAME_LEN] = {0};
|
||||||
if (tDecodeCStrTo(pDecoder, db) < 0) goto _err;
|
if (tDecodeCStrTo(pDecoder, db) < 0) goto _err;
|
||||||
int32_t len = strlen(db);
|
int32_t len = strlen(db);
|
||||||
taosHashPut(pRsp->writeDbs, db, len, db, len + 1);
|
taosHashPut(pRsp->writeDbs, db, len + 1, db, len + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tDecodeIsEnd(pDecoder)) {
|
if (!tDecodeIsEnd(pDecoder)) {
|
||||||
|
|
|
@ -74,6 +74,8 @@ typedef enum {
|
||||||
MND_OPER_SUBSCRIBE,
|
MND_OPER_SUBSCRIBE,
|
||||||
MND_OPER_CREATE_TOPIC,
|
MND_OPER_CREATE_TOPIC,
|
||||||
MND_OPER_DROP_TOPIC,
|
MND_OPER_DROP_TOPIC,
|
||||||
|
MND_OPER_CREATE_VIEW,
|
||||||
|
MND_OPER_DROP_VIEW,
|
||||||
} EOperType;
|
} EOperType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
@ -28,6 +28,7 @@ void mndCleanupPrivilege(SMnode *pMnode);
|
||||||
int32_t mndCheckOperPrivilege(SMnode *pMnode, const char *user, EOperType operType);
|
int32_t mndCheckOperPrivilege(SMnode *pMnode, const char *user, EOperType operType);
|
||||||
int32_t mndCheckDbPrivilege(SMnode *pMnode, const char *user, EOperType operType, SDbObj *pDb);
|
int32_t mndCheckDbPrivilege(SMnode *pMnode, const char *user, EOperType operType, SDbObj *pDb);
|
||||||
int32_t mndCheckDbPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *dbname);
|
int32_t mndCheckDbPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *dbname);
|
||||||
|
int32_t mndCheckViewPrivilege(SMnode *pMnode, const char *user, EOperType operType, const char *pViewFName);
|
||||||
int32_t mndCheckTopicPrivilege(SMnode *pMnode, const char *user, EOperType operType, SMqTopicObj *pTopic);
|
int32_t mndCheckTopicPrivilege(SMnode *pMnode, const char *user, EOperType operType, SMqTopicObj *pTopic);
|
||||||
int32_t mndCheckTopicPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *topicName);
|
int32_t mndCheckTopicPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *topicName);
|
||||||
int32_t mndCheckShowPrivilege(SMnode *pMnode, const char *user, EShowType showType, const char *dbname);
|
int32_t mndCheckShowPrivilege(SMnode *pMnode, const char *user, EShowType showType, const char *dbname);
|
||||||
|
|
|
@ -152,6 +152,7 @@ typedef struct SCtgAuthReq {
|
||||||
SGetUserAuthRsp authInfo;
|
SGetUserAuthRsp authInfo;
|
||||||
AUTH_TYPE singleType;
|
AUTH_TYPE singleType;
|
||||||
bool onlyCache;
|
bool onlyCache;
|
||||||
|
bool tbNotExists;
|
||||||
} SCtgAuthReq;
|
} SCtgAuthReq;
|
||||||
|
|
||||||
typedef struct SCtgAuthRsp {
|
typedef struct SCtgAuthRsp {
|
||||||
|
@ -244,6 +245,7 @@ typedef struct SCtgUdfCtx {
|
||||||
|
|
||||||
typedef struct SCtgUserCtx {
|
typedef struct SCtgUserCtx {
|
||||||
SUserAuthInfo user;
|
SUserAuthInfo user;
|
||||||
|
int32_t subTaskCode;
|
||||||
} SCtgUserCtx;
|
} SCtgUserCtx;
|
||||||
|
|
||||||
typedef struct SCtgViewsCtx {
|
typedef struct SCtgViewsCtx {
|
||||||
|
@ -918,7 +920,7 @@ int32_t ctgTbMetaExistInCache(SCatalog* pCtg, char* dbFName, char* tbName, int32
|
||||||
int32_t ctgReadTbMetaFromCache(SCatalog* pCtg, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta);
|
int32_t ctgReadTbMetaFromCache(SCatalog* pCtg, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta);
|
||||||
int32_t ctgReadTbVerFromCache(SCatalog* pCtg, SName* pTableName, int32_t* sver, int32_t* tver, int32_t* tbType,
|
int32_t ctgReadTbVerFromCache(SCatalog* pCtg, SName* pTableName, int32_t* sver, int32_t* tver, int32_t* tbType,
|
||||||
uint64_t* suid, char* stbName);
|
uint64_t* suid, char* stbName);
|
||||||
int32_t ctgChkAuthFromCache(SCatalog* pCtg, SUserAuthInfo* pReq, bool* inCache, SCtgAuthRsp* pRes);
|
int32_t ctgChkAuthFromCache(SCatalog* pCtg, SUserAuthInfo* pReq, bool tbNotExists, bool* inCache, SCtgAuthRsp* pRes);
|
||||||
int32_t ctgDropDbCacheEnqueue(SCatalog* pCtg, const char* dbFName, int64_t dbId);
|
int32_t ctgDropDbCacheEnqueue(SCatalog* pCtg, const char* dbFName, int64_t dbId);
|
||||||
int32_t ctgDropDbVgroupEnqueue(SCatalog* pCtg, const char* dbFName, bool syncReq);
|
int32_t ctgDropDbVgroupEnqueue(SCatalog* pCtg, const char* dbFName, bool syncReq);
|
||||||
int32_t ctgDropStbMetaEnqueue(SCatalog* pCtg, const char* dbFName, int64_t dbId, const char* stbName, uint64_t suid,
|
int32_t ctgDropStbMetaEnqueue(SCatalog* pCtg, const char* dbFName, int64_t dbId, const char* stbName, uint64_t suid,
|
||||||
|
|
|
@ -325,7 +325,7 @@ int32_t ctgChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, SUserAuthInfo *pReq,
|
||||||
SCtgAuthRsp rsp = {0};
|
SCtgAuthRsp rsp = {0};
|
||||||
rsp.pRawRes = pRes;
|
rsp.pRawRes = pRes;
|
||||||
|
|
||||||
CTG_ERR_RET(ctgChkAuthFromCache(pCtg, pReq, &inCache, &rsp));
|
CTG_ERR_RET(ctgChkAuthFromCache(pCtg, pReq, false, &inCache, &rsp));
|
||||||
|
|
||||||
if (inCache) {
|
if (inCache) {
|
||||||
if (exists) {
|
if (exists) {
|
||||||
|
|
|
@ -2431,6 +2431,7 @@ int32_t ctgLaunchGetUserTask(SCtgTask* pTask) {
|
||||||
bool inCache = false;
|
bool inCache = false;
|
||||||
SCtgAuthRsp rsp = {0};
|
SCtgAuthRsp rsp = {0};
|
||||||
SCtgJob* pJob = pTask->pJob;
|
SCtgJob* pJob = pTask->pJob;
|
||||||
|
bool tbNotExists = false;
|
||||||
SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1);
|
SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, -1);
|
||||||
if (NULL == pMsgCtx->pBatchs) {
|
if (NULL == pMsgCtx->pBatchs) {
|
||||||
pMsgCtx->pBatchs = pJob->pBatchs;
|
pMsgCtx->pBatchs = pJob->pBatchs;
|
||||||
|
@ -2440,8 +2441,17 @@ int32_t ctgLaunchGetUserTask(SCtgTask* pTask) {
|
||||||
if (NULL == rsp.pRawRes) {
|
if (NULL == rsp.pRawRes) {
|
||||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TSDB_CODE_SUCCESS != pCtx->subTaskCode) {
|
||||||
|
if (CTG_TABLE_NOT_EXIST(pCtx->subTaskCode)) {
|
||||||
|
tbNotExists = true;
|
||||||
|
pCtx->subTaskCode = 0;
|
||||||
|
} else {
|
||||||
|
CTG_ERR_RET(pCtx->subTaskCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CTG_ERR_RET(ctgChkAuthFromCache(pCtg, &pCtx->user, &inCache, &rsp));
|
CTG_ERR_RET(ctgChkAuthFromCache(pCtg, &pCtx->user, tbNotExists, &inCache, &rsp));
|
||||||
if (inCache) {
|
if (inCache) {
|
||||||
pTask->res = rsp.pRawRes;
|
pTask->res = rsp.pRawRes;
|
||||||
|
|
||||||
|
@ -2590,8 +2600,9 @@ _return:
|
||||||
int32_t ctgGetUserCb(SCtgTask* pTask) {
|
int32_t ctgGetUserCb(SCtgTask* pTask) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
CTG_ERR_JRET(pTask->subRes.code);
|
SCtgUserCtx* pCtx = (SCtgUserCtx*)pTask->taskCtx;
|
||||||
|
pCtx->subTaskCode = pTask->subRes.code;
|
||||||
|
|
||||||
CTG_RET(ctgLaunchGetUserTask(pTask));
|
CTG_RET(ctgLaunchGetUserTask(pTask));
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
|
|
|
@ -788,7 +788,7 @@ int32_t ctgGetCachedStbNameFromSuid(SCatalog* pCtg, char* dbFName, uint64_t suid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t ctgChkAuthFromCache(SCatalog *pCtg, SUserAuthInfo *pReq, bool *inCache, SCtgAuthRsp *pRes) {
|
int32_t ctgChkAuthFromCache(SCatalog *pCtg, SUserAuthInfo *pReq, bool tbNotExists, bool *inCache, SCtgAuthRsp *pRes) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
SCtgUserAuth *pUser = (SCtgUserAuth *)taosHashGet(pCtg->userCache, pReq->user, strlen(pReq->user));
|
SCtgUserAuth *pUser = (SCtgUserAuth *)taosHashGet(pCtg->userCache, pReq->user, strlen(pReq->user));
|
||||||
|
@ -805,6 +805,7 @@ int32_t ctgChkAuthFromCache(SCatalog *pCtg, SUserAuthInfo *pReq, bool *inCache,
|
||||||
SCtgAuthReq req = {0};
|
SCtgAuthReq req = {0};
|
||||||
req.pRawReq = pReq;
|
req.pRawReq = pReq;
|
||||||
req.onlyCache = true;
|
req.onlyCache = true;
|
||||||
|
req.tbNotExists = tbNotExists;
|
||||||
|
|
||||||
CTG_LOCK(CTG_READ, &pUser->lock);
|
CTG_LOCK(CTG_READ, &pUser->lock);
|
||||||
memcpy(&req.authInfo, &pUser->userAuth, sizeof(pUser->userAuth));
|
memcpy(&req.authInfo, &pUser->userAuth, sizeof(pUser->userAuth));
|
||||||
|
|
|
@ -1641,7 +1641,7 @@ int32_t ctgChkSetTbAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) {
|
||||||
while (true) {
|
while (true) {
|
||||||
taosMemoryFreeClear(pMeta);
|
taosMemoryFreeClear(pMeta);
|
||||||
|
|
||||||
char* pCond = taosHashGet(pTbs, tbFName, strlen(tbFName));
|
char* pCond = taosHashGet(pTbs, tbFName, strlen(tbFName) + 1);
|
||||||
if (pCond) {
|
if (pCond) {
|
||||||
if (strlen(pCond) > 1) {
|
if (strlen(pCond) > 1) {
|
||||||
CTG_ERR_JRET(nodesStringToNode(pCond, &res->pRawRes->pCond[AUTH_RES_BASIC]));
|
CTG_ERR_JRET(nodesStringToNode(pCond, &res->pRawRes->pCond[AUTH_RES_BASIC]));
|
||||||
|
@ -1713,8 +1713,12 @@ int32_t ctgChkSetBasicAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res
|
||||||
pRes->pass[AUTH_RES_BASIC] = false;
|
pRes->pass[AUTH_RES_BASIC] = false;
|
||||||
pRes->pCond[AUTH_RES_BASIC] = NULL;
|
pRes->pCond[AUTH_RES_BASIC] = NULL;
|
||||||
|
|
||||||
|
if (req->tbNotExists) {
|
||||||
|
pRes->pass[AUTH_RES_BASIC] = true;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
if (!pInfo->enable) {
|
if (!pInfo->enable) {
|
||||||
pRes->pass[AUTH_RES_BASIC] = false;
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1750,7 +1754,7 @@ int32_t ctgChkSetBasicAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->readDbs && taosHashGet(pInfo->readDbs, dbFName, strlen(dbFName))) {
|
if (pInfo->readDbs && taosHashGet(pInfo->readDbs, dbFName, strlen(dbFName) + 1)) {
|
||||||
pRes->pass[AUTH_RES_BASIC] = true;
|
pRes->pass[AUTH_RES_BASIC] = true;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1766,7 +1770,7 @@ int32_t ctgChkSetBasicAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInfo->writeDbs && taosHashGet(pInfo->writeDbs, dbFName, strlen(dbFName))) {
|
if (pInfo->writeDbs && taosHashGet(pInfo->writeDbs, dbFName, strlen(dbFName) + 1)) {
|
||||||
pRes->pass[AUTH_RES_BASIC] = true;
|
pRes->pass[AUTH_RES_BASIC] = true;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1774,9 +1778,9 @@ int32_t ctgChkSetBasicAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AUTH_TYPE_READ_OR_WRITE: {
|
case AUTH_TYPE_READ_OR_WRITE: {
|
||||||
if ((pInfo->readDbs && taosHashGet(pInfo->readDbs, dbFName, strlen(dbFName))) ||
|
if ((pInfo->readDbs && taosHashGet(pInfo->readDbs, dbFName, strlen(dbFName) + 1)) ||
|
||||||
(pInfo->writeDbs && taosHashGet(pInfo->writeDbs, dbFName, strlen(dbFName))) ||
|
(pInfo->writeDbs && taosHashGet(pInfo->writeDbs, dbFName, strlen(dbFName) + 1)) ||
|
||||||
(pInfo->useDbs && taosHashGet(pInfo->useDbs, dbFName, strlen(dbFName)))) {
|
(pInfo->useDbs && taosHashGet(pInfo->useDbs, dbFName, strlen(dbFName) + 1))) {
|
||||||
pRes->pass[AUTH_RES_BASIC] = true;
|
pRes->pass[AUTH_RES_BASIC] = true;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -2010,7 +2014,7 @@ uint64_t ctgGetUserCacheSize(SGetUserAuthRsp *pAuth) {
|
||||||
while (p != NULL) {
|
while (p != NULL) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
void* key = taosHashGetKey(p, &len);
|
void* key = taosHashGetKey(p, &len);
|
||||||
cacheSize += len + strlen(p);
|
cacheSize += len + strlen(p) + 1;
|
||||||
|
|
||||||
p = taosHashIterate(pAuth->createdDbs, p);
|
p = taosHashIterate(pAuth->createdDbs, p);
|
||||||
}
|
}
|
||||||
|
@ -2019,7 +2023,7 @@ uint64_t ctgGetUserCacheSize(SGetUserAuthRsp *pAuth) {
|
||||||
while (p != NULL) {
|
while (p != NULL) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
void* key = taosHashGetKey(p, &len);
|
void* key = taosHashGetKey(p, &len);
|
||||||
cacheSize += len + strlen(p);
|
cacheSize += len + strlen(p) + 1;
|
||||||
|
|
||||||
p = taosHashIterate(pAuth->readDbs, p);
|
p = taosHashIterate(pAuth->readDbs, p);
|
||||||
}
|
}
|
||||||
|
@ -2028,7 +2032,7 @@ uint64_t ctgGetUserCacheSize(SGetUserAuthRsp *pAuth) {
|
||||||
while (p != NULL) {
|
while (p != NULL) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
void* key = taosHashGetKey(p, &len);
|
void* key = taosHashGetKey(p, &len);
|
||||||
cacheSize += len + strlen(p);
|
cacheSize += len + strlen(p) + 1;
|
||||||
|
|
||||||
p = taosHashIterate(pAuth->writeDbs, p);
|
p = taosHashIterate(pAuth->writeDbs, p);
|
||||||
}
|
}
|
||||||
|
@ -2037,7 +2041,7 @@ uint64_t ctgGetUserCacheSize(SGetUserAuthRsp *pAuth) {
|
||||||
while (p != NULL) {
|
while (p != NULL) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
void* key = taosHashGetKey(p, &len);
|
void* key = taosHashGetKey(p, &len);
|
||||||
cacheSize += len + strlen(p);
|
cacheSize += len + strlen(p) + 1;
|
||||||
|
|
||||||
p = taosHashIterate(pAuth->readTbs, p);
|
p = taosHashIterate(pAuth->readTbs, p);
|
||||||
}
|
}
|
||||||
|
@ -2046,7 +2050,7 @@ uint64_t ctgGetUserCacheSize(SGetUserAuthRsp *pAuth) {
|
||||||
while (p != NULL) {
|
while (p != NULL) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
void* key = taosHashGetKey(p, &len);
|
void* key = taosHashGetKey(p, &len);
|
||||||
cacheSize += len + strlen(p);
|
cacheSize += len + strlen(p) + 1;
|
||||||
|
|
||||||
p = taosHashIterate(pAuth->writeTbs, p);
|
p = taosHashIterate(pAuth->writeTbs, p);
|
||||||
}
|
}
|
||||||
|
@ -2055,7 +2059,7 @@ uint64_t ctgGetUserCacheSize(SGetUserAuthRsp *pAuth) {
|
||||||
while (p != NULL) {
|
while (p != NULL) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
void* key = taosHashGetKey(p, &len);
|
void* key = taosHashGetKey(p, &len);
|
||||||
cacheSize += len + strlen(p);
|
cacheSize += len + strlen(p) + 1;
|
||||||
|
|
||||||
p = taosHashIterate(pAuth->alterTbs, p);
|
p = taosHashIterate(pAuth->alterTbs, p);
|
||||||
}
|
}
|
||||||
|
@ -2064,7 +2068,7 @@ uint64_t ctgGetUserCacheSize(SGetUserAuthRsp *pAuth) {
|
||||||
while (p != NULL) {
|
while (p != NULL) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
void* key = taosHashGetKey(p, &len);
|
void* key = taosHashGetKey(p, &len);
|
||||||
cacheSize += len + strlen(p);
|
cacheSize += len + strlen(p) + 1;
|
||||||
|
|
||||||
p = taosHashIterate(pAuth->readViews, p);
|
p = taosHashIterate(pAuth->readViews, p);
|
||||||
}
|
}
|
||||||
|
@ -2073,7 +2077,7 @@ uint64_t ctgGetUserCacheSize(SGetUserAuthRsp *pAuth) {
|
||||||
while (p != NULL) {
|
while (p != NULL) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
void* key = taosHashGetKey(p, &len);
|
void* key = taosHashGetKey(p, &len);
|
||||||
cacheSize += len + strlen(p);
|
cacheSize += len + strlen(p) + 1;
|
||||||
|
|
||||||
p = taosHashIterate(pAuth->writeViews, p);
|
p = taosHashIterate(pAuth->writeViews, p);
|
||||||
}
|
}
|
||||||
|
@ -2082,7 +2086,7 @@ uint64_t ctgGetUserCacheSize(SGetUserAuthRsp *pAuth) {
|
||||||
while (p != NULL) {
|
while (p != NULL) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
void* key = taosHashGetKey(p, &len);
|
void* key = taosHashGetKey(p, &len);
|
||||||
cacheSize += len + strlen(p);
|
cacheSize += len + strlen(p) + 1;
|
||||||
|
|
||||||
p = taosHashIterate(pAuth->alterViews, p);
|
p = taosHashIterate(pAuth->alterViews, p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -741,6 +741,19 @@ static int32_t selectStmtCopy(const SSelectStmt* pSrc, SSelectStmt* pDst) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t setOperatorCopy(const SSetOperator* pSrc, SSetOperator* pDst) {
|
||||||
|
COPY_SCALAR_FIELD(opType);
|
||||||
|
CLONE_NODE_LIST_FIELD(pProjectionList);
|
||||||
|
CLONE_NODE_FIELD(pLeft);
|
||||||
|
CLONE_NODE_FIELD(pRight);
|
||||||
|
CLONE_NODE_LIST_FIELD(pOrderByList);
|
||||||
|
CLONE_NODE_FIELD(pLimit);
|
||||||
|
COPY_CHAR_ARRAY_FIELD(stmtName);
|
||||||
|
COPY_SCALAR_FIELD(precision);
|
||||||
|
COPY_SCALAR_FIELD(timeLineResMode);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
SNode* nodesCloneNode(const SNode* pNode) {
|
SNode* nodesCloneNode(const SNode* pNode) {
|
||||||
if (NULL == pNode) {
|
if (NULL == pNode) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -829,6 +842,9 @@ SNode* nodesCloneNode(const SNode* pNode) {
|
||||||
case QUERY_NODE_HINT:
|
case QUERY_NODE_HINT:
|
||||||
code = hintNodeCopy((const SHintNode*)pNode, (SHintNode*)pDst);
|
code = hintNodeCopy((const SHintNode*)pNode, (SHintNode*)pDst);
|
||||||
break;
|
break;
|
||||||
|
case QUERY_NODE_SET_OPERATOR:
|
||||||
|
code = setOperatorCopy((const SSetOperator*)pNode, (SSetOperator*)pDst);
|
||||||
|
break;
|
||||||
case QUERY_NODE_SELECT_STMT:
|
case QUERY_NODE_SELECT_STMT:
|
||||||
code = selectStmtCopy((const SSelectStmt*)pNode, (SSelectStmt*)pDst);
|
code = selectStmtCopy((const SSelectStmt*)pNode, (SSelectStmt*)pDst);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -304,17 +304,7 @@ static int32_t authCreateView(SAuthCxt* pCxt, SCreateViewStmt* pStmt) {
|
||||||
#ifndef TD_ENTERPRISE
|
#ifndef TD_ENTERPRISE
|
||||||
return TSDB_CODE_OPS_NOT_SUPPORT;
|
return TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
#endif
|
#endif
|
||||||
int32_t code = checkAuth(pCxt, pStmt->dbName, NULL, AUTH_TYPE_WRITE, NULL);
|
return checkAuth(pCxt, pStmt->dbName, NULL, AUTH_TYPE_WRITE, NULL);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = checkViewAuth(pCxt, pStmt->dbName, pStmt->viewName, AUTH_TYPE_ALTER, NULL);
|
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
|
||||||
if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) {
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t authDropView(SAuthCxt* pCxt, SDropViewStmt* pStmt) {
|
static int32_t authDropView(SAuthCxt* pCxt, SDropViewStmt* pStmt) {
|
||||||
|
|
|
@ -7580,7 +7580,7 @@ static int32_t translateResumeStream(STranslateContext* pCxt, SResumeStreamStmt*
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t validateCreateView(STranslateContext* pCxt, SCreateViewStmt* pStmt) {
|
static int32_t validateCreateView(STranslateContext* pCxt, SCreateViewStmt* pStmt) {
|
||||||
if (QUERY_NODE_SELECT_STMT != nodeType(pStmt->pQuery)) {
|
if (QUERY_NODE_SELECT_STMT != nodeType(pStmt->pQuery) && QUERY_NODE_SET_OPERATOR != nodeType(pStmt->pQuery)) {
|
||||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_VIEW_QUERY, "Invalid view query type");
|
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_VIEW_QUERY, "Invalid view query type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7602,13 +7602,16 @@ static int32_t translateCreateView(STranslateContext* pCxt, SCreateViewStmt* pSt
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SParseSqlRes res = {.resType = PARSE_SQL_RES_SCHEMA};
|
SParseSqlRes res = {.resType = PARSE_SQL_RES_SCHEMA};
|
||||||
|
SName name;
|
||||||
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
|
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name);
|
||||||
|
tNameGetFullDbName(&name, dbFName);
|
||||||
|
|
||||||
int32_t code = validateCreateView(pCxt, pStmt);
|
int32_t code = validateCreateView(pCxt, pStmt);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = (*pCxt->pParseCxt->parseSqlFp)(pCxt->pParseCxt->parseSqlParam, pStmt->pQuerySql, false, NULL, &res);
|
code = (*pCxt->pParseCxt->parseSqlFp)(pCxt->pParseCxt->parseSqlParam, pStmt->dbName, pStmt->pQuerySql, false, NULL, &res);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
SName name;
|
|
||||||
toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name);
|
|
||||||
code = collectUseTable(&name, pCxt->pTargetTables);
|
code = collectUseTable(&name, pCxt->pTargetTables);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -7616,7 +7619,7 @@ static int32_t translateCreateView(STranslateContext* pCxt, SCreateViewStmt* pSt
|
||||||
pStmt->createReq.numOfCols = res.schemaRes.numOfCols;
|
pStmt->createReq.numOfCols = res.schemaRes.numOfCols;
|
||||||
pStmt->createReq.pSchema = res.schemaRes.pSchema;
|
pStmt->createReq.pSchema = res.schemaRes.pSchema;
|
||||||
strncpy(pStmt->createReq.name, pStmt->viewName, sizeof(pStmt->createReq.name) - 1);
|
strncpy(pStmt->createReq.name, pStmt->viewName, sizeof(pStmt->createReq.name) - 1);
|
||||||
snprintf(pStmt->createReq.dbFName, sizeof(pStmt->createReq.dbFName) - 1, "%d.%s", pCxt->pParseCxt->acctId, pStmt->dbName);
|
tstrncpy(pStmt->createReq.dbFName, dbFName, sizeof(pStmt->createReq.dbFName));
|
||||||
snprintf(pStmt->createReq.fullname, sizeof(pStmt->createReq.fullname) - 1, "%s.%s", pStmt->createReq.dbFName, pStmt->viewName);
|
snprintf(pStmt->createReq.fullname, sizeof(pStmt->createReq.fullname) - 1, "%s.%s", pStmt->createReq.dbFName, pStmt->viewName);
|
||||||
TSWAP(pStmt->createReq.querySql, pStmt->pQuerySql);
|
TSWAP(pStmt->createReq.querySql, pStmt->pQuerySql);
|
||||||
pStmt->createReq.orReplace = pStmt->orReplace;
|
pStmt->createReq.orReplace = pStmt->orReplace;
|
||||||
|
|
|
@ -10,9 +10,9 @@ sql drop view if exists view3;
|
||||||
sql_error drop view view2;
|
sql_error drop view view2;
|
||||||
sql_error drop view view3;
|
sql_error drop view view3;
|
||||||
|
|
||||||
sql create view view3 as select avg(f) from sta2;
|
sql create view view3 as select avg(f) from st2;
|
||||||
sql create or replace view view3 as select f fa from sta2;
|
sql create or replace view view3 as select f fa from st2;
|
||||||
sql_error create view view3 as select * from sta2;
|
sql_error create view view3 as select * from st2;
|
||||||
sql create view view4 as select * from view3;
|
sql create view view4 as select * from view3;
|
||||||
sql create or replace view view4 as select fa from view3;
|
sql create or replace view view4 as select fa from view3;
|
||||||
sql drop view view3;
|
sql drop view view3;
|
||||||
|
@ -20,9 +20,9 @@ sql_error create view view5 as select * from view3;
|
||||||
sql drop view view4;
|
sql drop view view4;
|
||||||
|
|
||||||
sql create view testa.view1 as select * from testa.sta1;
|
sql create view testa.view1 as select * from testa.sta1;
|
||||||
sql create view testa.view2 as select * from testb.stb2;
|
sql create view testa.view2 as select * from testb.st2;
|
||||||
sql create view testb.view1 as select * from testb.stb1;
|
sql create view testb.view1 as select * from testb.stb1;
|
||||||
sql create view testb.view2 as select * from testa.sta2;
|
sql create view testb.view2 as select * from testa.st2;
|
||||||
sql drop view view1;
|
sql drop view view1;
|
||||||
sql drop view view2;
|
sql drop view view2;
|
||||||
sql drop view testb.view1;
|
sql drop view testb.view1;
|
||||||
|
|
|
@ -8,4 +8,3 @@ sql insert into ctat select * from view1;
|
||||||
sql drop view view1;
|
sql drop view view1;
|
||||||
sql drop table ctat;
|
sql drop table ctat;
|
||||||
|
|
||||||
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
||||||
|
|
|
@ -0,0 +1,170 @@
|
||||||
|
sql connect
|
||||||
|
sql use testa;
|
||||||
|
|
||||||
|
sql create user u1 pass "taosdata"
|
||||||
|
sql create user u2 pass "taosdata"
|
||||||
|
sql create user u3 pass "taosdata"
|
||||||
|
|
||||||
|
print == root create views ==
|
||||||
|
sql create view view1 as select * from sta1;
|
||||||
|
sql create view view2 as select * from view1;
|
||||||
|
sql create view view3 as select * from view2;
|
||||||
|
|
||||||
|
sql_error grant all on view1 to root;
|
||||||
|
sql_error revoke all on view1 from root;
|
||||||
|
|
||||||
|
sql_error grant read on view1 to u1;
|
||||||
|
sql grant read on testa.view1 to u1;
|
||||||
|
|
||||||
|
sql select * from information_schema.ins_user_privileges order by user_name, privilege;
|
||||||
|
if $rows != 2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data10 != u1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data11 != read then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql connect u1
|
||||||
|
sql use testa
|
||||||
|
sql_error select * from sta1;
|
||||||
|
sql select * from view1;
|
||||||
|
sql_error select * from view2;
|
||||||
|
sql_error select * from testb.view1;
|
||||||
|
sql_error insert into view1 values (now, 1);
|
||||||
|
sql_error create or replace view1 as select * from st2;
|
||||||
|
sql_error create viewa as select * from sta1;
|
||||||
|
sql_error drop view view1;
|
||||||
|
sql show views;
|
||||||
|
sql show create view view1;
|
||||||
|
sql desc view1;
|
||||||
|
sql select * from information_schema.ins_views;
|
||||||
|
if $rows != 3 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql_error grant read on testa.view1 to u2;
|
||||||
|
sql_error revoke read on testa.view1 from u1;
|
||||||
|
|
||||||
|
sql connect root
|
||||||
|
sql use testa
|
||||||
|
sql drop view testa.view1;
|
||||||
|
sql select * from information_schema.ins_user_privileges order by user_name, privilege;
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 != root then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql grant all on testa.* to u1;
|
||||||
|
sql reset query cache
|
||||||
|
|
||||||
|
print == u1 create view1 ==
|
||||||
|
sql connect u1
|
||||||
|
sql use testa
|
||||||
|
sql select * from sta1;
|
||||||
|
sql_error insert into view1 values (now, 1);
|
||||||
|
sql create view view1 as select * from sta1;
|
||||||
|
|
||||||
|
sql connect root
|
||||||
|
sql grant read on testa.view1 to u2;
|
||||||
|
sql_error insert into view1 values (now, 1);
|
||||||
|
|
||||||
|
sql connect u2
|
||||||
|
sql use testa
|
||||||
|
sql_error select * from sta1;
|
||||||
|
sql_error insert into view1 values (now, 1);
|
||||||
|
sql select * from view1;
|
||||||
|
|
||||||
|
sql connect root
|
||||||
|
sql revoke all on testa.* from u1
|
||||||
|
sql reset query cache
|
||||||
|
|
||||||
|
sql connect u1
|
||||||
|
sql use testa
|
||||||
|
sql_error select * from sta1;
|
||||||
|
sql_error select * from view1;
|
||||||
|
|
||||||
|
sql connect u2
|
||||||
|
sql use testa
|
||||||
|
sql_error select * from view1;
|
||||||
|
|
||||||
|
sql connect root
|
||||||
|
sql grant all on testa.* to u2
|
||||||
|
sql reset query cache
|
||||||
|
|
||||||
|
sql connect u2
|
||||||
|
sql use testa
|
||||||
|
sql select * from view1;
|
||||||
|
sql_error create or replace view1 as select * from st2;
|
||||||
|
|
||||||
|
sql connect u1
|
||||||
|
sql use testa
|
||||||
|
sql_error create or replace view1 as select * from st2;
|
||||||
|
|
||||||
|
sql connect root
|
||||||
|
sql grant all on testa.* to u1
|
||||||
|
sql reset query cache
|
||||||
|
|
||||||
|
sql connect u1
|
||||||
|
sql use testa
|
||||||
|
sql create or replace view view1 as select * from st2;
|
||||||
|
|
||||||
|
sql connect root
|
||||||
|
sql grant alter on testa.view1 to u2
|
||||||
|
sql revoke all on testa.* from u1
|
||||||
|
sql reset query cache
|
||||||
|
|
||||||
|
print == u2 replace view1 ==
|
||||||
|
sql connect u2
|
||||||
|
sql use testa
|
||||||
|
sql select * from view1;
|
||||||
|
sql create or replace view view1 as select * from sta1;
|
||||||
|
sql_error insert into view1 values (now, 1);
|
||||||
|
sql select * from information_schema.ins_views where view_name = 'view1';
|
||||||
|
if $rows != 1 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data01 != testa then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data02 != u2 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql connect root
|
||||||
|
sql grant all on testa.view1 to u3;
|
||||||
|
|
||||||
|
sql connect u3
|
||||||
|
sql use testa
|
||||||
|
sql_error select * from sta1
|
||||||
|
sql_error insert into view1 values (now, 1);
|
||||||
|
sql select * from view1
|
||||||
|
|
||||||
|
sql connect root
|
||||||
|
sql revoke all on testa.* from u2
|
||||||
|
sql reset query cache
|
||||||
|
|
||||||
|
sql connect u3
|
||||||
|
sql use testa
|
||||||
|
sql_error select * from view1
|
||||||
|
sql_error insert into view1 values (now, 1);
|
||||||
|
|
||||||
|
sql connect root
|
||||||
|
sql grant all on testa.* to u3
|
||||||
|
sql drop user u1;
|
||||||
|
sql drop user u2;
|
||||||
|
sql reset query cache
|
||||||
|
|
||||||
|
sql connect u3
|
||||||
|
sql use testa
|
||||||
|
sql select * from view1
|
||||||
|
sql_error insert into view1 values (now, 1);
|
||||||
|
|
||||||
|
sql connect root
|
||||||
|
sql drop user u3;
|
||||||
|
sql drop view testa.view1;
|
||||||
|
sql drop view testa.view2;
|
||||||
|
sql drop view testa.view3;
|
||||||
|
|
|
@ -0,0 +1,117 @@
|
||||||
|
sql connect
|
||||||
|
sql use testa;
|
||||||
|
|
||||||
|
sql create user u1 pass "taosdata"
|
||||||
|
sql create user u2 pass "taosdata"
|
||||||
|
sql create user u3 pass "taosdata"
|
||||||
|
|
||||||
|
sql grant all on testa.* to u1;
|
||||||
|
sql grant all on testb.* to u2;
|
||||||
|
sql grant all on testa.stt to u3;
|
||||||
|
|
||||||
|
sql connect u1
|
||||||
|
sql use testa
|
||||||
|
sql create view view1 as select ts, f from st2;
|
||||||
|
|
||||||
|
sql connect u2
|
||||||
|
sql use testb
|
||||||
|
sql create view view1 as select ts, f from st2;
|
||||||
|
|
||||||
|
sql connect root
|
||||||
|
sql use testa
|
||||||
|
sql_error create view view2 as select * from view1 union all select * from view2;
|
||||||
|
sql create view view2 as select * from view1 union all select * from testb.view1;
|
||||||
|
sql use testb
|
||||||
|
sql create view view2 as select a.ts, a.f, b.f from testa.view1 a, view1 b where a.ts=b.ts;
|
||||||
|
sql grant all on testa.view2 to u3;
|
||||||
|
sql grant all on testb.view2 to u3;
|
||||||
|
|
||||||
|
print == start to query ==
|
||||||
|
sql connect u3
|
||||||
|
sql reset query cache
|
||||||
|
sql select * from testa.view2 order by f;
|
||||||
|
if $rows != 8 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data01 != 100221 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data11 != 100222 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data21 != 100223 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data31 != 100224 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data41 != 110221 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data51 != 110222 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data61 != 110223 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data71 != 110224 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql_error insert into tt (ts, f) select * from testa.view1;
|
||||||
|
sql_error insert into tt (ts, f) select * from testb.view1;
|
||||||
|
sql insert into testa.tt (ts, f) select * from testa.view2 order by ts, f;
|
||||||
|
if $rows != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
# insert result is not correct now
|
||||||
|
#if $data01 != 110221 then
|
||||||
|
# print $data01
|
||||||
|
# return -1
|
||||||
|
#endi
|
||||||
|
#if $data11 != 110222 then
|
||||||
|
# print $data11
|
||||||
|
# return -1
|
||||||
|
#endi
|
||||||
|
sql delete from testa.tt;
|
||||||
|
sql_error select * from testa.st2;
|
||||||
|
sql_error select * from testb.st2;
|
||||||
|
|
||||||
|
sql connect root
|
||||||
|
sql revoke all on testa.* from u1;
|
||||||
|
|
||||||
|
sql connect u3
|
||||||
|
sql reset query cache
|
||||||
|
sql_error select * from testa.view2;
|
||||||
|
sql_error select * from testa.view1;
|
||||||
|
|
||||||
|
sql connect root
|
||||||
|
sql use testb;
|
||||||
|
sql create or replace view testa.view1 as select ts, f from st2;
|
||||||
|
sql select * from testa.view1 order by ts;
|
||||||
|
if $rows != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data01 != 100221 then
|
||||||
|
print $data01
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data11 != 100222 then
|
||||||
|
print $data11
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
|
||||||
|
sql connect u3
|
||||||
|
sql reset query cache
|
||||||
|
sql select * from testa.view2;
|
||||||
|
sql_error select * from testa.view1;
|
||||||
|
|
||||||
|
print == drop user and views ==
|
||||||
|
sql connect root
|
||||||
|
sql drop user u1;
|
||||||
|
sql drop user u2;
|
||||||
|
sql drop user u3;
|
||||||
|
sql drop view testa.view1;
|
||||||
|
sql drop view testb.view1;
|
||||||
|
sql drop view testa.view2;
|
||||||
|
sql drop view testb.view2;
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
sql connect
|
|
||||||
sql use testa;
|
|
||||||
|
|
||||||
sql create user u1 pass "taosdata"
|
|
||||||
sql create user u2 pass "taosdata"
|
|
||||||
sql create user u3 pass "taosdata"
|
|
||||||
|
|
||||||
print == root create views ==
|
|
||||||
sql create view view1 as select * from sta1;
|
|
||||||
sql create view view2 as select * from view1;
|
|
||||||
sql create view view3 as select * from view2;
|
|
||||||
|
|
||||||
sql_error grant all on view1 to root;
|
|
||||||
sql_error revoke all on view1 from root;
|
|
||||||
|
|
||||||
sql_error grant read on view1 to u1;
|
|
||||||
sql grant read on testa.view1 to u1;
|
|
||||||
|
|
||||||
sql select * from information_schema.ins_user_privileges order by user_name, privilege;
|
|
||||||
if $rows != 2 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data10 != u1 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data11 != read then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
sql connect u1
|
|
||||||
sql use testa
|
|
||||||
sql_error select * from sta1;
|
|
||||||
sql select * from view1;
|
|
||||||
sql_error select * from view2;
|
|
||||||
sql_error select * from testb.view1;
|
|
||||||
sql_error insert into view1 values (now, 1);
|
|
||||||
sql_error create or replace view1 as select * from sta2;
|
|
||||||
sql_error create viewa as select * from sta1;
|
|
||||||
sql_error drop view view1;
|
|
||||||
sql show views;
|
|
||||||
sql show create view view1;
|
|
||||||
sql desc view1;
|
|
||||||
sql select * from information_schema.ins_views;
|
|
||||||
if $rows != 3 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
sql_error grant read on testa.view1 to u2;
|
|
||||||
sql_error revoke read on testa.view1 from u1;
|
|
||||||
|
|
||||||
sql connect root
|
|
||||||
sql use testa
|
|
||||||
sql drop view testa.view1;
|
|
||||||
sql select * from information_schema.ins_user_privileges order by user_name, privilege;
|
|
||||||
if $rows != 1 then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
if $data00 != root then
|
|
||||||
return -1
|
|
||||||
endi
|
|
||||||
|
|
||||||
sql drop user u1;
|
|
||||||
sql drop user u2;
|
|
||||||
sql drop user u3;
|
|
||||||
sql drop view testa.view2;
|
|
||||||
sql drop view testa.view3;
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ if $data01 != 110112.000000000 then
|
||||||
endi
|
endi
|
||||||
|
|
||||||
sql drop view testb.view2;
|
sql drop view testb.view2;
|
||||||
sql create or replace view view2 as select * from sta2;
|
sql create or replace view view2 as select * from st2;
|
||||||
sql select avg(view1.f), avg(view2.f) from view1, view2 where view1.ts = view2.ts and view1.f < 100114;
|
sql select avg(view1.f), avg(view2.f) from view1, view2 where view1.ts = view2.ts and view1.f < 100114;
|
||||||
if $rows != 1 then
|
if $rows != 1 then
|
||||||
return -1
|
return -1
|
||||||
|
@ -76,7 +76,7 @@ sql drop view view1;
|
||||||
sql drop view view2;
|
sql drop view view2;
|
||||||
|
|
||||||
sql create view view1 as select * from sta1;
|
sql create view view1 as select * from sta1;
|
||||||
sql create view view2 as select * from sta2;
|
sql create view view2 as select * from st2;
|
||||||
sql create view view3 as select a.ts ts, a.f af, b.f bf from view1 a join view2 b on a.ts = b.ts;
|
sql create view view3 as select a.ts ts, a.f af, b.f bf from view1 a join view2 b on a.ts = b.ts;
|
||||||
sql create view view3a as select a.ts ts, a.f, b.f from view1 a join view2 b on a.ts = b.ts;
|
sql create view view3a as select a.ts ts, a.f, b.f from view1 a join view2 b on a.ts = b.ts;
|
||||||
sql create view view4 as select _wstart, avg(bf) - avg(af) as b from view3 interval(1s);
|
sql create view view4 as select _wstart, avg(bf) - avg(af) as b from view3 interval(1s);
|
||||||
|
@ -115,4 +115,18 @@ if $rows != 1 then
|
||||||
endi
|
endi
|
||||||
sql drop view information_schema.view1;
|
sql drop view information_schema.view1;
|
||||||
|
|
||||||
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
sql use testa;
|
||||||
|
sql create view view1 as select * from st2;
|
||||||
|
sql use testb;
|
||||||
|
sql select f from testa.view1 order by f;
|
||||||
|
if $rows != 4 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data00 != 100221 then
|
||||||
|
print $data00
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
if $data10 != 100222 then
|
||||||
|
return -1
|
||||||
|
endi
|
||||||
|
sql drop view testa.view1;
|
||||||
|
|
|
@ -39,5 +39,3 @@ sql describe information_schema.view1;
|
||||||
sql show create view information_schema.view1;
|
sql show create view information_schema.view1;
|
||||||
sql drop view information_schema.view1;
|
sql drop view information_schema.view1;
|
||||||
|
|
||||||
|
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
||||||
|
|
|
@ -6,4 +6,3 @@ sql_error CREATE STREAM s1 INTO s1t AS SELECT _wstart, count(*) FROM view1 PARTI
|
||||||
|
|
||||||
sql drop view view1;
|
sql drop view view1;
|
||||||
|
|
||||||
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
|
||||||
|
|
|
@ -6,43 +6,49 @@ sql drop database if exists testa
|
||||||
sql create database testa vgroups 3;
|
sql create database testa vgroups 3;
|
||||||
sql use testa;
|
sql use testa;
|
||||||
|
|
||||||
sql create table sta1(ts timestamp, f int) tags (t int);
|
sql create table sta1(ts timestamp, f int, g int) tags (t int);
|
||||||
sql insert into cta11 using sta1 tags(1) values('2023-10-16 09:10:11', 100111);
|
sql insert into cta11 using sta1 tags(1) values('2023-10-16 09:10:11', 100111, 1001110);
|
||||||
sql insert into cta12 using sta1 tags(2) values('2023-10-16 09:10:12', 100112);
|
sql insert into cta12 using sta1 tags(2) values('2023-10-16 09:10:12', 100112, 1001120);
|
||||||
sql insert into cta13 using sta1 tags(3) values('2023-10-16 09:10:13', 100113);
|
sql insert into cta13 using sta1 tags(3) values('2023-10-16 09:10:13', 100113, 1001130);
|
||||||
sql insert into cta14 using sta1 tags(4) values('2023-10-16 09:10:14', 100114);
|
sql insert into cta14 using sta1 tags(4) values('2023-10-16 09:10:14', 100114, 1001140);
|
||||||
|
|
||||||
sql create table sta2(ts timestamp, f int) tags (t int);
|
sql create table st2(ts timestamp, f int, g int) tags (t int);
|
||||||
sql insert into cta21 using sta2 tags(1) values('2023-10-16 09:10:11', 100221);
|
sql insert into cta21 using st2 tags(1) values('2023-10-16 09:10:11', 100221, 1002210);
|
||||||
sql insert into cta22 using sta2 tags(2) values('2023-10-16 09:10:12', 100222);
|
sql insert into cta22 using st2 tags(2) values('2023-10-16 09:10:12', 100222, 1002220);
|
||||||
sql insert into cta23 using sta2 tags(3) values('2023-10-16 09:10:13', 100223);
|
sql insert into cta23 using st2 tags(3) values('2023-10-16 09:10:13', 100223, 1002230);
|
||||||
sql insert into cta24 using sta2 tags(4) values('2023-10-16 09:10:14', 100224);
|
sql insert into cta24 using st2 tags(4) values('2023-10-16 09:10:14', 100224, 1002240);
|
||||||
|
|
||||||
|
sql create table stt(ts timestamp, f int, g int) tags (t int);
|
||||||
|
sql create table tt using stt tags(99);
|
||||||
|
|
||||||
sql drop database if exists testb
|
sql drop database if exists testb
|
||||||
sql create database testb vgroups 1;
|
sql create database testb vgroups 1;
|
||||||
sql use testb;
|
sql use testb;
|
||||||
|
|
||||||
sql create table stb1(ts timestamp, f int) tags (t int);
|
sql create table stb1(ts timestamp, f int,g int) tags (t int);
|
||||||
sql insert into ctb11 using stb1 tags(1) values('2023-10-16 09:10:11', 110111);
|
sql insert into ctb11 using stb1 tags(1) values('2023-10-16 09:10:11', 110111, 1101110);
|
||||||
sql insert into ctb12 using stb1 tags(2) values('2023-10-16 09:10:12', 110112);
|
sql insert into ctb12 using stb1 tags(2) values('2023-10-16 09:10:12', 110112, 1101120);
|
||||||
sql insert into ctb13 using stb1 tags(3) values('2023-10-16 09:10:13', 110113);
|
sql insert into ctb13 using stb1 tags(3) values('2023-10-16 09:10:13', 110113, 1101130);
|
||||||
sql insert into ctb14 using stb1 tags(4) values('2023-10-16 09:10:14', 110114);
|
sql insert into ctb14 using stb1 tags(4) values('2023-10-16 09:10:14', 110114, 1101140);
|
||||||
|
|
||||||
sql create table stb2(ts timestamp, f int) tags (t int);
|
sql create table st2(ts timestamp, f int, g int) tags (t int);
|
||||||
sql insert into ctb21 using stb2 tags(1) values('2023-10-16 09:10:11', 110221);
|
sql insert into ctb21 using st2 tags(1) values('2023-10-16 09:10:11', 110221, 1102210);
|
||||||
sql insert into ctb22 using stb2 tags(2) values('2023-10-16 09:10:12', 110222);
|
sql insert into ctb22 using st2 tags(2) values('2023-10-16 09:10:12', 110222, 1102220);
|
||||||
sql insert into ctb23 using stb2 tags(3) values('2023-10-16 09:10:13', 110223);
|
sql insert into ctb23 using st2 tags(3) values('2023-10-16 09:10:13', 110223, 1102230);
|
||||||
sql insert into ctb24 using stb2 tags(4) values('2023-10-16 09:10:14', 110224);
|
sql insert into ctb24 using st2 tags(4) values('2023-10-16 09:10:14', 110224, 1102240);
|
||||||
|
|
||||||
run tsim/view/privilege_view.sim
|
run tsim/view/privilege_basic_view.sim
|
||||||
#run tsim/view/create_drop_view.sim
|
run tsim/view/privilege_nested_view.sim
|
||||||
#run tsim/view/query_view.sim
|
run tsim/view/create_drop_view.sim
|
||||||
|
run tsim/view/query_view.sim
|
||||||
|
|
||||||
print ================== restart server to commit data into disk
|
print ================== restart server to commit data into disk
|
||||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
||||||
system sh/exec.sh -n dnode1 -s start
|
system sh/exec.sh -n dnode1 -s start
|
||||||
print ================== server restart completed
|
print ================== server restart completed
|
||||||
|
|
||||||
|
run tsim/view/privilege_basic_view.sim
|
||||||
|
run tsim/view/privilege_nested_view.sim
|
||||||
run tsim/view/create_drop_view.sim
|
run tsim/view/create_drop_view.sim
|
||||||
run tsim/view/query_view.sim
|
run tsim/view/query_view.sim
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue