Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
43389aa5
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
43389aa5
编写于
3月 30, 2022
作者:
A
Alex Duan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add delete
上级
a99b0376
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
922 addition
and
13 deletion
+922
-13
src/client/inc/tscDelete.h
src/client/inc/tscDelete.h
+32
-0
src/client/inc/tscSubquery.h
src/client/inc/tscSubquery.h
+1
-1
src/client/src/tscDelete.c
src/client/src/tscDelete.c
+136
-0
src/client/src/tscServer.c
src/client/src/tscServer.c
+2
-2
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+3
-3
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+8
-1
src/tsdb/inc/tsdbDelete.h
src/tsdb/inc/tsdbDelete.h
+3
-3
src/tsdb/inc/tsdbMemTable.h
src/tsdb/inc/tsdbMemTable.h
+1
-1
src/tsdb/inc/tsdbint.h
src/tsdb/inc/tsdbint.h
+2
-2
src/tsdb/src/tsdbDelete.c
src/tsdb/src/tsdbDelete.c
+734
-0
未找到文件。
src/client/inc/tscDelete.h
0 → 100644
浏览文件 @
43389aa5
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_TSCDELETE_H
#define TDENGINE_TSCDELETE_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "qTableMeta.h"
int32_t
executeDelete
(
SSqlObj
*
pSql
,
SQueryInfo
*
pQueryInfo
);
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_TSCDELETE_H
src/client/inc/tscSubquery.h
浏览文件 @
43389aa5
...
...
@@ -54,7 +54,7 @@ void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs);
void
tscFreeRetrieveSup
(
void
**
param
);
SSqlObj
*
tscCreateSTableSubquery
(
SSqlObj
*
pSql
,
SRetrieveSupport
*
trsupport
,
SSqlObj
*
prevSqlObj
,
int32_t
cmd
,
__async_cb_func_t
fp
);
#ifdef __cplusplus
}
...
...
src/client/src/tscDelete.c
0 → 100644
浏览文件 @
43389aa5
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "tcmdtype.h"
#include "tscLog.h"
#include "tscUtil.h"
#include "tsclient.h"
#include "tscDelete.h"
int32_t
executeDelete
(
SSqlObj
*
pSql
,
SQueryInfo
*
pQueryInfo
)
{
int32_t
ret
=
TSDB_CODE_SUCCESS
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
if
(
!
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
// not super table
pSql
->
cmd
.
active
=
pQueryInfo
;
return
tscBuildAndSendRequest
(
pSql
,
pQueryInfo
);
}
//
// super table
//
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
// pRes->code check only serves in launching super table sub-queries
if
(
pRes
->
code
==
TSDB_CODE_TSC_QUERY_CANCELLED
)
{
pCmd
->
command
=
TSDB_SQL_RETRIEVE_GLOBALMERGE
;
// enable the abort of kill super table function.
return
pRes
->
code
;
}
tExtMemBuffer
**
pMemoryBuf
=
NULL
;
tOrderDescriptor
*
pDesc
=
NULL
;
pRes
->
qId
=
0x1
;
// hack the qhandle check
uint32_t
nBufferSize
=
(
1u
<<
18u
);
// 256KB, default buffer size
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
SSubqueryState
*
pState
=
&
pSql
->
subState
;
int32_t
numOfSub
=
(
pTableMetaInfo
->
pVgroupTables
==
NULL
)
?
pTableMetaInfo
->
vgroupList
->
numOfVgroups
:
(
int32_t
)
taosArrayGetSize
(
pTableMetaInfo
->
pVgroupTables
);
int32_t
ret
=
doInitSubState
(
pSql
,
numOfSub
);
if
(
ret
!=
0
)
{
tscAsyncResultOnError
(
pSql
);
return
ret
;
}
ret
=
tscCreateGlobalMergerEnv
(
pQueryInfo
,
&
pMemoryBuf
,
pSql
->
subState
.
numOfSub
,
&
pDesc
,
&
nBufferSize
,
pSql
->
self
);
if
(
ret
!=
0
)
{
pRes
->
code
=
ret
;
tscAsyncResultOnError
(
pSql
);
tfree
(
pDesc
);
tfree
(
pMemoryBuf
);
return
ret
;
}
tscDebug
(
"0x%"
PRIx64
" retrieved query data from %d vnode(s)"
,
pSql
->
self
,
pState
->
numOfSub
);
pRes
->
code
=
TSDB_CODE_SUCCESS
;
int32_t
i
=
0
;
for
(;
i
<
pState
->
numOfSub
;
++
i
)
{
SRetrieveSupport
*
trs
=
(
SRetrieveSupport
*
)
calloc
(
1
,
sizeof
(
SRetrieveSupport
));
if
(
trs
==
NULL
)
{
tscError
(
"0x%"
PRIx64
" failed to malloc buffer for SRetrieveSupport, orderOfSub:%d, reason:%s"
,
pSql
->
self
,
i
,
strerror
(
errno
));
break
;
}
trs
->
pExtMemBuffer
=
pMemoryBuf
;
trs
->
pOrderDescriptor
=
pDesc
;
trs
->
localBuffer
=
(
tFilePage
*
)
calloc
(
1
,
nBufferSize
+
sizeof
(
tFilePage
));
trs
->
localBufferSize
=
nBufferSize
+
sizeof
(
tFilePage
);
if
(
trs
->
localBuffer
==
NULL
)
{
tscError
(
"0x%"
PRIx64
" failed to malloc buffer for local buffer, orderOfSub:%d, reason:%s"
,
pSql
->
self
,
i
,
strerror
(
errno
));
tfree
(
trs
);
break
;
}
trs
->
localBuffer
->
num
=
0
;
trs
->
subqueryIndex
=
i
;
trs
->
pParentSql
=
pSql
;
SSqlObj
*
pNew
=
tscCreateSTableSubquery
(
pSql
,
trs
,
NULL
);
if
(
pNew
==
NULL
)
{
tscError
(
"0x%"
PRIx64
" failed to malloc buffer for subObj, orderOfSub:%d, reason:%s"
,
pSql
->
self
,
i
,
strerror
(
errno
));
tfree
(
trs
->
localBuffer
);
tfree
(
trs
);
break
;
}
// todo handle multi-vnode situation
if
(
pQueryInfo
->
tsBuf
)
{
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfo
(
&
pNew
->
cmd
);
pNewQueryInfo
->
tsBuf
=
tsBufClone
(
pQueryInfo
->
tsBuf
);
assert
(
pNewQueryInfo
->
tsBuf
!=
NULL
);
}
tscDebug
(
"0x%"
PRIx64
" sub:0x%"
PRIx64
" create subquery success. orderOfSub:%d"
,
pSql
->
self
,
pNew
->
self
,
trs
->
subqueryIndex
);
}
if
(
i
<
pState
->
numOfSub
)
{
tscError
(
"0x%"
PRIx64
" failed to prepare subquery structure and launch subqueries"
,
pSql
->
self
);
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
tscDestroyGlobalMergerEnv
(
pMemoryBuf
,
pDesc
,
pState
->
numOfSub
);
doCleanupSubqueries
(
pSql
,
i
);
return
pRes
->
code
;
// free all allocated resource
}
if
(
pRes
->
code
==
TSDB_CODE_TSC_QUERY_CANCELLED
)
{
tscDestroyGlobalMergerEnv
(
pMemoryBuf
,
pDesc
,
pState
->
numOfSub
);
doCleanupSubqueries
(
pSql
,
i
);
return
pRes
->
code
;
}
doConcurrentlySendSubQueries
(
pSql
);
return
TSDB_CODE_SUCCESS
;
}
\ No newline at end of file
src/client/src/tscServer.c
浏览文件 @
43389aa5
...
...
@@ -3380,7 +3380,7 @@ int tscBuildDelDataMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
return
build
S
TableDelDataMsg
(
pSql
,
pCmd
,
pQueryInfo
,
pTableMetaInfo
,
pInfo
);
return
buildTableDelDataMsg
(
pSql
,
pCmd
,
pQueryInfo
,
pTableMetaInfo
,
pInfo
);
}
else
{
return
buildTableDelDataMsg
(
pSql
,
pCmd
,
pQueryInfo
,
pTableMetaInfo
,
pInfo
);
}
...
...
@@ -3390,6 +3390,7 @@ void tscInitMsgsFp() {
tscBuildMsg
[
TSDB_SQL_SELECT
]
=
tscBuildQueryMsg
;
tscBuildMsg
[
TSDB_SQL_INSERT
]
=
tscBuildSubmitMsg
;
tscBuildMsg
[
TSDB_SQL_FETCH
]
=
tscBuildFetchMsg
;
tscBuildMsg
[
TSDB_SQL_DELETE_DATA
]
=
tscBuildDelDataMsg
;
tscBuildMsg
[
TSDB_SQL_CREATE_DB
]
=
tscBuildCreateDbMsg
;
tscBuildMsg
[
TSDB_SQL_CREATE_USER
]
=
tscBuildUserMsg
;
...
...
@@ -3425,7 +3426,6 @@ void tscInitMsgsFp() {
tscBuildMsg
[
TSDB_SQL_KILL_QUERY
]
=
tscBuildKillMsg
;
tscBuildMsg
[
TSDB_SQL_KILL_STREAM
]
=
tscBuildKillMsg
;
tscBuildMsg
[
TSDB_SQL_KILL_CONNECTION
]
=
tscBuildKillMsg
;
tscBuildMsg
[
TSDB_SQL_DELETE_DATA
]
=
tscBuildDelDataMsg
;
tscProcessMsgRsp
[
TSDB_SQL_SELECT
]
=
tscProcessQueryRsp
;
tscProcessMsgRsp
[
TSDB_SQL_FETCH
]
=
tscProcessRetrieveRspFromNode
;
...
...
src/client/src/tscSubquery.c
浏览文件 @
43389aa5
...
...
@@ -2716,7 +2716,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
trs
->
subqueryIndex
=
i
;
trs
->
pParentSql
=
pSql
;
SSqlObj
*
pNew
=
tscCreateSTableSubquery
(
pSql
,
trs
,
NULL
);
SSqlObj
*
pNew
=
tscCreateSTableSubquery
(
pSql
,
trs
,
NULL
,
tscRetrieveDataRes
,
CMD_SQL_SELECT
);
if
(
pNew
==
NULL
)
{
tscError
(
"0x%"
PRIx64
" failed to malloc buffer for subObj, orderOfSub:%d, reason:%s"
,
pSql
->
self
,
i
,
strerror
(
errno
));
tfree
(
trs
->
localBuffer
);
...
...
@@ -3165,12 +3165,12 @@ static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfR
}
}
static
SSqlObj
*
tscCreateSTableSubquery
(
SSqlObj
*
pSql
,
SRetrieveSupport
*
trsupport
,
SSqlObj
*
prevSqlObj
)
{
static
SSqlObj
*
tscCreateSTableSubquery
(
SSqlObj
*
pSql
,
SRetrieveSupport
*
trsupport
,
SSqlObj
*
prevSqlObj
,
int32_t
cmd
,
__async_cb_func_t
fp
)
{
const
int32_t
table_index
=
0
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pPQueryInfo
=
tscGetQueryInfo
(
pCmd
);
// Parent SQueryInfo
SSqlObj
*
pNew
=
createSubqueryObj
(
pSql
,
table_index
,
tscRetrieveDataRes
,
trsupport
,
TSDB_SQL_SELECT
,
prevSqlObj
);
SSqlObj
*
pNew
=
createSubqueryObj
(
pSql
,
table_index
,
fp
,
trsupport
,
cmd
,
prevSqlObj
);
if
(
pNew
!=
NULL
)
{
// the sub query of two-stage super table query
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pNew
->
cmd
);
...
...
src/client/src/tscUtil.c
浏览文件 @
43389aa5
...
...
@@ -30,6 +30,7 @@
#include "ttimer.h"
#include "ttokendef.h"
#include "cJSON.h"
#include "tscDelete.h"
#ifdef HTTP_EMBEDDED
#include "httpInt.h"
...
...
@@ -4168,7 +4169,13 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) {
if
(
pSql
->
cmd
.
command
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
)
{
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
0
);
return
;
}
}
else
if
(
pSql
->
cmd
.
command
==
TSDB_SQL_DELETE_DATA
)
{
code
=
executeDelete
(
pSql
,
pQueryInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
0
);
}
return
;
}
if
(
pSql
->
cmd
.
command
==
TSDB_SQL_SELECT
)
{
tscAddIntoSqlList
(
pSql
);
...
...
src/tsdb/inc/tsdb
Trunca
te.h
→
src/tsdb/inc/tsdb
Dele
te.h
浏览文件 @
43389aa5
...
...
@@ -12,8 +12,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_TSDB_
TRUNCA
TE_H_
#define _TD_TSDB_
TRUNCA
TE_H_
#ifndef _TD_TSDB_
DELE
TE_H_
#define _TD_TSDB_
DELE
TE_H_
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -38,4 +38,4 @@ int tsdbControlDelete(STsdbRepo* pRepo, SControlDataInfo* pCtlDataInfo);
}
#endif
#endif
/* _TD_TSDB_TRUNCATE_H_ */
\ No newline at end of file
#endif
/* _TD_TSDB_DELETE_H_ */
\ No newline at end of file
src/tsdb/inc/tsdbMemTable.h
浏览文件 @
43389aa5
...
...
@@ -16,7 +16,7 @@
#ifndef _TD_TSDB_MEMTABLE_H_
#define _TD_TSDB_MEMTABLE_H_
#include "tsdb
Trunca
te.h"
#include "tsdb
Dele
te.h"
typedef
struct
{
int
rowsInserted
;
int
rowsUpdated
;
...
...
src/tsdb/inc/tsdbint.h
浏览文件 @
43389aa5
...
...
@@ -66,8 +66,8 @@ extern "C" {
#include "tsdbCommit.h"
// Compact
#include "tsdbCompact.h"
//
Trunca
te
#include "tsdb
Trunca
te.h"
//
Dele
te
#include "tsdb
Dele
te.h"
// Commit Queue
#include "tsdbCommitQueue.h"
...
...
src/tsdb/src/tsdb
Trunca
te.c
→
src/tsdb/src/tsdb
Dele
te.c
浏览文件 @
43389aa5
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录