Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0f148c6f
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
0f148c6f
编写于
6月 21, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: show create table
上级
b084be71
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
736 addition
and
167 deletion
+736
-167
include/common/tname.h
include/common/tname.h
+2
-0
include/libs/qcom/query.h
include/libs/qcom/query.h
+2
-0
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+1
-1
source/common/src/tname.c
source/common/src/tname.c
+9
-0
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+50
-10
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+0
-53
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+373
-75
source/libs/catalog/src/ctgCache.c
source/libs/catalog/src/ctgCache.c
+88
-0
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+157
-19
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+0
-9
source/libs/qcom/src/queryUtil.c
source/libs/qcom/src/queryUtil.c
+54
-0
未找到文件。
include/common/tname.h
浏览文件 @
0f148c6f
...
...
@@ -63,6 +63,8 @@ int32_t tNameSetAcctId(SName* dst, int32_t acctId);
bool
tNameDBNameEqual
(
SName
*
left
,
SName
*
right
);
bool
tNameTbNameEqual
(
SName
*
left
,
SName
*
right
);
typedef
struct
{
// input
SArray
*
tags
;
// element is SSmlKv
...
...
include/libs/qcom/query.h
浏览文件 @
0f148c6f
...
...
@@ -209,6 +209,8 @@ SSchema createSchema(int8_t type, int32_t bytes, col_id_t colId, const char* nam
void
destroyQueryExecRes
(
SQueryExecRes
*
pRes
);
int32_t
dataConverToStr
(
char
*
str
,
int
type
,
void
*
buf
,
int32_t
bufSize
,
int32_t
*
len
);
char
*
parseTagDatatoJson
(
void
*
p
);
int32_t
cloneTableMeta
(
STableMeta
*
pSrc
,
STableMeta
**
pDst
);
int32_t
cloneDbVgInfo
(
SDBVgInfo
*
pSrc
,
SDBVgInfo
**
pDst
);
extern
int32_t
(
*
queryBuildMsg
[
TDMT_MAX
])(
void
*
input
,
char
**
msg
,
int32_t
msgSize
,
int32_t
*
msgLen
,
void
*
(
*
mallocFp
)(
int32_t
));
extern
int32_t
(
*
queryProcessMsgRsp
[
TDMT_MAX
])(
void
*
output
,
char
*
msg
,
int32_t
msgSize
);
...
...
source/client/inc/clientInt.h
浏览文件 @
0f148c6f
...
...
@@ -46,7 +46,7 @@ extern "C" {
#define ERROR_MSG_BUF_DEFAULT_SIZE 512
#define HEARTBEAT_INTERVAL 1500 // ms
#define SYNC_ON_TOP_OF_ASYNC
0
#define SYNC_ON_TOP_OF_ASYNC
1
enum
{
RES_TYPE__QUERY
=
1
,
...
...
source/common/src/tname.c
浏览文件 @
0f148c6f
...
...
@@ -240,6 +240,15 @@ bool tNameDBNameEqual(SName* left, SName* right) {
return
(
0
==
strcmp
(
left
->
dbname
,
right
->
dbname
));
}
bool
tNameTbNameEqual
(
SName
*
left
,
SName
*
right
)
{
bool
equal
=
tNameDBNameEqual
(
left
,
right
);
if
(
equal
)
{
return
(
0
==
strcmp
(
left
->
tname
,
right
->
tname
));
}
return
equal
;
}
int32_t
tNameFromString
(
SName
*
dst
,
const
char
*
str
,
uint32_t
type
)
{
assert
(
dst
!=
NULL
&&
str
!=
NULL
&&
strlen
(
str
)
>
0
);
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
0f148c6f
...
...
@@ -71,11 +71,18 @@ typedef enum {
CTG_TASK_GET_TB_META
,
CTG_TASK_GET_TB_HASH
,
CTG_TASK_GET_TB_INDEX
,
CTG_TASK_GET_TB_CFG
,
CTG_TASK_GET_INDEX
,
CTG_TASK_GET_UDF
,
CTG_TASK_GET_USER
,
}
CTG_TASK_TYPE
;
typedef
enum
{
CTG_TASK_LAUNCHED
=
1
,
CTG_TASK_DONE
,
}
CTG_TASK_STATUS
;
typedef
struct
SCtgDebug
{
bool
lockEnable
;
bool
cacheEnable
;
...
...
@@ -102,6 +109,12 @@ typedef struct SCtgTbIndexCtx {
SName
*
pName
;
}
SCtgTbIndexCtx
;
typedef
struct
SCtgTbCfgCtx
{
SName
*
pName
;
int32_t
tbType
;
SVgroupInfo
*
pVgInfo
;
}
SCtgTbCfgCtx
;
typedef
struct
SCtgDbVgCtx
{
char
dbFName
[
TSDB_DB_FNAME_LEN
];
}
SCtgDbVgCtx
;
...
...
@@ -190,7 +203,9 @@ typedef struct SCtgJob {
SArray
*
pTasks
;
int32_t
taskDone
;
SMetaData
jobRes
;
int32_t
taskIdx
;
SRWLatch
taskLock
;
uint64_t
queryId
;
SCatalog
*
pCtg
;
SRequestConnInfo
conn
;
...
...
@@ -206,6 +221,7 @@ typedef struct SCtgJob {
int32_t
userNum
;
int32_t
dbInfoNum
;
int32_t
tbIndexNum
;
int32_t
tbCfgNum
;
}
SCtgJob
;
typedef
struct
SCtgMsgCtx
{
...
...
@@ -215,24 +231,44 @@ typedef struct SCtgMsgCtx {
char
*
target
;
}
SCtgMsgCtx
;
typedef
struct
SCtgTask
SCtgTask
;
typedef
int32_t
(
*
ctgSubTaskCbFp
)(
SCtgTask
*
);
typedef
struct
SCtgSubRes
{
CTG_TASK_TYPE
type
;
int32_t
code
;
void
*
res
;
ctgSubTaskCbFp
fp
;
}
SCtgSubRes
;
typedef
struct
SCtgTask
{
CTG_TASK_TYPE
type
;
int32_t
taskId
;
SCtgJob
*
pJob
;
void
*
taskCtx
;
SCtgMsgCtx
msgCtx
;
int32_t
code
;
void
*
res
;
CTG_TASK_TYPE
type
;
int32_t
taskId
;
SCtgJob
*
pJob
;
void
*
taskCtx
;
SCtgMsgCtx
msgCtx
;
int32_t
code
;
void
*
res
;
CTG_TASK_STATUS
status
;
SRWLatch
lock
;
SArray
*
pParents
;
SCtgSubRes
subRes
;
}
SCtgTask
;
typedef
int32_t
(
*
ctgInitTaskFp
)(
SCtgJob
*
,
int32_t
,
void
*
);
typedef
int32_t
(
*
ctgLanchTaskFp
)(
SCtgTask
*
);
typedef
int32_t
(
*
ctgHandleTaskMsgRspFp
)(
SCtgTask
*
,
int32_t
,
const
SDataBuf
*
,
int32_t
);
typedef
int32_t
(
*
ctgDumpTaskResFp
)(
SCtgTask
*
);
typedef
int32_t
(
*
ctgCloneTaskResFp
)(
SCtgTask
*
,
void
**
);
typedef
int32_t
(
*
ctgCompTaskFp
)(
SCtgTask
*
,
void
*
,
bool
*
);
typedef
struct
SCtgAsyncFps
{
ctgLanchTaskFp
launchFp
;
ctgInitTaskFp
initFp
;
ctgLanchTaskFp
launchFp
;
ctgHandleTaskMsgRspFp
handleRspFp
;
ctgDumpTaskResFp
dumpResFp
;
ctgDumpTaskResFp
dumpResFp
;
ctgCompTaskFp
compFp
;
ctgCloneTaskResFp
cloneFp
;
}
SCtgAsyncFps
;
typedef
struct
SCtgApiStat
{
...
...
@@ -521,6 +557,7 @@ int32_t ctgOpDropTbIndex(SCtgCacheOperation *operation);
int32_t
ctgOpUpdateTbIndex
(
SCtgCacheOperation
*
operation
);
int32_t
ctgOpClearCache
(
SCtgCacheOperation
*
operation
);
int32_t
ctgReadTbTypeFromCache
(
SCatalog
*
pCtg
,
char
*
dbFName
,
char
*
tableName
,
int32_t
*
tbType
);
int32_t
ctgGetTbHashVgroupFromCache
(
SCatalog
*
pCtg
,
const
SName
*
pTableName
,
SVgroupInfo
**
pVgroup
);
...
...
@@ -542,6 +579,8 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const S
int32_t
ctgInitJob
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgJob
**
job
,
uint64_t
reqId
,
const
SCatalogReq
*
pReq
,
catalogCallback
fp
,
void
*
param
,
int32_t
*
taskNum
);
int32_t
ctgLaunchJob
(
SCtgJob
*
pJob
);
int32_t
ctgMakeAsyncRes
(
SCtgJob
*
pJob
);
int32_t
ctgLaunchSubTask
(
SCtgTask
*
pTask
,
CTG_TASK_TYPE
type
,
ctgSubTaskCbFp
fp
,
void
*
param
);
int32_t
ctgGetTbCfgCb
(
SCtgTask
*
pTask
);
int32_t
ctgCloneVgInfo
(
SDBVgInfo
*
src
,
SDBVgInfo
**
dst
);
int32_t
ctgCloneMetaOutput
(
STableMetaOutput
*
output
,
STableMetaOutput
**
pOutput
);
...
...
@@ -562,6 +601,7 @@ char * ctgTaskTypeStr(CTG_TASK_TYPE type);
int32_t
ctgUpdateSendTargetInfo
(
SMsgSendInfo
*
pMsgSendInfo
,
int32_t
msgType
,
SCtgTask
*
pTask
);
int32_t
ctgCloneTableIndex
(
SArray
*
pIndex
,
SArray
**
pRes
);
void
ctgFreeSTableIndex
(
void
*
info
);
void
ctgClearSubTaskRes
(
SCtgSubRes
*
pRes
);
extern
SCatalogMgmt
gCtgMgmt
;
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
0f148c6f
...
...
@@ -22,36 +22,6 @@
SCatalogMgmt
gCtgMgmt
=
{
0
};
int32_t
ctgRemoveTbMetaFromCache
(
SCatalog
*
pCtg
,
SName
*
pTableName
,
bool
syncReq
)
{
int32_t
code
=
0
;
STableMeta
*
tblMeta
=
NULL
;
SCtgTbMetaCtx
tbCtx
=
{
0
};
tbCtx
.
flag
=
CTG_FLAG_UNKNOWN_STB
;
tbCtx
.
pName
=
pTableName
;
CTG_ERR_JRET
(
ctgReadTbMetaFromCache
(
pCtg
,
&
tbCtx
,
&
tblMeta
));
if
(
NULL
==
tblMeta
)
{
ctgDebug
(
"table already not in cache, db:%s, tblName:%s"
,
pTableName
->
dbname
,
pTableName
->
tname
);
return
TSDB_CODE_SUCCESS
;
}
char
dbFName
[
TSDB_DB_FNAME_LEN
];
tNameGetFullDbName
(
pTableName
,
dbFName
);
if
(
TSDB_SUPER_TABLE
==
tblMeta
->
tableType
)
{
CTG_ERR_JRET
(
ctgDropStbMetaEnqueue
(
pCtg
,
dbFName
,
tbCtx
.
tbInfo
.
dbId
,
pTableName
->
tname
,
tblMeta
->
suid
,
syncReq
));
}
else
{
CTG_ERR_JRET
(
ctgDropTbMetaEnqueue
(
pCtg
,
dbFName
,
tbCtx
.
tbInfo
.
dbId
,
pTableName
->
tname
,
syncReq
));
}
_return:
taosMemoryFreeClear
(
tblMeta
);
CTG_RET
(
code
);
}
int32_t
ctgGetDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SCtgDBCache
**
dbCache
,
SDBVgInfo
**
pInfo
)
{
int32_t
code
=
0
;
...
...
@@ -212,29 +182,6 @@ _return:
CTG_RET
(
code
);
}
int32_t
ctgGetTbMetaFromCache
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
)
{
if
(
CTG_IS_SYS_DBNAME
(
ctx
->
pName
->
dbname
))
{
CTG_FLAG_SET_SYS_DB
(
ctx
->
flag
);
}
CTG_ERR_RET
(
ctgReadTbMetaFromCache
(
pCtg
,
ctx
,
pTableMeta
));
if
(
*
pTableMeta
)
{
if
(
CTG_FLAG_MATCH_STB
(
ctx
->
flag
,
(
*
pTableMeta
)
->
tableType
)
&&
((
!
CTG_FLAG_IS_FORCE_UPDATE
(
ctx
->
flag
))
||
(
CTG_FLAG_IS_SYS_DB
(
ctx
->
flag
))))
{
return
TSDB_CODE_SUCCESS
;
}
taosMemoryFreeClear
(
*
pTableMeta
);
}
if
(
CTG_FLAG_IS_UNKNOWN_STB
(
ctx
->
flag
))
{
CTG_FLAG_SET_STB
(
ctx
->
flag
,
ctx
->
tbInfo
.
tbType
);
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgGetTbMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
)
{
int32_t
code
=
0
;
STableMetaOutput
*
output
=
NULL
;
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
0f148c6f
此差异已折叠。
点击以展开。
source/libs/catalog/src/ctgCache.c
浏览文件 @
0f148c6f
...
...
@@ -2061,4 +2061,92 @@ int32_t ctgStartUpdateThread() {
}
int32_t
ctgGetTbMetaFromCache
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
SCtgTbMetaCtx
*
ctx
,
STableMeta
**
pTableMeta
)
{
if
(
CTG_IS_SYS_DBNAME
(
ctx
->
pName
->
dbname
))
{
CTG_FLAG_SET_SYS_DB
(
ctx
->
flag
);
}
CTG_ERR_RET
(
ctgReadTbMetaFromCache
(
pCtg
,
ctx
,
pTableMeta
));
if
(
*
pTableMeta
)
{
if
(
CTG_FLAG_MATCH_STB
(
ctx
->
flag
,
(
*
pTableMeta
)
->
tableType
)
&&
((
!
CTG_FLAG_IS_FORCE_UPDATE
(
ctx
->
flag
))
||
(
CTG_FLAG_IS_SYS_DB
(
ctx
->
flag
))))
{
return
TSDB_CODE_SUCCESS
;
}
taosMemoryFreeClear
(
*
pTableMeta
);
}
if
(
CTG_FLAG_IS_UNKNOWN_STB
(
ctx
->
flag
))
{
CTG_FLAG_SET_STB
(
ctx
->
flag
,
ctx
->
tbInfo
.
tbType
);
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgRemoveTbMetaFromCache
(
SCatalog
*
pCtg
,
SName
*
pTableName
,
bool
syncReq
)
{
int32_t
code
=
0
;
STableMeta
*
tblMeta
=
NULL
;
SCtgTbMetaCtx
tbCtx
=
{
0
};
tbCtx
.
flag
=
CTG_FLAG_UNKNOWN_STB
;
tbCtx
.
pName
=
pTableName
;
CTG_ERR_JRET
(
ctgReadTbMetaFromCache
(
pCtg
,
&
tbCtx
,
&
tblMeta
));
if
(
NULL
==
tblMeta
)
{
ctgDebug
(
"table already not in cache, db:%s, tblName:%s"
,
pTableName
->
dbname
,
pTableName
->
tname
);
return
TSDB_CODE_SUCCESS
;
}
char
dbFName
[
TSDB_DB_FNAME_LEN
];
tNameGetFullDbName
(
pTableName
,
dbFName
);
if
(
TSDB_SUPER_TABLE
==
tblMeta
->
tableType
)
{
CTG_ERR_JRET
(
ctgDropStbMetaEnqueue
(
pCtg
,
dbFName
,
tbCtx
.
tbInfo
.
dbId
,
pTableName
->
tname
,
tblMeta
->
suid
,
syncReq
));
}
else
{
CTG_ERR_JRET
(
ctgDropTbMetaEnqueue
(
pCtg
,
dbFName
,
tbCtx
.
tbInfo
.
dbId
,
pTableName
->
tname
,
syncReq
));
}
_return:
taosMemoryFreeClear
(
tblMeta
);
CTG_RET
(
code
);
}
int32_t
ctgGetTbHashVgroupFromCache
(
SCatalog
*
pCtg
,
const
SName
*
pTableName
,
SVgroupInfo
**
pVgroup
)
{
if
(
CTG_IS_SYS_DBNAME
(
pTableName
->
dbname
))
{
ctgError
(
"no valid vgInfo for db, dbname:%s"
,
pTableName
->
dbname
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
SCtgDBCache
*
dbCache
=
NULL
;
int32_t
code
=
0
;
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
pTableName
,
dbFName
);
CTG_ERR_RET
(
ctgAcquireVgInfoFromCache
(
pCtg
,
dbFName
,
&
dbCache
));
if
(
NULL
==
dbCache
)
{
*
pVgroup
=
NULL
;
return
TSDB_CODE_SUCCESS
;
}
*
pVgroup
=
taosMemoryCalloc
(
1
,
sizeof
(
SVgroupInfo
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
dbCache
->
vgCache
.
vgInfo
,
pTableName
,
*
pVgroup
));
_return:
if
(
dbCache
)
{
ctgReleaseVgInfoToCache
(
pCtg
,
dbCache
);
}
if
(
code
)
{
taosMemoryFreeClear
(
*
pVgroup
);
}
CTG_RET
(
code
);
}
source/libs/catalog/src/ctgUtil.c
浏览文件 @
0f148c6f
...
...
@@ -33,6 +33,10 @@ char *ctgTaskTypeStr(CTG_TASK_TYPE type) {
return
"[get table meta]"
;
case
CTG_TASK_GET_TB_HASH
:
return
"[get table hash]"
;
case
CTG_TASK_GET_TB_INDEX
:
return
"[get table index]"
;
case
CTG_TASK_GET_TB_CFG
:
return
"[get table cfg]"
;
case
CTG_TASK_GET_INDEX
:
return
"[get index]"
;
case
CTG_TASK_GET_UDF
:
...
...
@@ -96,6 +100,9 @@ void ctgFreeSMetaData(SMetaData* pData) {
taosArrayDestroy
(
pData
->
pQnodeList
);
pData
->
pQnodeList
=
NULL
;
taosArrayDestroy
(
pData
->
pTableCfg
);
pData
->
pTableCfg
=
NULL
;
}
void
ctgFreeSCtgUserAuth
(
SCtgUserAuth
*
userCache
)
{
...
...
@@ -280,6 +287,13 @@ void ctgFreeMsgCtx(SCtgMsgCtx* pCtx) {
}
break
;
}
case
TDMT_VND_TABLE_CFG
:
case
TDMT_MND_TABLE_CFG
:
{
STableCfgRsp
*
pOut
=
(
STableCfgRsp
*
)
pCtx
->
out
;
tFreeSTableCfgRsp
(
pOut
);
taosMemoryFreeClear
(
pCtx
->
out
);
break
;
}
case
TDMT_MND_RETRIEVE_FUNC
:
{
SFuncInfo
*
pOut
=
(
SFuncInfo
*
)
pCtx
->
out
;
taosMemoryFree
(
pOut
->
pCode
);
...
...
@@ -328,14 +342,135 @@ void ctgResetTbMetaTask(SCtgTask* pTask) {
taosMemoryFreeClear
(
pTask
->
res
);
}
void
ctgFreeTask
(
SCtgTask
*
pTask
)
{
ctgFreeMsgCtx
(
&
pTask
->
msgCtx
);
void
ctgFreeTaskRes
(
CTG_TASK_TYPE
type
,
void
**
pRes
)
{
switch
(
type
)
{
case
CTG_TASK_GET_QNODE
:
{
taosArrayDestroy
((
SArray
*
)
*
pRes
);
*
pRes
=
NULL
;
break
;
}
case
CTG_TASK_GET_TB_META
:
{
taosMemoryFreeClear
(
*
pRes
);
break
;
}
case
CTG_TASK_GET_DB_VGROUP
:
{
taosArrayDestroy
((
SArray
*
)
*
pRes
);
*
pRes
=
NULL
;
break
;
}
case
CTG_TASK_GET_DB_CFG
:
{
if
(
*
pRes
)
{
SDbCfgInfo
*
pInfo
=
(
SDbCfgInfo
*
)
*
pRes
;
taosArrayDestroy
(
pInfo
->
pRetensions
);
taosMemoryFreeClear
(
*
pRes
);
}
break
;
}
case
CTG_TASK_GET_DB_INFO
:
{
taosMemoryFreeClear
(
*
pRes
);
break
;
}
case
CTG_TASK_GET_TB_HASH
:
{
taosMemoryFreeClear
(
*
pRes
);
break
;
}
case
CTG_TASK_GET_TB_INDEX
:
{
taosArrayDestroyEx
(
*
pRes
,
tFreeSTableIndexInfo
);
*
pRes
=
NULL
;
break
;
}
case
CTG_TASK_GET_INDEX
:
{
taosMemoryFreeClear
(
*
pRes
);
break
;
}
case
CTG_TASK_GET_UDF
:
{
taosMemoryFreeClear
(
*
pRes
);
break
;
}
case
CTG_TASK_GET_USER
:
{
taosMemoryFreeClear
(
*
pRes
);
break
;
}
default:
qError
(
"invalid task type %d"
,
type
);
break
;
}
}
void
ctgFreeSubTaskRes
(
CTG_TASK_TYPE
type
,
void
**
pRes
)
{
switch
(
type
)
{
case
CTG_TASK_GET_QNODE
:
{
taosArrayDestroy
((
SArray
*
)
*
pRes
);
*
pRes
=
NULL
;
break
;
}
case
CTG_TASK_GET_TB_META
:
{
taosMemoryFreeClear
(
*
pRes
);
break
;
}
case
CTG_TASK_GET_DB_VGROUP
:
{
if
(
*
pRes
)
{
SDBVgInfo
*
pInfo
=
(
SDBVgInfo
*
)
*
pRes
;
taosHashCleanup
(
pInfo
->
vgHash
);
taosMemoryFreeClear
(
*
pRes
);
}
break
;
}
case
CTG_TASK_GET_DB_CFG
:
{
if
(
*
pRes
)
{
SDbCfgInfo
*
pInfo
=
(
SDbCfgInfo
*
)
*
pRes
;
taosArrayDestroy
(
pInfo
->
pRetensions
);
taosMemoryFreeClear
(
*
pRes
);
}
break
;
}
case
CTG_TASK_GET_DB_INFO
:
{
taosMemoryFreeClear
(
*
pRes
);
break
;
}
case
CTG_TASK_GET_TB_HASH
:
{
taosMemoryFreeClear
(
*
pRes
);
break
;
}
case
CTG_TASK_GET_TB_INDEX
:
{
taosArrayDestroyEx
(
*
pRes
,
tFreeSTableIndexInfo
);
*
pRes
=
NULL
;
break
;
}
case
CTG_TASK_GET_INDEX
:
{
taosMemoryFreeClear
(
*
pRes
);
break
;
}
case
CTG_TASK_GET_UDF
:
{
taosMemoryFreeClear
(
*
pRes
);
break
;
}
case
CTG_TASK_GET_USER
:
{
taosMemoryFreeClear
(
*
pRes
);
break
;
}
default:
qError
(
"invalid task type %d"
,
type
);
break
;
}
}
void
ctgClearSubTaskRes
(
SCtgSubRes
*
pRes
)
{
pRes
->
code
=
0
;
if
(
NULL
==
pRes
->
res
)
{
return
;
}
ctgFreeSubTaskRes
(
pRes
->
type
,
&
pRes
->
res
);
}
void
ctgFreeTaskCtx
(
SCtgTask
*
pTask
)
{
switch
(
pTask
->
type
)
{
case
CTG_TASK_GET_QNODE
:
{
taosArrayDestroy
((
SArray
*
)
pTask
->
res
);
taosMemoryFreeClear
(
pTask
->
taskCtx
);
pTask
->
res
=
NULL
;
break
;
}
case
CTG_TASK_GET_TB_META
:
{
...
...
@@ -346,56 +481,49 @@ void ctgFreeTask(SCtgTask* pTask) {
pTask
->
msgCtx
.
lastOut
=
NULL
;
}
taosMemoryFreeClear
(
pTask
->
taskCtx
);
taosMemoryFreeClear
(
pTask
->
res
);
break
;
}
case
CTG_TASK_GET_DB_VGROUP
:
{
taosArrayDestroy
((
SArray
*
)
pTask
->
res
);
taosMemoryFreeClear
(
pTask
->
taskCtx
);
pTask
->
res
=
NULL
;
break
;
}
case
CTG_TASK_GET_DB_CFG
:
{
taosMemoryFreeClear
(
pTask
->
taskCtx
);
if
(
pTask
->
res
)
{
SDbCfgInfo
*
pInfo
=
(
SDbCfgInfo
*
)
pTask
->
res
;
taosArrayDestroy
(
pInfo
->
pRetensions
);
taosMemoryFreeClear
(
pTask
->
res
);
}
break
;
}
case
CTG_TASK_GET_DB_INFO
:
{
taosMemoryFreeClear
(
pTask
->
taskCtx
);
taosMemoryFreeClear
(
pTask
->
res
);
break
;
}
case
CTG_TASK_GET_TB_HASH
:
{
SCtgTbHashCtx
*
taskCtx
=
(
SCtgTbHashCtx
*
)
pTask
->
taskCtx
;
taosMemoryFreeClear
(
taskCtx
->
pName
);
taosMemoryFreeClear
(
pTask
->
taskCtx
);
taosMemoryFreeClear
(
pTask
->
res
);
break
;
}
case
CTG_TASK_GET_TB_INDEX
:
{
SCtgTbIndexCtx
*
taskCtx
=
(
SCtgTbIndexCtx
*
)
pTask
->
taskCtx
;
taosMemoryFreeClear
(
taskCtx
->
pName
);
taosMemoryFreeClear
(
pTask
->
taskCtx
);
taosArrayDestroyEx
(
pTask
->
res
,
tFreeSTableIndexInfo
);
break
;
}
case
CTG_TASK_GET_TB_CFG
:
{
SCtgTbCfgCtx
*
taskCtx
=
(
SCtgTbCfgCtx
*
)
pTask
->
taskCtx
;
taosMemoryFreeClear
(
taskCtx
->
pName
);
taosMemoryFreeClear
(
taskCtx
->
pVgInfo
);
taosMemoryFreeClear
(
pTask
->
taskCtx
);
break
;
}
case
CTG_TASK_GET_INDEX
:
{
taosMemoryFreeClear
(
pTask
->
taskCtx
);
taosMemoryFreeClear
(
pTask
->
res
);
break
;
}
case
CTG_TASK_GET_UDF
:
{
taosMemoryFreeClear
(
pTask
->
taskCtx
);
taosMemoryFreeClear
(
pTask
->
res
);
break
;
}
case
CTG_TASK_GET_USER
:
{
taosMemoryFreeClear
(
pTask
->
taskCtx
);
taosMemoryFreeClear
(
pTask
->
res
);
break
;
}
default:
...
...
@@ -404,6 +532,16 @@ void ctgFreeTask(SCtgTask* pTask) {
}
}
void
ctgFreeTask
(
SCtgTask
*
pTask
)
{
ctgFreeMsgCtx
(
&
pTask
->
msgCtx
);
ctgFreeTaskRes
(
pTask
->
type
,
&
pTask
->
res
);
ctgFreeTaskCtx
(
pTask
);
taosArrayDestroy
(
pTask
->
pParents
);
ctgClearSubTaskRes
(
&
pTask
->
subRes
);
}
void
ctgFreeTasks
(
SArray
*
pArray
)
{
if
(
NULL
==
pArray
)
{
return
;
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
0f148c6f
...
...
@@ -1081,15 +1081,6 @@ end:
return
code
;
}
static
int32_t
cloneTableMeta
(
STableMeta
*
pSrc
,
STableMeta
**
pDst
)
{
*
pDst
=
taosMemoryMalloc
(
TABLE_META_SIZE
(
pSrc
));
if
(
NULL
==
*
pDst
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
memcpy
(
*
pDst
,
pSrc
,
TABLE_META_SIZE
(
pSrc
));
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
storeTableMeta
(
SInsertParseContext
*
pCxt
,
SHashObj
*
pHash
,
SName
*
pTableName
,
const
char
*
pName
,
int32_t
len
,
STableMeta
*
pMeta
)
{
SVgroupInfo
vg
;
...
...
source/libs/qcom/src/queryUtil.c
浏览文件 @
0f148c6f
...
...
@@ -373,3 +373,57 @@ end:
}
int32_t
cloneTableMeta
(
STableMeta
*
pSrc
,
STableMeta
**
pDst
)
{
if
(
NULL
==
pSrc
)
{
*
pDst
=
NULL
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
metaSize
=
(
pSrc
->
tableInfo
.
numOfColumns
+
pSrc
->
tableInfo
.
numOfTags
)
*
sizeof
(
SSchema
);
*
pDst
=
taosMemoryMalloc
(
metaSize
);
if
(
NULL
==
*
pDst
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
memcpy
(
*
pDst
,
pSrc
,
metaSize
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
cloneDbVgInfo
(
SDBVgInfo
*
pSrc
,
SDBVgInfo
**
pDst
)
{
if
(
NULL
==
pSrc
)
{
*
pDst
=
NULL
;
return
TSDB_CODE_SUCCESS
;
}
*
pDst
=
taosMemoryMalloc
(
sizeof
(
*
pSrc
));
if
(
NULL
==
*
pDst
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
memcpy
(
*
pDst
,
pSrc
,
sizeof
(
*
pSrc
));
if
(
pSrc
->
vgHash
)
{
(
*
pDst
)
->
vgHash
=
taosHashInit
(
taosHashGetSize
(
pSrc
->
vgHash
),
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
(
*
pDst
)
->
vgHash
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
SVgroupInfo
*
vgInfo
=
NULL
;
void
*
pIter
=
taosHashIterate
(
pSrc
->
vgHash
,
NULL
);
while
(
pIter
)
{
vgInfo
=
pIter
;
int32_t
*
vgId
=
taosHashGetKey
(
pIter
,
NULL
);
if
(
0
!=
taosHashPut
((
*
pDst
)
->
vgHash
,
vgId
,
sizeof
(
*
vgId
),
vgInfo
,
sizeof
(
*
vgInfo
)))
{
qError
(
"taosHashPut failed, vgId:%d"
,
vgInfo
->
vgId
);
taosHashCancelIterate
(
pSrc
->
vgHash
,
pIter
);
taosHashCleanup
((
*
pDst
)
->
vgHash
);
taosMemoryFreeClear
(
*
pDst
);
return
TSDB_CODE_CTG_MEM_ERROR
;
}
pIter
=
taosHashIterate
(
pSrc
->
vgHash
,
pIter
);
}
}
return
TSDB_CODE_SUCCESS
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录