Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d962a271
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看板
提交
d962a271
编写于
12月 11, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
catalog init version
上级
a9f9194a
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
63 addition
and
38 deletion
+63
-38
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+23
-10
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+6
-2
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+10
-2
source/libs/parser/inc/parserInt.h
source/libs/parser/inc/parserInt.h
+2
-2
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+3
-3
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+3
-3
source/libs/parser/test/parserTests.cpp
source/libs/parser/test/parserTests.cpp
+12
-12
source/libs/parser/test/plannerTest.cpp
source/libs/parser/test/plannerTest.cpp
+3
-3
source/libs/parser/test/tokenizerTest.cpp
source/libs/parser/test/tokenizerTest.cpp
+1
-1
未找到文件。
include/libs/catalog/catalog.h
浏览文件 @
d962a271
...
...
@@ -30,19 +30,19 @@ extern "C" {
struct
SCatalog
;
typedef
struct
S
Meta
Req
{
typedef
struct
S
Catalog
Req
{
char
clusterId
[
TSDB_CLUSTER_ID_LEN
];
SArray
*
pTableName
;
// table full name
SArray
*
pUdf
;
// udf name
bool
qNodeEpset
;
// valid qnode
}
S
Meta
Req
;
}
S
Catalog
Req
;
typedef
struct
S
MetaData
{
typedef
struct
S
CatalogRsp
{
SArray
*
pTableMeta
;
// tableMeta
SArray
*
pVgroupInfo
;
// vgroupInfo list
SArray
*
pUdfList
;
// udf info list
SEpSet
*
pEpSet
;
// qnode epset list
}
S
MetaData
;
}
S
CatalogRsp
;
typedef
struct
STableComInfo
{
uint8_t
numOfTags
;
// the number of tags in schema
...
...
@@ -78,32 +78,45 @@ typedef struct STableMeta {
SSchema
schema
[];
}
STableMeta
;
typedef
struct
SCatalogCfg
{
}
SCatalogCfg
;
int32_t
catalogInit
(
SCatalog
*
cfg
);
/**
* Catalog service object, which is utilized to hold tableMeta (meta/vgroupInfo/udfInfo) at the client-side.
* There is ONLY one SCatalog object for one process space, and this function returns a singleton.
* @param
pMgmtEps
* @param
clusterId
* @return
*/
struct
SCatalog
*
getCatalogHandle
(
const
SEpSet
*
pMgmtEps
);
struct
SCatalog
*
catalogGetHandle
(
const
char
*
clusterId
);
/**
* Get the required meta data from mnode.
* Note that this is a synchronized API and is also thread-safety.
* @param pCatalog
* @param pMgmtEps
* @param pMetaReq
* @param pMetaData
* @return
*/
int32_t
catalogGetMetaData
(
struct
SCatalog
*
pCatalog
,
const
SMetaReq
*
pMetaReq
,
SMetaData
*
pMetaData
);
int32_t
catalogGetAllMeta
(
struct
SCatalog
*
pCatalog
,
const
SEpSet
*
pMgmtEps
,
const
SCatalogReq
*
pCatalogReq
,
SCatalogRsp
*
pCatalogData
);
int32_t
catalogRenewTableMeta
(
struct
SCatalog
*
pCatalog
,
const
SEpSet
*
pMgmtEps
,
const
STableMeta
*
pTableMeta
);
int32_t
catalogRenewAndGetTableMeta
(
struct
SCatalog
*
pCatalog
,
const
SEpSet
*
pMgmtEps
,
const
STableMeta
*
pTableMeta
,
SCatalogRsp
*
pCatalogData
);
/**
* Destroy catalog
service handle
* Destroy catalog
and relase all resources
* @param pCatalog
*/
void
destroyCatalog
(
struct
SCatalog
*
pCatalog
);
void
catalogDestroy
(
void
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_CATALOG_H_*/
\ No newline at end of file
#endif
/*_TD_CATALOG_H_*/
source/libs/catalog/inc/catalogInt.h
浏览文件 @
d962a271
...
...
@@ -23,10 +23,14 @@ extern "C" {
#include "catalog.h"
typedef
struct
SCatalog
{
void
*
pMsgSender
;
// used to send messsage to mnode to fetch necessary metadata
SHashObj
*
pData
;
// items cached for each cluster, the hash key is the cluster-id, returned by mgmt node
}
SCatalog
;
typedef
struct
SCatalogMgmt
{
void
*
pMsgSender
;
// used to send messsage to mnode to fetch necessary metadata
SHashObj
*
pMeta
;
// items cached for each cluster, the hash key is the cluster-id, returned by mgmt node
}
SCatalogMgmt
;
#ifdef __cplusplus
}
#endif
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
d962a271
...
...
@@ -15,10 +15,18 @@
#include "catalogInt.h"
struct
SCatalog
*
getCatalogHandle
(
const
SEpSet
*
pMgmtEps
)
{
SCatalogMgmt
ctgMgmt
=
{
0
};
int32_t
catalogInit
(
SCatalog
*
cfg
)
{
ctgMgmt
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
}
struct
SCatalog
*
catalogGetHandle
(
const
char
*
clusterId
)
{
return
(
struct
SCatalog
*
)
0x1
;
}
int32_t
catalogGet
MetaData
(
struct
SCatalog
*
pCatalog
,
const
SMetaReq
*
pMetaReq
,
SMetaData
*
pMetaData
)
{
int32_t
catalogGet
AllMeta
(
struct
SCatalog
*
pCatalog
,
const
SEpSet
*
pMgmtEps
,
const
SCatalogReq
*
pMetaReq
,
SCatalogRsp
*
pMetaData
)
{
return
0
;
}
source/libs/parser/inc/parserInt.h
浏览文件 @
d962a271
...
...
@@ -87,13 +87,13 @@ int32_t checkForInvalidExpr(SQueryStmtInfo* pQueryInfo, SMsgBuf* pMsgBuf);
* @param msgBufLen
* @return
*/
int32_t
qParserExtractRequestedMetaInfo
(
const
SSqlInfo
*
pSqlInfo
,
S
Meta
Req
*
pMetaInfo
,
char
*
msg
,
int32_t
msgBufLen
);
int32_t
qParserExtractRequestedMetaInfo
(
const
SSqlInfo
*
pSqlInfo
,
S
Catalog
Req
*
pMetaInfo
,
char
*
msg
,
int32_t
msgBufLen
);
/**
* Destroy the meta data request structure.
* @param pMetaInfo
*/
void
qParserClearupMetaRequestInfo
(
S
Meta
Req
*
pMetaInfo
);
void
qParserClearupMetaRequestInfo
(
S
Catalog
Req
*
pMetaInfo
);
#ifdef __cplusplus
}
...
...
source/libs/parser/src/astValidate.c
浏览文件 @
d962a271
...
...
@@ -4077,8 +4077,8 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
}
#endif
S
Meta
Req
req
=
{
0
};
S
MetaData
data
=
{
0
};
S
Catalog
Req
req
=
{
0
};
S
CatalogRsp
data
=
{
0
};
// TODO: check if the qnode info has been cached already
req
.
qNodeEpset
=
true
;
...
...
@@ -4088,7 +4088,7 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
}
// load the meta data from catalog
code
=
catalogGet
MetaData
(
pCatalog
,
&
req
,
&
data
);
code
=
catalogGet
AllMeta
(
pCatalog
,
NULL
,
&
req
,
&
data
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
source/libs/parser/src/parser.c
浏览文件 @
d962a271
...
...
@@ -42,7 +42,7 @@ int32_t qParseQuerySql(const char* pStr, size_t length, struct SQueryStmtInfo**
return
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
}
struct
SCatalog
*
pCatalog
=
getCatalog
Handle
(
NULL
);
struct
SCatalog
*
pCatalog
=
catalogGet
Handle
(
NULL
);
return
qParserValidateSqlNode
(
pCatalog
,
&
info
,
*
pQueryInfo
,
id
,
msg
,
msgLen
);
}
...
...
@@ -131,7 +131,7 @@ static void freePtrElem(void* p) {
tfree
(
*
(
char
**
)
p
);
}
int32_t
qParserExtractRequestedMetaInfo
(
const
SSqlInfo
*
pSqlInfo
,
S
Meta
Req
*
pMetaInfo
,
char
*
msg
,
int32_t
msgBufLen
)
{
int32_t
qParserExtractRequestedMetaInfo
(
const
SSqlInfo
*
pSqlInfo
,
S
Catalog
Req
*
pMetaInfo
,
char
*
msg
,
int32_t
msgBufLen
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SMsgBuf
msgBuf
=
{.
buf
=
msg
,
.
len
=
msgBufLen
};
...
...
@@ -188,7 +188,7 @@ int32_t qParserExtractRequestedMetaInfo(const SSqlInfo* pSqlInfo, SMetaReq* pMet
return
code
;
}
void
qParserClearupMetaRequestInfo
(
S
Meta
Req
*
pMetaReq
)
{
void
qParserClearupMetaRequestInfo
(
S
Catalog
Req
*
pMetaReq
)
{
if
(
pMetaReq
==
NULL
)
{
return
;
}
...
...
source/libs/parser/test/parserTests.cpp
浏览文件 @
d962a271
...
...
@@ -38,7 +38,7 @@ void setSchema(SSchema* p, int32_t type, int32_t bytes, const char* name, int32_
strcpy
(
p
->
name
,
name
);
}
void
setTableMetaInfo
(
SQueryStmtInfo
*
pQueryInfo
,
S
Meta
Req
*
req
)
{
void
setTableMetaInfo
(
SQueryStmtInfo
*
pQueryInfo
,
S
Catalog
Req
*
req
)
{
pQueryInfo
->
numOfTables
=
1
;
pQueryInfo
->
pTableMetaInfo
=
(
STableMetaInfo
**
)
calloc
(
1
,
POINTER_BYTES
);
...
...
@@ -80,7 +80,7 @@ void sqlCheck(const char* sql, bool valid) {
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
S
Meta
Req
req
=
{
0
};
S
Catalog
Req
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
@@ -117,7 +117,7 @@ TEST(testCase, validateAST_test) {
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
S
Meta
Req
req
=
{
0
};
S
Catalog
Req
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
@@ -175,7 +175,7 @@ TEST(testCase, function_Test) {
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
S
Meta
Req
req
=
{
0
};
S
Catalog
Req
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
@@ -221,7 +221,7 @@ TEST(testCase, function_Test2) {
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
S
Meta
Req
req
=
{
0
};
S
Catalog
Req
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
@@ -267,7 +267,7 @@ TEST(testCase, function_Test3) {
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
S
Meta
Req
req
=
{
0
};
S
Catalog
Req
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
@@ -312,7 +312,7 @@ TEST(testCase, function_Test4) {
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
S
Meta
Req
req
=
{
0
};
S
Catalog
Req
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
@@ -360,7 +360,7 @@ TEST(testCase, function_Test5) {
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
S
Meta
Req
req
=
{
0
};
S
Catalog
Req
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
@@ -445,7 +445,7 @@ TEST(testCase, function_Test6) {
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
S
Meta
Req
req
=
{
0
};
S
Catalog
Req
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
@@ -523,7 +523,7 @@ TEST(testCase, function_Test6) {
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
S
Meta
Req
req
=
{
0
};
S
Catalog
Req
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
@@ -585,7 +585,7 @@ TEST(testCase, function_Test6) {
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
S
Meta
Req
req
=
{
0
};
S
Catalog
Req
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
@@ -664,7 +664,7 @@ TEST(testCase, function_Test6) {
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
S
Meta
Req
req
=
{
0
};
S
Catalog
Req
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
source/libs/parser/test/plannerTest.cpp
浏览文件 @
d962a271
...
...
@@ -39,7 +39,7 @@ void setSchema(SSchema* p, int32_t type, int32_t bytes, const char* name, int32_
strcpy
(
p
->
name
,
name
);
}
void
setTableMetaInfo
(
SQueryStmtInfo
*
pQueryInfo
,
S
Meta
Req
*
req
)
{
void
setTableMetaInfo
(
SQueryStmtInfo
*
pQueryInfo
,
S
Catalog
Req
*
req
)
{
pQueryInfo
->
numOfTables
=
1
;
pQueryInfo
->
pTableMetaInfo
=
(
STableMetaInfo
**
)
calloc
(
1
,
POINTER_BYTES
);
...
...
@@ -79,7 +79,7 @@ void generateLogicplan(const char* sql) {
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
S
Meta
Req
req
=
{
0
};
S
Catalog
Req
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
@@ -119,7 +119,7 @@ TEST(testCase, planner_test) {
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
ASSERT_EQ
(
code
,
0
);
S
Meta
Req
req
=
{
0
};
S
Catalog
Req
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
source/libs/parser/test/tokenizerTest.cpp
浏览文件 @
d962a271
...
...
@@ -714,7 +714,7 @@ TEST(testCase, extractMeta_test) {
ASSERT_EQ
(
info1
.
valid
,
true
);
char
msg
[
128
]
=
{
0
};
S
Meta
Req
req
=
{
0
};
S
Catalog
Req
req
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录