Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
d48ba502
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看板
提交
d48ba502
编写于
4月 23, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] fix bug found by regression test.
上级
f17bf6d7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
23 addition
and
53 deletion
+23
-53
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+0
-41
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+13
-6
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+9
-3
src/query/src/qSqlParser.c
src/query/src/qSqlParser.c
+1
-1
tests/script/general/parser/having.sim
tests/script/general/parser/having.sim
+0
-2
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
d48ba502
...
...
@@ -496,47 +496,6 @@ int32_t tscSQLSyntaxErrMsg(char* msg, const char* additionalInfo, const char* s
int32_t
tscToSQLCmd
(
SSqlObj
*
pSql
,
struct
SSqlInfo
*
pInfo
);
static
FORCE_INLINE
void
tscGetResultColumnChr
(
SSqlRes
*
pRes
,
SFieldInfo
*
pFieldInfo
,
int32_t
columnIndex
,
int32_t
offset
)
{
SInternalField
*
pInfo
=
(
SInternalField
*
)
TARRAY_GET_ELEM
(
pFieldInfo
->
internalField
,
columnIndex
);
int32_t
type
=
pInfo
->
field
.
type
;
int32_t
bytes
=
pInfo
->
field
.
bytes
;
char
*
pData
=
pRes
->
data
+
(
int32_t
)(
offset
*
pRes
->
numOfRows
+
bytes
*
pRes
->
row
);
UNUSED
(
pData
);
// user defined constant value output columns
if
(
pInfo
->
pExpr
!=
NULL
&&
TSDB_COL_IS_UD_COL
(
pInfo
->
pExpr
->
base
.
colInfo
.
flag
))
{
if
(
type
==
TSDB_DATA_TYPE_NCHAR
||
type
==
TSDB_DATA_TYPE_BINARY
)
{
pData
=
pInfo
->
pExpr
->
base
.
param
[
1
].
pz
;
pRes
->
length
[
columnIndex
]
=
pInfo
->
pExpr
->
base
.
param
[
1
].
nLen
;
pRes
->
tsrow
[
columnIndex
]
=
(
pInfo
->
pExpr
->
base
.
param
[
1
].
nType
==
TSDB_DATA_TYPE_NULL
)
?
NULL
:
(
unsigned
char
*
)
pData
;
}
else
{
assert
(
bytes
==
tDataTypes
[
type
].
bytes
);
pRes
->
tsrow
[
columnIndex
]
=
isNull
(
pData
,
type
)
?
NULL
:
(
unsigned
char
*
)
&
pInfo
->
pExpr
->
base
.
param
[
1
].
i64
;
pRes
->
length
[
columnIndex
]
=
bytes
;
}
}
else
{
if
(
type
==
TSDB_DATA_TYPE_NCHAR
||
type
==
TSDB_DATA_TYPE_BINARY
)
{
int32_t
realLen
=
varDataLen
(
pData
);
assert
(
realLen
<=
bytes
-
VARSTR_HEADER_SIZE
);
pRes
->
tsrow
[
columnIndex
]
=
(
isNull
(
pData
,
type
))
?
NULL
:
(
unsigned
char
*
)((
tstr
*
)
pData
)
->
data
;
if
(
realLen
<
pInfo
->
pExpr
->
base
.
resBytes
-
VARSTR_HEADER_SIZE
)
{
// todo refactor
*
(
pData
+
realLen
+
VARSTR_HEADER_SIZE
)
=
0
;
}
pRes
->
length
[
columnIndex
]
=
realLen
;
}
else
{
assert
(
bytes
==
tDataTypes
[
type
].
bytes
);
pRes
->
tsrow
[
columnIndex
]
=
isNull
(
pData
,
type
)
?
NULL
:
(
unsigned
char
*
)
pData
;
pRes
->
length
[
columnIndex
]
=
bytes
;
}
}
}
extern
int32_t
sentinel
;
extern
SHashObj
*
tscVgroupMap
;
extern
SHashObj
*
tscTableMetaInfo
;
...
...
src/client/src/tscSQLParser.c
浏览文件 @
d48ba502
...
...
@@ -6801,12 +6801,16 @@ int32_t tscGetExprFilters(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pSelect
tSqlExprItem
*
pItem
=
taosArrayGet
(
pSelectNodeList
,
i
);
if
(
tSqlExprCompare
(
pItem
->
pNode
,
pSqlExpr
)
==
0
)
{
// exists, not added it,
int32_t
functionId
=
isValidFunction
(
pSqlExpr
->
operand
.
z
,
pSqlExpr
->
operand
.
n
);
tSqlExprItem
*
pParamElem
=
taosArrayGet
(
pSqlExpr
->
pParam
,
0
);
SStrToken
*
pToken
=
&
pParamElem
->
pNode
->
colInfo
;
SColumnIndex
index
=
COLUMN_INDEX_INITIALIZER
;
getColumnIndexByName
(
pCmd
,
pToken
,
pQueryInfo
,
&
index
);
int32_t
functionId
=
pSqlExpr
->
functionId
;
if
(
pSqlExpr
->
pParam
==
NULL
)
{
index
.
columnIndex
=
0
;
index
.
tableIndex
=
0
;
}
else
{
tSqlExprItem
*
pParamElem
=
taosArrayGet
(
pSqlExpr
->
pParam
,
0
);
SStrToken
*
pToken
=
&
pParamElem
->
pNode
->
colInfo
;
getColumnIndexByName
(
pCmd
,
pToken
,
pQueryInfo
,
&
index
);
}
size_t
numOfNodeInSel
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
k
=
0
;
k
<
numOfNodeInSel
;
++
k
)
{
...
...
@@ -6843,6 +6847,10 @@ int32_t tscGetExprFilters(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SArray* pSelect
size_t
n
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
(
int32_t
)
n
-
1
);
SInternalField
*
pField
=
taosArrayGet
(
pQueryInfo
->
fieldsInfo
.
internalField
,
n
-
1
);
pField
->
visible
=
false
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -6920,7 +6928,6 @@ static int32_t handleExprInHavingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, S
}
return
TSDB_CODE_SUCCESS
;
// return genExprFilter(pInfo->pFieldFilters);
}
int32_t
getHavingExpr
(
SSqlCmd
*
pCmd
,
SQueryInfo
*
pQueryInfo
,
SArray
*
pSelectNodeList
,
tSqlExpr
*
pExpr
,
int32_t
parentOptr
)
{
...
...
src/client/src/tscSubquery.c
浏览文件 @
d48ba502
...
...
@@ -3403,20 +3403,26 @@ TAOS_ROW doSetResultRowData(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
pCmd
,
pCmd
->
clauseIndex
);
size_t
size
=
tscNumOfFields
(
pQueryInfo
);
int32_t
j
=
0
;
for
(
int
i
=
0
;
i
<
size
;
++
i
)
{
SInternalField
*
pInfo
=
(
SInternalField
*
)
TARRAY_GET_ELEM
(
pQueryInfo
->
fieldsInfo
.
internalField
,
i
);
if
(
!
pInfo
->
visible
)
{
continue
;
}
int32_t
type
=
pInfo
->
field
.
type
;
int32_t
bytes
=
pInfo
->
field
.
bytes
;
if
(
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
pRes
->
tsrow
[
i
]
=
isNull
(
pRes
->
urow
[
i
],
type
)
?
NULL
:
pRes
->
urow
[
i
];
pRes
->
tsrow
[
j
]
=
isNull
(
pRes
->
urow
[
i
],
type
)
?
NULL
:
pRes
->
urow
[
i
];
}
else
{
pRes
->
tsrow
[
i
]
=
isNull
(
pRes
->
urow
[
i
],
type
)
?
NULL
:
varDataVal
(
pRes
->
urow
[
i
]);
pRes
->
length
[
i
]
=
varDataLen
(
pRes
->
urow
[
i
]);
pRes
->
tsrow
[
j
]
=
isNull
(
pRes
->
urow
[
i
],
type
)
?
NULL
:
varDataVal
(
pRes
->
urow
[
i
]);
pRes
->
length
[
j
]
=
varDataLen
(
pRes
->
urow
[
i
]);
}
((
char
**
)
pRes
->
urow
)[
i
]
+=
bytes
;
j
+=
1
;
}
pRes
->
row
++
;
// index increase one-step
...
...
src/query/src/qSqlParser.c
浏览文件 @
d48ba502
...
...
@@ -358,7 +358,7 @@ int32_t tSqlExprCompare(tSqlExpr *left, tSqlExpr *right) {
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
tSqlExprItem
*
pLeftElem
=
taosArrayGet
(
left
->
pParam
,
i
);
tSqlExpr
*
pSubLeft
=
pLeftElem
->
pNode
;
tSqlExprItem
*
pRightElem
=
taosArrayGet
(
lef
t
->
pParam
,
i
);
tSqlExprItem
*
pRightElem
=
taosArrayGet
(
righ
t
->
pParam
,
i
);
tSqlExpr
*
pSubRight
=
pRightElem
->
pNode
;
if
(
tSqlExprCompare
(
pSubLeft
,
pSubRight
))
{
...
...
tests/script/general/parser/having.sim
浏览文件 @
d48ba502
...
...
@@ -141,9 +141,7 @@ if $data30 != 4 then
endi
sql_error select top(f1,2) from st2 group by f1 having count(f2) > 0;
sql_error select top(f1,2) from st2 group by f1 having count(f2) > 0;
sql_error select top(f1,2) from st2 group by f1 having avg(f1) > 0;
sql select avg(f1),count(f1) from st2 group by f1 having avg(f1) > 2;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录