Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
723110c4
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看板
提交
723110c4
编写于
10月 19, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add retrieve db and table route info API
上级
19469259
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
144 addition
and
13 deletion
+144
-13
include/client/taos.h
include/client/taos.h
+19
-0
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+1
-1
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+1
-1
source/client/src/clientMain.c
source/client/src/clientMain.c
+52
-0
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+61
-1
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+2
-2
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+2
-2
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+3
-3
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+3
-3
未找到文件。
include/client/taos.h
浏览文件 @
723110c4
...
...
@@ -126,6 +126,22 @@ typedef struct setConfRet {
char
retMsg
[
RET_MSG_LENGTH
];
}
setConfRet
;
typedef
struct
TAOS_VGROUP_HASH_INFO
{
int32_t
vgId
;
uint32_t
hashBegin
;
uint32_t
hashEnd
;
}
TAOS_VGROUP_HASH_INFO
;
typedef
struct
TAOS_DB_ROUTE_INFO
{
int32_t
routeVersion
;
int16_t
hashPrefix
;
int16_t
hashSuffix
;
int8_t
hashMethod
;
int32_t
vgNum
;
TAOS_VGROUP_HASH_INFO
*
vgHash
;
}
TAOS_DB_ROUTE_INFO
;
DLL_EXPORT
void
taos_cleanup
(
void
);
DLL_EXPORT
int
taos_options
(
TSDB_OPTION
option
,
const
void
*
arg
,
...);
DLL_EXPORT
setConfRet
taos_set_config
(
const
char
*
config
);
...
...
@@ -196,6 +212,9 @@ DLL_EXPORT void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, vo
DLL_EXPORT
void
taos_fetch_raw_block_a
(
TAOS_RES
*
res
,
__taos_async_fn_t
fp
,
void
*
param
);
DLL_EXPORT
const
void
*
taos_get_raw_block
(
TAOS_RES
*
res
);
DLL_EXPORT
int
taos_get_db_route_info
(
TAOS
*
taos
,
const
char
*
db
,
TAOS_DB_ROUTE_INFO
*
dbInfo
);
DLL_EXPORT
int
taos_get_table_vgId
(
TAOS
*
taos
,
const
char
*
table
,
TAOS_DB_ROUTE_INFO
*
dbInfo
,
int
*
vgId
);
DLL_EXPORT
int
taos_load_table_info
(
TAOS
*
taos
,
const
char
*
tableNameList
);
DLL_EXPORT
TAOS_RES
*
taos_schemaless_insert
(
TAOS
*
taos
,
char
*
lines
[],
int
numLines
,
int
protocol
,
int
precision
);
DLL_EXPORT
TAOS_RES
*
taos_schemaless_insert_raw
(
TAOS
*
taos
,
char
*
lines
,
int
len
,
int32_t
*
totalRows
,
int
protocol
,
int
precision
);
...
...
include/libs/catalog/catalog.h
浏览文件 @
723110c4
...
...
@@ -163,7 +163,7 @@ int32_t catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* vers
* @param pVgroupList (output, vgroup info list, element is SVgroupInfo, NEED to simply free the array by caller)
* @return error code
*/
int32_t
catalogGetDBVg
Info
(
SCatalog
*
pCatalog
,
SRequestConnInfo
*
pConn
,
const
char
*
pDBName
,
SArray
**
pVgroupList
);
int32_t
catalogGetDBVg
List
(
SCatalog
*
pCatalog
,
SRequestConnInfo
*
pConn
,
const
char
*
pDBName
,
SArray
**
pVgroupList
);
int32_t
catalogUpdateDBVgInfo
(
SCatalog
*
pCatalog
,
const
char
*
dbName
,
uint64_t
dbId
,
SDBVgInfo
*
dbInfo
);
...
...
source/client/src/clientImpl.c
浏览文件 @
723110c4
...
...
@@ -643,7 +643,7 @@ int32_t buildSyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray*
.
requestObjRefId
=
pRequest
->
self
,
.
mgmtEps
=
getEpSet_s
(
&
pInst
->
mgmtEp
)};
code
=
catalogGetDBVg
Info
(
pCtg
,
&
conn
,
dbFName
,
&
pVgList
);
code
=
catalogGetDBVg
List
(
pCtg
,
&
conn
,
dbFName
,
&
pVgList
);
if
(
code
)
{
goto
_return
;
}
...
...
source/client/src/clientMain.c
浏览文件 @
723110c4
...
...
@@ -989,6 +989,58 @@ const void *taos_get_raw_block(TAOS_RES *res) {
return
pRequest
->
body
.
resInfo
.
pData
;
}
int
taos_get_db_route_info
(
TAOS
*
taos
,
const
char
*
db
,
TAOS_DB_ROUTE_INFO
*
dbInfo
)
{
if
(
NULL
==
taos
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
terrno
;
}
if
(
NULL
==
db
||
NULL
==
dbInfo
)
{
tscError
(
"invalid input param, db:%p, dbInfo:%p"
,
db
,
dbInfo
);
terrno
=
TSDB_CODE_TSC_INVALID_INPUT
;
return
terrno
;
}
int64_t
connId
=
*
(
int64_t
*
)
taos
;
SRequestObj
*
pRequest
=
NULL
;
char
*
sql
=
"taos_get_db_route_info"
;
int32_t
code
=
buildRequest
(
connId
,
sql
,
strlen
(
sql
),
NULL
,
false
,
&
pRequest
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
terrno
;
}
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
SCatalog
*
pCtg
=
NULL
;
code
=
catalogGetHandle
(
pTscObj
->
pAppInfo
->
clusterId
,
&
pCtg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_return
;
}
SRequestConnInfo
conn
=
{
.
pTrans
=
pTscObj
->
pAppInfo
->
pTransporter
,
.
requestId
=
pRequest
->
requestId
,
.
requestObjRefId
=
pRequest
->
self
};
conn
.
mgmtEps
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
);
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
snprintf
(
dbFName
,
sizeof
(
dbFName
),
"%d.%s"
,
pTscObj
->
acctId
,
db
);
code
=
catalogGetDBVgInfo
(
pCtg
,
&
conn
,
dbFName
,
dbInfo
);
if
(
code
)
{
goto
_return
;
}
_return:
terrno
=
code
;
destroyRequest
(
pRequest
);
return
code
;
}
int
taos_get_table_vgId
(
TAOS
*
taos
,
const
char
*
table
,
TAOS_DB_ROUTE_INFO
*
dbInfo
,
int
*
vgId
)
{
}
int
taos_load_table_info
(
TAOS
*
taos
,
const
char
*
tableNameList
)
{
if
(
NULL
==
taos
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
723110c4
...
...
@@ -725,7 +725,7 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogGetDBVg
Info
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SArray
**
vgroupList
)
{
int32_t
catalogGetDBVg
List
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SArray
**
vgroupList
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
dbFName
||
NULL
==
pConn
||
NULL
==
vgroupList
)
{
...
...
@@ -764,6 +764,66 @@ _return:
CTG_API_LEAVE
(
code
);
}
int32_t
catalogGetDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
TAOS_DB_ROUTE_INFO
*
pInfo
)
{
CTG_API_ENTER
();
if
(
NULL
==
pCtg
||
NULL
==
dbFName
||
NULL
==
pConn
||
NULL
==
pInfo
)
{
CTG_API_LEAVE
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
SCtgDBCache
*
dbCache
=
NULL
;
int32_t
code
=
0
;
SDBVgInfo
*
dbInfo
=
NULL
;
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
dbFName
,
&
dbCache
,
&
dbInfo
));
if
(
dbCache
)
{
dbInfo
=
dbCache
->
vgCache
.
vgInfo
;
}
pInfo
->
routeVersion
=
dbInfo
->
vgVersion
;
pInfo
->
hashPrefix
=
dbInfo
->
hashPrefix
;
pInfo
->
hashSuffix
=
dbInfo
->
hashSuffix
;
pInfo
->
hashMethod
=
dbInfo
->
hashMethod
;
pInfo
->
vgNum
=
taosHashGetSize
(
dbInfo
->
vgHash
);
if
(
pInfo
->
vgNum
<=
0
)
{
ctgError
(
"invalid vgNum %d in db %s's vgHash"
,
pInfo
->
vgNum
,
dbFName
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
pInfo
->
vgHash
=
taosMemoryCalloc
(
pInfo
->
vgNum
,
sizeof
(
TAOS_VGROUP_HASH_INFO
));
if
(
NULL
==
pInfo
->
vgHash
)
{
CTG_ERR_JRET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
SVgroupInfo
*
vgInfo
=
NULL
;
int32_t
i
=
0
;
void
*
pIter
=
taosHashIterate
(
dbInfo
->
vgHash
,
NULL
);
while
(
pIter
)
{
vgInfo
=
pIter
;
pInfo
->
vgHash
[
i
].
vgId
=
vgInfo
->
vgId
;
pInfo
->
vgHash
[
i
].
hashBegin
=
vgInfo
->
hashBegin
;
pInfo
->
vgHash
[
i
].
hashEnd
=
vgInfo
->
hashEnd
;
pIter
=
taosHashIterate
(
dbInfo
->
vgHash
,
pIter
);
vgInfo
=
NULL
;
++
i
;
}
_return:
if
(
dbCache
)
{
ctgRUnlockVgInfo
(
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
}
if
(
dbInfo
)
{
taosHashCleanup
(
dbInfo
->
vgHash
);
taosMemoryFreeClear
(
dbInfo
);
}
CTG_API_LEAVE
(
code
);
}
int32_t
catalogUpdateDBVgInfo
(
SCatalog
*
pCtg
,
const
char
*
dbFName
,
uint64_t
dbId
,
SDBVgInfo
*
dbInfo
)
{
CTG_API_ENTER
();
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
723110c4
...
...
@@ -778,7 +778,7 @@ void *ctgTestGetDbVgroupThread(void *param) {
int32_t
n
=
0
;
while
(
!
ctgTestStop
)
{
code
=
catalogGetDBVg
Info
(
pCtg
,
mockPointer
,
ctgTestDbname
,
&
vgList
);
code
=
catalogGetDBVg
List
(
pCtg
,
mockPointer
,
ctgTestDbname
,
&
vgList
);
if
(
code
)
{
assert
(
0
);
}
...
...
@@ -2063,7 +2063,7 @@ TEST(dbVgroup, getSetDbVgroupCase) {
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
code
=
catalogGetDBVg
Info
(
pCtg
,
mockPointer
,
ctgTestDbname
,
&
vgList
);
code
=
catalogGetDBVg
List
(
pCtg
,
mockPointer
,
ctgTestDbname
,
&
vgList
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
taosArrayGetSize
((
const
SArray
*
)
vgList
),
ctgTestVgNum
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
723110c4
...
...
@@ -417,11 +417,11 @@ static int32_t getDBVgInfoImpl(STranslateContext* pCxt, const SName* pName, SArr
.
requestId
=
pParCxt
->
requestId
,
.
requestObjRefId
=
pParCxt
->
requestRid
,
.
mgmtEps
=
pParCxt
->
mgmtEpSet
};
code
=
catalogGetDBVg
Info
(
pParCxt
->
pCatalog
,
&
conn
,
fullDbName
,
pVgInfo
);
code
=
catalogGetDBVg
List
(
pParCxt
->
pCatalog
,
&
conn
,
fullDbName
,
pVgInfo
);
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
parserError
(
"0x%"
PRIx64
" catalogGetDBVg
Info
error, code:%s, dbFName:%s"
,
pCxt
->
pParseCxt
->
requestId
,
parserError
(
"0x%"
PRIx64
" catalogGetDBVg
List
error, code:%s, dbFName:%s"
,
pCxt
->
pParseCxt
->
requestId
,
tstrerror
(
code
),
fullDbName
);
}
return
code
;
...
...
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
723110c4
...
...
@@ -243,8 +243,8 @@ int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* ve
return
0
;
}
int32_t
__catalogGetDBVg
Info
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SArray
**
pVgList
)
{
return
g_mockCatalogService
->
catalogGetDBVg
Info
(
dbFName
,
pVgList
);
int32_t
__catalogGetDBVg
List
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SArray
**
pVgList
)
{
return
g_mockCatalogService
->
catalogGetDBVg
List
(
dbFName
,
pVgList
);
}
int32_t
__catalogGetDBCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SDbCfgInfo
*
pDbCfg
)
{
...
...
@@ -293,7 +293,7 @@ void initMetaDataEnv() {
stub
.
set
(
catalogGetTableHashVgroup
,
__catalogGetTableHashVgroup
);
stub
.
set
(
catalogGetTableDistVgInfo
,
__catalogGetTableDistVgInfo
);
stub
.
set
(
catalogGetDBVgVersion
,
__catalogGetDBVgVersion
);
stub
.
set
(
catalogGetDBVg
Info
,
__catalogGetDBVgInfo
);
stub
.
set
(
catalogGetDBVg
List
,
__catalogGetDBVgList
);
stub
.
set
(
catalogGetDBCfg
,
__catalogGetDBCfg
);
stub
.
set
(
catalogChkAuth
,
__catalogChkAuth
);
stub
.
set
(
catalogGetUdfInfo
,
__catalogGetUdfInfo
);
...
...
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
723110c4
...
...
@@ -132,7 +132,7 @@ class MockCatalogServiceImpl {
return
copyTableVgroup
(
db
,
tNameGetTableName
(
pTableName
),
vgList
);
}
int32_t
catalogGetDBVg
Info
(
const
char
*
pDbFName
,
SArray
**
pVgList
)
const
{
int32_t
catalogGetDBVg
List
(
const
char
*
pDbFName
,
SArray
**
pVgList
)
const
{
std
::
string
dbFName
(
pDbFName
);
DbMetaCache
::
const_iterator
it
=
meta_
.
find
(
dbFName
.
substr
(
std
::
string
(
pDbFName
).
find_last_of
(
'.'
)
+
1
));
if
(
meta_
.
end
()
==
it
)
{
...
...
@@ -663,8 +663,8 @@ int32_t MockCatalogService::catalogGetTableDistVgInfo(const SName* pTableName, S
return
impl_
->
catalogGetTableDistVgInfo
(
pTableName
,
pVgList
);
}
int32_t
MockCatalogService
::
catalogGetDBVg
Info
(
const
char
*
pDbFName
,
SArray
**
pVgList
)
const
{
return
impl_
->
catalogGetDBVg
Info
(
pDbFName
,
pVgList
);
int32_t
MockCatalogService
::
catalogGetDBVg
List
(
const
char
*
pDbFName
,
SArray
**
pVgList
)
const
{
return
impl_
->
catalogGetDBVg
List
(
pDbFName
,
pVgList
);
}
int32_t
MockCatalogService
::
catalogGetDBCfg
(
const
char
*
pDbFName
,
SDbCfgInfo
*
pDbCfg
)
const
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录