Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
哥们要飞
TDengine
提交
a3b1dbb8
T
TDengine
项目概览
哥们要飞
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a3b1dbb8
编写于
6月 08, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] fix bugs in group by normal columns
上级
21d8e66d
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
63 addition
and
136 deletion
+63
-136
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+17
-20
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+2
-2
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+3
-5
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+2
-2
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+2
-0
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+3
-1
src/client/src/tscStream.c
src/client/src/tscStream.c
+2
-3
src/query/inc/qsqlparser.h
src/query/inc/qsqlparser.h
+1
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+4
-91
src/query/src/qparserImpl.c
src/query/src/qparserImpl.c
+11
-9
tests/script/general/parser/groupby.sim
tests/script/general/parser/groupby.sim
+16
-2
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
a3b1dbb8
...
@@ -191,14 +191,14 @@ typedef struct SDataBlockList { // todo remove
...
@@ -191,14 +191,14 @@ typedef struct SDataBlockList { // todo remove
}
SDataBlockList
;
}
SDataBlockList
;
typedef
struct
SQueryInfo
{
typedef
struct
SQueryInfo
{
int16_t
command
;
// the command may be different for each subclause, so keep it seperately.
int16_t
command
;
// the command may be different for each subclause, so keep it seperately.
uint32_t
type
;
// query/insert/import type
uint32_t
type
;
// query/insert/import type
char
slidingTimeUnit
;
char
slidingTimeUnit
;
STimeWindow
window
;
STimeWindow
window
;
int64_t
intervalTime
;
// aggregation time interval
int64_t
intervalTime
;
// aggregation time interval
int64_t
slidingTime
;
// sliding window in mseconds
int64_t
slidingTime
;
// sliding window in mseconds
SSqlGroupbyExpr
groupbyExpr
;
// group by tags info
SSqlGroupbyExpr
groupbyExpr
;
// group by tags info
SArray
*
colList
;
// SArray<SColumn*>
SArray
*
colList
;
// SArray<SColumn*>
SFieldInfo
fieldsInfo
;
SFieldInfo
fieldsInfo
;
...
@@ -207,11 +207,11 @@ typedef struct SQueryInfo {
...
@@ -207,11 +207,11 @@ typedef struct SQueryInfo {
SLimitVal
slimit
;
SLimitVal
slimit
;
STagCond
tagCond
;
STagCond
tagCond
;
SOrderVal
order
;
SOrderVal
order
;
int16_t
fillType
;
// interpolate
type
int16_t
fillType
;
// final result fill
type
int16_t
numOfTables
;
int16_t
numOfTables
;
STableMetaInfo
**
pTableMetaInfo
;
STableMetaInfo
**
pTableMetaInfo
;
struct
STSBuf
*
tsBuf
;
struct
STSBuf
*
tsBuf
;
int64_t
*
fillVal
;
// default value for
interpolation
int64_t
*
fillVal
;
// default value for
fill
char
*
msg
;
// pointer to the pCmd->payload to keep error message temporarily
char
*
msg
;
// pointer to the pCmd->payload to keep error message temporarily
int64_t
clauseLimit
;
// limit for current sub clause
int64_t
clauseLimit
;
// limit for current sub clause
...
@@ -222,15 +222,15 @@ typedef struct SQueryInfo {
...
@@ -222,15 +222,15 @@ typedef struct SQueryInfo {
typedef
struct
{
typedef
struct
{
int
command
;
int
command
;
uint8_t
msgType
;
uint8_t
msgType
;
bool
autoCreated
;
// if the table is missing, on-the-fly create it. during getmeterMeta
bool
autoCreated
;
// if the table is missing, on-the-fly create it. during getmeterMeta
int8_t
dataSourceType
;
// load data from file or not
int8_t
dataSourceType
;
// load data from file or not
union
{
union
{
int32_t
count
;
int32_t
count
;
int32_t
numOfTablesInSubmit
;
int32_t
numOfTablesInSubmit
;
};
};
int32_t
insertType
;
int32_t
clauseIndex
;
// index of multiple subclause query
int32_t
clauseIndex
;
// index of multiple subclause query
int8_t
parseFinished
;
int8_t
parseFinished
;
short
numOfCols
;
short
numOfCols
;
...
@@ -239,14 +239,12 @@ typedef struct {
...
@@ -239,14 +239,12 @@ typedef struct {
int32_t
payloadLen
;
int32_t
payloadLen
;
SQueryInfo
**
pQueryInfo
;
SQueryInfo
**
pQueryInfo
;
int32_t
numOfClause
;
int32_t
numOfClause
;
char
*
curSql
;
// current sql, resume position of sql after parsing paused
void
*
pTableList
;
// referred table involved in sql
int32_t
batchSize
;
// for parameter ('?') binding and batch processing
int32_t
numOfParams
;
SDataBlockList
*
pDataBlocks
;
// submit data blocks after parsing sql
SDataBlockList
*
pDataBlocks
;
// submit data blocks after parsing sql
char
*
curSql
;
// current sql, resume position of sql after parsing paused
void
*
pTableList
;
// referred table involved in sql
// for parameter ('?') binding and batch processing
int32_t
batchSize
;
int32_t
numOfParams
;
}
SSqlCmd
;
}
SSqlCmd
;
typedef
struct
SResRec
{
typedef
struct
SResRec
{
...
@@ -316,7 +314,6 @@ typedef struct SSqlObj {
...
@@ -316,7 +314,6 @@ typedef struct SSqlObj {
SRpcIpSet
ipList
;
SRpcIpSet
ipList
;
char
freed
:
4
;
char
freed
:
4
;
char
listed
:
4
;
char
listed
:
4
;
uint32_t
insertType
;
tsem_t
rspSem
;
tsem_t
rspSem
;
SSqlCmd
cmd
;
SSqlCmd
cmd
;
SSqlRes
res
;
SSqlRes
res
;
...
...
src/client/src/tscFunctionImpl.c
浏览文件 @
a3b1dbb8
...
@@ -1293,7 +1293,7 @@ static void max_function_f(SQLFunctionCtx *pCtx, int32_t index) {
...
@@ -1293,7 +1293,7 @@ static void max_function_f(SQLFunctionCtx *pCtx, int32_t index) {
minMax_function_f
(
pCtx
,
index
,
0
);
minMax_function_f
(
pCtx
,
index
,
0
);
SResultInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
if
(
pResInfo
->
hasResult
==
DATA_SET_FLAG
)
{
if
(
pResInfo
->
hasResult
==
DATA_SET_FLAG
&&
pResInfo
->
superTableQ
)
{
char
*
flag
=
pCtx
->
aOutputBuf
+
pCtx
->
inputBytes
;
char
*
flag
=
pCtx
->
aOutputBuf
+
pCtx
->
inputBytes
;
*
flag
=
DATA_SET_FLAG
;
*
flag
=
DATA_SET_FLAG
;
}
}
...
@@ -1309,7 +1309,7 @@ static void min_function_f(SQLFunctionCtx *pCtx, int32_t index) {
...
@@ -1309,7 +1309,7 @@ static void min_function_f(SQLFunctionCtx *pCtx, int32_t index) {
minMax_function_f
(
pCtx
,
index
,
1
);
minMax_function_f
(
pCtx
,
index
,
1
);
SResultInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
if
(
pResInfo
->
hasResult
==
DATA_SET_FLAG
)
{
if
(
pResInfo
->
hasResult
==
DATA_SET_FLAG
&&
pResInfo
->
superTableQ
)
{
char
*
flag
=
pCtx
->
aOutputBuf
+
pCtx
->
inputBytes
;
char
*
flag
=
pCtx
->
aOutputBuf
+
pCtx
->
inputBytes
;
*
flag
=
DATA_SET_FLAG
;
*
flag
=
DATA_SET_FLAG
;
}
}
...
...
src/client/src/tscParseInsert.c
浏览文件 @
a3b1dbb8
...
@@ -1314,7 +1314,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
...
@@ -1314,7 +1314,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
tscGetQueryInfoDetailSafely
(
pCmd
,
pCmd
->
clauseIndex
,
&
pQueryInfo
);
tscGetQueryInfoDetailSafely
(
pCmd
,
pCmd
->
clauseIndex
,
&
pQueryInfo
);
TSDB_QUERY_SET_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_INSERT
);
TSDB_QUERY_SET_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_INSERT
);
TSDB_QUERY_SET_TYPE
(
pQueryInfo
->
type
,
p
Sql
->
insertType
);
TSDB_QUERY_SET_TYPE
(
pQueryInfo
->
type
,
p
Cmd
->
insertType
);
sToken
=
tStrGetToken
(
pSql
->
sqlstr
,
&
index
,
false
,
0
,
NULL
);
sToken
=
tStrGetToken
(
pSql
->
sqlstr
,
&
index
,
false
,
0
,
NULL
);
if
(
sToken
.
type
!=
TK_INTO
)
{
if
(
sToken
.
type
!=
TK_INTO
)
{
...
@@ -1342,7 +1342,7 @@ int tsParseSql(SSqlObj *pSql, bool initialParse) {
...
@@ -1342,7 +1342,7 @@ int tsParseSql(SSqlObj *pSql, bool initialParse) {
* Set the fp before parse the sql string, in case of getTableMeta failed, in which
* Set the fp before parse the sql string, in case of getTableMeta failed, in which
* the error handle callback function can rightfully restore the user-defined callback function (fp).
* the error handle callback function can rightfully restore the user-defined callback function (fp).
*/
*/
if
(
initialParse
&&
(
pSql
->
insertType
!=
TSDB_QUERY_TYPE_STMT_INSERT
))
{
if
(
initialParse
&&
(
pSql
->
cmd
.
insertType
!=
TSDB_QUERY_TYPE_STMT_INSERT
))
{
pSql
->
fetchFp
=
pSql
->
fp
;
pSql
->
fetchFp
=
pSql
->
fp
;
pSql
->
fp
=
(
void
(
*
)())
tscHandleMultivnodeInsert
;
pSql
->
fp
=
(
void
(
*
)())
tscHandleMultivnodeInsert
;
}
}
...
@@ -1354,9 +1354,7 @@ int tsParseSql(SSqlObj *pSql, bool initialParse) {
...
@@ -1354,9 +1354,7 @@ int tsParseSql(SSqlObj *pSql, bool initialParse) {
return
ret
;
return
ret
;
}
}
SSqlInfo
SQLInfo
=
{
0
};
SSqlInfo
SQLInfo
=
qSQLParse
(
pSql
->
sqlstr
);
tSQLParse
(
&
SQLInfo
,
pSql
->
sqlstr
);
ret
=
tscToSQLCmd
(
pSql
,
&
SQLInfo
);
ret
=
tscToSQLCmd
(
pSql
,
&
SQLInfo
);
SQLInfoDestroy
(
&
SQLInfo
);
SQLInfoDestroy
(
&
SQLInfo
);
}
}
...
...
src/client/src/tscPrepare.c
浏览文件 @
a3b1dbb8
...
@@ -451,7 +451,7 @@ static int insertStmtExecute(STscStmt* stmt) {
...
@@ -451,7 +451,7 @@ static int insertStmtExecute(STscStmt* stmt) {
pRes
->
qhandle
=
0
;
pRes
->
qhandle
=
0
;
pSql
->
insertType
=
0
;
pSql
->
cmd
.
insertType
=
0
;
pSql
->
fetchFp
=
waitForQueryRsp
;
pSql
->
fetchFp
=
waitForQueryRsp
;
pSql
->
fp
=
(
void
(
*
)())
tscHandleMultivnodeInsert
;
pSql
->
fp
=
(
void
(
*
)())
tscHandleMultivnodeInsert
;
...
@@ -515,7 +515,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
...
@@ -515,7 +515,7 @@ int taos_stmt_prepare(TAOS_STMT* stmt, const char* sql, unsigned long length) {
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
pSql
->
param
=
(
void
*
)
pSql
;
pSql
->
param
=
(
void
*
)
pSql
;
pSql
->
fp
=
waitForQueryRsp
;
pSql
->
fp
=
waitForQueryRsp
;
pSql
->
insertType
=
TSDB_QUERY_TYPE_STMT_INSERT
;
pSql
->
cmd
.
insertType
=
TSDB_QUERY_TYPE_STMT_INSERT
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
))
{
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
))
{
tscError
(
"%p failed to malloc payload buffer"
,
pSql
);
tscError
(
"%p failed to malloc payload buffer"
,
pSql
);
...
...
src/client/src/tscSQLParser.c
浏览文件 @
a3b1dbb8
...
@@ -517,6 +517,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -517,6 +517,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
}
}
}
}
pSql
->
cmd
.
parseFinished
=
true
;
return
TSDB_CODE_SUCCESS
;
// do not build query message here
return
TSDB_CODE_SUCCESS
;
// do not build query message here
}
}
...
@@ -542,6 +543,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -542,6 +543,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"not support sql expression"
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"not support sql expression"
);
}
}
pSql
->
cmd
.
parseFinished
=
true
;
return
tscBuildMsg
[
pCmd
->
command
](
pSql
,
pInfo
);
return
tscBuildMsg
[
pCmd
->
command
](
pSql
,
pInfo
);
}
}
...
...
src/client/src/tscSecondaryMerge.c
浏览文件 @
a3b1dbb8
...
@@ -1185,7 +1185,9 @@ bool needToMerge(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer, tFilePage
...
@@ -1185,7 +1185,9 @@ bool needToMerge(SQueryInfo *pQueryInfo, SLocalReducer *pLocalReducer, tFilePage
int32_t
ret
=
0
;
// merge all result by default
int32_t
ret
=
0
;
// merge all result by default
int16_t
functionId
=
pLocalReducer
->
pCtx
[
0
].
functionId
;
int16_t
functionId
=
pLocalReducer
->
pCtx
[
0
].
functionId
;
if
(
functionId
==
TSDB_FUNC_PRJ
||
functionId
==
TSDB_FUNC_ARITHM
)
{
// column projection query
// todo opt performance
if
((
/*functionId == TSDB_FUNC_PRJ || */
functionId
==
TSDB_FUNC_ARITHM
)
||
(
tscIsProjectionQueryOnSTable
(
pQueryInfo
,
0
)))
{
// column projection query
ret
=
1
;
// disable merge procedure
ret
=
1
;
// disable merge procedure
}
else
{
}
else
{
tOrderDescriptor
*
pDesc
=
pLocalReducer
->
pDesc
;
tOrderDescriptor
*
pDesc
=
pLocalReducer
->
pDesc
;
...
...
src/client/src/tscStream.c
浏览文件 @
a3b1dbb8
...
@@ -505,10 +505,9 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
...
@@ -505,10 +505,9 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
tsem_init
(
&
pSql
->
rspSem
,
0
,
0
);
tsem_init
(
&
pSql
->
rspSem
,
0
,
0
);
SSqlInfo
SQLInfo
=
{
0
};
SSqlInfo
SQLInfo
=
qSQLParse
(
pSql
->
sqlstr
);
tSQLParse
(
&
SQLInfo
,
pSql
->
sqlstr
);
tscResetSqlCmdObj
(
&
pSql
->
cmd
);
tscResetSqlCmdObj
(
&
pSql
->
cmd
);
ret
=
tscAllocPayload
(
&
pSql
->
cmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
);
ret
=
tscAllocPayload
(
&
pSql
->
cmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
);
if
(
TSDB_CODE_SUCCESS
!=
ret
)
{
if
(
TSDB_CODE_SUCCESS
!=
ret
)
{
setErrorInfo
(
pSql
,
ret
,
NULL
);
setErrorInfo
(
pSql
,
ret
,
NULL
);
...
...
src/query/inc/qsqlparser.h
浏览文件 @
a3b1dbb8
...
@@ -322,7 +322,7 @@ enum {
...
@@ -322,7 +322,7 @@ enum {
#define NORMAL_ARITHMETIC 1
#define NORMAL_ARITHMETIC 1
#define AGG_ARIGHTMEIC 2
#define AGG_ARIGHTMEIC 2
int32_t
tSQLParse
(
SSqlInfo
*
pSQLInfo
,
const
char
*
pSql
);
SSqlInfo
qSQLParse
(
const
char
*
str
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/query/src/qExecutor.c
浏览文件 @
a3b1dbb8
...
@@ -373,7 +373,6 @@ static SWindowResult *doSetTimeWindowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SWin
...
@@ -373,7 +373,6 @@ static SWindowResult *doSetTimeWindowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SWin
SPosInfo
pos
=
{
-
1
,
-
1
};
SPosInfo
pos
=
{
-
1
,
-
1
};
createQueryResultInfo
(
pQuery
,
&
pWindowResInfo
->
pResult
[
i
],
pRuntimeEnv
->
stableQuery
,
&
pos
);
createQueryResultInfo
(
pQuery
,
&
pWindowResInfo
->
pResult
[
i
],
pRuntimeEnv
->
stableQuery
,
&
pos
);
}
}
pWindowResInfo
->
capacity
=
newCap
;
pWindowResInfo
->
capacity
=
newCap
;
}
}
...
@@ -1566,11 +1565,6 @@ static bool isFirstLastRowQuery(SQuery *pQuery) {
...
@@ -1566,11 +1565,6 @@ static bool isFirstLastRowQuery(SQuery *pQuery) {
return
false
;
return
false
;
}
}
static
UNUSED_FUNC
bool
notHasQueryTimeRange
(
SQuery
*
pQuery
)
{
return
(
pQuery
->
window
.
skey
==
0
&&
pQuery
->
window
.
ekey
==
INT64_MAX
&&
QUERY_IS_ASC_QUERY
(
pQuery
))
||
(
pQuery
->
window
.
skey
==
INT64_MAX
&&
pQuery
->
window
.
ekey
==
0
&&
(
!
QUERY_IS_ASC_QUERY
(
pQuery
)));
}
static
bool
needReverseScan
(
SQuery
*
pQuery
)
{
static
bool
needReverseScan
(
SQuery
*
pQuery
)
{
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
int32_t
functionId
=
pQuery
->
pSelectExpr
[
i
].
base
.
functionId
;
int32_t
functionId
=
pQuery
->
pSelectExpr
[
i
].
base
.
functionId
;
...
@@ -1768,61 +1762,6 @@ static void changeExecuteScanOrder(SQuery *pQuery, bool stableQuery) {
...
@@ -1768,61 +1762,6 @@ static void changeExecuteScanOrder(SQuery *pQuery, bool stableQuery) {
}
}
}
}
static
UNUSED_FUNC
void
doSetInterpVal
(
SQLFunctionCtx
*
pCtx
,
TSKEY
ts
,
int16_t
type
,
int32_t
index
,
char
*
data
)
{
assert
(
pCtx
->
param
[
index
].
pz
==
NULL
);
int32_t
len
=
0
;
size_t
t
=
0
;
if
(
type
==
TSDB_DATA_TYPE_BINARY
)
{
t
=
strlen
(
data
);
len
=
t
+
1
+
TSDB_KEYSIZE
;
pCtx
->
param
[
index
].
pz
=
calloc
(
1
,
len
);
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
t
=
wcslen
((
const
wchar_t
*
)
data
);
len
=
(
t
+
1
)
*
TSDB_NCHAR_SIZE
+
TSDB_KEYSIZE
;
pCtx
->
param
[
index
].
pz
=
calloc
(
1
,
len
);
}
else
{
len
=
TSDB_KEYSIZE
*
2
;
pCtx
->
param
[
index
].
pz
=
malloc
(
len
);
}
pCtx
->
param
[
index
].
nType
=
TSDB_DATA_TYPE_BINARY
;
char
*
z
=
pCtx
->
param
[
index
].
pz
;
*
(
TSKEY
*
)
z
=
ts
;
z
+=
TSDB_KEYSIZE
;
switch
(
type
)
{
case
TSDB_DATA_TYPE_FLOAT
:
*
(
double
*
)
z
=
GET_FLOAT_VAL
(
data
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
*
(
double
*
)
z
=
GET_DOUBLE_VAL
(
data
);
break
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
*
(
int64_t
*
)
z
=
GET_INT64_VAL
(
data
);
break
;
case
TSDB_DATA_TYPE_BINARY
:
strncpy
(
z
,
data
,
t
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
{
wcsncpy
((
wchar_t
*
)
z
,
(
const
wchar_t
*
)
data
,
t
);
}
break
;
default:
assert
(
0
);
}
pCtx
->
param
[
index
].
nLen
=
len
;
}
static
int32_t
getInitialPageNum
(
SQInfo
*
pQInfo
)
{
static
int32_t
getInitialPageNum
(
SQInfo
*
pQInfo
)
{
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
int32_t
INITIAL_RESULT_ROWS_VALUE
=
16
;
int32_t
INITIAL_RESULT_ROWS_VALUE
=
16
;
...
@@ -4071,43 +4010,17 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool
...
@@ -4071,43 +4010,17 @@ int32_t doInitQInfo(SQInfo *pQInfo, void *param, void *tsdb, int32_t vgId, bool
initWindowResInfo
(
&
pRuntimeEnv
->
windowResInfo
,
pRuntimeEnv
,
rows
,
4096
,
type
);
initWindowResInfo
(
&
pRuntimeEnv
->
windowResInfo
,
pRuntimeEnv
,
rows
,
4096
,
type
);
}
}
setQueryStatus
(
pQuery
,
QUERY_NOT_COMPLETED
);
/*
* in case of last_row query without query range, we set the query timestamp to be
* STable->lastKey. Otherwise, keep the initial query time range unchanged.
*/
// if (isFirstLastRowQuery(pQuery)) {
// if (!normalizeUnBoundLastRowQuery(pQInfo, &interpInfo)) {
// sem_post(&pQInfo->dataReady);
// pointInterpSupporterDestroy(&interpInfo);
// return TSDB_CODE_SUCCESS;
// }
// }
if
(
pQuery
->
fillType
!=
TSDB_FILL_NONE
&&
!
isPointInterpoQuery
(
pQuery
))
{
if
(
pQuery
->
fillType
!=
TSDB_FILL_NONE
&&
!
isPointInterpoQuery
(
pQuery
))
{
SFillColInfo
*
pColInfo
=
taosCreateFillColInfo
(
pQuery
);
SFillColInfo
*
pColInfo
=
taosCreateFillColInfo
(
pQuery
);
pRuntimeEnv
->
pFillInfo
=
taosInitFillInfo
(
pQuery
->
order
.
order
,
0
,
0
,
pQuery
->
rec
.
capacity
,
pQuery
->
numOfOutput
,
pRuntimeEnv
->
pFillInfo
=
taosInitFillInfo
(
pQuery
->
order
.
order
,
0
,
0
,
pQuery
->
rec
.
capacity
,
pQuery
->
numOfOutput
,
pQuery
->
slidingTime
,
pQuery
->
fillType
,
pColInfo
);
pQuery
->
slidingTime
,
pQuery
->
fillType
,
pColInfo
);
}
}
pRuntimeEnv
->
topBotQuery
=
isTopBottomQuery
(
pQuery
);
return
TSDB_CODE_SUCCESS
;
}
static
UNUSED_FUNC
bool
isGroupbyEachTable
(
SSqlGroupbyExpr
*
pGroupbyExpr
,
STableGroupInfo
*
pSidset
)
{
if
(
pGroupbyExpr
==
NULL
||
pGroupbyExpr
->
numOfGroupCols
==
0
)
{
return
false
;
}
for
(
int32_t
i
=
0
;
i
<
pGroupbyExpr
->
numOfGroupCols
;
++
i
)
{
// todo refactor
SColIndex
*
pColIndex
=
taosArrayGet
(
pGroupbyExpr
->
columnInfo
,
i
);
pRuntimeEnv
->
topBotQuery
=
isTopBottomQuery
(
pQuery
);
if
(
pColIndex
->
flag
==
TSDB_COL_TAG
)
{
setQueryStatus
(
pQuery
,
QUERY_NOT_COMPLETED
);
return
true
;
}
}
return
false
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
enableExecutionForNextTable
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
static
void
enableExecutionForNextTable
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
...
...
src/query/src/qparserImpl.c
浏览文件 @
a3b1dbb8
...
@@ -26,16 +26,18 @@
...
@@ -26,16 +26,18 @@
#include "tstrbuild.h"
#include "tstrbuild.h"
#include "queryLog.h"
#include "queryLog.h"
int32_t
tSQLParse
(
SSqlInfo
*
pSQLInfo
,
const
char
*
pStr
)
{
SSqlInfo
qSQLParse
(
const
char
*
pStr
)
{
void
*
pParser
=
ParseAlloc
(
malloc
);
void
*
pParser
=
ParseAlloc
(
malloc
);
pSQLInfo
->
valid
=
true
;
SSqlInfo
sqlInfo
=
{
0
};
sqlInfo
.
valid
=
true
;
int32_t
i
=
0
;
int32_t
i
=
0
;
while
(
1
)
{
while
(
1
)
{
SSQLToken
t0
=
{
0
};
SSQLToken
t0
=
{
0
};
if
(
pStr
[
i
]
==
0
)
{
if
(
pStr
[
i
]
==
0
)
{
Parse
(
pParser
,
0
,
t0
,
pSQL
Info
);
Parse
(
pParser
,
0
,
t0
,
&
sql
Info
);
goto
abort_parse
;
goto
abort_parse
;
}
}
...
@@ -49,19 +51,19 @@ int32_t tSQLParse(SSqlInfo *pSQLInfo, const char *pStr) {
...
@@ -49,19 +51,19 @@ int32_t tSQLParse(SSqlInfo *pSQLInfo, const char *pStr) {
break
;
break
;
}
}
case
TK_SEMI
:
{
case
TK_SEMI
:
{
Parse
(
pParser
,
0
,
t0
,
pSQL
Info
);
Parse
(
pParser
,
0
,
t0
,
&
sql
Info
);
goto
abort_parse
;
goto
abort_parse
;
}
}
case
TK_QUESTION
:
case
TK_QUESTION
:
case
TK_ILLEGAL
:
{
case
TK_ILLEGAL
:
{
snprintf
(
pSQLInfo
->
pzErrMsg
,
tListLen
(
pSQLInfo
->
pzErrMsg
),
"unrecognized token:
\"
%s
\"
"
,
t0
.
z
);
snprintf
(
sqlInfo
.
pzErrMsg
,
tListLen
(
sqlInfo
.
pzErrMsg
),
"unrecognized token:
\"
%s
\"
"
,
t0
.
z
);
pSQLInfo
->
valid
=
false
;
sqlInfo
.
valid
=
false
;
goto
abort_parse
;
goto
abort_parse
;
}
}
default:
default:
Parse
(
pParser
,
t0
.
type
,
t0
,
pSQL
Info
);
Parse
(
pParser
,
t0
.
type
,
t0
,
&
sql
Info
);
if
(
pSQLInfo
->
valid
==
false
)
{
if
(
sqlInfo
.
valid
==
false
)
{
goto
abort_parse
;
goto
abort_parse
;
}
}
}
}
...
@@ -69,7 +71,7 @@ int32_t tSQLParse(SSqlInfo *pSQLInfo, const char *pStr) {
...
@@ -69,7 +71,7 @@ int32_t tSQLParse(SSqlInfo *pSQLInfo, const char *pStr) {
abort_parse:
abort_parse:
ParseFree
(
pParser
,
free
);
ParseFree
(
pParser
,
free
);
return
0
;
return
sqlInfo
;
}
}
tSQLExprList
*
tSQLExprListAppend
(
tSQLExprList
*
pList
,
tSQLExpr
*
pNode
,
SSQLToken
*
pToken
)
{
tSQLExprList
*
tSQLExprListAppend
(
tSQLExprList
*
pList
,
tSQLExpr
*
pNode
,
SSQLToken
*
pToken
)
{
...
...
tests/script/general/parser/groupby.sim
浏览文件 @
a3b1dbb8
...
@@ -180,7 +180,7 @@ if $data03 != 0 then
...
@@ -180,7 +180,7 @@ if $data03 != 0 then
endi
endi
print $data04
print $data04
if $data04 != 0.0000 then
if $data04 != 0.0000
0
then
return -1
return -1
endi
endi
...
@@ -201,7 +201,8 @@ if $data13 != 1 then
...
@@ -201,7 +201,8 @@ if $data13 != 1 then
return -1
return -1
endi
endi
if $data14 != 1.0000 then
if $data14 != 1.00000 then
print expect 1.00000, actual:$data14
return -1
return -1
endi
endi
...
@@ -345,6 +346,19 @@ if $data94 != 9 then
...
@@ -345,6 +346,19 @@ if $data94 != 9 then
return -1
return -1
endi
endi
sql select c1,sum(c1),avg(c1),count(*) from group_mt0 where c1<5 group by c1;
if $row != 5 then
return -1
endi
if $data00 != 0 then
return -1
endi
if $data01 != 800 then
return -1
endi
sql select first(c1), last(ts), first(ts), last(c1),sum(c1),avg(c1),count(*) from group_mt0 where c1<20 group by tbname,c1;
sql select first(c1), last(ts), first(ts), last(c1),sum(c1),avg(c1),count(*) from group_mt0 where c1<20 group by tbname,c1;
if $row != 160 then
if $row != 160 then
return -1
return -1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录