Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c584a884
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
提交
c584a884
编写于
1月 07, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
d3c67de0
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
100 addition
and
32 deletion
+100
-32
include/libs/qcom/query.h
include/libs/qcom/query.h
+13
-1
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+2
-1
source/dnode/vnode/impl/src/vnodeQuery.c
source/dnode/vnode/impl/src/vnodeQuery.c
+3
-0
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+8
-1
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+70
-25
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+1
-1
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+3
-3
未找到文件。
include/libs/qcom/query.h
浏览文件 @
c584a884
...
@@ -87,8 +87,15 @@ typedef struct SUseDbOutput {
...
@@ -87,8 +87,15 @@ typedef struct SUseDbOutput {
SDBVgroupInfo
dbVgroup
;
SDBVgroupInfo
dbVgroup
;
}
SUseDbOutput
;
}
SUseDbOutput
;
typedef
enum
{
META_TYPE_NON_TABLE
=
1
,
META_TYPE_CTABLE
,
META_TYPE_TABLE
,
META_TYPE_BOTH_TABLE
,
};
typedef
struct
STableMetaOutput
{
typedef
struct
STableMetaOutput
{
int32_t
meta
Num
;
int32_t
meta
Type
;
char
ctbFname
[
TSDB_TABLE_FNAME_LEN
];
char
ctbFname
[
TSDB_TABLE_FNAME_LEN
];
char
tbFname
[
TSDB_TABLE_FNAME_LEN
];
char
tbFname
[
TSDB_TABLE_FNAME_LEN
];
SCTableMeta
ctbMeta
;
SCTableMeta
ctbMeta
;
...
@@ -150,6 +157,11 @@ void initQueryModuleMsgHandle();
...
@@ -150,6 +157,11 @@ void initQueryModuleMsgHandle();
extern
int32_t
(
*
queryBuildMsg
[
TDMT_MAX
])(
void
*
input
,
char
**
msg
,
int32_t
msgSize
,
int32_t
*
msgLen
);
extern
int32_t
(
*
queryBuildMsg
[
TDMT_MAX
])(
void
*
input
,
char
**
msg
,
int32_t
msgSize
,
int32_t
*
msgLen
);
extern
int32_t
(
*
queryProcessMsgRsp
[
TDMT_MAX
])(
void
*
output
,
char
*
msg
,
int32_t
msgSize
);
extern
int32_t
(
*
queryProcessMsgRsp
[
TDMT_MAX
])(
void
*
output
,
char
*
msg
,
int32_t
msgSize
);
#define SET_META_TYPE_NONE(t) (t) = META_TYPE_NON_TABLE
#define SET_META_TYPE_CTABLE(t) (t) = META_TYPE_CTABLE
#define SET_META_TYPE_TABLE(t) (t) = META_TYPE_TABLE
#define SET_META_TYPE_BOTH_TABLE(t) (t) = META_TYPE_BOTH_TABLE
#define qFatal(...) do { if (qDebugFlag & DEBUG_FATAL) { taosPrintLog("QRY FATAL ", qDebugFlag, __VA_ARGS__); }} while(0)
#define qFatal(...) do { if (qDebugFlag & DEBUG_FATAL) { taosPrintLog("QRY FATAL ", qDebugFlag, __VA_ARGS__); }} while(0)
#define qError(...) do { if (qDebugFlag & DEBUG_ERROR) { taosPrintLog("QRY ERROR ", qDebugFlag, __VA_ARGS__); }} while(0)
#define qError(...) do { if (qDebugFlag & DEBUG_ERROR) { taosPrintLog("QRY ERROR ", qDebugFlag, __VA_ARGS__); }} while(0)
#define qWarn(...) do { if (qDebugFlag & DEBUG_WARN) { taosPrintLog("QRY WARN ", qDebugFlag, __VA_ARGS__); }} while(0)
#define qWarn(...) do { if (qDebugFlag & DEBUG_WARN) { taosPrintLog("QRY WARN ", qDebugFlag, __VA_ARGS__); }} while(0)
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
c584a884
...
@@ -769,7 +769,8 @@ static int32_t mndProcessStbMetaMsg(SMnodeMsg *pMsg) {
...
@@ -769,7 +769,8 @@ static int32_t mndProcessStbMetaMsg(SMnodeMsg *pMsg) {
pMeta
->
tableType
=
TSDB_SUPER_TABLE
;
pMeta
->
tableType
=
TSDB_SUPER_TABLE
;
pMeta
->
update
=
pDb
->
cfg
.
update
;
pMeta
->
update
=
pDb
->
cfg
.
update
;
pMeta
->
sversion
=
htonl
(
pStb
->
version
);
pMeta
->
sversion
=
htonl
(
pStb
->
version
);
pMeta
->
suid
=
htonl
(
pStb
->
uid
);
pMeta
->
suid
=
htobe64
(
pStb
->
uid
);
pMeta
->
tuid
=
htobe64
(
pStb
->
uid
);
for
(
int32_t
i
=
0
;
i
<
totalCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
totalCols
;
++
i
)
{
SSchema
*
pSchema
=
&
pMeta
->
pSchema
[
i
];
SSchema
*
pSchema
=
&
pMeta
->
pSchema
[
i
];
...
...
source/dnode/vnode/impl/src/vnodeQuery.c
浏览文件 @
c584a884
...
@@ -105,6 +105,9 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -105,6 +105,9 @@ static int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
strcpy
(
pTbMetaMsg
->
stbFname
,
pStbCfg
->
name
);
strcpy
(
pTbMetaMsg
->
stbFname
,
pStbCfg
->
name
);
pTbMetaMsg
->
suid
=
htobe64
(
pTbCfg
->
ctbCfg
.
suid
);
pTbMetaMsg
->
suid
=
htobe64
(
pTbCfg
->
ctbCfg
.
suid
);
}
else
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
strcpy
(
pTbMetaMsg
->
stbFname
,
pTbCfg
->
name
);
pTbMetaMsg
->
suid
=
htobe64
(
uid
);
}
}
pTbMetaMsg
->
numOfTags
=
htonl
(
nTagCols
);
pTbMetaMsg
->
numOfTags
=
htonl
(
nTagCols
);
pTbMetaMsg
->
numOfColumns
=
htonl
(
nCols
);
pTbMetaMsg
->
numOfColumns
=
htonl
(
nCols
);
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
c584a884
...
@@ -35,6 +35,8 @@ extern "C" {
...
@@ -35,6 +35,8 @@ extern "C" {
#define CTG_DEFAULT_INVALID_VERSION (-1)
#define CTG_DEFAULT_INVALID_VERSION (-1)
#define CTG_ERR_CODE_TABLE_NOT_EXIST TSDB_CODE_TDB_INVALID_TABLE_ID
enum
{
enum
{
CTG_READ
=
1
,
CTG_READ
=
1
,
CTG_WRITE
,
CTG_WRITE
,
...
@@ -88,13 +90,18 @@ typedef struct SCatalogMgmt {
...
@@ -88,13 +90,18 @@ typedef struct SCatalogMgmt {
typedef
uint32_t
(
*
tableNameHashFp
)(
const
char
*
,
uint32_t
);
typedef
uint32_t
(
*
tableNameHashFp
)(
const
char
*
,
uint32_t
);
#define CTG_IS_META_NONE(type) ((type) == META_TYPE_NON_TABLE)
#define CTG_IS_META_CTABLE(type) ((type) == META_TYPE_CTABLE)
#define CTG_IS_META_TABLE(type) ((type) == META_TYPE_TABLE)
#define CTG_IS_META_BOTH(type) ((type) == META_TYPE_BOTH_TABLE)
#define CTG_IS_STABLE(isSTable) (1 == (isSTable))
#define CTG_IS_STABLE(isSTable) (1 == (isSTable))
#define CTG_IS_NOT_STABLE(isSTable) (0 == (isSTable))
#define CTG_IS_NOT_STABLE(isSTable) (0 == (isSTable))
#define CTG_IS_UNKNOWN_STABLE(isSTable) ((isSTable) < 0)
#define CTG_IS_UNKNOWN_STABLE(isSTable) ((isSTable) < 0)
#define CTG_SET_STABLE(isSTable, tbType) do { (isSTable) = ((tbType) == TSDB_SUPER_TABLE) ? 1 : ((tbType) > TSDB_SUPER_TABLE ? 0 : -1); } while (0)
#define CTG_SET_STABLE(isSTable, tbType) do { (isSTable) = ((tbType) == TSDB_SUPER_TABLE) ? 1 : ((tbType) > TSDB_SUPER_TABLE ? 0 : -1); } while (0)
#define CTG_TBTYPE_MATCH(isSTable, tbType) (CTG_IS_UNKNOWN_STABLE(isSTable) || (CTG_IS_STABLE(isSTable) && (tbType) == TSDB_SUPER_TABLE) || (CTG_IS_NOT_STABLE(isSTable) && (tbType) != TSDB_SUPER_TABLE))
#define CTG_TBTYPE_MATCH(isSTable, tbType) (CTG_IS_UNKNOWN_STABLE(isSTable) || (CTG_IS_STABLE(isSTable) && (tbType) == TSDB_SUPER_TABLE) || (CTG_IS_NOT_STABLE(isSTable) && (tbType) != TSDB_SUPER_TABLE))
#define CTG_TABLE_NOT_EXIST(code) (code ==
TSDB_CODE_TDB_INVALID_TABLE_ID
)
#define CTG_TABLE_NOT_EXIST(code) (code ==
CTG_ERR_CODE_TABLE_NOT_EXIST
)
#define ctgFatal(param, ...) qFatal("CTG:%p " param, pCatalog, __VA_ARGS__)
#define ctgFatal(param, ...) qFatal("CTG:%p " param, pCatalog, __VA_ARGS__)
#define ctgError(param, ...) qError("CTG:%p " param, pCatalog, __VA_ARGS__)
#define ctgError(param, ...) qError("CTG:%p " param, pCatalog, __VA_ARGS__)
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
c584a884
...
@@ -96,6 +96,29 @@ int32_t ctgGetDBVgroupFromMnode(struct SCatalog* pCatalog, void *pRpc, const SEp
...
@@ -96,6 +96,29 @@ int32_t ctgGetDBVgroupFromMnode(struct SCatalog* pCatalog, void *pRpc, const SEp
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgIsTableMetaExistInCache
(
struct
SCatalog
*
pCatalog
,
const
char
*
tbFullName
,
int32_t
*
exist
)
{
if
(
NULL
==
pCatalog
->
tableCache
.
cache
)
{
*
exist
=
0
;
ctgWarn
(
"empty tablemeta cache, tbName:%s"
,
tbFullName
);
return
TSDB_CODE_SUCCESS
;
}
size_t
sz
=
0
;
STableMeta
*
tbMeta
=
taosHashGet
(
pCatalog
->
tableCache
.
cache
,
tbFullName
,
strlen
(
tbFullName
));
if
(
NULL
==
tbMeta
)
{
*
exist
=
0
;
ctgDebug
(
"tablemeta not in cache, tbName:%s"
,
tbFullName
);
return
TSDB_CODE_SUCCESS
;
}
*
exist
=
1
;
ctgDebug
(
"tablemeta is in cache, tbName:%s"
,
tbFullName
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgGetTableMetaFromCache
(
struct
SCatalog
*
pCatalog
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
*
exist
)
{
int32_t
ctgGetTableMetaFromCache
(
struct
SCatalog
*
pCatalog
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
*
exist
)
{
if
(
NULL
==
pCatalog
->
tableCache
.
cache
)
{
if
(
NULL
==
pCatalog
->
tableCache
.
cache
)
{
...
@@ -201,7 +224,7 @@ void ctgGenEpSet(SEpSet *epSet, SVgroupInfo *vgroupInfo) {
...
@@ -201,7 +224,7 @@ void ctgGenEpSet(SEpSet *epSet, SVgroupInfo *vgroupInfo) {
}
}
}
}
int32_t
ctgGetTableMetaFromMnodeImpl
(
struct
SCatalog
*
pCatalog
,
void
*
p
Rpc
,
const
SEpSet
*
pMgmtEps
,
char
*
tbFullName
,
STableMetaOutput
*
output
)
{
int32_t
ctgGetTableMetaFromMnodeImpl
(
struct
SCatalog
*
pCatalog
,
void
*
p
Transporter
,
const
SEpSet
*
pMgmtEps
,
char
*
tbFullName
,
STableMetaOutput
*
output
)
{
SBuildTableMetaInput
bInput
=
{.
vgId
=
0
,
.
dbName
=
NULL
,
.
tableFullName
=
tbFullName
};
SBuildTableMetaInput
bInput
=
{.
vgId
=
0
,
.
dbName
=
NULL
,
.
tableFullName
=
tbFullName
};
char
*
msg
=
NULL
;
char
*
msg
=
NULL
;
SEpSet
*
pVnodeEpSet
=
NULL
;
SEpSet
*
pVnodeEpSet
=
NULL
;
...
@@ -223,11 +246,11 @@ int32_t ctgGetTableMetaFromMnodeImpl(struct SCatalog* pCatalog, void *pRpc, cons
...
@@ -223,11 +246,11 @@ int32_t ctgGetTableMetaFromMnodeImpl(struct SCatalog* pCatalog, void *pRpc, cons
SRpcMsg
rpcRsp
=
{
0
};
SRpcMsg
rpcRsp
=
{
0
};
rpcSendRecv
(
p
Rpc
,
(
SEpSet
*
)
pMgmtEps
,
&
rpcMsg
,
&
rpcRsp
);
rpcSendRecv
(
p
Transporter
,
(
SEpSet
*
)
pMgmtEps
,
&
rpcMsg
,
&
rpcRsp
);
if
(
TSDB_CODE_SUCCESS
!=
rpcRsp
.
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
rpcRsp
.
code
)
{
if
(
CTG_TABLE_NOT_EXIST
(
rpcRsp
.
code
))
{
if
(
CTG_TABLE_NOT_EXIST
(
rpcRsp
.
code
))
{
output
->
metaNum
=
0
;
SET_META_TYPE_NONE
(
output
->
metaType
)
;
ctgDebug
(
"stablemeta not exist in mnode, tbName:%s"
,
tbFullName
);
ctgDebug
(
"stablemeta not exist in mnode, tbName:%s"
,
tbFullName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -247,15 +270,15 @@ int32_t ctgGetTableMetaFromMnodeImpl(struct SCatalog* pCatalog, void *pRpc, cons
...
@@ -247,15 +270,15 @@ int32_t ctgGetTableMetaFromMnodeImpl(struct SCatalog* pCatalog, void *pRpc, cons
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
ctgGetTableMetaFromMnode
(
struct
SCatalog
*
pCatalog
,
void
*
p
Rpc
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMetaOutput
*
output
)
{
int32_t
ctgGetTableMetaFromMnode
(
struct
SCatalog
*
pCatalog
,
void
*
p
Transporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
STableMetaOutput
*
output
)
{
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
tNameExtractFullName
(
pTableName
,
tbFullName
);
tNameExtractFullName
(
pTableName
,
tbFullName
);
return
ctgGetTableMetaFromMnodeImpl
(
pCatalog
,
p
Rpc
,
pMgmtEps
,
tbFullName
,
output
);
return
ctgGetTableMetaFromMnodeImpl
(
pCatalog
,
p
Transporter
,
pMgmtEps
,
tbFullName
,
output
);
}
}
int32_t
ctgGetTableMetaFromVnode
(
struct
SCatalog
*
pCatalog
,
void
*
p
Rpc
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
SVgroupInfo
*
vgroupInfo
,
STableMetaOutput
*
output
)
{
int32_t
ctgGetTableMetaFromVnode
(
struct
SCatalog
*
pCatalog
,
void
*
p
Transporter
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
SVgroupInfo
*
vgroupInfo
,
STableMetaOutput
*
output
)
{
if
(
NULL
==
pCatalog
||
NULL
==
p
Rpc
||
NULL
==
pMgmtEps
||
NULL
==
pTableName
||
NULL
==
vgroupInfo
||
NULL
==
output
)
{
if
(
NULL
==
pCatalog
||
NULL
==
p
Transporter
||
NULL
==
pMgmtEps
||
NULL
==
pTableName
||
NULL
==
vgroupInfo
||
NULL
==
output
)
{
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
}
...
@@ -285,11 +308,11 @@ int32_t ctgGetTableMetaFromVnode(struct SCatalog* pCatalog, void *pRpc, const SE
...
@@ -285,11 +308,11 @@ int32_t ctgGetTableMetaFromVnode(struct SCatalog* pCatalog, void *pRpc, const SE
SEpSet
epSet
;
SEpSet
epSet
;
ctgGenEpSet
(
&
epSet
,
vgroupInfo
);
ctgGenEpSet
(
&
epSet
,
vgroupInfo
);
rpcSendRecv
(
p
Rpc
,
&
epSet
,
&
rpcMsg
,
&
rpcRsp
);
rpcSendRecv
(
p
Transporter
,
&
epSet
,
&
rpcMsg
,
&
rpcRsp
);
if
(
TSDB_CODE_SUCCESS
!=
rpcRsp
.
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
rpcRsp
.
code
)
{
if
(
CTG_TABLE_NOT_EXIST
(
rpcRsp
.
code
))
{
if
(
CTG_TABLE_NOT_EXIST
(
rpcRsp
.
code
))
{
output
->
metaNum
=
0
;
SET_META_TYPE_NONE
(
output
->
metaType
)
;
ctgDebug
(
"tablemeta not exist in vnode, tbName:%s"
,
pTableName
->
tname
);
ctgDebug
(
"tablemeta not exist in vnode, tbName:%s"
,
pTableName
->
tname
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -589,11 +612,6 @@ int32_t ctgMetaRentGet(SMetaRentMgmt *mgmt, void **res, uint32_t *num, int32_t s
...
@@ -589,11 +612,6 @@ int32_t ctgMetaRentGet(SMetaRentMgmt *mgmt, void **res, uint32_t *num, int32_t s
int32_t
ctgUpdateTableMetaCache
(
struct
SCatalog
*
pCatalog
,
STableMetaOutput
*
output
)
{
int32_t
ctgUpdateTableMetaCache
(
struct
SCatalog
*
pCatalog
,
STableMetaOutput
*
output
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
if
(
output
->
metaNum
!=
1
&&
output
->
metaNum
!=
2
)
{
ctgError
(
"invalid table meta number in meta rsp, num:%d"
,
output
->
metaNum
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
if
(
NULL
==
output
->
tbMeta
)
{
if
(
NULL
==
output
->
tbMeta
)
{
ctgError
(
"no valid table meta got from meta rsp, tbName:%s"
,
output
->
tbFname
);
ctgError
(
"no valid table meta got from meta rsp, tbName:%s"
,
output
->
tbFname
);
...
@@ -624,19 +642,23 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out
...
@@ -624,19 +642,23 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out
}
}
}
}
if
(
output
->
metaNum
==
2
)
{
if
(
CTG_IS_META_CTABLE
(
output
->
metaType
)
||
CTG_IS_META_BOTH
(
output
->
metaType
)
)
{
if
(
taosHashPut
(
pCatalog
->
tableCache
.
cache
,
output
->
ctbFname
,
strlen
(
output
->
ctbFname
),
&
output
->
ctbMeta
,
sizeof
(
output
->
ctbMeta
))
!=
0
)
{
if
(
taosHashPut
(
pCatalog
->
tableCache
.
cache
,
output
->
ctbFname
,
strlen
(
output
->
ctbFname
),
&
output
->
ctbMeta
,
sizeof
(
output
->
ctbMeta
))
!=
0
)
{
ctgError
(
"taosHashPut ctablemeta to cache failed, ctbName:%s"
,
output
->
ctbFname
);
ctgError
(
"taosHashPut ctablemeta to cache failed, ctbName:%s"
,
output
->
ctbFname
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
ctgDebug
(
"update tablemeta to cache, tbName:%s"
,
output
->
ctbFname
);
ctgDebug
(
"update child tablemeta to cache, tbName:%s"
,
output
->
ctbFname
);
}
if
(
TSDB_SUPER_TABLE
!=
output
->
tbMeta
->
tableType
)
{
if
(
CTG_IS_META_CTABLE
(
output
->
metaType
))
{
ctgError
(
"table type error, expected:%d, actual:%d"
,
TSDB_SUPER_TABLE
,
output
->
tbMeta
->
tableType
);
return
TSDB_CODE_SUCCESS
;
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
}
if
(
CTG_IS_META_BOTH
(
output
->
metaType
)
&&
TSDB_SUPER_TABLE
!=
output
->
tbMeta
->
tableType
)
{
ctgError
(
"table type error, expected:%d, actual:%d"
,
TSDB_SUPER_TABLE
,
output
->
tbMeta
->
tableType
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
int32_t
tbSize
=
sizeof
(
*
output
->
tbMeta
)
+
sizeof
(
SSchema
)
*
(
output
->
tbMeta
->
tableInfo
.
numOfColumns
+
output
->
tbMeta
->
tableInfo
.
numOfTags
);
int32_t
tbSize
=
sizeof
(
*
output
->
tbMeta
)
+
sizeof
(
SSchema
)
*
(
output
->
tbMeta
->
tableInfo
.
numOfColumns
+
output
->
tbMeta
->
tableInfo
.
numOfTags
);
...
@@ -757,30 +779,53 @@ int32_t ctgRenewTableMetaImpl(struct SCatalog* pCatalog, void *pTransporter, con
...
@@ -757,30 +779,53 @@ int32_t ctgRenewTableMetaImpl(struct SCatalog* pCatalog, void *pTransporter, con
if
(
CTG_IS_STABLE
(
isSTable
))
{
if
(
CTG_IS_STABLE
(
isSTable
))
{
ctgDebug
(
"will renew table meta, supposed to be stable, tbName:%s"
,
pTableName
->
tname
);
ctgDebug
(
"will renew table meta, supposed to be stable, tbName:%s"
,
pTableName
->
tname
);
// if get from mnode failed, will not try vnode
CTG_ERR_JRET
(
ctgGetTableMetaFromMnode
(
pCatalog
,
pTransporter
,
pMgmtEps
,
pTableName
,
&
moutput
));
CTG_ERR_JRET
(
ctgGetTableMetaFromMnode
(
pCatalog
,
pTransporter
,
pMgmtEps
,
pTableName
,
&
moutput
));
if
(
0
==
moutput
.
metaNum
)
{
if
(
CTG_IS_META_NONE
(
moutput
.
metaType
)
)
{
CTG_ERR_JRET
(
ctgGetTableMetaFromVnode
(
pCatalog
,
pTransporter
,
pMgmtEps
,
pTableName
,
&
vgroupInfo
,
&
voutput
));
CTG_ERR_JRET
(
ctgGetTableMetaFromVnode
(
pCatalog
,
pTransporter
,
pMgmtEps
,
pTableName
,
&
vgroupInfo
,
&
voutput
));
}
else
{
}
else
{
output
=
&
moutput
;
output
=
&
moutput
;
}
}
}
else
{
}
else
{
ctgDebug
(
"will renew table meta, not supposed to be stable, tbName:%s, isStable:%d"
,
pTableName
->
tname
,
isSTable
);
ctgDebug
(
"will renew table meta, not supposed to be stable, tbName:%s, isStable:%d"
,
pTableName
->
tname
,
isSTable
);
// if get from vnode failed or no table meta, will not try mnode
CTG_ERR_JRET
(
ctgGetTableMetaFromVnode
(
pCatalog
,
pTransporter
,
pMgmtEps
,
pTableName
,
&
vgroupInfo
,
&
voutput
));
CTG_ERR_JRET
(
ctgGetTableMetaFromVnode
(
pCatalog
,
pTransporter
,
pMgmtEps
,
pTableName
,
&
vgroupInfo
,
&
voutput
));
if
(
voutput
.
metaNum
>
0
&&
TSDB_SUPER_TABLE
==
voutput
.
tbMeta
->
tableType
)
{
if
(
CTG_IS_META_TABLE
(
voutput
.
metaType
)
&&
TSDB_SUPER_TABLE
==
voutput
.
tbMeta
->
tableType
)
{
ctgDebug
(
"will continue to renew table meta since got stable, tbName:%s, meta
Num:%d"
,
pTableName
->
tname
,
voutput
.
metaNum
);
ctgDebug
(
"will continue to renew table meta since got stable, tbName:%s, meta
Type:%d"
,
pTableName
->
tname
,
voutput
.
metaType
);
CTG_ERR_JRET
(
ctgGetTableMetaFromMnodeImpl
(
pCatalog
,
pTransporter
,
pMgmtEps
,
voutput
.
tbFname
,
&
moutput
));
CTG_ERR_JRET
(
ctgGetTableMetaFromMnodeImpl
(
pCatalog
,
pTransporter
,
pMgmtEps
,
voutput
.
tbFname
,
&
moutput
));
tfree
(
voutput
.
tbMeta
);
tfree
(
voutput
.
tbMeta
);
voutput
.
tbMeta
=
moutput
.
tbMeta
;
voutput
.
tbMeta
=
moutput
.
tbMeta
;
moutput
.
tbMeta
=
NULL
;
moutput
.
tbMeta
=
NULL
;
}
else
if
(
CTG_IS_META_BOTH
(
voutput
.
metaType
))
{
int32_t
exist
=
0
;
CTG_ERR_JRET
(
ctgIsTableMetaExistInCache
(
pCatalog
,
voutput
.
tbFname
,
&
exist
));
if
(
0
==
exist
)
{
CTG_ERR_JRET
(
ctgGetTableMetaFromMnodeImpl
(
pCatalog
,
pTransporter
,
pMgmtEps
,
voutput
.
tbFname
,
&
moutput
));
if
(
CTG_IS_META_NONE
(
moutput
.
metaType
))
{
SET_META_TYPE_NONE
(
voutput
.
metaType
);
}
tfree
(
voutput
.
tbMeta
);
voutput
.
tbMeta
=
moutput
.
tbMeta
;
moutput
.
tbMeta
=
NULL
;
}
else
{
SET_META_TYPE_CTABLE
(
voutput
.
metaType
);
}
}
}
}
}
if
(
CTG_IS_META_NONE
(
output
->
metaType
))
{
ctgError
(
"no tablemeta got, tbNmae:%s"
,
pTableName
->
tname
);
CTG_ERR_JRET
(
CTG_ERR_CODE_TABLE_NOT_EXIST
);
}
CTG_ERR_JRET
(
ctgUpdateTableMetaCache
(
pCatalog
,
output
));
CTG_ERR_JRET
(
ctgUpdateTableMetaCache
(
pCatalog
,
output
));
_return:
_return:
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
c584a884
...
@@ -128,7 +128,7 @@ void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) {
...
@@ -128,7 +128,7 @@ void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) {
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
tNameExtractFullName
(
&
cn
,
tbFullName
);
tNameExtractFullName
(
&
cn
,
tbFullName
);
output
->
metaNum
=
2
;
SET_META_TYPE_BOTH_TABLE
(
output
->
metaType
)
;
strcpy
(
output
->
ctbFname
,
tbFullName
);
strcpy
(
output
->
ctbFname
,
tbFullName
);
...
...
source/libs/qcom/src/querymsg.c
浏览文件 @
c584a884
...
@@ -210,7 +210,7 @@ int32_t queryCreateTableMetaFromMsg(STableMetaMsg* msg, bool isSuperTable, STabl
...
@@ -210,7 +210,7 @@ int32_t queryCreateTableMetaFromMsg(STableMetaMsg* msg, bool isSuperTable, STabl
pTableMeta
->
vgId
=
isSuperTable
?
0
:
msg
->
vgId
;
pTableMeta
->
vgId
=
isSuperTable
?
0
:
msg
->
vgId
;
pTableMeta
->
tableType
=
isSuperTable
?
TSDB_SUPER_TABLE
:
msg
->
tableType
;
pTableMeta
->
tableType
=
isSuperTable
?
TSDB_SUPER_TABLE
:
msg
->
tableType
;
pTableMeta
->
uid
=
msg
->
tuid
;
pTableMeta
->
uid
=
isSuperTable
?
msg
->
suid
:
msg
->
tuid
;
pTableMeta
->
suid
=
msg
->
suid
;
pTableMeta
->
suid
=
msg
->
suid
;
pTableMeta
->
sversion
=
msg
->
sversion
;
pTableMeta
->
sversion
=
msg
->
sversion
;
pTableMeta
->
tversion
=
msg
->
tversion
;
pTableMeta
->
tversion
=
msg
->
tversion
;
...
@@ -246,7 +246,7 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) {
...
@@ -246,7 +246,7 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) {
}
}
if
(
pMetaMsg
->
tableType
==
TSDB_CHILD_TABLE
)
{
if
(
pMetaMsg
->
tableType
==
TSDB_CHILD_TABLE
)
{
pOut
->
metaNum
=
2
;
SET_META_TYPE_BOTH_TABLE
(
pOut
->
metaType
)
;
if
(
pMetaMsg
->
dbFname
[
0
])
{
if
(
pMetaMsg
->
dbFname
[
0
])
{
snprintf
(
pOut
->
ctbFname
,
sizeof
(
pOut
->
ctbFname
),
"%s.%s"
,
pMetaMsg
->
dbFname
,
pMetaMsg
->
tbFname
);
snprintf
(
pOut
->
ctbFname
,
sizeof
(
pOut
->
ctbFname
),
"%s.%s"
,
pMetaMsg
->
dbFname
,
pMetaMsg
->
tbFname
);
...
@@ -263,7 +263,7 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) {
...
@@ -263,7 +263,7 @@ int32_t queryProcessTableMetaRsp(void* output, char *msg, int32_t msgSize) {
code
=
queryCreateTableMetaFromMsg
(
pMetaMsg
,
true
,
&
pOut
->
tbMeta
);
code
=
queryCreateTableMetaFromMsg
(
pMetaMsg
,
true
,
&
pOut
->
tbMeta
);
}
else
{
}
else
{
pOut
->
metaNum
=
1
;
SET_META_TYPE_TABLE
(
pOut
->
metaType
)
;
if
(
pMetaMsg
->
dbFname
[
0
])
{
if
(
pMetaMsg
->
dbFname
[
0
])
{
snprintf
(
pOut
->
tbFname
,
sizeof
(
pOut
->
tbFname
),
"%s.%s"
,
pMetaMsg
->
dbFname
,
pMetaMsg
->
tbFname
);
snprintf
(
pOut
->
tbFname
,
sizeof
(
pOut
->
tbFname
),
"%s.%s"
,
pMetaMsg
->
dbFname
,
pMetaMsg
->
tbFname
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录