Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e56cd51a
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e56cd51a
编写于
6月 06, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-426]
上级
ca8976ae
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
81 addition
and
62 deletion
+81
-62
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+51
-15
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+8
-11
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+0
-7
src/client/src/tscServer.c
src/client/src/tscServer.c
+8
-21
src/client/src/tscSql.c
src/client/src/tscSql.c
+6
-5
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+8
-3
未找到文件。
src/client/src/tscLocal.c
浏览文件 @
e56cd51a
...
...
@@ -26,7 +26,7 @@
#include "tschemautil.h"
#include "tname.h"
static
void
tscSetLocalQueryResult
(
SSqlObj
*
pSql
,
const
char
*
val
,
const
char
*
columnName
,
size_t
valueLength
);
static
void
tscSetLocalQueryResult
(
SSqlObj
*
pSql
,
const
char
*
val
,
const
char
*
columnName
,
int16_t
type
,
size_t
valueLength
);
static
int32_t
getToStringLength
(
const
char
*
pData
,
int32_t
length
,
int32_t
type
)
{
char
buf
[
512
]
=
{
0
};
...
...
@@ -275,22 +275,37 @@ static void tscProcessCurrentUser(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SSqlExpr
*
pExpr
=
taosArrayGetP
(
pQueryInfo
->
exprList
,
0
);
tscSetLocalQueryResult
(
pSql
,
pSql
->
pTscObj
->
user
,
pExpr
->
aliasName
,
TSDB_USER_LEN
);
pExpr
->
resBytes
=
TSDB_USER_LEN
+
TSDB_DATA_TYPE_BINARY
;
pExpr
->
resType
=
TSDB_DATA_TYPE_BINARY
;
char
*
vx
=
calloc
(
1
,
pExpr
->
resBytes
);
STR_WITH_MAXSIZE_TO_VARSTR
(
vx
,
pSql
->
pTscObj
->
user
,
TSDB_USER_LEN
);
tscSetLocalQueryResult
(
pSql
,
vx
,
pExpr
->
aliasName
,
pExpr
->
resType
,
pExpr
->
resBytes
);
free
(
vx
);
}
static
void
tscProcessCurrentDB
(
SSqlObj
*
pSql
)
{
char
db
[
TSDB_DB_NAME_LEN
+
1
]
=
{
0
};
extractDBName
(
pSql
->
pTscObj
->
db
,
db
);
// no use db is invoked before.
if
(
strlen
(
db
)
==
0
)
{
setNull
(
db
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
);
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SSqlExpr
*
pExpr
=
taosArrayGetP
(
pQueryInfo
->
exprList
,
0
);
tscSetLocalQueryResult
(
pSql
,
db
,
pExpr
->
aliasName
,
TSDB_DB_NAME_LEN
);
pExpr
->
resType
=
TSDB_DATA_TYPE_BINARY
;
size_t
t
=
strlen
(
db
);
pExpr
->
resBytes
=
TSDB_DB_NAME_LEN
+
VARSTR_HEADER_SIZE
;
char
*
vx
=
calloc
(
1
,
pExpr
->
resBytes
);
if
(
t
==
0
)
{
setVardataNull
(
vx
,
TSDB_DATA_TYPE_BINARY
);
}
else
{
STR_WITH_SIZE_TO_VARSTR
(
vx
,
db
,
t
);
}
tscSetLocalQueryResult
(
pSql
,
vx
,
pExpr
->
aliasName
,
pExpr
->
resType
,
pExpr
->
resBytes
);
free
(
vx
);
}
static
void
tscProcessServerVer
(
SSqlObj
*
pSql
)
{
...
...
@@ -298,14 +313,32 @@ static void tscProcessServerVer(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SSqlExpr
*
pExpr
=
taosArrayGetP
(
pQueryInfo
->
exprList
,
0
);
tscSetLocalQueryResult
(
pSql
,
v
,
pExpr
->
aliasName
,
tListLen
(
pSql
->
pTscObj
->
sversion
));
pExpr
->
resType
=
TSDB_DATA_TYPE_BINARY
;
size_t
t
=
strlen
(
v
);
pExpr
->
resBytes
=
t
+
VARSTR_HEADER_SIZE
;
char
*
vx
=
calloc
(
1
,
pExpr
->
resBytes
);
STR_WITH_SIZE_TO_VARSTR
(
vx
,
v
,
t
);
tscSetLocalQueryResult
(
pSql
,
vx
,
pExpr
->
aliasName
,
pExpr
->
resType
,
pExpr
->
resBytes
);
tfree
(
vx
);
}
static
void
tscProcessClientVer
(
SSqlObj
*
pSql
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SSqlExpr
*
pExpr
=
taosArrayGetP
(
pQueryInfo
->
exprList
,
0
);
tscSetLocalQueryResult
(
pSql
,
version
,
pExpr
->
aliasName
,
strlen
(
version
));
pExpr
->
resType
=
TSDB_DATA_TYPE_BINARY
;
size_t
t
=
strlen
(
version
);
pExpr
->
resBytes
=
t
+
VARSTR_HEADER_SIZE
;
char
*
v
=
calloc
(
1
,
pExpr
->
resBytes
);
STR_WITH_SIZE_TO_VARSTR
(
v
,
version
,
t
);
tscSetLocalQueryResult
(
pSql
,
v
,
pExpr
->
aliasName
,
pExpr
->
resType
,
pExpr
->
resBytes
);
tfree
(
v
);
}
static
void
tscProcessServStatus
(
SSqlObj
*
pSql
)
{
...
...
@@ -325,10 +358,11 @@ static void tscProcessServStatus(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SSqlExpr
*
pExpr
=
taosArrayGetP
(
pQueryInfo
->
exprList
,
0
);
tscSetLocalQueryResult
(
pSql
,
"1"
,
pExpr
->
aliasName
,
2
);
int32_t
val
=
1
;
tscSetLocalQueryResult
(
pSql
,
(
char
*
)
&
val
,
pExpr
->
aliasName
,
TSDB_DATA_TYPE_INT
,
sizeof
(
int32_t
));
}
void
tscSetLocalQueryResult
(
SSqlObj
*
pSql
,
const
char
*
val
,
const
char
*
columnName
,
size_t
valueLength
)
{
void
tscSetLocalQueryResult
(
SSqlObj
*
pSql
,
const
char
*
val
,
const
char
*
columnName
,
int16_t
type
,
size_t
valueLength
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
...
...
@@ -338,8 +372,10 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa
pQueryInfo
->
order
.
order
=
TSDB_ORDER_ASC
;
tscFieldInfoClear
(
&
pQueryInfo
->
fieldsInfo
);
pQueryInfo
->
fieldsInfo
.
pFields
=
taosArrayInit
(
1
,
sizeof
(
TAOS_FIELD
));
pQueryInfo
->
fieldsInfo
.
pSupportInfo
=
taosArrayInit
(
1
,
sizeof
(
SFieldSupInfo
));
TAOS_FIELD
f
=
tscCreateField
(
TSDB_DATA_TYPE_BINARY
,
columnName
,
valueLength
);
TAOS_FIELD
f
=
tscCreateField
(
type
,
columnName
,
valueLength
);
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
tscInitResObjForLocalQuery
(
pSql
,
1
,
valueLength
);
...
...
@@ -348,7 +384,7 @@ void tscSetLocalQueryResult(SSqlObj *pSql, const char *val, const char *columnNa
SFieldSupInfo
*
pInfo
=
tscFieldInfoGetSupp
(
&
pQueryInfo
->
fieldsInfo
,
0
);
pInfo
->
pSqlExpr
=
taosArrayGetP
(
pQueryInfo
->
exprList
,
0
);
strn
cpy
(
pRes
->
data
,
val
,
pField
->
bytes
);
mem
cpy
(
pRes
->
data
,
val
,
pField
->
bytes
);
}
int
tscProcessLocalCmd
(
SSqlObj
*
pSql
)
{
...
...
@@ -385,7 +421,7 @@ int tscProcessLocalCmd(SSqlObj *pSql) {
// keep the code in local variable in order to avoid invalid read in case of async query
int32_t
code
=
pSql
->
res
.
code
;
if
(
code
==
TSDB_CODE_SUCCESS
)
{
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
0
);
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
code
);
}
else
{
tscQueueAsyncRes
(
pSql
);
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
e56cd51a
...
...
@@ -5395,20 +5395,15 @@ int32_t doLocalQueryProcess(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
switch
(
index
)
{
case
0
:
pQueryInfo
->
command
=
TSDB_SQL_CURRENT_DB
;
return
TSDB_CODE_SUCCESS
;
pQueryInfo
->
command
=
TSDB_SQL_CURRENT_DB
;
break
;
case
1
:
pQueryInfo
->
command
=
TSDB_SQL_SERV_VERSION
;
return
TSDB_CODE_SUCCESS
;
case
2
:
pQueryInfo
->
command
=
TSDB_SQL_SERV_STATUS
;
return
TSDB_CODE_SUCCESS
;
pQueryInfo
->
command
=
TSDB_SQL_SERV_VERSION
;
break
;
case
2
:
pQueryInfo
->
command
=
TSDB_SQL_SERV_STATUS
;
break
;
case
3
:
pQueryInfo
->
command
=
TSDB_SQL_CLI_VERSION
;
return
TSDB_CODE_SUCCESS
;
pQueryInfo
->
command
=
TSDB_SQL_CLI_VERSION
;
break
;
case
4
:
pQueryInfo
->
command
=
TSDB_SQL_CURRENT_USER
;
return
TSDB_CODE_SUCCESS
;
pQueryInfo
->
command
=
TSDB_SQL_CURRENT_USER
;
break
;
default:
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg3
);
}
}
...
...
@@ -5418,6 +5413,8 @@ int32_t doLocalQueryProcess(SQueryInfo* pQueryInfo, SQuerySQL* pQuerySql) {
const
char
*
name
=
(
pExprList
->
a
[
0
].
aliasName
!=
NULL
)
?
pExprList
->
a
[
0
].
aliasName
:
functionsInfo
[
index
].
name
;
strncpy
(
pExpr1
->
aliasName
,
name
,
tListLen
(
pExpr1
->
aliasName
));
return
TSDB_CODE_SUCCESS
;
}
// can only perform the parameters based on the macro definitation
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
e56cd51a
...
...
@@ -131,13 +131,6 @@ SSchema* tscGetTableColumnSchema(const STableMeta* pTableMeta, int32_t startCol)
assert
(
pTableMeta
!=
NULL
);
SSchema
*
pSchema
=
(
SSchema
*
)
pTableMeta
->
schema
;
#if 0
if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
assert (pTableMeta->pSTable != NULL);
pSchema = pTableMeta->pSTable->schema;
}
#endif
return
&
pSchema
[
startCol
];
}
...
...
src/client/src/tscServer.c
浏览文件 @
e56cd51a
...
...
@@ -1391,22 +1391,9 @@ int tscProcessDescribeTableRsp(SSqlObj *pSql) {
return
tscLocalResultCommonBuilder
(
pSql
,
numOfRes
);
}
int
tscProcessTagRetrieveRsp
(
SSqlObj
*
pSql
)
{
// SSqlCmd *pCmd = &pSql->cmd;
// SQueryInfo * pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
// STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0);
int32_t
numOfRes
=
0
;
#if 0
if (tscSqlExprGet(pQueryInfo, 0)->functionId == TSDB_FUNC_TAGPRJ) {
numOfRes = pTableMetaInfo->pMetricMeta->numOfTables;
} else {
numOfRes = 1; // for count function, there is only one output.
}
#endif
int
tscProcessLocalRetrieveRsp
(
SSqlObj
*
pSql
)
{
int32_t
numOfRes
=
1
;
pSql
->
res
.
completed
=
true
;
return
tscLocalResultCommonBuilder
(
pSql
,
numOfRes
);
}
...
...
@@ -2562,11 +2549,11 @@ void tscInitMsgsFp() {
tscProcessMsgRsp
[
TSDB_SQL_RETRIEVE
]
=
tscProcessRetrieveRspFromNode
;
// rsp handled by same function.
tscProcessMsgRsp
[
TSDB_SQL_DESCRIBE_TABLE
]
=
tscProcessDescribeTableRsp
;
tscProcessMsgRsp
[
TSDB_SQL_CURRENT_DB
]
=
tscProcessTag
RetrieveRsp
;
tscProcessMsgRsp
[
TSDB_SQL_CURRENT_USER
]
=
tscProcess
Tag
RetrieveRsp
;
tscProcessMsgRsp
[
TSDB_SQL_SERV_VERSION
]
=
tscProcess
Tag
RetrieveRsp
;
tscProcessMsgRsp
[
TSDB_SQL_CLI_VERSION
]
=
tscProcessTag
RetrieveRsp
;
tscProcessMsgRsp
[
TSDB_SQL_SERV_STATUS
]
=
tscProcessTag
RetrieveRsp
;
tscProcessMsgRsp
[
TSDB_SQL_CURRENT_DB
]
=
tscProcessLocal
RetrieveRsp
;
tscProcessMsgRsp
[
TSDB_SQL_CURRENT_USER
]
=
tscProcess
Local
RetrieveRsp
;
tscProcessMsgRsp
[
TSDB_SQL_SERV_VERSION
]
=
tscProcess
Local
RetrieveRsp
;
tscProcessMsgRsp
[
TSDB_SQL_CLI_VERSION
]
=
tscProcessLocal
RetrieveRsp
;
tscProcessMsgRsp
[
TSDB_SQL_SERV_STATUS
]
=
tscProcessLocal
RetrieveRsp
;
tscProcessMsgRsp
[
TSDB_SQL_RETRIEVE_EMPTY_RESULT
]
=
tscProcessEmptyResultRsp
;
...
...
src/client/src/tscSql.c
浏览文件 @
e56cd51a
...
...
@@ -414,10 +414,6 @@ int taos_fetch_block_impl(TAOS_RES *res, TAOS_ROW *rows) {
static
void
waitForRetrieveRsp
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
)
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
if
(
numOfRows
<
0
)
{
// set the error code
pSql
->
res
.
code
=
-
numOfRows
;
}
sem_post
(
&
pSql
->
rspSem
);
}
...
...
@@ -445,7 +441,12 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
pCmd
->
command
==
TSDB_SQL_FETCH
||
pCmd
->
command
==
TSDB_SQL_SHOW
||
pCmd
->
command
==
TSDB_SQL_SELECT
||
pCmd
->
command
==
TSDB_SQL_DESCRIBE_TABLE
))
{
pCmd
->
command
==
TSDB_SQL_DESCRIBE_TABLE
||
pCmd
->
command
==
TSDB_SQL_SERV_STATUS
||
pCmd
->
command
==
TSDB_SQL_CURRENT_DB
||
pCmd
->
command
==
TSDB_SQL_SERV_VERSION
||
pCmd
->
command
==
TSDB_SQL_CLI_VERSION
||
pCmd
->
command
==
TSDB_SQL_CURRENT_USER
))
{
taos_fetch_rows_a
(
res
,
waitForRetrieveRsp
,
pSql
->
pTscObj
);
sem_wait
(
&
pSql
->
rspSem
);
}
...
...
src/client/src/tscUtil.c
浏览文件 @
e56cd51a
...
...
@@ -965,7 +965,8 @@ static SSqlExpr* doBuildSqlExpr(SQueryInfo* pQueryInfo, int16_t functionId, SCol
SSchema
*
pSchema
=
tscGetTableTagSchema
(
pTableMetaInfo
->
pTableMeta
);
pExpr
->
colInfo
.
colId
=
pSchema
[
pColIndex
->
columnIndex
].
colId
;
strncpy
(
pExpr
->
colInfo
.
name
,
pSchema
[
pColIndex
->
columnIndex
].
name
,
TSDB_COL_NAME_LEN
);
}
else
{
}
else
if
(
pTableMetaInfo
->
pTableMeta
!=
NULL
)
{
// in handling select database/version/server_status(), the pTableMeta is NULL
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
pColIndex
->
columnIndex
);
pExpr
->
colInfo
.
colId
=
pSchema
->
colId
;
strncpy
(
pExpr
->
colInfo
.
name
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
);
...
...
@@ -977,8 +978,12 @@ static SSqlExpr* doBuildSqlExpr(SQueryInfo* pQueryInfo, int16_t functionId, SCol
pExpr
->
colInfo
.
colIndex
=
pColIndex
->
columnIndex
;
pExpr
->
resType
=
type
;
pExpr
->
resBytes
=
size
;
pExpr
->
interBytes
=
interSize
;
pExpr
->
uid
=
pTableMetaInfo
->
pTableMeta
->
uid
;
pExpr
->
interBytes
=
interSize
;
if
(
pTableMetaInfo
->
pTableMeta
)
{
pExpr
->
uid
=
pTableMetaInfo
->
pTableMeta
->
uid
;
}
return
pExpr
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录