Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
343df4e2
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
343df4e2
编写于
8月 29, 2019
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the issue #435
上级
948ab4c5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
36 deletion
+32
-36
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+32
-36
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
343df4e2
...
...
@@ -108,7 +108,7 @@ static int32_t validateColumnName(char* name);
static
int32_t
setKillInfo
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
);
static
bool
hasTimestampForPointInterpQuery
(
SSqlCmd
*
pCmd
);
static
void
updateTagColumnIndex
(
SSqlCmd
*
pCmd
);
static
int32_t
setLimitOffsetValueInfo
(
SSqlObj
*
pSql
,
SQuerySQL
*
pQuerySql
);
static
int32_t
parseLimitClause
(
SSqlObj
*
pSql
,
SQuerySQL
*
pQuerySql
);
static
void
addRequiredTagColumn
(
SSqlCmd
*
pCmd
,
int32_t
tagColIndex
);
static
int32_t
parseCreateDBOptions
(
SCreateDBInfo
*
pCreateDbSql
,
SSqlCmd
*
pCmd
);
...
...
@@ -876,7 +876,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pCmd
->
limit
=
pQuerySql
->
limit
;
/* temporarily save the original limitation value */
if
((
code
=
setLimitOffsetValueInfo
(
pSql
,
pQuerySql
))
!=
TSDB_CODE_SUCCESS
)
{
if
((
code
=
parseLimitClause
(
pSql
,
pQuerySql
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -3930,20 +3930,29 @@ bool hasTimestampForPointInterpQuery(SSqlCmd* pCmd) {
return
(
pCmd
->
stime
==
pCmd
->
etime
)
&&
(
pCmd
->
stime
!=
0
);
}
int32_t
setLimitOffsetValueInfo
(
SSqlObj
*
pSql
,
SQuerySQL
*
pQuerySql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
bool
isMetric
=
UTIL_METER_IS_METRIC
(
pCmd
);
int32_t
parseLimitClause
(
SSqlObj
*
pSql
,
SQuerySQL
*
pQuerySql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
const
char
*
msg0
=
"soffset can not be less than 0"
;
const
char
*
msg1
=
"
offset can not be less than 0
"
;
const
char
*
msg2
=
"
slimit/soffset only available for STable query
"
;
const
char
*
msg3
=
"
function not supported on table
"
;
const
char
*
msg0
=
"soffset
/offset
can not be less than 0"
;
const
char
*
msg1
=
"
slimit/soffset only available for STable query
"
;
const
char
*
msg2
=
"
function not supported on table
"
;
const
char
*
msg3
=
"
slimit/soffset can not apply to projection query
"
;
// handle the limit offset value, validate the limit
pCmd
->
limit
=
pQuerySql
->
limit
;
pCmd
->
glimit
=
pQuerySql
->
glimit
;
if
(
isMetric
)
{
if
(
pCmd
->
glimit
.
offset
<
0
||
pCmd
->
limit
.
offset
<
0
)
{
setErrMsg
(
pCmd
,
msg0
);
return
TSDB_CODE_INVALID_SQL
;
}
if
(
pCmd
->
limit
.
limit
==
0
)
{
tscTrace
(
"%p limit 0, no output result"
,
pSql
);
pCmd
->
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
}
if
(
UTIL_METER_IS_METRIC
(
pCmd
))
{
bool
queryOnTags
=
false
;
int32_t
ret
=
tscQueryOnlyMetricTags
(
pCmd
,
&
queryOnTags
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -3952,34 +3961,30 @@ int32_t setLimitOffsetValueInfo(SSqlObj* pSql, SQuerySQL* pQuerySql) {
if
(
queryOnTags
==
true
)
{
// local handle the metric tag query
pCmd
->
command
=
TSDB_SQL_RETRIEVE_TAGS
;
}
else
{
if
(
tscProjectionQueryOnMetric
(
pSql
)
&&
(
pCmd
->
glimit
.
limit
>
0
||
pCmd
->
glimit
.
offset
>
0
))
{
setErrMsg
(
pCmd
,
msg3
);
return
TSDB_CODE_INVALID_SQL
;
}
}
if
(
pCmd
->
glimit
.
limit
==
0
||
pCmd
->
limit
.
limit
==
0
)
{
if
(
pCmd
->
glimit
.
limit
==
0
)
{
tscTrace
(
"%p limit 0, no output result"
,
pSql
);
pCmd
->
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
return
TSDB_CODE_SUCCESS
;
}
if
(
pCmd
->
glimit
.
offset
<
0
)
{
setErrMsg
(
pCmd
,
msg0
);
return
TSDB_CODE_INVALID_SQL
;
}
/*
* get the distribution of all meters among available vnodes that satisfy query condition from mnode ,
* then launching multiple async-queries on referenced vnodes, which is the first-stage query operation]
* get the distribution of all tables among available virtual nodes that satisfy query condition and
* created according to this super table from management node.
* And then launching multiple async-queries on required virtual nodes, which is the first-stage query operation.
*/
int32_t
code
=
tscGetMetricMeta
(
pSql
,
pCmd
->
name
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
/*
* Query results are empty. Therefore, the result is filled with 0 if count function is employed in selection
* clause.
*
* The fill of empty result is required only when interval clause is absent.
*/
//No tables included. No results generated. Query results are empty.
SMetricMeta
*
pMetricMeta
=
pCmd
->
pMetricMeta
;
if
(
pCmd
->
pMeterMeta
==
NULL
||
pMetricMeta
==
NULL
||
pMetricMeta
->
numOfVnodes
==
0
||
pMetricMeta
->
numOfMeters
==
0
)
{
...
...
@@ -3991,27 +3996,18 @@ int32_t setLimitOffsetValueInfo(SSqlObj* pSql, SQuerySQL* pQuerySql) {
pCmd
->
globalLimit
=
pCmd
->
limit
.
limit
;
}
else
{
if
(
pCmd
->
glimit
.
limit
!=
-
1
||
pCmd
->
glimit
.
offset
!=
0
)
{
setErrMsg
(
pCmd
,
msg
2
);
setErrMsg
(
pCmd
,
msg
1
);
return
TSDB_CODE_INVALID_SQL
;
}
// filter the query functions operating on "tbname" column that are not supported by normal columns.
for
(
int32_t
i
=
0
;
i
<
pCmd
->
fieldsInfo
.
numOfOutputCols
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pCmd
,
i
);
if
(
pExpr
->
colInfo
.
colIdx
==
-
1
)
{
setErrMsg
(
pCmd
,
msg
3
);
setErrMsg
(
pCmd
,
msg
2
);
return
TSDB_CODE_INVALID_SQL
;
}
}
if
(
pCmd
->
limit
.
limit
==
0
)
{
tscTrace
(
"%p limit 0, no output result"
,
pSql
);
pCmd
->
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
}
if
(
pCmd
->
limit
.
offset
<
0
)
{
setErrMsg
(
pCmd
,
msg1
);
return
TSDB_CODE_INVALID_SQL
;
}
}
return
TSDB_CODE_SUCCESS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录