Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e1020b79
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看板
提交
e1020b79
编写于
1月 06, 2023
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:add interface for taos_get_current_db
上级
730fbe42
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
102 addition
and
80 deletion
+102
-80
include/client/taos.h
include/client/taos.h
+1
-1
source/client/src/clientMain.c
source/client/src/clientMain.c
+22
-3
source/common/src/systable.c
source/common/src/systable.c
+0
-1
source/libs/executor/src/sysscanoperator.c
source/libs/executor/src/sysscanoperator.c
+79
-40
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+0
-28
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+0
-7
未找到文件。
include/client/taos.h
浏览文件 @
e1020b79
...
...
@@ -208,7 +208,7 @@ DLL_EXPORT TAOS_ROW *taos_result_block(TAOS_RES *res);
DLL_EXPORT
const
char
*
taos_get_server_info
(
TAOS
*
taos
);
DLL_EXPORT
const
char
*
taos_get_client_info
();
DLL_EXPORT
const
char
*
taos_get_current_db
(
TAOS
*
taos
,
size_
t
*
required
);
DLL_EXPORT
int
taos_get_current_db
(
TAOS
*
taos
,
char
*
database
,
int
len
,
in
t
*
required
);
DLL_EXPORT
const
char
*
taos_errstr
(
TAOS_RES
*
res
);
DLL_EXPORT
int
taos_errno
(
TAOS_RES
*
res
);
...
...
source/client/src/clientMain.c
浏览文件 @
e1020b79
...
...
@@ -686,13 +686,32 @@ const char *taos_get_server_info(TAOS *taos) {
return
pTscObj
->
sDetailVer
;
}
const
char
*
taos_get_current_db
(
TAOS
*
taos
,
size_
t
*
required
)
{
int
taos_get_current_db
(
TAOS
*
taos
,
char
*
database
,
int
len
,
in
t
*
required
)
{
STscObj
*
pTscObj
=
acquireTscObj
(
*
(
int64_t
*
)
taos
);
if
(
pTscObj
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_DISCONNECTED
;
return
NULL
;
return
-
1
;
}
int
code
=
TSDB_CODE_SUCCESS
;
taosThreadMutexLock
(
&
pTscObj
->
mutex
);
if
(
database
==
NULL
||
len
<=
0
){
if
(
required
!=
NULL
)
*
required
=
strlen
(
pTscObj
->
db
)
+
1
;
terrno
=
TSDB_CODE_INVALID_PARA
;
return
-
1
;
}
return
pTscObj
->
db
;
if
(
len
<
strlen
(
pTscObj
->
db
)
+
1
){
tstrncpy
(
database
,
pTscObj
->
db
,
len
);
if
(
required
)
*
required
=
strlen
(
pTscObj
->
db
)
+
1
;
terrno
=
TSDB_CODE_INVALID_PARA
;
code
=
-
1
;
}
else
{
strcpy
(
database
,
pTscObj
->
db
);
code
=
0
;
}
taosThreadMutexUnlock
(
&
pTscObj
->
mutex
);
return
code
;
}
static
void
destoryTablesReq
(
void
*
p
)
{
...
...
source/common/src/systable.c
浏览文件 @
e1020b79
...
...
@@ -179,7 +179,6 @@ static const SSysDbTableSchema userTagsSchema[] = {
static
const
SSysDbTableSchema
userColsSchema
[]
=
{
{.
name
=
"table_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"db_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"stable_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"col_name"
,
.
bytes
=
TSDB_COL_NAME_LEN
-
1
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"col_type"
,
.
bytes
=
32
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
,
.
sysInfo
=
false
},
{.
name
=
"col_length"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
,
.
sysInfo
=
false
},
...
...
source/libs/executor/src/sysscanoperator.c
浏览文件 @
e1020b79
...
...
@@ -140,6 +140,9 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo,
SMetaReader
*
smrChildTable
,
const
char
*
dbname
,
const
char
*
tableName
,
int32_t
*
pNumOfRows
,
const
SSDataBlock
*
dataBlock
);
static
int32_t
sysTableUserColsFillOneTableCols
(
const
SSysTableScanInfo
*
pInfo
,
SMetaReader
*
smrTable
,
const
char
*
dbname
,
int32_t
*
pNumOfRows
,
const
SSDataBlock
*
dataBlock
);
static
void
relocateAndFilterSysTagsScanResult
(
SSysTableScanInfo
*
pInfo
,
int32_t
numOfRows
,
SSDataBlock
*
dataBlock
,
SFilterInfo
*
pFilterInfo
);
...
...
@@ -443,38 +446,26 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
char
tableName
[
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
tableName
,
condTableName
);
SMetaReader
smr
Child
Table
=
{
0
};
metaReaderInit
(
&
smr
Child
Table
,
pInfo
->
readHandle
.
meta
,
0
);
int32_t
code
=
metaGetTableEntryByName
(
&
smr
Child
Table
,
condTableName
);
SMetaReader
smrTable
=
{
0
};
metaReaderInit
(
&
smrTable
,
pInfo
->
readHandle
.
meta
,
0
);
int32_t
code
=
metaGetTableEntryByName
(
&
smrTable
,
condTableName
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// terrno has been set by metaGetTableEntryByName, therefore, return directly
metaReaderClear
(
&
smr
Child
Table
);
metaReaderClear
(
&
smrTable
);
blockDataDestroy
(
dataBlock
);
pInfo
->
loadInfo
.
totalRows
=
0
;
return
NULL
;
}
if
(
smr
ChildTable
.
me
.
type
!
=
TSDB_CHILD_TABLE
)
{
metaReaderClear
(
&
smr
Child
Table
);
if
(
smr
Table
.
me
.
type
=
=
TSDB_CHILD_TABLE
)
{
metaReaderClear
(
&
smrTable
);
blockDataDestroy
(
dataBlock
);
pInfo
->
loadInfo
.
totalRows
=
0
;
return
NULL
;
}
SMetaReader
smrSuperTable
=
{
0
};
metaReaderInit
(
&
smrSuperTable
,
pInfo
->
readHandle
.
meta
,
META_READER_NOLOCK
);
code
=
metaGetTableEntryByUid
(
&
smrSuperTable
,
smrChildTable
.
me
.
ctbEntry
.
suid
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// terrno has been set by metaGetTableEntryByUid
metaReaderClear
(
&
smrSuperTable
);
metaReaderClear
(
&
smrChildTable
);
blockDataDestroy
(
dataBlock
);
return
NULL
;
}
sysTableUserTagsFillOneTableTags
(
pInfo
,
&
smrSuperTable
,
&
smrChildTable
,
dbname
,
tableName
,
&
numOfRows
,
dataBlock
);
metaReaderClear
(
&
smrSuperTable
);
metaReaderClear
(
&
smrChildTable
);
sysTableUserColsFillOneTableCols
(
pInfo
,
&
smrTable
,
dbname
,
&
numOfRows
,
dataBlock
);
metaReaderClear
(
&
smrTable
);
if
(
numOfRows
>
0
)
{
relocateAndFilterSysTagsScanResult
(
pInfo
,
numOfRows
,
dataBlock
,
pOperator
->
exprSupp
.
pFilterInfo
);
...
...
@@ -492,29 +483,11 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
}
while
((
ret
=
metaTbCursorNext
(
pInfo
->
pCur
))
==
0
)
{
if
(
pInfo
->
pCur
->
mr
.
me
.
type
!
=
TSDB_CHILD_TABLE
)
{
if
(
pInfo
->
pCur
->
mr
.
me
.
type
=
=
TSDB_CHILD_TABLE
)
{
continue
;
}
char
tableName
[
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
tableName
,
pInfo
->
pCur
->
mr
.
me
.
name
);
SMetaReader
smrSuperTable
=
{
0
};
metaReaderInit
(
&
smrSuperTable
,
pInfo
->
readHandle
.
meta
,
0
);
uint64_t
suid
=
pInfo
->
pCur
->
mr
.
me
.
ctbEntry
.
suid
;
int32_t
code
=
metaGetTableEntryByUid
(
&
smrSuperTable
,
suid
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"failed to get super table meta, uid:0x%"
PRIx64
", code:%s, %s"
,
suid
,
tstrerror
(
terrno
),
GET_TASKID
(
pTaskInfo
));
metaReaderClear
(
&
smrSuperTable
);
metaCloseTbCursor
(
pInfo
->
pCur
);
pInfo
->
pCur
=
NULL
;
T_LONG_JMP
(
pTaskInfo
->
env
,
terrno
);
}
sysTableUserTagsFillOneTableTags
(
pInfo
,
&
smrSuperTable
,
&
pInfo
->
pCur
->
mr
,
dbname
,
tableName
,
&
numOfRows
,
dataBlock
);
metaReaderClear
(
&
smrSuperTable
);
sysTableUserColsFillOneTableCols
(
pInfo
,
&
pInfo
->
pCur
->
mr
,
dbname
,
&
numOfRows
,
dataBlock
);
if
(
numOfRows
>=
pOperator
->
resultInfo
.
capacity
)
{
relocateAndFilterSysTagsScanResult
(
pInfo
,
numOfRows
,
dataBlock
,
pOperator
->
exprSupp
.
pFilterInfo
);
...
...
@@ -857,6 +830,72 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo,
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
sysTableUserColsFillOneTableCols
(
const
SSysTableScanInfo
*
pInfo
,
SMetaReader
*
smrTable
,
const
char
*
dbname
,
int32_t
*
pNumOfRows
,
const
SSDataBlock
*
dataBlock
)
{
char
tableName
[
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
tableName
,
smrTable
->
me
.
name
);
SSchemaWrapper
schemaRow
=
{
0
};
if
(
smrTable
->
me
.
type
==
TSDB_SUPER_TABLE
){
schemaRow
=
smrTable
->
me
.
stbEntry
.
schemaRow
;
}
else
if
(
smrTable
->
me
.
type
==
TSDB_NORMAL_TABLE
){
schemaRow
=
smrTable
->
me
.
ntbEntry
.
schemaRow
;
}
int32_t
numOfRows
=
*
pNumOfRows
;
int32_t
numOfCols
=
schemaRow
.
nCols
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
NULL
;
// table name
pColInfoData
=
taosArrayGet
(
dataBlock
->
pDataBlock
,
0
);
colDataAppend
(
pColInfoData
,
numOfRows
,
tableName
,
tableName
==
NULL
?
true
:
false
);
// database name
pColInfoData
=
taosArrayGet
(
dataBlock
->
pDataBlock
,
1
);
colDataAppend
(
pColInfoData
,
numOfRows
,
dbname
,
false
);
// col name
char
colName
[
TSDB_COL_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
colName
,
schemaRow
.
pSchema
[
i
].
name
);
pColInfoData
=
taosArrayGet
(
dataBlock
->
pDataBlock
,
2
);
colDataAppend
(
pColInfoData
,
numOfRows
,
colName
,
false
);
// col type
int8_t
colType
=
schemaRow
.
pSchema
[
i
].
type
;
pColInfoData
=
taosArrayGet
(
dataBlock
->
pDataBlock
,
3
);
char
colTypeStr
[
VARSTR_HEADER_SIZE
+
32
];
int
colTypeLen
=
sprintf
(
varDataVal
(
colTypeStr
),
"%s"
,
tDataTypes
[
colType
].
name
);
if
(
colType
==
TSDB_DATA_TYPE_VARCHAR
)
{
colTypeLen
+=
sprintf
(
varDataVal
(
colTypeStr
)
+
colTypeLen
,
"(%d)"
,
(
int32_t
)(
schemaRow
.
pSchema
[
i
].
bytes
-
VARSTR_HEADER_SIZE
));
}
else
if
(
colType
==
TSDB_DATA_TYPE_NCHAR
)
{
colTypeLen
+=
sprintf
(
varDataVal
(
colTypeStr
)
+
colTypeLen
,
"(%d)"
,
(
int32_t
)((
schemaRow
.
pSchema
[
i
].
bytes
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
));
}
varDataSetLen
(
colTypeStr
,
colTypeLen
);
colDataAppend
(
pColInfoData
,
numOfRows
,
(
char
*
)
colTypeStr
,
false
);
pColInfoData
=
taosArrayGet
(
dataBlock
->
pDataBlock
,
4
);
colDataAppend
(
pColInfoData
,
numOfRows
,
(
const
char
*
)
&
schemaRow
.
pSchema
[
i
].
bytes
,
false
);
pColInfoData
=
taosArrayGet
(
dataBlock
->
pDataBlock
,
5
);
colDataAppend
(
pColInfoData
,
numOfRows
,
NULL
,
true
);
pColInfoData
=
taosArrayGet
(
dataBlock
->
pDataBlock
,
6
);
colDataAppend
(
pColInfoData
,
numOfRows
,
NULL
,
true
);
pColInfoData
=
taosArrayGet
(
dataBlock
->
pDataBlock
,
7
);
colDataAppend
(
pColInfoData
,
numOfRows
,
NULL
,
true
);
++
numOfRows
;
}
*
pNumOfRows
=
numOfRows
;
return
TSDB_CODE_SUCCESS
;
}
static
SSDataBlock
*
buildInfoSchemaTableMetaBlock
(
char
*
tableName
)
{
size_t
size
=
0
;
const
SSysTableMeta
*
pMeta
=
NULL
;
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
e1020b79
...
...
@@ -147,16 +147,6 @@ static int32_t collectMetaKeyFromInsTags(SCollectMetaKeyCxt* pCxt) {
return
code
;
}
static
int32_t
collectMetaKeyFromInsCols
(
SCollectMetaKeyCxt
*
pCxt
)
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pCxt
->
pStmt
;
SName
name
=
{
0
};
int32_t
code
=
getVnodeSysTableTargetName
(
pCxt
->
pParseCxt
->
acctId
,
pSelect
->
pWhere
,
&
name
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
collectMetaKeyFromInsTagsImpl
(
pCxt
,
&
name
);
}
return
code
;
}
static
int32_t
collectMetaKeyFromRealTableImpl
(
SCollectMetaKeyCxt
*
pCxt
,
const
char
*
pDb
,
const
char
*
pTable
,
AUTH_TYPE
authType
)
{
int32_t
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
pDb
,
pTable
,
pCxt
->
pMetaCache
);
...
...
@@ -180,11 +170,6 @@ static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, const c
QUERY_NODE_SELECT_STMT
==
nodeType
(
pCxt
->
pStmt
))
{
code
=
collectMetaKeyFromInsTags
(
pCxt
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
0
==
strcmp
(
pTable
,
TSDB_INS_TABLE_COLS
)
&&
QUERY_NODE_SELECT_STMT
==
nodeType
(
pCxt
->
pStmt
))
{
code
=
collectMetaKeyFromInsCols
(
pCxt
);
}
return
code
;
}
...
...
@@ -490,19 +475,6 @@ static int32_t collectMetaKeyFromShowTags(SCollectMetaKeyCxt* pCxt, SShowStmt* p
return
code
;
}
static
int32_t
collectMetaKeyFromShowCols
(
SCollectMetaKeyCxt
*
pCxt
,
SShowStmt
*
pStmt
)
{
int32_t
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_COLS
,
pCxt
->
pMetaCache
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveDbVgInfoInCache
(
pCxt
->
pParseCxt
->
acctId
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pStmt
->
pTbName
)
{
code
=
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
((
SValueNode
*
)
pStmt
->
pTbName
)
->
literal
,
pCxt
->
pMetaCache
);
}
return
code
;
}
static
int32_t
collectMetaKeyFromShowStableTags
(
SCollectMetaKeyCxt
*
pCxt
,
SShowTableTagsStmt
*
pStmt
)
{
return
collectMetaKeyFromRealTableImpl
(
pCxt
,
((
SValueNode
*
)
pStmt
->
pDbName
)
->
literal
,
((
SValueNode
*
)
pStmt
->
pTbName
)
->
literal
,
AUTH_TYPE_READ
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
e1020b79
...
...
@@ -162,13 +162,6 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"*"
}
},
{
.
showType
=
QUERY_NODE_SHOW_TAGS_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
.
pTableName
=
TSDB_INS_TABLE_COLS
,
.
numOfShowCols
=
1
,
.
pShowCols
=
{
"*"
}
},
{
.
showType
=
QUERY_NODE_SHOW_USERS_STMT
,
.
pDbName
=
TSDB_INFORMATION_SCHEMA_DB
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录