Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8a11875e
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8a11875e
编写于
9月 08, 2021
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-6127]<feature> one taos driver connect two cluster
上级
c803ebd8
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
33 addition
and
32 deletion
+33
-32
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+4
-4
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+3
-3
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+6
-6
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+1
-1
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+2
-3
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+17
-15
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
8a11875e
...
...
@@ -119,7 +119,7 @@ typedef struct SBlockKeyInfo {
int32_t
converToStr
(
char
*
str
,
int
type
,
void
*
buf
,
int32_t
bufSize
,
int32_t
*
len
);
int32_t
tscCreateDataBlock
(
size_t
initialSize
,
int32_t
rowSize
,
int32_t
startOffset
,
SName
*
name
,
STableMeta
*
pTableMeta
,
STableDataBlocks
**
dataBlocks
);
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
,
bool
removeMeta
);
void
tscDestroyDataBlock
(
S
SqlObj
*
pSql
,
S
TableDataBlocks
*
pDataBlock
,
bool
removeMeta
);
void
tscSortRemoveDataBlockDupRowsRaw
(
STableDataBlocks
*
dataBuf
);
int
tscSortRemoveDataBlockDupRows
(
STableDataBlocks
*
dataBuf
,
SBlockKeyInfo
*
pBlkKeyInfo
);
int32_t
tsSetBlockInfo
(
SSubmitBlk
*
pBlocks
,
const
STableMeta
*
pTableMeta
,
int32_t
numOfRows
);
...
...
@@ -130,12 +130,12 @@ void doRetrieveSubqueryData(SSchedMsg *pMsg);
SParamInfo
*
tscAddParamToDataBlock
(
STableDataBlocks
*
pDataBlock
,
char
type
,
uint8_t
timePrec
,
int16_t
bytes
,
uint32_t
offset
);
void
*
tscDestroyBlockArrayList
(
SArray
*
pDataBlockList
);
void
*
tscDestroyBlockArrayList
(
S
SqlObj
*
pSql
,
S
Array
*
pDataBlockList
);
void
*
tscDestroyUdfArrayList
(
SArray
*
pUdfList
);
void
*
tscDestroyBlockHashTable
(
SHashObj
*
pBlockHashTable
,
bool
removeMeta
);
void
*
tscDestroyBlockHashTable
(
S
SqlObj
*
pSql
,
S
HashObj
*
pBlockHashTable
,
bool
removeMeta
);
int32_t
tscCopyDataBlockToPayload
(
SSqlObj
*
pSql
,
STableDataBlocks
*
pDataBlock
);
int32_t
tscMergeTableDataBlocks
(
SInsertStatementParam
*
pInsertParam
,
bool
freeBlockMap
);
int32_t
tscMergeTableDataBlocks
(
S
SqlObj
*
pSql
,
S
InsertStatementParam
*
pInsertParam
,
bool
freeBlockMap
);
int32_t
tscGetDataBlockFromList
(
SHashObj
*
pHashList
,
int64_t
id
,
int32_t
size
,
int32_t
startOffset
,
int32_t
rowSize
,
SName
*
pName
,
STableMeta
*
pTableMeta
,
STableDataBlocks
**
dataBlocks
,
SArray
*
pBlockList
);
...
...
src/client/src/tscParseInsert.c
浏览文件 @
8a11875e
...
...
@@ -1529,7 +1529,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
// merge according to vgId
if
(
!
TSDB_QUERY_HAS_TYPE
(
pInsertParam
->
insertType
,
TSDB_QUERY_TYPE_STMT_INSERT
)
&&
taosHashGetSize
(
pInsertParam
->
pTableBlockHashList
)
>
0
)
{
if
((
code
=
tscMergeTableDataBlocks
(
pInsertParam
,
true
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
tscMergeTableDataBlocks
(
p
Sql
,
p
InsertParam
,
true
))
!=
TSDB_CODE_SUCCESS
)
{
goto
_clean
;
}
}
...
...
@@ -1635,7 +1635,7 @@ static int doPackSendDataBlock(SSqlObj* pSql, SInsertStatementParam *pInsertPara
return
tscInvalidOperationMsg
(
pInsertParam
->
msg
,
"too many rows in sql, total number of rows should be less than 32767"
,
NULL
);
}
if
((
code
=
tscMergeTableDataBlocks
(
pInsertParam
,
true
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
tscMergeTableDataBlocks
(
p
Sql
,
p
InsertParam
,
true
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -1696,7 +1696,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int32_t numOfRow
SInsertStatementParam
*
pInsertParam
=
&
pCmd
->
insertParam
;
destroyTableNameList
(
pInsertParam
);
pInsertParam
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pInsertParam
->
pDataBlocks
);
pInsertParam
->
pDataBlocks
=
tscDestroyBlockArrayList
(
p
ParentSql
,
p
InsertParam
->
pDataBlocks
);
if
(
pInsertParam
->
pTableBlockHashList
==
NULL
)
{
pInsertParam
->
pTableBlockHashList
=
taosHashInit
(
16
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
false
);
...
...
src/client/src/tscPrepare.c
浏览文件 @
8a11875e
...
...
@@ -1163,7 +1163,7 @@ static int insertStmtExecute(STscStmt* stmt) {
fillTablesColumnsNull
(
stmt
->
pSql
);
int
code
=
tscMergeTableDataBlocks
(
&
stmt
->
pSql
->
cmd
.
insertParam
,
false
);
int
code
=
tscMergeTableDataBlocks
(
stmt
->
pSql
,
&
stmt
->
pSql
->
cmd
.
insertParam
,
false
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -1194,7 +1194,7 @@ static int insertStmtExecute(STscStmt* stmt) {
pCmd
->
insertParam
.
numOfTables
=
0
;
tfree
(
pCmd
->
insertParam
.
pTableNameList
);
pCmd
->
insertParam
.
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
insertParam
.
pDataBlocks
);
pCmd
->
insertParam
.
pDataBlocks
=
tscDestroyBlockArrayList
(
p
Sql
,
p
Cmd
->
insertParam
.
pDataBlocks
);
return
pSql
->
res
.
code
;
}
...
...
@@ -1215,7 +1215,7 @@ static void insertBatchClean(STscStmt* pStmt) {
tfree
(
pCmd
->
insertParam
.
pTableNameList
);
pCmd
->
insertParam
.
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
insertParam
.
pDataBlocks
);
pCmd
->
insertParam
.
pDataBlocks
=
tscDestroyBlockArrayList
(
p
Sql
,
p
Cmd
->
insertParam
.
pDataBlocks
);
pCmd
->
insertParam
.
numOfTables
=
0
;
taosHashClear
(
pCmd
->
insertParam
.
pTableBlockHashList
);
...
...
@@ -1242,7 +1242,7 @@ static int insertBatchStmtExecute(STscStmt* pStmt) {
fillTablesColumnsNull
(
pStmt
->
pSql
);
if
((
code
=
tscMergeTableDataBlocks
(
&
pStmt
->
pSql
->
cmd
.
insertParam
,
false
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
tscMergeTableDataBlocks
(
pStmt
->
pSql
,
&
pStmt
->
pSql
->
cmd
.
insertParam
,
false
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -1774,8 +1774,8 @@ int taos_stmt_close(TAOS_STMT* stmt) {
if
(
pStmt
->
pSql
&&
pStmt
->
pSql
->
res
.
code
!=
0
)
{
rmMeta
=
true
;
}
tscDestroyDataBlock
(
pStmt
->
mtb
.
lastBlock
,
rmMeta
);
pStmt
->
mtb
.
pTableBlockHashList
=
tscDestroyBlockHashTable
(
pStmt
->
mtb
.
pTableBlockHashList
,
rmMeta
);
tscDestroyDataBlock
(
pStmt
->
pSql
,
pStmt
->
mtb
.
lastBlock
,
rmMeta
);
pStmt
->
mtb
.
pTableBlockHashList
=
tscDestroyBlockHashTable
(
pStmt
->
pSql
,
pStmt
->
mtb
.
pTableBlockHashList
,
rmMeta
);
if
(
pStmt
->
pSql
){
taosHashCleanup
(
pStmt
->
pSql
->
cmd
.
insertParam
.
pTableBlockHashList
);
}
...
...
src/client/src/tscSubquery.c
浏览文件 @
8a11875e
...
...
@@ -3374,7 +3374,7 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) {
goto
_error
;
}
pCmd
->
insertParam
.
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
insertParam
.
pDataBlocks
);
pCmd
->
insertParam
.
pDataBlocks
=
tscDestroyBlockArrayList
(
p
Sql
,
p
Cmd
->
insertParam
.
pDataBlocks
);
// use the local variable
for
(
int32_t
j
=
0
;
j
<
numOfSub
;
++
j
)
{
...
...
src/client/src/tscSystem.c
浏览文件 @
8a11875e
...
...
@@ -153,9 +153,8 @@ void *tscAcquireClusterInfo(const char *clusterId) {
pObj
=
*
ppObj
;
}
if
(
pObj
)
{
pObj
->
ref
+=
1
;
}
if
(
pObj
)
{
pObj
->
ref
+=
1
;
}
pthread_mutex_unlock
(
&
clusterMutex
);
return
pObj
;
}
...
...
src/client/src/tscUtil.c
浏览文件 @
8a11875e
...
...
@@ -1421,6 +1421,7 @@ void destroyTableNameList(SInsertStatementParam* pInsertParam) {
}
void
tscResetSqlCmd
(
SSqlCmd
*
pCmd
,
bool
clearCachedMeta
,
uint64_t
id
)
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
taosAcquireRef
(
tscObjRef
,
id
);
pCmd
->
command
=
0
;
pCmd
->
numOfCols
=
0
;
pCmd
->
count
=
0
;
...
...
@@ -1429,13 +1430,14 @@ void tscResetSqlCmd(SSqlCmd* pCmd, bool clearCachedMeta, uint64_t id) {
pCmd
->
insertParam
.
sql
=
NULL
;
destroyTableNameList
(
&
pCmd
->
insertParam
);
pCmd
->
insertParam
.
pTableBlockHashList
=
tscDestroyBlockHashTable
(
pCmd
->
insertParam
.
pTableBlockHashList
,
clearCachedMeta
);
pCmd
->
insertParam
.
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
insertParam
.
pDataBlocks
);
pCmd
->
insertParam
.
pTableBlockHashList
=
tscDestroyBlockHashTable
(
p
Sql
,
p
Cmd
->
insertParam
.
pTableBlockHashList
,
clearCachedMeta
);
pCmd
->
insertParam
.
pDataBlocks
=
tscDestroyBlockArrayList
(
p
Sql
,
p
Cmd
->
insertParam
.
pDataBlocks
);
tfree
(
pCmd
->
insertParam
.
tagData
.
data
);
pCmd
->
insertParam
.
tagData
.
dataLen
=
0
;
tscFreeQueryInfo
(
pCmd
,
clearCachedMeta
,
id
);
pCmd
->
pTableMetaMap
=
tscCleanupTableMetaMap
(
pCmd
->
pTableMetaMap
);
taosReleaseRef
(
tscObjRef
,
id
);
}
void
*
tscCleanupTableMetaMap
(
SHashObj
*
pTableMetaMap
)
{
...
...
@@ -1566,7 +1568,7 @@ void tscDestroyBoundColumnInfo(SParsedDataColInfo* pColInfo) {
tfree
(
pColInfo
->
colIdxInfo
);
}
void
tscDestroyDataBlock
(
STableDataBlocks
*
pDataBlock
,
bool
removeMeta
)
{
void
tscDestroyDataBlock
(
S
SqlObj
*
pSql
,
S
TableDataBlocks
*
pDataBlock
,
bool
removeMeta
)
{
if
(
pDataBlock
==
NULL
)
{
return
;
}
...
...
@@ -1577,7 +1579,7 @@ void tscDestroyDataBlock(STableDataBlocks* pDataBlock, bool removeMeta) {
char
name
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
tNameExtractFullName
(
&
pDataBlock
->
tableName
,
name
);
//taosHashRemove(tscTableMetaMap
, name, strnlen(name, TSDB_TABLE_FNAME_LEN));
taosHashRemove
(
UTIL_GET_TABLEMETA
(
pSql
)
,
name
,
strnlen
(
name
,
TSDB_TABLE_FNAME_LEN
));
}
if
(
!
pDataBlock
->
cloned
)
{
...
...
@@ -1618,7 +1620,7 @@ SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint
return
param
;
}
void
*
tscDestroyBlockArrayList
(
SArray
*
pDataBlockList
)
{
void
*
tscDestroyBlockArrayList
(
S
SqlObj
*
pSql
,
S
Array
*
pDataBlockList
)
{
if
(
pDataBlockList
==
NULL
)
{
return
NULL
;
}
...
...
@@ -1626,7 +1628,7 @@ void* tscDestroyBlockArrayList(SArray* pDataBlockList) {
size_t
size
=
taosArrayGetSize
(
pDataBlockList
);
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
void
*
d
=
taosArrayGetP
(
pDataBlockList
,
i
);
tscDestroyDataBlock
(
d
,
false
);
tscDestroyDataBlock
(
pSql
,
d
,
false
);
}
taosArrayDestroy
(
pDataBlockList
);
...
...
@@ -1674,14 +1676,14 @@ void* tscDestroyUdfArrayList(SArray* pUdfList) {
void
*
tscDestroyBlockHashTable
(
SHashObj
*
pBlockHashTable
,
bool
removeMeta
)
{
void
*
tscDestroyBlockHashTable
(
S
SqlObj
*
pSql
,
S
HashObj
*
pBlockHashTable
,
bool
removeMeta
)
{
if
(
pBlockHashTable
==
NULL
)
{
return
NULL
;
}
STableDataBlocks
**
p
=
taosHashIterate
(
pBlockHashTable
,
NULL
);
while
(
p
)
{
tscDestroyDataBlock
(
*
p
,
removeMeta
);
tscDestroyDataBlock
(
pSql
,
*
p
,
removeMeta
);
p
=
taosHashIterate
(
pBlockHashTable
,
p
);
}
...
...
@@ -1922,7 +1924,7 @@ static int32_t getRowExpandSize(STableMeta* pTableMeta) {
return
result
;
}
static
void
extractTableNameList
(
SInsertStatementParam
*
pInsertParam
,
bool
freeBlockMap
)
{
static
void
extractTableNameList
(
S
SqlObj
*
pSql
,
S
InsertStatementParam
*
pInsertParam
,
bool
freeBlockMap
)
{
pInsertParam
->
numOfTables
=
(
int32_t
)
taosHashGetSize
(
pInsertParam
->
pTableBlockHashList
);
if
(
pInsertParam
->
pTableNameList
==
NULL
)
{
pInsertParam
->
pTableNameList
=
malloc
(
pInsertParam
->
numOfTables
*
POINTER_BYTES
);
...
...
@@ -1939,11 +1941,11 @@ static void extractTableNameList(SInsertStatementParam *pInsertParam, bool freeB
}
if
(
freeBlockMap
)
{
pInsertParam
->
pTableBlockHashList
=
tscDestroyBlockHashTable
(
pInsertParam
->
pTableBlockHashList
,
false
);
pInsertParam
->
pTableBlockHashList
=
tscDestroyBlockHashTable
(
p
Sql
,
p
InsertParam
->
pTableBlockHashList
,
false
);
}
}
int32_t
tscMergeTableDataBlocks
(
SInsertStatementParam
*
pInsertParam
,
bool
freeBlockMap
)
{
int32_t
tscMergeTableDataBlocks
(
S
SqlObj
*
pSql
,
S
InsertStatementParam
*
pInsertParam
,
bool
freeBlockMap
)
{
const
int
INSERT_HEAD_SIZE
=
sizeof
(
SMsgDesc
)
+
sizeof
(
SSubmitMsg
);
int
code
=
0
;
bool
isRawPayload
=
IS_RAW_PAYLOAD
(
pInsertParam
->
payloadType
);
...
...
@@ -1968,7 +1970,7 @@ int32_t tscMergeTableDataBlocks(SInsertStatementParam *pInsertParam, bool freeBl
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"0x%"
PRIx64
" failed to prepare the data block buffer for merging table data, code:%d"
,
pInsertParam
->
objectId
,
ret
);
taosHashCleanup
(
pVnodeDataBlockHashList
);
tscDestroyBlockArrayList
(
pVnodeDataBlockList
);
tscDestroyBlockArrayList
(
p
Sql
,
p
VnodeDataBlockList
);
tfree
(
blkKeyInfo
.
pKeyTuple
);
return
ret
;
}
...
...
@@ -1987,7 +1989,7 @@ int32_t tscMergeTableDataBlocks(SInsertStatementParam *pInsertParam, bool freeBl
tscError
(
"0x%"
PRIx64
" failed to allocate memory for merging submit block, size:%d"
,
pInsertParam
->
objectId
,
dataBuf
->
nAllocSize
);
taosHashCleanup
(
pVnodeDataBlockHashList
);
tscDestroyBlockArrayList
(
pVnodeDataBlockList
);
tscDestroyBlockArrayList
(
p
Sql
,
p
VnodeDataBlockList
);
tfree
(
dataBuf
->
pData
);
tfree
(
blkKeyInfo
.
pKeyTuple
);
...
...
@@ -2005,7 +2007,7 @@ int32_t tscMergeTableDataBlocks(SInsertStatementParam *pInsertParam, bool freeBl
}
else
{
if
((
code
=
tscSortRemoveDataBlockDupRows
(
pOneTableBlock
,
&
blkKeyInfo
))
!=
0
)
{
taosHashCleanup
(
pVnodeDataBlockHashList
);
tscDestroyBlockArrayList
(
pVnodeDataBlockList
);
tscDestroyBlockArrayList
(
p
Sql
,
p
VnodeDataBlockList
);
tfree
(
dataBuf
->
pData
);
tfree
(
blkKeyInfo
.
pKeyTuple
);
return
code
;
...
...
@@ -2052,7 +2054,7 @@ int32_t tscMergeTableDataBlocks(SInsertStatementParam *pInsertParam, bool freeBl
pOneTableBlock
=
*
p
;
}
extractTableNameList
(
pInsertParam
,
freeBlockMap
);
extractTableNameList
(
p
Sql
,
p
InsertParam
,
freeBlockMap
);
// free the table data blocks;
pInsertParam
->
pDataBlocks
=
pVnodeDataBlockList
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录