enh: insert optimize
This commit is contained in:
parent
80dc658dbb
commit
7484ff430c
|
@ -186,8 +186,6 @@ int32_t catalogRemoveStbMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId,
|
|||
*/
|
||||
int32_t catalogGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName,
|
||||
STableMeta** pTableMeta);
|
||||
int32_t catalogGetCachedTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName,
|
||||
STableMeta** pTableMeta);
|
||||
|
||||
/**
|
||||
* Get a super table's meta data.
|
||||
|
@ -200,8 +198,6 @@ int32_t catalogGetCachedTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const
|
|||
*/
|
||||
int32_t catalogGetSTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName,
|
||||
STableMeta** pTableMeta);
|
||||
int32_t catalogGetCachedSTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName,
|
||||
STableMeta** pTableMeta);
|
||||
|
||||
int32_t catalogUpdateTableMeta(SCatalog* pCatalog, STableMetaRsp* rspMsg);
|
||||
|
||||
|
@ -211,7 +207,7 @@ int32_t catalogGetCachedTableMeta(SCatalog* pCtg, const SName* pTableName, STabl
|
|||
|
||||
int32_t catalogGetCachedSTableMeta(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta);
|
||||
|
||||
int32_t catalogGetCachedTableHashVgroup(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists);
|
||||
int32_t catalogGetCachedTableHashVgroup(SCatalog* pCtg, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists);
|
||||
|
||||
/**
|
||||
* Force refresh DB's local cached vgroup info.
|
||||
|
@ -271,8 +267,7 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCatalog, SRequestConnInfo* pConn, c
|
|||
* @return error code
|
||||
*/
|
||||
int32_t catalogGetTableHashVgroup(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pName, SVgroupInfo* vgInfo);
|
||||
int32_t catalogGetCachedTableHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName,
|
||||
SVgroupInfo* pVgroup, bool* exists);
|
||||
|
||||
/**
|
||||
* Get all meta data required in pReq.
|
||||
* @param pCatalog (input, got with catalogGetHandle)
|
||||
|
@ -312,8 +307,8 @@ int32_t catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* f
|
|||
int32_t catalogChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, const char* dbFName, AUTH_TYPE type,
|
||||
bool* pass);
|
||||
|
||||
int32_t catalogChkAuthFromCache(SCatalog* pCtg, const char* user, const char* dbFName, AUTH_TYPE type,
|
||||
bool* pass, bool* exists);
|
||||
int32_t catalogChkAuthFromCache(SCatalog* pCtg, const char* user, const char* dbFName, AUTH_TYPE type, bool* pass,
|
||||
bool* exists);
|
||||
|
||||
int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth);
|
||||
|
||||
|
@ -329,9 +324,9 @@ SMetaData* catalogCloneMetaData(SMetaData* pData);
|
|||
|
||||
void catalogFreeMetaData(SMetaData* pData);
|
||||
|
||||
int32_t ctgdEnableDebug(char *option, bool enable);
|
||||
int32_t ctgdEnableDebug(char* option, bool enable);
|
||||
|
||||
int32_t ctgdHandleDbgCommand(char *command);
|
||||
int32_t ctgdHandleDbgCommand(char* command);
|
||||
|
||||
/**
|
||||
* Destroy catalog and relase all resources
|
||||
|
|
|
@ -740,42 +740,46 @@ static int32_t parseUsingClauseBottom(SInsertParseContext* pCxt, SVnodeModifOpSt
|
|||
return code;
|
||||
}
|
||||
|
||||
static int32_t checkAuth(SParseContext* pCxt, SName* pTbName) {
|
||||
static int32_t checkAuth(SParseContext* pCxt, SName* pTbName, bool* pMissCache) {
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
tNameGetFullDbName(pTbName, dbFName);
|
||||
SRequestConnInfo conn = {.pTrans = pCxt->pTransporter,
|
||||
.requestId = pCxt->requestId,
|
||||
.requestObjRefId = pCxt->requestRid,
|
||||
.mgmtEps = pCxt->mgmtEpSet};
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
bool pass = true;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
bool pass = true;
|
||||
bool exists = true;
|
||||
if (pCxt->async) {
|
||||
// todo replace with cached api
|
||||
code = catalogChkAuth(pCxt->pCatalog, &conn, pCxt->pUser, dbFName, AUTH_TYPE_WRITE, &pass);
|
||||
code = catalogChkAuthFromCache(pCxt->pCatalog, pCxt->pUser, dbFName, AUTH_TYPE_WRITE, &pass, &exists);
|
||||
} else {
|
||||
SRequestConnInfo conn = {.pTrans = pCxt->pTransporter,
|
||||
.requestId = pCxt->requestId,
|
||||
.requestObjRefId = pCxt->requestRid,
|
||||
.mgmtEps = pCxt->mgmtEpSet};
|
||||
code = catalogChkAuth(pCxt->pCatalog, &conn, pCxt->pUser, dbFName, AUTH_TYPE_WRITE, &pass);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && !pass) {
|
||||
code = TSDB_CODE_PAR_PERMISSION_DENIED;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
if (!exists) {
|
||||
*pMissCache = true;
|
||||
} else if (!pass) {
|
||||
code = TSDB_CODE_PAR_PERMISSION_DENIED;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t getTableMeta(SInsertParseContext* pCxt, SName* pTbName, bool isStb, STableMeta** pTableMeta,
|
||||
bool* pMissCache) {
|
||||
SParseContext* pComCxt = pCxt->pComCxt;
|
||||
SRequestConnInfo conn = {.pTrans = pComCxt->pTransporter,
|
||||
.requestId = pComCxt->requestId,
|
||||
.requestObjRefId = pComCxt->requestRid,
|
||||
.mgmtEps = pComCxt->mgmtEpSet};
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SParseContext* pComCxt = pCxt->pComCxt;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (pComCxt->async) {
|
||||
if (isStb) {
|
||||
code = catalogGetCachedSTableMeta(pComCxt->pCatalog, &conn, pTbName, pTableMeta);
|
||||
code = catalogGetCachedSTableMeta(pComCxt->pCatalog, pTbName, pTableMeta);
|
||||
} else {
|
||||
code = catalogGetCachedTableMeta(pComCxt->pCatalog, &conn, pTbName, pTableMeta);
|
||||
code = catalogGetCachedTableMeta(pComCxt->pCatalog, pTbName, pTableMeta);
|
||||
}
|
||||
} else {
|
||||
SRequestConnInfo conn = {.pTrans = pComCxt->pTransporter,
|
||||
.requestId = pComCxt->requestId,
|
||||
.requestObjRefId = pComCxt->requestRid,
|
||||
.mgmtEps = pComCxt->mgmtEpSet};
|
||||
if (isStb) {
|
||||
code = catalogGetSTableMeta(pComCxt->pCatalog, &conn, pTbName, pTableMeta);
|
||||
} else {
|
||||
|
@ -793,16 +797,16 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SName* pTbName, bool isSt
|
|||
}
|
||||
|
||||
static int32_t getTableVgroup(SParseContext* pCxt, SVnodeModifOpStmt* pStmt, bool isStb, bool* pMissCache) {
|
||||
SRequestConnInfo conn = {.pTrans = pCxt->pTransporter,
|
||||
.requestId = pCxt->requestId,
|
||||
.requestObjRefId = pCxt->requestRid,
|
||||
.mgmtEps = pCxt->mgmtEpSet};
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SVgroupInfo vg;
|
||||
bool exists = true;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SVgroupInfo vg;
|
||||
bool exists = true;
|
||||
if (pCxt->async) {
|
||||
code = catalogGetCachedTableHashVgroup(pCxt->pCatalog, &conn, &pStmt->targetTableName, &vg, &exists);
|
||||
code = catalogGetCachedTableHashVgroup(pCxt->pCatalog, &pStmt->targetTableName, &vg, &exists);
|
||||
} else {
|
||||
SRequestConnInfo conn = {.pTrans = pCxt->pTransporter,
|
||||
.requestId = pCxt->requestId,
|
||||
.requestObjRefId = pCxt->requestRid,
|
||||
.mgmtEps = pCxt->mgmtEpSet};
|
||||
code = catalogGetTableHashVgroup(pCxt->pCatalog, &conn, &pStmt->targetTableName, &vg);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -818,8 +822,8 @@ static int32_t getTableVgroup(SParseContext* pCxt, SVnodeModifOpStmt* pStmt, boo
|
|||
}
|
||||
|
||||
static int32_t getTargetTableSchema(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt) {
|
||||
int32_t code = checkAuth(pCxt->pComCxt, &pStmt->targetTableName);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
int32_t code = checkAuth(pCxt->pComCxt, &pStmt->targetTableName, &pCxt->missCache);
|
||||
if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) {
|
||||
code = getTableMeta(pCxt, &pStmt->targetTableName, false, &pStmt->pTableMeta, &pCxt->missCache);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) {
|
||||
|
@ -833,8 +837,8 @@ static int32_t preParseUsingTableName(SInsertParseContext* pCxt, SVnodeModifOpSt
|
|||
}
|
||||
|
||||
static int32_t getUsingTableSchema(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt) {
|
||||
int32_t code = checkAuth(pCxt->pComCxt, &pStmt->targetTableName);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
int32_t code = checkAuth(pCxt->pComCxt, &pStmt->targetTableName, &pCxt->missCache);
|
||||
if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) {
|
||||
code = getTableMeta(pCxt, &pStmt->usingTableName, true, &pStmt->pTableMeta, &pCxt->missCache);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && !pCxt->missCache) {
|
||||
|
|
Loading…
Reference in New Issue