Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
bfcdbf76
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看板
提交
bfcdbf76
编写于
5月 28, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] fix bugs in interp query
上级
eae2cd3e
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
81 addition
and
79 deletion
+81
-79
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+2
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+2
-13
src/client/src/tscSql.c
src/client/src/tscSql.c
+29
-20
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+4
-3
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+44
-42
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
bfcdbf76
...
@@ -318,9 +318,10 @@ typedef struct SSqlObj {
...
@@ -318,9 +318,10 @@ typedef struct SSqlObj {
char
freed
:
4
;
char
freed
:
4
;
char
listed
:
4
;
char
listed
:
4
;
tsem_t
rspSem
;
tsem_t
rspSem
;
pthread_mutex_t
inUse
;
// make sure that one connection can only be utilized by one thread/process
SSqlCmd
cmd
;
SSqlCmd
cmd
;
SSqlRes
res
;
SSqlRes
res
;
uint
8_t
numOfSubs
;
uint
16_t
numOfSubs
;
struct
SSqlObj
**
pSubs
;
struct
SSqlObj
**
pSubs
;
struct
SSqlObj
*
prev
,
*
next
;
struct
SSqlObj
*
prev
,
*
next
;
}
SSqlObj
;
}
SSqlObj
;
...
...
src/client/src/tscServer.c
浏览文件 @
bfcdbf76
...
@@ -1846,17 +1846,6 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
...
@@ -1846,17 +1846,6 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
size_t
size
=
0
;
size_t
size
=
0
;
STableMeta
*
pTableMeta
=
tscCreateTableMetaFromMsg
(
pMetaMsg
,
&
size
);
STableMeta
*
pTableMeta
=
tscCreateTableMetaFromMsg
(
pMetaMsg
,
&
size
);
#if 0
// if current table is created according to super table, get the table meta of super table
if (pTableMeta->tableType == TSDB_CHILD_TABLE) {
char id[TSDB_TABLE_ID_LEN + 1] = {0};
strncpy(id, pMetaMsg->stableId, TSDB_TABLE_ID_LEN);
// NOTE: if the table meta of super table is not cached at client side yet, the pSTable is NULL
pTableMeta->pSTable = taosCacheAcquireByName(tscCacheHandle, id);
}
#endif
// todo add one more function: taosAddDataIfNotExists();
// todo add one more function: taosAddDataIfNotExists();
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
0
,
0
);
assert
(
pTableMetaInfo
->
pTableMeta
==
NULL
);
assert
(
pTableMetaInfo
->
pTableMeta
==
NULL
);
...
@@ -1978,7 +1967,7 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
...
@@ -1978,7 +1967,7 @@ int tscProcessMultiMeterMetaRsp(SSqlObj *pSql) {
pSql->res.code = TSDB_CODE_SUCCESS;
pSql->res.code = TSDB_CODE_SUCCESS;
pSql->res.numOfTotal = i;
pSql->res.numOfTotal = i;
tscTrace("%p load multi-metermeta resp complete num:%d", pSql, pSql->res.numOfTotal);
tscTrace("%p load multi-metermeta resp
from
complete num:%d", pSql, pSql->res.numOfTotal);
#endif
#endif
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
src/client/src/tscSql.c
浏览文件 @
bfcdbf76
...
@@ -123,6 +123,13 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
...
@@ -123,6 +123,13 @@ STscObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
tsem_init
(
&
pSql
->
rspSem
,
0
,
0
);
tsem_init
(
&
pSql
->
rspSem
,
0
,
0
);
pthread_mutexattr_t
mutexattr
;
memset
(
&
mutexattr
,
0
,
sizeof
(
pthread_mutexattr_t
));
pthread_mutexattr_settype
(
&
mutexattr
,
PTHREAD_MUTEX_RECURSIVE_NP
);
pthread_mutex_init
(
&
pSql
->
inUse
,
&
mutexattr
);
pthread_mutexattr_destroy
(
&
mutexattr
);
pObj
->
pSql
=
pSql
;
pObj
->
pSql
=
pSql
;
pObj
->
pDnodeConn
=
pDnodeConn
;
pObj
->
pDnodeConn
=
pDnodeConn
;
...
@@ -284,12 +291,23 @@ int taos_query(TAOS *taos, const char *sqlstr) {
...
@@ -284,12 +291,23 @@ int taos_query(TAOS *taos, const char *sqlstr) {
}
}
SSqlObj
*
pSql
=
pObj
->
pSql
;
SSqlObj
*
pSql
=
pObj
->
pSql
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
// now this TAOS_CONN object is in use by one thread
pthread_mutex_lock
(
&
pSql
->
inUse
);
size_t
sqlLen
=
strlen
(
sqlstr
);
size_t
sqlLen
=
strlen
(
sqlstr
);
doAsyncQuery
(
pObj
,
pSql
,
waitForQueryRsp
,
taos
,
sqlstr
,
sqlLen
);
doAsyncQuery
(
pObj
,
pSql
,
waitForQueryRsp
,
taos
,
sqlstr
,
sqlLen
);
// wait for the callback function to post the semaphore
// wait for the callback function to post the semaphore
sem_wait
(
&
pSql
->
rspSem
);
tsem_wait
(
&
pSql
->
rspSem
);
if
(
pCmd
->
command
!=
TSDB_SQL_SELECT
&&
pCmd
->
command
!=
TSDB_SQL_SHOW
&&
pCmd
->
command
!=
TSDB_SQL_DESCRIBE_TABLE
)
{
pthread_mutex_unlock
(
&
pSql
->
inUse
);
}
return
pSql
->
res
.
code
;
return
pSql
->
res
.
code
;
}
}
...
@@ -525,7 +543,7 @@ int taos_select_db(TAOS *taos, const char *db) {
...
@@ -525,7 +543,7 @@ int taos_select_db(TAOS *taos, const char *db) {
return
taos_query
(
taos
,
sql
);
return
taos_query
(
taos
,
sql
);
}
}
void
taos_free_result
_imp
(
TAOS_RES
*
res
,
int
keepCmd
)
{
void
taos_free_result
(
TAOS_RES
*
res
)
{
if
(
res
==
NULL
)
return
;
if
(
res
==
NULL
)
return
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
res
;
SSqlObj
*
pSql
=
(
SSqlObj
*
)
res
;
...
@@ -536,26 +554,24 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) {
...
@@ -536,26 +554,24 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) {
if
(
pSql
->
signature
!=
pSql
)
return
;
if
(
pSql
->
signature
!=
pSql
)
return
;
STscObj
*
pObj
=
pSql
->
pTscObj
;
if
(
pRes
==
NULL
||
pRes
->
qhandle
==
0
)
{
if
(
pRes
==
NULL
||
pRes
->
qhandle
==
0
)
{
/* Query rsp is not received from vnode, so the qhandle is NULL */
/* Query rsp is not received from vnode, so the qhandle is NULL */
tscTrace
(
"%p qhandle is null, abort free, fp:%p"
,
pSql
,
pSql
->
fp
);
tscTrace
(
"%p qhandle is null, abort free, fp:%p"
,
pSql
,
pSql
->
fp
);
STscObj
*
pTscObj
=
pSql
->
pTscObj
;
if
(
pTscObj
->
pSql
!=
pSql
)
{
// The semaphore can not be changed while freeing async sub query objects.
if
(
pObj
->
pSql
!=
pSql
)
{
tscTrace
(
"%p SqlObj is freed by app"
,
pSql
);
tscTrace
(
"%p SqlObj is freed by app"
,
pSql
);
tscFreeSqlObj
(
pSql
);
tscFreeSqlObj
(
pSql
);
}
else
{
if
(
keepCmd
)
{
tscFreeSqlResult
(
pSql
);
}
else
{
}
else
{
tscPartiallyFreeSqlObj
(
pSql
);
tscPartiallyFreeSqlObj
(
pSql
);
}
pthread_mutex_unlock
(
&
pSql
->
inUse
);
// now this TAOS_CONN can be used by other threads
}
}
return
;
return
;
}
}
// set freeFlag to 1 in retrieve message if there are un-retrieved results
// set freeFlag to 1 in retrieve message if there are un-retrieved results
data in node
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
if
(
pQueryInfo
==
NULL
)
{
if
(
pQueryInfo
==
NULL
)
{
tscPartiallyFreeSqlObj
(
pSql
);
tscPartiallyFreeSqlObj
(
pSql
);
...
@@ -599,20 +615,13 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) {
...
@@ -599,20 +615,13 @@ void taos_free_result_imp(TAOS_RES *res, int keepCmd) {
if
(
pTscObj
->
pSql
!=
pSql
)
{
if
(
pTscObj
->
pSql
!=
pSql
)
{
tscFreeSqlObj
(
pSql
);
tscFreeSqlObj
(
pSql
);
tscTrace
(
"%p sql result is freed by app"
,
pSql
);
tscTrace
(
"%p sql result is freed by app"
,
pSql
);
}
else
{
if
(
keepCmd
)
{
tscFreeSqlResult
(
pSql
);
tscTrace
(
"%p sql result is freed while sql command is kept"
,
pSql
);
}
else
{
}
else
{
tscPartiallyFreeSqlObj
(
pSql
);
tscPartiallyFreeSqlObj
(
pSql
);
tscTrace
(
"%p sql result is freed by app"
,
pSql
);
tscTrace
(
"%p sql result is freed by app"
,
pSql
);
}
}
}
}
}
}
}
void
taos_free_result
(
TAOS_RES
*
res
)
{
taos_free_result_imp
(
res
,
0
);
}
// todo should not be used in async query
// todo should not be used in async query
int
taos_errno
(
TAOS
*
taos
)
{
int
taos_errno
(
TAOS
*
taos
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
...
...
src/client/src/tscUtil.c
浏览文件 @
bfcdbf76
...
@@ -1767,11 +1767,12 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
...
@@ -1767,11 +1767,12 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
pNewQueryInfo
->
limit
=
pQueryInfo
->
limit
;
pNewQueryInfo
->
limit
=
pQueryInfo
->
limit
;
pNewQueryInfo
->
slimit
=
pQueryInfo
->
slimit
;
pNewQueryInfo
->
slimit
=
pQueryInfo
->
slimit
;
pNewQueryInfo
->
order
=
pQueryInfo
->
order
;
pNewQueryInfo
->
order
=
pQueryInfo
->
order
;
pNewQueryInfo
->
clauseLimit
=
pQueryInfo
->
clauseLimit
;
pNewQueryInfo
->
tsBuf
=
NULL
;
pNewQueryInfo
->
pTableMetaInfo
=
NULL
;
pNewQueryInfo
->
fillType
=
pQueryInfo
->
fillType
;
pNewQueryInfo
->
fillVal
=
NULL
;
pNewQueryInfo
->
fillVal
=
NULL
;
pNewQueryInfo
->
clauseLimit
=
pQueryInfo
->
clauseLimit
;
pNewQueryInfo
->
numOfTables
=
0
;
pNewQueryInfo
->
numOfTables
=
0
;
pNewQueryInfo
->
tsBuf
=
NULL
;
pNewQueryInfo
->
pTableMetaInfo
=
NULL
;
pNewQueryInfo
->
groupbyExpr
=
pQueryInfo
->
groupbyExpr
;
pNewQueryInfo
->
groupbyExpr
=
pQueryInfo
->
groupbyExpr
;
if
(
pQueryInfo
->
groupbyExpr
.
columnInfo
!=
NULL
)
{
if
(
pQueryInfo
->
groupbyExpr
.
columnInfo
!=
NULL
)
{
...
...
src/query/src/qExecutor.c
浏览文件 @
bfcdbf76
...
@@ -4525,14 +4525,13 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
...
@@ -4525,14 +4525,13 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
size_t
numOfGroups
=
taosArrayGetSize
(
pQInfo
->
groupInfo
.
pGroupList
);
size_t
numOfGroups
=
taosArrayGetSize
(
pQInfo
->
groupInfo
.
pGroupList
);
if
(
isPointInterpoQuery
(
pQuery
))
{
if
(
isPointInterpoQuery
(
pQuery
)
||
isFirstLastRowQuery
(
pQuery
)
)
{
resetCtxOutputBuf
(
pRuntimeEnv
);
resetCtxOutputBuf
(
pRuntimeEnv
);
assert
(
pQuery
->
limit
.
offset
==
0
&&
pQuery
->
limit
.
limit
!=
0
);
assert
(
pQuery
->
limit
.
offset
==
0
&&
pQuery
->
limit
.
limit
!=
0
);
while
(
pQInfo
->
groupIndex
<
numOfGroups
)
{
while
(
pQInfo
->
groupIndex
<
numOfGroups
)
{
SArray
*
group
=
taosArrayGetP
(
pQInfo
->
groupInfo
.
pGroupList
,
pQInfo
->
groupIndex
);
SArray
*
group
=
taosArrayGetP
(
pQInfo
->
groupInfo
.
pGroupList
,
pQInfo
->
groupIndex
);
if
(
isFirstLastRowQuery
(
pQuery
))
{
qTrace
(
"QInfo:%p last_row query on group:%d, total group:%d, current group:%d"
,
pQInfo
,
pQInfo
->
groupIndex
,
qTrace
(
"QInfo:%p last_row query on group:%d, total group:%d, current group:%d"
,
pQInfo
,
pQInfo
->
groupIndex
,
numOfGroups
);
numOfGroups
);
...
@@ -4555,7 +4554,11 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
...
@@ -4555,7 +4554,11 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
pRuntimeEnv
->
pQueryHandle
=
NULL
;
pRuntimeEnv
->
pQueryHandle
=
NULL
;
}
}
if
(
isFirstLastRowQuery
(
pQuery
))
{
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryLastRow
(
pQInfo
->
tsdb
,
&
cond
,
&
gp
);
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryLastRow
(
pQInfo
->
tsdb
,
&
cond
,
&
gp
);
}
else
{
pRuntimeEnv
->
pQueryHandle
=
tsdbQueryRowsInExternalWindow
(
pQInfo
->
tsdb
,
&
cond
,
&
gp
);
}
initCtxOutputBuf
(
pRuntimeEnv
);
initCtxOutputBuf
(
pRuntimeEnv
);
setTagVal
(
pRuntimeEnv
,
(
STableId
*
)
taosArrayGet
(
tx
,
0
),
pQInfo
->
tsdb
);
setTagVal
(
pRuntimeEnv
,
(
STableId
*
)
taosArrayGet
(
tx
,
0
),
pQInfo
->
tsdb
);
...
@@ -4576,7 +4579,6 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
...
@@ -4576,7 +4579,6 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
// enable execution for next table, when handling the projection query
// enable execution for next table, when handling the projection query
enableExecutionForNextTable
(
pRuntimeEnv
);
enableExecutionForNextTable
(
pRuntimeEnv
);
}
}
}
}
else
{
}
else
{
/*
/*
* 1. super table projection query, 2. group-by on normal columns query, 3. ts-comp query
* 1. super table projection query, 2. group-by on normal columns query, 3. ts-comp query
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录