Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
96aa44e2
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
96aa44e2
编写于
12月 03, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:error for sml
上级
d86e4cee
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
53 deletion
+57
-53
include/libs/parser/parser.h
include/libs/parser/parser.h
+3
-4
source/client/src/clientSml.c
source/client/src/clientSml.c
+4
-20
source/libs/parser/src/parInsertSml.c
source/libs/parser/src/parInsertSml.c
+47
-27
source/libs/parser/src/parInsertUtil.c
source/libs/parser/src/parInsertUtil.c
+3
-2
未找到文件。
include/libs/parser/parser.h
浏览文件 @
96aa44e2
...
...
@@ -106,11 +106,10 @@ int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char*
void
qDestroyBoundColInfo
(
void
*
pInfo
);
void
*
smlInitHandle
(
SQuery
*
pQuery
);
void
smlDestroyHandle
(
void
*
pHandle
);
int32_t
smlBindData
(
void
*
handle
,
SArray
*
tags
,
SArray
*
colsSchema
,
SArray
*
cols
,
bool
format
,
STableMeta
*
pTableMeta
,
SQuery
*
smlInitHandle
();
int32_t
smlBindData
(
SQuery
*
handle
,
SArray
*
tags
,
SArray
*
colsSchema
,
SArray
*
cols
,
bool
format
,
STableMeta
*
pTableMeta
,
char
*
tableName
,
const
char
*
sTableName
,
int32_t
sTableNameLen
,
int32_t
ttl
,
char
*
msgBuf
,
int16_t
msgBufLen
);
int32_t
smlBuildOutput
(
void
*
handle
,
SHashObj
*
pVgHash
);
int32_t
smlBuildOutput
(
SQuery
*
handle
,
SHashObj
*
pVgHash
);
int32_t
rewriteToVnodeModifyOpStmt
(
SQuery
*
pQuery
,
SArray
*
pBufArray
);
SArray
*
serializeVgroupsCreateTableBatch
(
SHashObj
*
pVgroupHashmap
);
...
...
source/client/src/clientSml.c
浏览文件 @
96aa44e2
...
...
@@ -170,7 +170,6 @@ typedef struct {
SHashObj
*
childTables
;
SHashObj
*
superTables
;
SHashObj
*
pVgHash
;
void
*
exec
;
STscObj
*
taos
;
SCatalog
*
pCatalog
;
...
...
@@ -1488,7 +1487,6 @@ static void smlDestroyCols(SArray *cols) {
static
void
smlDestroyInfo
(
SSmlHandle
*
info
)
{
if
(
!
info
)
return
;
qDestroyQuery
(
info
->
pQuery
);
smlDestroyHandle
(
info
->
exec
);
// destroy info->childTables
void
**
p1
=
(
void
**
)
taosHashIterate
(
info
->
childTables
,
NULL
);
...
...
@@ -1526,19 +1524,7 @@ static SSmlHandle *smlBuildSmlInfo(STscObj *pTscObj, SRequestObj *request, SMLPr
}
info
->
id
=
smlGenId
();
info
->
pQuery
=
(
SQuery
*
)
nodesMakeNode
(
QUERY_NODE_QUERY
);
if
(
NULL
==
info
->
pQuery
)
{
uError
(
"SML:0x%"
PRIx64
" create info->pQuery error"
,
info
->
id
);
goto
cleanup
;
}
info
->
pQuery
->
execMode
=
QUERY_EXEC_MODE_SCHEDULE
;
info
->
pQuery
->
haveResultSet
=
false
;
info
->
pQuery
->
msgType
=
TDMT_VND_SUBMIT
;
info
->
pQuery
->
pRoot
=
(
SNode
*
)
nodesMakeNode
(
QUERY_NODE_VNODE_MODIF_STMT
);
if
(
NULL
==
info
->
pQuery
->
pRoot
)
{
uError
(
"SML:0x%"
PRIx64
" create info->pQuery->pRoot error"
,
info
->
id
);
goto
cleanup
;
}
info
->
pQuery
=
smlInitHandle
();
if
(
pTscObj
)
{
info
->
taos
=
pTscObj
;
...
...
@@ -1561,10 +1547,8 @@ static SSmlHandle *smlBuildSmlInfo(STscObj *pTscObj, SRequestObj *request, SMLPr
info
->
pRequest
=
request
;
info
->
msgBuf
.
buf
=
info
->
pRequest
->
msgBuf
;
info
->
msgBuf
.
len
=
ERROR_MSG_BUF_DEFAULT_SIZE
;
info
->
pRequest
->
stmtType
=
info
->
pQuery
->
pRoot
->
type
;
}
info
->
exec
=
smlInitHandle
(
info
->
pQuery
);
info
->
childTables
=
taosHashInit
(
32
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
info
->
superTables
=
taosHashInit
(
32
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
info
->
pVgHash
=
taosHashInit
(
16
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_NO_LOCK
);
...
...
@@ -1577,7 +1561,7 @@ static SSmlHandle *smlBuildSmlInfo(STscObj *pTscObj, SRequestObj *request, SMLPr
goto
cleanup
;
}
}
if
(
NULL
==
info
->
exec
||
NULL
==
info
->
childTables
||
NULL
==
info
->
superTables
||
NULL
==
info
->
pVgHash
||
if
(
NULL
==
info
->
pQuery
||
NULL
==
info
->
childTables
||
NULL
==
info
->
superTables
||
NULL
==
info
->
pVgHash
||
NULL
==
info
->
dumplicateKey
)
{
uError
(
"SML:0x%"
PRIx64
" create info failed"
,
info
->
id
);
goto
cleanup
;
...
...
@@ -2337,7 +2321,7 @@ static int32_t smlInsertData(SSmlHandle *info) {
(
*
pMeta
)
->
tableMeta
->
vgId
=
vg
.
vgId
;
(
*
pMeta
)
->
tableMeta
->
uid
=
tableData
->
uid
;
// one table merge data block together according uid
code
=
smlBindData
(
info
->
exec
,
tableData
->
tags
,
(
*
pMeta
)
->
cols
,
tableData
->
cols
,
info
->
dataFormat
,
code
=
smlBindData
(
info
->
pQuery
,
tableData
->
tags
,
(
*
pMeta
)
->
cols
,
tableData
->
cols
,
info
->
dataFormat
,
(
*
pMeta
)
->
tableMeta
,
tableData
->
childTableName
,
tableData
->
sTableName
,
tableData
->
sTableNameLen
,
info
->
ttl
,
info
->
msgBuf
.
buf
,
info
->
msgBuf
.
len
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -2347,7 +2331,7 @@ static int32_t smlInsertData(SSmlHandle *info) {
oneTable
=
(
SSmlTableInfo
**
)
taosHashIterate
(
info
->
childTables
,
oneTable
);
}
code
=
smlBuildOutput
(
info
->
exec
,
info
->
pVgHash
);
code
=
smlBuildOutput
(
info
->
pQuery
,
info
->
pVgHash
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" smlBuildOutput failed"
,
info
->
id
);
return
code
;
...
...
source/libs/parser/src/parInsertSml.c
浏览文件 @
96aa44e2
...
...
@@ -45,12 +45,6 @@ int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char*
return
TSDB_CODE_SUCCESS
;
}
typedef
struct
SmlExecHandle
{
SHashObj
*
pBlockHash
;
SQuery
*
pQuery
;
}
SSmlExecHandle
;
static
int32_t
smlBoundColumnData
(
SArray
*
cols
,
SBoundColInfo
*
pBoundInfo
,
SSchema
*
pSchema
,
bool
isTag
)
{
bool
*
pUseCols
=
taosMemoryCalloc
(
pBoundInfo
->
numOfCols
,
sizeof
(
bool
));
if
(
NULL
==
pUseCols
)
{
...
...
@@ -164,11 +158,10 @@ end:
return
code
;
}
int32_t
smlBindData
(
void
*
handle
,
SArray
*
tags
,
SArray
*
colsSchema
,
SArray
*
cols
,
bool
format
,
STableMeta
*
pTableMeta
,
int32_t
smlBindData
(
SQuery
*
query
,
SArray
*
tags
,
SArray
*
colsSchema
,
SArray
*
cols
,
bool
format
,
STableMeta
*
pTableMeta
,
char
*
tableName
,
const
char
*
sTableName
,
int32_t
sTableNameLen
,
int32_t
ttl
,
char
*
msgBuf
,
int16_t
msgBufLen
)
{
SMsgBuf
pBuf
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
SSmlExecHandle
*
smlHandle
=
(
SSmlExecHandle
*
)
handle
;
SSchema
*
pTagsSchema
=
getTableTagSchema
(
pTableMeta
);
SBoundColInfo
bindTags
=
{
0
};
SVCreateTbReq
*
pCreateTblReq
=
NULL
;
...
...
@@ -200,7 +193,7 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
memcpy
(
pCreateTblReq
->
ctb
.
stbName
,
sTableName
,
sTableNameLen
);
STableDataCxt
*
pTableCxt
=
NULL
;
ret
=
insGetTableDataCxt
(
smlHandle
->
pBlockHash
,
&
pTableMeta
->
uid
,
sizeof
(
pTableMeta
->
uid
),
ret
=
insGetTableDataCxt
(
((
SVnodeModifOpStmt
*
)(
query
->
pRoot
))
->
pTableBlockHashObj
,
&
pTableMeta
->
uid
,
sizeof
(
pTableMeta
->
uid
),
pTableMeta
,
&
pCreateTblReq
,
&
pTableCxt
,
false
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
buildInvalidOperationMsg
(
&
pBuf
,
"insGetTableDataCxt error"
);
...
...
@@ -247,12 +240,12 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
}
if
(
kv
->
type
==
TSDB_DATA_TYPE_NCHAR
){
int32_t
len
=
0
;
char
*
pUcs4
=
taosMemoryCalloc
(
1
,
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
);
char
*
pUcs4
=
taosMemoryCalloc
(
1
,
p
Col
Schema
->
bytes
-
VARSTR_HEADER_SIZE
);
if
(
NULL
==
pUcs4
)
{
ret
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
end
;
}
if
(
!
taosMbsToUcs4
(
kv
->
value
,
kv
->
length
,
(
TdUcs4
*
)
pUcs4
,
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
,
&
len
))
{
if
(
!
taosMbsToUcs4
(
kv
->
value
,
kv
->
length
,
(
TdUcs4
*
)
pUcs4
,
p
Col
Schema
->
bytes
-
VARSTR_HEADER_SIZE
,
&
len
))
{
if
(
errno
==
E2BIG
)
{
buildInvalidOperationMsg
(
&
pBuf
,
"value too long"
);
ret
=
TSDB_CODE_PAR_VALUE_TOO_LONG
;
...
...
@@ -271,6 +264,14 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
}
pVal
->
flag
=
CV_FLAG_VALUE
;
}
SRow
**
pRow
=
taosArrayReserve
(
pTableCxt
->
pData
->
aRowP
,
1
);
ret
=
tRowBuild
(
pTableCxt
->
pValues
,
pTableCxt
->
pSchema
,
pRow
);
if
(
TSDB_CODE_SUCCESS
!=
ret
)
{
buildInvalidOperationMsg
(
&
pBuf
,
"tRowBuild error"
);
goto
end
;
}
insCheckTableDataOrder
(
pTableCxt
,
TD_ROW_KEY
(
*
pRow
));
}
end:
...
...
@@ -280,23 +281,42 @@ end:
return
ret
;
}
void
*
smlInitHandle
(
SQuery
*
pQuery
)
{
SSmlExecHandle
*
handle
=
taosMemoryCalloc
(
1
,
sizeof
(
SSmlExecHandle
));
if
(
!
handle
)
return
NULL
;
handle
->
pBlockHash
=
taosHashInit
(
16
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
false
);
handle
->
pQuery
=
pQuery
;
return
handle
;
}
SQuery
*
smlInitHandle
()
{
SQuery
*
pQuery
=
(
SQuery
*
)
nodesMakeNode
(
QUERY_NODE_QUERY
);
if
(
NULL
==
pQuery
)
{
uError
(
"create pQuery error"
);
return
NULL
;
}
pQuery
->
execMode
=
QUERY_EXEC_MODE_SCHEDULE
;
pQuery
->
haveResultSet
=
false
;
pQuery
->
msgType
=
TDMT_VND_SUBMIT
;
SVnodeModifOpStmt
*
stmt
=
(
SVnodeModifOpStmt
*
)
nodesMakeNode
(
QUERY_NODE_VNODE_MODIF_STMT
);
if
(
NULL
==
stmt
)
{
uError
(
"create SVnodeModifOpStmt error"
);
qDestroyQuery
(
pQuery
);
return
NULL
;
}
stmt
->
pVgroupsHashObj
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_NO_LOCK
);
stmt
->
pTableBlockHashObj
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_NO_LOCK
);
stmt
->
freeHashFunc
=
insDestroyTableDataCxtHashMap
;
stmt
->
freeArrayFunc
=
insDestroyVgroupDataCxtList
;
void
smlDestroyHandle
(
void
*
pHandle
)
{
if
(
!
pHandle
)
return
;
SSmlExecHandle
*
handle
=
(
SSmlExecHandle
*
)
pHandle
;
insDestroyBlockHashmap
(
handle
->
pBlockHash
);
taosMemoryFree
(
handle
);
pQuery
->
pRoot
=
(
SNode
*
)
stmt
;
return
pQuery
;
}
int32_t
smlBuildOutput
(
void
*
handle
,
SHashObj
*
pVgHash
)
{
SSmlExecHandle
*
smlHandle
=
(
SSmlExecHandle
*
)
handle
;
return
qBuildStmtOutput
(
smlHandle
->
pQuery
,
pVgHash
,
smlHandle
->
pBlockHash
);
int32_t
smlBuildOutput
(
SQuery
*
handle
,
SHashObj
*
pVgHash
)
{
SVnodeModifOpStmt
*
pStmt
=
(
SVnodeModifOpStmt
*
)(
handle
)
->
pRoot
;
// merge according to vgId
int32_t
code
=
insMergeTableDataCxt
(
pStmt
->
pTableBlockHashObj
,
&
pStmt
->
pVgDataBlocks
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"insMergeTableDataCxt failed"
);
return
code
;
}
code
=
insBuildVgDataBlocks
(
pVgHash
,
pStmt
->
pVgDataBlocks
,
&
pStmt
->
pDataBlocks
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"insBuildVgDataBlocks failed"
);
return
code
;
}
return
code
;
}
source/libs/parser/src/parInsertUtil.c
浏览文件 @
96aa44e2
...
...
@@ -1083,8 +1083,9 @@ static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreat
int32_t
insGetTableDataCxt
(
SHashObj
*
pHash
,
void
*
id
,
int32_t
idLen
,
STableMeta
*
pTableMeta
,
SVCreateTbReq
**
pCreateTbReq
,
STableDataCxt
**
pTableCxt
,
bool
colMode
)
{
*
pTableCxt
=
taosHashGet
(
pHash
,
id
,
idLen
);
if
(
NULL
!=
*
pTableCxt
)
{
STableDataCxt
**
tmp
=
(
STableDataCxt
**
)
taosHashGet
(
pHash
,
id
,
idLen
);
if
(
NULL
!=
tmp
)
{
*
pTableCxt
=
*
tmp
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
code
=
createTableDataCxt
(
pTableMeta
,
pCreateTbReq
,
pTableCxt
,
colMode
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录