Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7484ff43
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7484ff43
编写于
11月 05, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: insert optimize
上级
80dc658d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
42 deletion
+41
-42
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+6
-11
source/libs/parser/src/parInsertSql.c
source/libs/parser/src/parInsertSql.c
+35
-31
未找到文件。
include/libs/catalog/catalog.h
浏览文件 @
7484ff43
...
...
@@ -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
...
...
source/libs/parser/src/parInsertSql.c
浏览文件 @
7484ff43
...
...
@@ -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
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录