Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
e7fa1ad0
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看板
提交
e7fa1ad0
编写于
9月 17, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-1478]
上级
4f83e113
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
58 addition
and
38 deletion
+58
-38
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+2
-3
src/query/inc/qResultbuf.h
src/query/inc/qResultbuf.h
+2
-3
src/query/inc/qUtil.h
src/query/inc/qUtil.h
+0
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+47
-31
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+1
-0
tests/script/general/parser/lastrow_query.sim
tests/script/general/parser/lastrow_query.sim
+6
-0
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
e7fa1ad0
...
...
@@ -351,7 +351,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case
TSDB_SQL_DESCRIBE_TABLE
:
{
SStrToken
*
pToken
=
&
pInfo
->
pDCLInfo
->
a
[
0
];
const
char
*
msg1
=
"invalid table name"
;
const
char
*
msg2
=
"table name
is
too long"
;
const
char
*
msg2
=
"table name too long"
;
if
(
tscValidateName
(
pToken
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
...
...
@@ -410,7 +410,6 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const
char
*
msg3
=
"name too long"
;
pCmd
->
command
=
pInfo
->
type
;
// tDCLSQL* pDCL = pInfo->pDCLInfo;
SUserInfo
*
pUser
=
&
pInfo
->
pDCLInfo
->
user
;
SStrToken
*
pName
=
&
pUser
->
user
;
...
...
@@ -773,7 +772,7 @@ int32_t parseSlidingClause(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SQuerySQL* pQu
int32_t
tscSetTableFullName
(
STableMetaInfo
*
pTableMetaInfo
,
SStrToken
*
pzTableName
,
SSqlObj
*
pSql
)
{
const
char
*
msg1
=
"name too long"
;
const
char
*
msg2
=
"current database
name is
invalid"
;
const
char
*
msg2
=
"current database
or database name
invalid"
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
src/query/inc/qResultbuf.h
浏览文件 @
e7fa1ad0
...
...
@@ -73,12 +73,11 @@ typedef struct SDiskbasedResultBuf {
bool
comp
;
// compressed before flushed to disk
int32_t
nextPos
;
// next page flush position
const
void
*
handle
;
// for debug purpose
const
void
*
handle
;
// for debug purpose
SResultBufStatis
statis
;
}
SDiskbasedResultBuf
;
#define DEFAULT_INTERN_BUF_PAGE_SIZE (4096L)
#define DEFAULT_INMEM_BUF_PAGES 10
#define DEFAULT_INTERN_BUF_PAGE_SIZE (256L) // in bytes
#define PAGE_INFO_INITIALIZER (SPageDiskInfo){-1, -1}
/**
...
...
src/query/inc/qUtil.h
浏览文件 @
e7fa1ad0
...
...
@@ -39,7 +39,6 @@ static FORCE_INLINE SWindowResult *getWindowResult(SWindowResInfo *pWindowResInf
}
#define curTimeWindowIndex(_winres) ((_winres)->curIndex)
#define GET_TIMEWINDOW(_winresInfo, _win) (STimeWindow) {(_win)->skey, ((_win)->skey + (_winresInfo)->interval - 1)}
#define GET_ROW_PARAM_FOR_MULTIOUTPUT(_q, tbq, sq) (((tbq) && (!sq))? (_q)->pSelectExpr[1].base.arg->argValue.i64:1)
bool
isWindowResClosed
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
);
...
...
src/query/src/qExecutor.c
浏览文件 @
e7fa1ad0
...
...
@@ -187,7 +187,7 @@ static void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData,
SDataStatis
*
pStatis
,
void
*
param
,
int32_t
colIndex
);
static
void
initCtxOutputBuf
(
SQueryRuntimeEnv
*
pRuntimeEnv
);
static
void
destroyTableQueryInfo
(
STableQueryInfo
*
pTableQueryInfo
);
static
void
destroyTableQueryInfo
Impl
(
STableQueryInfo
*
pTableQueryInfo
);
static
void
resetCtxOutputBuf
(
SQueryRuntimeEnv
*
pRuntimeEnv
);
static
bool
hasMainOutput
(
SQuery
*
pQuery
);
static
void
buildTagQueryResult
(
SQInfo
*
pQInfo
);
...
...
@@ -1983,8 +1983,7 @@ static void changeExecuteScanOrder(SQInfo *pQInfo, SQueryTableMsg* pQueryMsg, bo
// todo handle the case the the order irrelevant query type mixed up with order critical query type
// descending order query for last_row query
if
(
isFirstLastRowQuery
(
pQuery
))
{
qDebug
(
"QInfo:%p scan order changed for last_row query, old:%d, new:%d"
,
GET_QINFO_ADDR
(
pQuery
),
pQuery
->
order
.
order
,
TSDB_ORDER_ASC
);
qDebug
(
"QInfo:%p scan order changed for last_row query, old:%d, new:%d"
,
pQInfo
,
pQuery
->
order
.
order
,
TSDB_ORDER_ASC
);
pQuery
->
order
.
order
=
TSDB_ORDER_ASC
;
if
(
pQuery
->
window
.
skey
>
pQuery
->
window
.
ekey
)
{
...
...
@@ -2086,13 +2085,14 @@ static int32_t getInitialPageNum(SQInfo *pQInfo) {
static
void
getIntermediateBufInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
int32_t
*
ps
,
int32_t
*
rowsize
)
{
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
int32_t
MIN_ROWS_PER_PAGE
=
4
;
*
rowsize
=
(
int32_t
)(
pQuery
->
rowSize
*
GET_ROW_PARAM_FOR_MULTIOUTPUT
(
pQuery
,
pRuntimeEnv
->
topBotQuery
,
pRuntimeEnv
->
stableQuery
));
int32_t
overhead
=
sizeof
(
tFilePage
);
// one page contains at least two rows
*
ps
=
DEFAULT_INTERN_BUF_PAGE_SIZE
;
while
(((
*
rowsize
)
*
2
)
>
(
*
ps
)
-
overhead
)
{
while
(((
*
rowsize
)
*
MIN_ROWS_PER_PAGE
)
>
(
*
ps
)
-
overhead
)
{
*
ps
=
(
*
ps
<<
1u
);
}
...
...
@@ -3715,7 +3715,7 @@ static STableQueryInfo *createTableQueryInfo(SQueryRuntimeEnv *pRuntimeEnv, void
return
pTableQueryInfo
;
}
void
destroyTableQueryInfo
(
STableQueryInfo
*
pTableQueryInfo
)
{
void
destroyTableQueryInfo
Impl
(
STableQueryInfo
*
pTableQueryInfo
)
{
if
(
pTableQueryInfo
==
NULL
)
{
return
;
}
...
...
@@ -4391,6 +4391,8 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) {
return
true
;
}
static
void
doDestroyTableQueryInfo
(
STableGroupInfo
*
pTableqinfoGroupInfo
);
static
int32_t
setupQueryHandle
(
void
*
tsdb
,
SQInfo
*
pQInfo
,
bool
isSTableQuery
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
...
...
@@ -4430,16 +4432,20 @@ static int32_t setupQueryHandle(void* tsdb, SQInfo* pQInfo, bool isSTableQuery)
// update the query time window
pQuery
->
window
=
cond
.
twindow
;
size_t
numOfGroups
=
GET_NUM_OF_TABLEGROUP
(
pQInfo
);
for
(
int32_t
i
=
0
;
i
<
numOfGroups
;
++
i
)
{
SArray
*
group
=
GET_TABLEGROUP
(
pQInfo
,
i
);
if
(
pQInfo
->
tableGroupInfo
.
numOfTables
==
0
)
{
doDestroyTableQueryInfo
(
&
pQInfo
->
tableqinfoGroupInfo
);
}
else
{
size_t
numOfGroups
=
GET_NUM_OF_TABLEGROUP
(
pQInfo
);
for
(
int32_t
i
=
0
;
i
<
numOfGroups
;
++
i
)
{
SArray
*
group
=
GET_TABLEGROUP
(
pQInfo
,
i
);
size_t
t
=
taosArrayGetSize
(
group
);
for
(
int32_t
j
=
0
;
j
<
t
;
++
j
)
{
STableQueryInfo
*
pCheckInfo
=
taosArrayGetP
(
group
,
j
);
size_t
t
=
taosArrayGetSize
(
group
);
for
(
int32_t
j
=
0
;
j
<
t
;
++
j
)
{
STableQueryInfo
*
pCheckInfo
=
taosArrayGetP
(
group
,
j
);
pCheckInfo
->
win
=
pQuery
->
window
;
pCheckInfo
->
lastKey
=
pCheckInfo
->
win
.
skey
;
pCheckInfo
->
win
=
pQuery
->
window
;
pCheckInfo
->
lastKey
=
pCheckInfo
->
win
.
skey
;
}
}
}
}
else
if
(
isPointInterpoQuery
(
pQuery
))
{
...
...
@@ -6324,17 +6330,43 @@ _error:
}
static
void
freeColumnFilterInfo
(
SColumnFilterInfo
*
pFilter
,
int32_t
numOfFilters
)
{
if
(
pFilter
==
NULL
)
{
if
(
pFilter
==
NULL
||
numOfFilters
==
0
)
{
return
;
}
for
(
int32_t
i
=
0
;
i
<
numOfFilters
;
i
++
)
{
if
(
pFilter
[
i
].
filterstr
)
{
free
((
void
*
)(
pFilter
[
i
].
pz
));
}
}
free
(
pFilter
);
}
static
void
doDestroyTableQueryInfo
(
STableGroupInfo
*
pTableqinfoGroupInfo
)
{
if
(
pTableqinfoGroupInfo
->
pGroupList
!=
NULL
)
{
int32_t
numOfGroups
=
taosArrayGetSize
(
pTableqinfoGroupInfo
->
pGroupList
);
for
(
int32_t
i
=
0
;
i
<
numOfGroups
;
++
i
)
{
SArray
*
p
=
taosArrayGetP
(
pTableqinfoGroupInfo
->
pGroupList
,
i
);
size_t
num
=
taosArrayGetSize
(
p
);
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
STableQueryInfo
*
item
=
taosArrayGetP
(
p
,
j
);
destroyTableQueryInfoImpl
(
item
);
}
taosArrayDestroy
(
p
);
}
}
taosArrayDestroy
(
pTableqinfoGroupInfo
->
pGroupList
);
taosHashCleanup
(
pTableqinfoGroupInfo
->
map
);
pTableqinfoGroupInfo
->
pGroupList
=
NULL
;
pTableqinfoGroupInfo
->
map
=
NULL
;
pTableqinfoGroupInfo
->
numOfTables
=
0
;
}
static
void
freeQInfo
(
SQInfo
*
pQInfo
)
{
if
(
!
isValidQInfo
(
pQInfo
))
{
return
;
...
...
@@ -6395,25 +6427,9 @@ static void freeQInfo(SQInfo *pQInfo) {
taosTFree
(
pQuery
);
}
// todo refactor, extract method to destroytableDataInfo
if
(
pQInfo
->
tableqinfoGroupInfo
.
pGroupList
!=
NULL
)
{
int32_t
numOfGroups
=
(
int32_t
)(
GET_NUM_OF_TABLEGROUP
(
pQInfo
));
for
(
int32_t
i
=
0
;
i
<
numOfGroups
;
++
i
)
{
SArray
*
p
=
GET_TABLEGROUP
(
pQInfo
,
i
);
size_t
num
=
taosArrayGetSize
(
p
);
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
STableQueryInfo
*
item
=
taosArrayGetP
(
p
,
j
);
destroyTableQueryInfo
(
item
);
}
taosArrayDestroy
(
p
);
}
}
doDestroyTableQueryInfo
(
&
pQInfo
->
tableqinfoGroupInfo
);
taosTFree
(
pQInfo
->
pBuf
);
taosArrayDestroy
(
pQInfo
->
tableqinfoGroupInfo
.
pGroupList
);
taosHashCleanup
(
pQInfo
->
tableqinfoGroupInfo
.
map
);
tsdbDestroyTableGroup
(
&
pQInfo
->
tableGroupInfo
);
taosArrayDestroy
(
pQInfo
->
arrTableIdInfo
);
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
e7fa1ad0
...
...
@@ -2707,4 +2707,5 @@ void tsdbDestroyTableGroup(STableGroupInfo *pGroupList) {
}
taosArrayDestroy
(
pGroupList
->
pGroupList
);
pGroupList
->
numOfTables
=
0
;
}
tests/script/general/parser/lastrow_query.sim
浏览文件 @
e7fa1ad0
...
...
@@ -218,4 +218,10 @@ endi
if $data04 != 123.981000000 then
print expect 123.981000000, actual: $data04
return -1
endi
sql create table tu(ts timestamp, k int)
sql select last_row(*) from tu
if $row != 0 then
return -1
endi
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录