Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
e4f83886
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看板
提交
e4f83886
编写于
6月 09, 2021
作者:
P
Ping Xiao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into xiaoping/add_test_case
上级
a76457b4
8b6d4cd8
变更
62
展开全部
显示空白变更内容
内联
并排
Showing
62 changed file
with
2416 addition
and
1650 deletion
+2416
-1650
cmake/define.inc
cmake/define.inc
+21
-6
cmake/input.inc
cmake/input.inc
+5
-0
documentation20/cn/00.index/docs.md
documentation20/cn/00.index/docs.md
+1
-0
documentation20/cn/03.architecture/docs.md
documentation20/cn/03.architecture/docs.md
+1
-1
documentation20/cn/08.connector/01.java/docs.md
documentation20/cn/08.connector/01.java/docs.md
+4
-2
documentation20/cn/11.administrator/docs.md
documentation20/cn/11.administrator/docs.md
+1
-1
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+1
-0
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-0
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+6
-6
src/client/src/tscProfile.c
src/client/src/tscProfile.c
+20
-9
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+117
-115
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/client/src/tscStream.c
src/client/src/tscStream.c
+27
-27
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+31
-7
src/common/src/tglobal.c
src/common/src/tglobal.c
+20
-0
src/common/src/tvariant.c
src/common/src/tvariant.c
+1
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java
...est/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java
+1
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java
...bc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java
+2
-1
src/connector/python/taos/cinterface.py
src/connector/python/taos/cinterface.py
+1
-1
src/cq/src/cqMain.c
src/cq/src/cqMain.c
+3
-17
src/inc/tcq.h
src/inc/tcq.h
+17
-0
src/inc/tsdb.h
src/inc/tsdb.h
+1
-1
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+13
-4
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+11
-5
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+7
-2
src/os/inc/osTime.h
src/os/inc/osTime.h
+13
-3
src/os/src/detail/osString.c
src/os/src/detail/osString.c
+3
-0
src/os/src/detail/osTime.c
src/os/src/detail/osTime.c
+51
-21
src/plugins/http/inc/httpJson.h
src/plugins/http/inc/httpJson.h
+2
-2
src/plugins/http/src/httpJson.c
src/plugins/http/src/httpJson.c
+72
-22
src/plugins/http/src/httpRestJson.c
src/plugins/http/src/httpRestJson.c
+2
-4
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+2
-1
src/query/inc/qSqlparser.h
src/query/inc/qSqlparser.h
+1
-1
src/query/inc/sql.y
src/query/inc/sql.y
+2
-4
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+29
-19
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+31
-22
src/query/src/qSqlParser.c
src/query/src/qSqlParser.c
+6
-5
src/query/src/queryMain.c
src/query/src/queryMain.c
+2
-2
src/query/src/sql.c
src/query/src/sql.c
+948
-1280
src/tsdb/inc/tsdbint.h
src/tsdb/inc/tsdbint.h
+1
-0
src/tsdb/src/tsdbCompact.c
src/tsdb/src/tsdbCompact.c
+508
-3
src/tsdb/src/tsdbMain.c
src/tsdb/src/tsdbMain.c
+3
-0
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+25
-16
src/util/inc/tutil.h
src/util/inc/tutil.h
+1
-0
src/util/src/ttokenizer.c
src/util/src/ttokenizer.c
+2
-2
src/util/src/tutil.c
src/util/src/tutil.c
+30
-0
tests/examples/c/apitest.c
tests/examples/c/apitest.c
+4
-6
tests/examples/c/demo.c
tests/examples/c/demo.c
+1
-1
tests/examples/c/prepare.c
tests/examples/c/prepare.c
+1
-1
tests/examples/c/subscribe.c
tests/examples/c/subscribe.c
+1
-2
tests/mas/Jenkinsfile
tests/mas/Jenkinsfile
+1
-1
tests/pytest/cluster/clusterSetup.py
tests/pytest/cluster/clusterSetup.py
+52
-17
tests/pytest/functions/showOfflineThresholdIs864000.py
tests/pytest/functions/showOfflineThresholdIs864000.py
+2
-2
tests/script/fullGeneralSuite.sim
tests/script/fullGeneralSuite.sim
+1
-0
tests/script/general/db/alter_option.sim
tests/script/general/db/alter_option.sim
+1
-1
tests/script/general/db/topic1.sim
tests/script/general/db/topic1.sim
+1
-1
tests/script/general/parser/function.sim
tests/script/general/parser/function.sim
+122
-0
tests/script/general/parser/nestquery.sim
tests/script/general/parser/nestquery.sim
+49
-0
tests/script/general/parser/precision_ns.sim
tests/script/general/parser/precision_ns.sim
+113
-0
tests/script/general/parser/testSuite.sim
tests/script/general/parser/testSuite.sim
+1
-0
tests/script/regressionSuite.sim
tests/script/regressionSuite.sim
+1
-0
tests/tsim/src/simExe.c
tests/tsim/src/simExe.c
+17
-3
未找到文件。
cmake/define.inc
浏览文件 @
e4f83886
...
...
@@ -123,7 +123,11 @@ IF (TD_LINUX)
MESSAGE
(
STATUS
"set ningsi macro to true"
)
ENDIF
()
IF
(
TD_MEMORY_SANITIZER
)
SET
(
DEBUG_FLAGS
"-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -O0 -g3 -DDEBUG"
)
ELSE
()
SET
(
DEBUG_FLAGS
"-O0 -g3 -DDEBUG"
)
ENDIF
()
SET
(
RELEASE_FLAGS
"-O3 -Wno-error"
)
IF
(
$
{
COVER
}
MATCHES
"true"
)
...
...
@@ -144,7 +148,11 @@ IF (TD_DARWIN_64)
ADD_DEFINITIONS
(
-
DUSE_LIBICONV
)
MESSAGE
(
STATUS
"darwin64 is defined"
)
SET
(
COMMON_FLAGS
"-std=gnu99 -Wall -Werror -Wno-missing-braces -fPIC -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE"
)
IF
(
TD_MEMORY_SANITIZER
)
SET
(
DEBUG_FLAGS
"-fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -O0 -g3 -DDEBUG"
)
ELSE
()
SET
(
DEBUG_FLAGS
"-O0 -g3 -DDEBUG"
)
ENDIF
()
SET
(
RELEASE_FLAGS
"-Og"
)
INCLUDE_DIRECTORIES
(
$
{
TD_COMMUNITY_DIR
}
/
deps
/
cJson
/
inc
)
INCLUDE_DIRECTORIES
(
$
{
TD_COMMUNITY_DIR
}
/
deps
/
lz4
/
inc
)
...
...
@@ -162,7 +170,14 @@ IF (TD_WINDOWS)
IF
(
MSVC
AND
(
MSVC_VERSION
GREATER_EQUAL
1900
))
SET
(
COMMON_FLAGS
"${COMMON_FLAGS} /Wv:18"
)
ENDIF
()
SET
(
DEBUG_FLAGS
"/fsanitize=thread /fsanitize=leak /fsanitize=memory /fsanitize=undefined /fsanitize=hwaddress /Zi /W3 /GL"
)
IF
(
TD_MEMORY_SANITIZER
)
MESSAGE
(
"memory sanitizer detected as true"
)
SET
(
DEBUG_FLAGS
"/fsanitize=address /Zi /W3 /GL"
)
ELSE
()
MESSAGE
(
"memory sanitizer detected as false"
)
SET
(
DEBUG_FLAGS
"/Zi /W3 /GL"
)
ENDIF
()
SET
(
RELEASE_FLAGS
"/W0 /O3 /GL"
)
ENDIF
()
...
...
cmake/input.inc
浏览文件 @
e4f83886
...
...
@@ -83,3 +83,8 @@ SET(TD_BUILD_JDBC TRUE)
IF
(
$
{
BUILD_JDBC
}
MATCHES
"false"
)
SET
(
TD_BUILD_JDBC
FALSE
)
ENDIF
()
SET
(
TD_MEMORY_SANITIZER
FALSE
)
IF
(
$
{
MEMORY_SANITIZER
}
MATCHES
"true"
)
SET
(
TD_MEMORY_SANITIZER
TRUE
)
ENDIF
()
documentation20/cn/00.index/docs.md
浏览文件 @
e4f83886
...
...
@@ -15,6 +15,7 @@ TDengine是一个高效的存储、查询、分析时序大数据的平台,专
*
[
命令行程序TAOS
](
/getting-started#console
)
:访问TDengine的简便方式
*
[
极速体验
](
/getting-started#demo
)
:运行示例程序,快速体验高效的数据插入、查询
*
[
支持平台列表
](
/getting-started#platforms
)
:TDengine服务器和客户端支持的平台列表
*
[
Kubenetes部署
](
https://taosdata.github.io/TDengine-Operator/zh/index.html
)
:TDengine在Kubenetes环境进行部署的详细说明
## [整体架构](/architecture)
...
...
documentation20/cn/03.architecture/docs.md
浏览文件 @
e4f83886
...
...
@@ -176,7 +176,7 @@ TDengine 分布式架构的逻辑结构图如下:
**通讯方式:**
TDengine系统的各个数据节点之间,以及应用驱动与各数据节点之间的通讯是通过TCP/UDP进行的。因为考虑到物联网场景,数据写入的包一般不大,因此TDengine 除采用TCP做传输之外,还采用UDP方式,因为UDP 更加高效,而且不受连接数的限制。TDengine实现了自己的超时、重传、确认等机制,以确保UDP的可靠传输。对于数据量不到15K的数据包,采取UDP的方式进行传输,超过15K的,或者是查询类的操作,自动采取TCP的方式进行传输。同时,TDengine根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。对于数据节点之间的数据复制,只采用TCP方式进行数据传输。
**FQDN配置**
:一个数据节点有一个或多个FQDN,可以在系统配置文件taos.cfg通过参数“fqdn"进行指定,如果没有指定,系统将自动获取计算机的hostname作为其FQDN。如果节点没有配置FQDN,可以直接将该节点的配置参数fqdn设置为它的IP地址。但不建议使用IP,因为IP地址可变,一旦变化,将让集群无法正常工作。一个数据节点的EP(End Point)由FQDN + Port组成。采用FQDN,需要保证DNS服务正常工作,或者在节点以及应用所在的节点配置好hosts文件。
**FQDN配置**
:一个数据节点有一个或多个FQDN,可以在系统配置文件taos.cfg通过参数“fqdn"进行指定,如果没有指定,系统将自动获取计算机的hostname作为其FQDN。如果节点没有配置FQDN,可以直接将该节点的配置参数fqdn设置为它的IP地址。但不建议使用IP,因为IP地址可变,一旦变化,将让集群无法正常工作。一个数据节点的EP(End Point)由FQDN + Port组成。采用FQDN,需要保证DNS服务正常工作,或者在节点以及应用所在的节点配置好hosts文件。
另外,这个参数值的长度需要控制在 96 个字符以内。
**端口配置:**
一个数据节点对外的端口由TDengine的系统配置参数serverPort决定,对集群内部通讯的端口是serverPort+5。集群内数据节点之间的数据复制操作还占有一个TCP端口,是serverPort+10. 为支持多线程高效的处理UDP数据,每个对内和对外的UDP连接,都需要占用5个连续的端口。因此一个数据节点总的端口范围为serverPort到serverPort + 10,总共11个TCP/UDP端口。(另外还可能有 RESTful、Arbitrator 所使用的端口,那样的话就一共是 13 个。)使用时,需要确保防火墙将这些端口打开,以备使用。每个数据节点可以配置不同的serverPort。(详细的端口情况请参见
[
TDengine 2.0 端口说明
](
https://www.taosdata.com/cn/documentation/faq#port
)
)
...
...
documentation20/cn/08.connector/01.java/docs.md
浏览文件 @
e4f83886
...
...
@@ -325,10 +325,12 @@ for (int i = 0; i < numOfRows; i++){
}
s
.
setString
(
2
,
s2
,
10
);
// AddBatch 之后,
可以再设定新的表名、TAGS、VALUES 取值,这样就能实现一次执行向多个数据表写入
:
// AddBatch 之后,
缓存并未清空。为避免混乱,并不推荐在 ExecuteBatch 之前再次绑定新一批的数据
:
s
.
columnDataAddBatch
();
// 执行语句:
// 执行
绑定数据后的
语句:
s
.
columnDataExecuteBatch
();
// 执行语句后清空缓存。在清空之后,可以复用当前的对象,绑定新的一批数据(可以是新表名、新 TAGS 值、新 VALUES 值):
s
.
columnDataClearBatch
();
// 执行完毕,释放资源:
s
.
columnDataCloseBatch
();
```
...
...
documentation20/cn/11.administrator/docs.md
浏览文件 @
e4f83886
...
...
@@ -99,7 +99,7 @@ taosd -C
下面仅仅列出一些重要的配置参数,更多的参数请看配置文件里的说明。各个参数的详细介绍及作用请看前述章节,而且这些参数的缺省配置都是工作的,一般无需设置。
**注意:配置修改后,需要重启*taosd*服务才能生效。**
-
firstEp: taosd启动时,主动连接的集群中首个dnode的end point, 默认值为localhost:6030。
-
fqdn:数据节点的FQDN,缺省为操作系统配置的第一个hostname。如果习惯IP地址访问,可设置为该节点的IP地址。
-
fqdn:数据节点的FQDN,缺省为操作系统配置的第一个hostname。如果习惯IP地址访问,可设置为该节点的IP地址。
这个参数值的长度需要控制在 96 个字符以内。
-
serverPort:taosd启动后,对外服务的端口号,默认值为6030。(RESTful服务使用的端口号是在此基础上+11,即默认值为6041。)
-
dataDir: 数据文件目录,所有的数据文件都将写入该目录。默认值:/var/lib/taos。
-
logDir:日志文件目录,客户端和服务器的运行日志文件将写入该目录。默认值:/var/log/taos。
...
...
src/client/inc/tscUtil.h
浏览文件 @
e4f83886
...
...
@@ -138,6 +138,7 @@ bool isSimpleAggregateRv(SQueryInfo* pQueryInfo);
bool
tscNonOrderedProjectionQueryOnSTable
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
bool
tscOrderedProjectionQueryOnSTable
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
bool
tscIsDiffDerivQuery
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsProjectionQueryOnSTable
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
bool
tscIsProjectionQuery
(
SQueryInfo
*
pQueryInfo
);
...
...
src/client/inc/tsclient.h
浏览文件 @
e4f83886
...
...
@@ -266,6 +266,7 @@ typedef struct SSqlObj {
typedef
struct
SSqlStream
{
SSqlObj
*
pSql
;
void
*
cqhandle
;
// stream belong to SCQContext handle
const
char
*
dstTable
;
uint32_t
streamId
;
char
listed
;
...
...
src/client/src/tscParseInsert.c
浏览文件 @
e4f83886
...
...
@@ -107,14 +107,10 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
return
tscInvalidOperationMsg
(
error
,
"value expected in timestamp"
,
sToken
.
z
);
}
if
(
parseAbsoluteDuration
(
valueToken
.
z
,
valueToken
.
n
,
&
interval
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
parseAbsoluteDuration
(
valueToken
.
z
,
valueToken
.
n
,
&
interval
,
timePrec
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
if
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
{
interval
/=
1000
;
}
if
(
sToken
.
type
==
TK_PLUS
)
{
useconds
+=
interval
;
}
else
{
...
...
@@ -468,6 +464,10 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
int32_t
cnt
=
0
;
int32_t
j
=
0
;
if
(
sToken
.
n
>=
TSDB_MAX_BYTES_PER_ROW
)
{
return
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"too long string"
,
sToken
.
z
);
}
for
(
uint32_t
k
=
1
;
k
<
sToken
.
n
-
1
;
++
k
)
{
if
(
sToken
.
z
[
k
]
==
'\\'
||
(
sToken
.
z
[
k
]
==
delim
&&
sToken
.
z
[
k
+
1
]
==
delim
))
{
tmpTokenBuf
[
j
]
=
sToken
.
z
[
k
+
1
];
...
...
@@ -711,7 +711,7 @@ static int32_t doParseInsertStatement(SInsertStatementParam *pInsertParam, char
}
code
=
TSDB_CODE_TSC_INVALID_OPERATION
;
char
tmpTokenBuf
[
16
*
1024
]
=
{
0
};
// used for deleting Escape character: \\, \', \"
char
tmpTokenBuf
[
TSDB_MAX_BYTES_PER_ROW
]
=
{
0
};
// used for deleting Escape character: \\, \', \"
int32_t
numOfRows
=
0
;
code
=
tsParseValues
(
str
,
dataBuf
,
maxNumOfRows
,
pInsertParam
,
&
numOfRows
,
tmpTokenBuf
);
...
...
src/client/src/tscProfile.c
浏览文件 @
e4f83886
...
...
@@ -19,6 +19,7 @@
#include "ttimer.h"
#include "tutil.h"
#include "taosmsg.h"
#include "tcq.h"
#include "taos.h"
...
...
@@ -294,24 +295,34 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
return
msgLen
;
}
void
tscKillConnection
(
STscObj
*
pObj
)
{
pthread_mutex_lock
(
&
pObj
->
mutex
);
SSqlObj
*
pSql
=
pObj
->
sqlList
;
while
(
pSql
)
{
pSql
=
pSql
->
next
;
// cqContext->dbconn is killed then call this callback
void
cqConnKilledNotify
(
void
*
handle
,
void
*
conn
)
{
if
(
handle
==
NULL
||
conn
==
NULL
){
return
;
}
SCqContext
*
pContext
=
(
SCqContext
*
)
handle
;
if
(
pContext
->
dbConn
==
conn
){
atomic_store_ptr
(
&
(
pContext
->
dbConn
),
NULL
);
}
}
void
tscKillConnection
(
STscObj
*
pObj
)
{
// get stream header by locked
pthread_mutex_lock
(
&
pObj
->
mutex
);
SSqlStream
*
pStream
=
pObj
->
streamList
;
pthread_mutex_unlock
(
&
pObj
->
mutex
);
while
(
pStream
)
{
SSqlStream
*
tmp
=
pStream
->
next
;
// set associate variant to NULL
cqConnKilledNotify
(
pStream
->
cqhandle
,
pObj
);
// taos_close_stream function call pObj->mutet lock , careful death-lock
taos_close_stream
(
pStream
);
pStream
=
tmp
;
}
pthread_mutex_unlock
(
&
pObj
->
mutex
);
tscDebug
(
"connection:%p is killed"
,
pObj
);
taos_close
(
pObj
);
}
src/client/src/tscSQLParser.c
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
src/client/src/tscServer.c
浏览文件 @
e4f83886
...
...
@@ -912,7 +912,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
SGroupbyExpr
*
pGroupbyExpr
=
query
.
pGroupbyExpr
;
if
(
pGroupbyExpr
->
numOfGroupCols
>
0
)
{
if
(
pGroupbyExpr
!=
NULL
&&
pGroupbyExpr
->
numOfGroupCols
>
0
)
{
pQueryMsg
->
orderByIdx
=
htons
(
pGroupbyExpr
->
orderIndex
);
pQueryMsg
->
orderType
=
htons
(
pGroupbyExpr
->
orderType
);
...
...
src/client/src/tscStream.c
浏览文件 @
e4f83886
...
...
@@ -53,9 +53,7 @@ static int64_t tscGetRetryDelayTime(SSqlStream* pStream, int64_t slidingTime, in
if
(
pStream
->
interval
.
intervalUnit
!=
'n'
&&
pStream
->
interval
.
intervalUnit
!=
'y'
)
{
// change to ms
if
(
prec
==
TSDB_TIME_PRECISION_MICRO
)
{
slidingTime
=
slidingTime
/
1000
;
}
slidingTime
=
convertTimePrecision
(
slidingTime
,
pStream
->
precision
,
TSDB_TIME_PRECISION_MILLI
);
if
(
slidingTime
<
retryDelta
)
{
return
slidingTime
;
...
...
@@ -139,8 +137,13 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) {
pStream
->
numOfRes
=
0
;
// reset the numOfRes.
SSqlObj
*
pSql
=
pStream
->
pSql
;
// pSql == NULL maybe killStream already called
if
(
pSql
==
NULL
)
{
return
;
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
tscDebug
(
"0x%"
PRIx64
"
timer launch query
"
,
pSql
->
self
);
tscDebug
(
"0x%"
PRIx64
"
add into timer
"
,
pSql
->
self
);
if
(
pStream
->
isProject
)
{
/*
...
...
@@ -157,11 +160,7 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) {
pQueryInfo
->
window
.
skey
=
pStream
->
stime
;
int64_t
etime
=
taosGetTimestamp
(
pStream
->
precision
);
// delay to wait all data in last time window
if
(
pStream
->
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
etime
-=
tsMaxStreamComputDelay
*
1000l
;
}
else
{
etime
-=
tsMaxStreamComputDelay
;
}
etime
-=
convertTimePrecision
(
tsMaxStreamComputDelay
,
TSDB_TIME_PRECISION_MILLI
,
pStream
->
precision
);
if
(
etime
>
pStream
->
etime
)
{
etime
=
pStream
->
etime
;
}
else
if
(
pStream
->
interval
.
intervalUnit
!=
'y'
&&
pStream
->
interval
.
intervalUnit
!=
'n'
)
{
...
...
@@ -178,8 +177,8 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) {
int64_t
timer
=
pStream
->
interval
.
sliding
;
if
(
pStream
->
interval
.
intervalUnit
==
'y'
||
pStream
->
interval
.
intervalUnit
==
'n'
)
{
timer
=
86400
*
1000l
;
}
else
if
(
pStream
->
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
timer
/=
1000l
;
}
else
{
timer
=
convertTimePrecision
(
timer
,
pStream
->
precision
,
TSDB_TIME_PRECISION_MILLI
)
;
}
tscSetRetryTimer
(
pStream
,
pSql
,
timer
);
return
;
...
...
@@ -339,8 +338,12 @@ static void tscSetRetryTimer(SSqlStream *pStream, SSqlObj *pSql, int64_t timer)
if
(
pStream
->
isProject
)
{
int64_t
now
=
taosGetTimestamp
(
pStream
->
precision
);
int64_t
etime
=
now
>
pStream
->
etime
?
pStream
->
etime
:
now
;
int64_t
maxRetent
=
tsMaxRetentWindow
*
1000
;
if
(
pStream
->
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
maxRetent
*=
1000
;
}
if
(
pStream
->
etime
<
now
&&
now
-
pStream
->
etime
>
tsMaxRetentWindow
)
{
if
(
pStream
->
etime
<
now
&&
now
-
pStream
->
etime
>
maxRetent
)
{
/*
* current time window will be closed, since it too early to exceed the maxRetentWindow value
*/
...
...
@@ -369,8 +372,7 @@ static void tscSetRetryTimer(SSqlStream *pStream, SSqlObj *pSql, int64_t timer)
}
static
int64_t
getLaunchTimeDelay
(
const
SSqlStream
*
pStream
)
{
int64_t
maxDelay
=
(
pStream
->
precision
==
TSDB_TIME_PRECISION_MICRO
)
?
tsMaxStreamComputDelay
*
1000L
:
tsMaxStreamComputDelay
;
int64_t
maxDelay
=
convertTimePrecision
(
tsMaxStreamComputDelay
,
TSDB_TIME_PRECISION_MILLI
,
pStream
->
precision
);
int64_t
delayDelta
=
maxDelay
;
if
(
pStream
->
interval
.
intervalUnit
!=
'n'
&&
pStream
->
interval
.
intervalUnit
!=
'y'
)
{
...
...
@@ -438,16 +440,14 @@ static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql) {
timer
+=
getLaunchTimeDelay
(
pStream
);
if
(
pStream
->
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
timer
=
timer
/
1000L
;
}
timer
=
convertTimePrecision
(
timer
,
pStream
->
precision
,
TSDB_TIME_PRECISION_MILLI
);
tscSetRetryTimer
(
pStream
,
pSql
,
timer
);
}
static
int32_t
tscSetSlidingWindowInfo
(
SSqlObj
*
pSql
,
SSqlStream
*
pStream
)
{
int64_t
minIntervalTime
=
(
pStream
->
precision
==
TSDB_TIME_PRECISION_MICRO
)
?
tsMinIntervalTime
*
1000L
:
tsMinIntervalTime
;
convertTimePrecision
(
tsMinIntervalTime
,
TSDB_TIME_PRECISION_MILLI
,
pStream
->
precision
)
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
...
...
@@ -471,7 +471,7 @@ static int32_t tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) {
}
int64_t
minSlidingTime
=
(
pStream
->
precision
==
TSDB_TIME_PRECISION_MICRO
)
?
tsMinSlidingTime
*
1000L
:
tsMinSlidingTime
;
convertTimePrecision
(
tsMinSlidingTime
,
TSDB_TIME_PRECISION_MILLI
,
pStream
->
precision
)
;
if
(
pQueryInfo
->
interval
.
intervalUnit
!=
'n'
&&
pQueryInfo
->
interval
.
intervalUnit
!=
'y'
&&
pQueryInfo
->
interval
.
sliding
<
minSlidingTime
)
{
tscWarn
(
"0x%"
PRIx64
" stream:%p, original sliding value:%"
PRId64
" too small, reset to:%"
PRId64
,
pSql
->
self
,
pStream
,
...
...
@@ -539,13 +539,12 @@ static int64_t tscGetLaunchTimestamp(const SSqlStream *pStream) {
timer
=
pStream
->
stime
-
now
;
}
int64_t
startDelay
=
(
pStream
->
precision
==
TSDB_TIME_PRECISION_MICRO
)
?
tsStreamCompStartDelay
*
1000L
:
tsStreamCompStartDelay
;
int64_t
startDelay
=
convertTimePrecision
(
tsStreamCompStartDelay
,
TSDB_TIME_PRECISION_MILLI
,
pStream
->
precision
);
timer
+=
getLaunchTimeDelay
(
pStream
);
timer
+=
startDelay
;
return
(
pStream
->
precision
==
TSDB_TIME_PRECISION_MICRO
)
?
timer
/
1000L
:
timer
;
return
convertTimePrecision
(
timer
,
pStream
->
precision
,
TSDB_TIME_PRECISION_MILLI
)
;
}
static
void
tscCreateStream
(
void
*
param
,
TAOS_RES
*
res
,
int
code
)
{
...
...
@@ -664,7 +663,7 @@ void cbParseSql(void* param, TAOS_RES* res, int code) {
}
TAOS_STREAM
*
taos_open_stream_withname
(
TAOS
*
taos
,
const
char
*
dstTable
,
const
char
*
sqlstr
,
void
(
*
fp
)(
void
*
param
,
TAOS_RES
*
,
TAOS_ROW
row
),
int64_t
stime
,
void
*
param
,
void
(
*
callback
)(
void
*
))
{
int64_t
stime
,
void
*
param
,
void
(
*
callback
)(
void
*
)
,
void
*
cqhandle
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
return
NULL
;
...
...
@@ -697,6 +696,7 @@ TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const c
pStream
->
callback
=
callback
;
pStream
->
param
=
param
;
pStream
->
pSql
=
pSql
;
pStream
->
cqhandle
=
cqhandle
;
pSql
->
pStream
=
pStream
;
pSql
->
param
=
pStream
;
pSql
->
maxRetry
=
TSDB_MAX_REPLICA
;
...
...
@@ -745,7 +745,7 @@ TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const c
TAOS_STREAM
*
taos_open_stream
(
TAOS
*
taos
,
const
char
*
sqlstr
,
void
(
*
fp
)(
void
*
param
,
TAOS_RES
*
,
TAOS_ROW
row
),
int64_t
stime
,
void
*
param
,
void
(
*
callback
)(
void
*
))
{
return
taos_open_stream_withname
(
taos
,
""
,
sqlstr
,
fp
,
stime
,
param
,
callback
);
return
taos_open_stream_withname
(
taos
,
""
,
sqlstr
,
fp
,
stime
,
param
,
callback
,
NULL
);
}
void
taos_close_stream
(
TAOS_STREAM
*
handle
)
{
...
...
src/client/src/tscUtil.c
浏览文件 @
e4f83886
...
...
@@ -255,10 +255,14 @@ bool tscIsProjectionQuery(SQueryInfo* pQueryInfo) {
size_t
size
=
tscNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
int32_t
functionId
=
tscExprGet
(
pQueryInfo
,
i
)
->
base
.
functionId
;
int32_t
f
=
tscExprGet
(
pQueryInfo
,
i
)
->
base
.
functionId
;
if
(
f
==
TSDB_FUNC_TS_DUMMY
)
{
continue
;
}
if
(
functionId
!=
TSDB_FUNC_PRJ
&&
functionId
!=
TSDB_FUNC_TAGPRJ
&&
functionId
!=
TSDB_FUNC_TAG
&&
functionId
!=
TSDB_FUNC_TS
&&
functionId
!=
TSDB_FUNC_ARITHM
)
{
if
(
f
!=
TSDB_FUNC_PRJ
&&
f
!=
TSDB_FUNC_TAGPRJ
&&
f
!=
TSDB_FUNC_TAG
&&
f
!=
TSDB_FUNC_TS
&&
f
!=
TSDB_FUNC_ARITHM
&&
f
!=
TSDB_FUNC_DIFF
&&
f
!=
TSDB_FUNC_DERIVATIVE
)
{
return
false
;
}
}
...
...
@@ -266,6 +270,24 @@ bool tscIsProjectionQuery(SQueryInfo* pQueryInfo) {
return
true
;
}
bool
tscIsDiffDerivQuery
(
SQueryInfo
*
pQueryInfo
)
{
size_t
size
=
tscNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
int32_t
f
=
tscExprGet
(
pQueryInfo
,
i
)
->
base
.
functionId
;
if
(
f
==
TSDB_FUNC_TS_DUMMY
)
{
continue
;
}
if
(
f
==
TSDB_FUNC_DIFF
||
f
==
TSDB_FUNC_DERIVATIVE
)
{
return
true
;
}
}
return
false
;
}
bool
tscHasColumnFilter
(
SQueryInfo
*
pQueryInfo
)
{
// filter on primary timestamp column
if
(
pQueryInfo
->
window
.
skey
!=
INT64_MIN
||
pQueryInfo
->
window
.
ekey
!=
INT64_MAX
)
{
...
...
@@ -962,6 +984,9 @@ static void destroyDummyInputOperator(void* param, int32_t numOfOutput) {
pInfo
->
block
=
destroyOutputBuf
(
pInfo
->
block
);
pInfo
->
pSql
=
NULL
;
cleanupResultRowInfo
(
&
pInfo
->
pTableQueryInfo
->
resInfo
);
tfree
(
pInfo
->
pTableQueryInfo
);
}
// todo this operator servers as the adapter for Operator tree and SqlRes result, remove it later
...
...
@@ -4263,10 +4288,9 @@ int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAt
STableMetaInfo
*
pTableMetaInfo
=
pQueryInfo
->
pTableMetaInfo
[
0
];
if
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
>
0
)
{
pQueryAttr
->
pGroupbyExpr
=
calloc
(
1
,
sizeof
(
SGroupbyExpr
));
*
(
pQueryAttr
->
pGroupbyExpr
)
=
pQueryInfo
->
groupbyExpr
;
if
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
>
0
)
{
pQueryAttr
->
pGroupbyExpr
->
columnInfo
=
taosArrayDup
(
pQueryInfo
->
groupbyExpr
.
columnInfo
);
}
else
{
assert
(
pQueryInfo
->
groupbyExpr
.
columnInfo
==
NULL
);
...
...
@@ -4345,7 +4369,7 @@ int32_t tscCreateQueryFromQueryInfo(SQueryInfo* pQueryInfo, SQueryAttr* pQueryAt
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
if
(
pQueryAttr
->
pGroupbyExpr
->
numOfGroupCols
<
0
)
{
if
(
pQueryAttr
->
pGroupbyExpr
!=
NULL
&&
pQueryAttr
->
pGroupbyExpr
->
numOfGroupCols
<
0
)
{
tscError
(
"%p illegal value of numOfGroupCols in query msg: %d"
,
addr
,
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
);
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
...
...
src/common/src/tglobal.c
浏览文件 @
e4f83886
...
...
@@ -831,6 +831,16 @@ static void doInitGlobalConfig(void) {
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"precision"
;
cfg
.
ptr
=
&
tsTimePrecision
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
TSDB_MIN_PRECISION
;
cfg
.
maxValue
=
TSDB_MAX_PRECISION
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"comp"
;
cfg
.
ptr
=
&
tsCompression
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT8
;
...
...
@@ -901,6 +911,16 @@ static void doInitGlobalConfig(void) {
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"cachelast"
;
cfg
.
ptr
=
&
tsCacheLastRow
;
cfg
.
valType
=
TAOS_CFG_VTYPE_INT8
;
cfg
.
cfgType
=
TSDB_CFG_CTYPE_B_CONFIG
|
TSDB_CFG_CTYPE_B_SHOW
;
cfg
.
minValue
=
TSDB_MIN_DB_CACHE_LAST_ROW
;
cfg
.
maxValue
=
TSDB_MAX_DB_CACHE_LAST_ROW
;
cfg
.
ptrLength
=
0
;
cfg
.
unitType
=
TAOS_CFG_UTYPE_NONE
;
taosInitConfigOption
(
cfg
);
cfg
.
option
=
"mqttHostName"
;
cfg
.
ptr
=
tsMqttHostName
;
cfg
.
valType
=
TAOS_CFG_VTYPE_STRING
;
...
...
src/common/src/tvariant.c
浏览文件 @
e4f83886
...
...
@@ -74,7 +74,7 @@ void tVariantCreate(tVariant *pVar, SStrToken *token) {
case
TSDB_DATA_TYPE_BINARY
:
{
pVar
->
pz
=
strndup
(
token
->
z
,
token
->
n
);
pVar
->
nLen
=
str
dequote
(
pVar
->
pz
);
pVar
->
nLen
=
str
Rmquote
(
pVar
->
pz
,
token
->
n
);
break
;
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBPreparedStatementTest.java
浏览文件 @
e4f83886
src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBResultSetTest.java
浏览文件 @
e4f83886
...
...
@@ -177,6 +177,7 @@ public class TSDBResultSetTest {
rs
.
getAsciiStream
(
"f1"
);
}
@SuppressWarnings
(
"deprecation"
)
@Test
(
expected
=
SQLFeatureNotSupportedException
.
class
)
public
void
getUnicodeStream
()
throws
SQLException
{
rs
.
getUnicodeStream
(
"f1"
);
...
...
src/connector/python/taos/cinterface.py
浏览文件 @
e4f83886
...
...
@@ -242,7 +242,7 @@ def _load_taos_linux():
def
_load_taos_darwin
():
return
ctypes
.
c
DLL
(
'libtaos.dylib'
)
return
ctypes
.
C
DLL
(
'libtaos.dylib'
)
def
_load_taos_windows
():
...
...
src/cq/src/cqMain.c
浏览文件 @
e4f83886
...
...
@@ -38,21 +38,6 @@
#define cDebug(...) { if (cqDebugFlag & DEBUG_DEBUG) { taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__); }}
#define cTrace(...) { if (cqDebugFlag & DEBUG_TRACE) { taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__); }}
typedef
struct
{
int32_t
vgId
;
int32_t
master
;
int32_t
num
;
// number of continuous streams
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_KEY_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
FCqWrite
cqWrite
;
struct
SCqObj
*
pHead
;
void
*
dbConn
;
void
*
tmrCtrl
;
pthread_mutex_t
mutex
;
int32_t
delete
;
int32_t
cqObjNum
;
}
SCqContext
;
typedef
struct
SCqObj
{
tmr_h
tmrId
;
...
...
@@ -439,7 +424,7 @@ static void cqProcessCreateTimer(void *param, void *tmrId) {
// inner implement in tscStream.c
TAOS_STREAM
*
taos_open_stream_withname
(
TAOS
*
taos
,
const
char
*
desName
,
const
char
*
sqlstr
,
void
(
*
fp
)(
void
*
param
,
TAOS_RES
*
,
TAOS_ROW
row
),
int64_t
stime
,
void
*
param
,
void
(
*
callback
)(
void
*
));
int64_t
stime
,
void
*
param
,
void
(
*
callback
)(
void
*
)
,
void
*
cqhandle
);
static
void
cqCreateStream
(
SCqContext
*
pContext
,
SCqObj
*
pObj
)
{
pObj
->
pContext
=
pContext
;
...
...
@@ -453,7 +438,8 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) {
pObj
->
tmrId
=
0
;
if
(
pObj
->
pStream
==
NULL
)
{
pObj
->
pStream
=
taos_open_stream_withname
(
pContext
->
dbConn
,
pObj
->
dstTable
,
pObj
->
sqlStr
,
cqProcessStreamRes
,
INT64_MIN
,
(
void
*
)
pObj
->
rid
,
NULL
);
pObj
->
pStream
=
taos_open_stream_withname
(
pContext
->
dbConn
,
pObj
->
dstTable
,
pObj
->
sqlStr
,
cqProcessStreamRes
,
\
INT64_MIN
,
(
void
*
)
pObj
->
rid
,
NULL
,
pContext
);
// TODO the pObj->pStream may be released if error happens
if
(
pObj
->
pStream
)
{
...
...
src/inc/tcq.h
浏览文件 @
e4f83886
...
...
@@ -31,6 +31,23 @@ typedef struct {
FCqWrite
cqWrite
;
}
SCqCfg
;
// SCqContext
typedef
struct
{
int32_t
vgId
;
int32_t
master
;
int32_t
num
;
// number of continuous streams
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_KEY_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
FCqWrite
cqWrite
;
struct
SCqObj
*
pHead
;
void
*
dbConn
;
void
*
tmrCtrl
;
pthread_mutex_t
mutex
;
int32_t
delete
;
int32_t
cqObjNum
;
}
SCqContext
;
// the following API shall be called by vnode
void
*
cqOpen
(
void
*
ahandle
,
const
SCqCfg
*
pCfg
);
void
cqClose
(
void
*
handle
);
...
...
src/inc/tsdb.h
浏览文件 @
e4f83886
...
...
@@ -94,7 +94,7 @@ STsdbRepo *tsdbOpenRepo(STsdbCfg *pCfg, STsdbAppH *pAppH);
int
tsdbCloseRepo
(
STsdbRepo
*
repo
,
int
toCommit
);
int32_t
tsdbConfigRepo
(
STsdbRepo
*
repo
,
STsdbCfg
*
pCfg
);
int
tsdbGetState
(
STsdbRepo
*
repo
);
bool
tsdbInCompact
(
STsdbRepo
*
repo
);
// --------- TSDB TABLE DEFINITION
typedef
struct
{
uint64_t
uid
;
// the unique table ID
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
e4f83886
...
...
@@ -398,7 +398,10 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
time_t
tt
;
int32_t
ms
=
0
;
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
tt
=
(
time_t
)(
val
/
1000000000
);
ms
=
val
%
1000000000
;
}
else
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
tt
=
(
time_t
)(
val
/
1000000
);
ms
=
val
%
1000000
;
}
else
{
...
...
@@ -419,7 +422,9 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
#endif
if
(
tt
<=
0
&&
ms
<
0
)
{
tt
--
;
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
ms
+=
1000000000
;
}
else
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
ms
+=
1000000
;
}
else
{
ms
+=
1000
;
...
...
@@ -427,9 +432,11 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
}
struct
tm
*
ptm
=
localtime
(
&
tt
);
size_t
pos
=
strftime
(
buf
,
3
2
,
"%Y-%m-%d %H:%M:%S"
,
ptm
);
size_t
pos
=
strftime
(
buf
,
3
5
,
"%Y-%m-%d %H:%M:%S"
,
ptm
);
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
sprintf
(
buf
+
pos
,
".%09d"
,
ms
);
}
else
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
sprintf
(
buf
+
pos
,
".%06d"
,
ms
);
}
else
{
sprintf
(
buf
+
pos
,
".%03d"
,
ms
);
...
...
@@ -778,6 +785,8 @@ static int calcColWidth(TAOS_FIELD* field, int precision) {
case
TSDB_DATA_TYPE_TIMESTAMP
:
if
(
args
.
is_raw_time
)
{
return
MAX
(
14
,
width
);
}
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
return
MAX
(
29
,
width
);
}
else
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
return
MAX
(
26
,
width
);
// '2020-01-01 00:00:00.000000'
}
else
{
...
...
src/kit/taosdemo/taosdemo.c
浏览文件 @
e4f83886
...
...
@@ -1213,7 +1213,6 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) {
}
int
totalLen
=
0
;
char
temp
[
16000
];
// fetch the records row by row
while
((
row
=
taos_fetch_row
(
res
)))
{
...
...
@@ -1224,6 +1223,7 @@ static void fetchResult(TAOS_RES *res, threadInfo* pThreadInfo) {
memset
(
databuf
,
0
,
100
*
1024
*
1024
);
}
num_rows
++
;
char
temp
[
16000
]
=
{
0
};
int
len
=
taos_print_row
(
temp
,
row
,
fields
,
num_fields
);
len
+=
sprintf
(
temp
+
len
,
"
\n
"
);
//printf("query result:%s\n", temp);
...
...
@@ -1852,7 +1852,9 @@ static void printfQueryMeta() {
static
char
*
formatTimestamp
(
char
*
buf
,
int64_t
val
,
int
precision
)
{
time_t
tt
;
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
tt
=
(
time_t
)(
val
/
1000000000
);
}
else
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
tt
=
(
time_t
)(
val
/
1000000
);
}
else
{
tt
=
(
time_t
)(
val
/
1000
);
...
...
@@ -1873,7 +1875,9 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
struct
tm
*
ptm
=
localtime
(
&
tt
);
size_t
pos
=
strftime
(
buf
,
32
,
"%Y-%m-%d %H:%M:%S"
,
ptm
);
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
sprintf
(
buf
+
pos
,
".%09d"
,
(
int
)(
val
%
1000000000
));
}
else
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
sprintf
(
buf
+
pos
,
".%06d"
,
(
int
)(
val
%
1000000
));
}
else
{
sprintf
(
buf
+
pos
,
".%03d"
,
(
int
)(
val
%
1000
));
...
...
@@ -6255,6 +6259,8 @@ static void startMultiThreadInsertData(int threads, char* db_name,
timePrec
=
TSDB_TIME_PRECISION_MILLI
;
}
else
if
(
0
==
strncasecmp
(
precision
,
"us"
,
2
))
{
timePrec
=
TSDB_TIME_PRECISION_MICRO
;
}
else
if
(
0
==
strncasecmp
(
precision
,
"ns"
,
2
))
{
timePrec
=
TSDB_TIME_PRECISION_NANO
;
}
else
{
errorPrint
(
"Not support precision: %s
\n
"
,
precision
);
exit
(
-
1
);
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
e4f83886
...
...
@@ -820,8 +820,13 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void
#endif
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
char
*
prec
=
(
pDb
->
cfg
.
precision
==
TSDB_TIME_PRECISION_MILLI
)
?
TSDB_TIME_PRECISION_MILLI_STR
:
TSDB_TIME_PRECISION_MICRO_STR
;
char
*
prec
=
NULL
;
switch
(
pDb
->
cfg
.
precision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
prec
=
TSDB_TIME_PRECISION_MILLI_STR
;
break
;
case
TSDB_TIME_PRECISION_MICRO
:
prec
=
TSDB_TIME_PRECISION_MICRO_STR
;
break
;
case
TSDB_TIME_PRECISION_NANO
:
prec
=
TSDB_TIME_PRECISION_NANO_STR
;
break
;
default:
assert
(
false
);
break
;
}
STR_WITH_SIZE_TO_VARSTR
(
pWrite
,
prec
,
2
);
cols
++
;
...
...
src/os/inc/osTime.h
浏览文件 @
e4f83886
...
...
@@ -55,6 +55,13 @@ static FORCE_INLINE int64_t taosGetTimestampUs() {
return
(
int64_t
)
systemTime
.
tv_sec
*
1000000L
+
(
int64_t
)
systemTime
.
tv_usec
;
}
//@return timestamp in nanosecond
static
FORCE_INLINE
int64_t
taosGetTimestampNs
()
{
struct
timespec
systemTime
=
{
0
};
clock_gettime
(
CLOCK_REALTIME
,
&
systemTime
);
return
(
int64_t
)
systemTime
.
tv_sec
*
1000000000L
+
(
int64_t
)
systemTime
.
tv_nsec
;
}
/*
* @return timestamp decided by global conf variable, tsTimePrecision
* if precision == TSDB_TIME_PRECISION_MICRO, it returns timestamp in microsecond.
...
...
@@ -63,7 +70,9 @@ static FORCE_INLINE int64_t taosGetTimestampUs() {
static
FORCE_INLINE
int64_t
taosGetTimestamp
(
int32_t
precision
)
{
if
(
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
return
taosGetTimestampUs
();
}
else
{
}
else
if
(
precision
==
TSDB_TIME_PRECISION_NANO
)
{
return
taosGetTimestampNs
();
}
else
{
return
taosGetTimestampMs
();
}
}
...
...
@@ -88,12 +97,13 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision);
int64_t
taosTimeTruncate
(
int64_t
t
,
const
SInterval
*
pInterval
,
int32_t
precision
);
int32_t
taosTimeCountInterval
(
int64_t
skey
,
int64_t
ekey
,
int64_t
interval
,
char
unit
,
int32_t
precision
);
int32_t
parseAbsoluteDuration
(
char
*
token
,
int32_t
tokenlen
,
int64_t
*
ts
);
int32_t
parseNatualDuration
(
const
char
*
token
,
int32_t
tokenLen
,
int64_t
*
duration
,
char
*
unit
);
int32_t
parseAbsoluteDuration
(
char
*
token
,
int32_t
tokenlen
,
int64_t
*
ts
,
int32_t
timePrecision
);
int32_t
parseNatualDuration
(
const
char
*
token
,
int32_t
tokenLen
,
int64_t
*
duration
,
char
*
unit
,
int32_t
timePrecision
);
int32_t
taosParseTime
(
char
*
timestr
,
int64_t
*
time
,
int32_t
len
,
int32_t
timePrec
,
int8_t
dayligth
);
void
deltaToUtcInitOnce
();
int64_t
convertTimePrecision
(
int64_t
time
,
int32_t
fromPrecision
,
int32_t
toPrecision
);
#ifdef __cplusplus
}
#endif
...
...
src/os/src/detail/osString.c
浏览文件 @
e4f83886
...
...
@@ -59,6 +59,9 @@ bool taosMbsToUcs4(char *mbs, size_t mbsLength, char *ucs4, int32_t ucs4_max_len
iconv_close
(
cd
);
if
(
len
!=
NULL
)
{
*
len
=
(
int32_t
)(
ucs4_max_len
-
outLeft
);
if
(
*
len
<
0
)
{
return
false
;
}
}
return
true
;
...
...
src/os/src/detail/osTime.c
浏览文件 @
e4f83886
...
...
@@ -14,7 +14,13 @@
*/
#define _BSD_SOURCE
#ifdef DARWIN
#define _XOPEN_SOURCE
#else
#define _XOPEN_SOURCE 500
#endif
#define _DEFAULT_SOURCE
#include "os.h"
...
...
@@ -119,8 +125,9 @@ int64_t parseFraction(char* str, char** end, int32_t timePrec) {
const
int32_t
MILLI_SEC_FRACTION_LEN
=
3
;
const
int32_t
MICRO_SEC_FRACTION_LEN
=
6
;
const
int32_t
NANO_SEC_FRACTION_LEN
=
9
;
int32_t
factor
[
6
]
=
{
1
,
10
,
100
,
1000
,
10000
,
1
00000
};
int32_t
factor
[
9
]
=
{
1
,
10
,
100
,
1000
,
10000
,
100000
,
1000000
,
10000000
,
1000
00000
};
int32_t
times
=
1
;
while
(
str
[
i
]
>=
'0'
&&
str
[
i
]
<=
'9'
)
{
...
...
@@ -140,12 +147,17 @@ int64_t parseFraction(char* str, char** end, int32_t timePrec) {
}
times
=
MILLI_SEC_FRACTION_LEN
-
i
;
}
else
{
assert
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
);
}
else
if
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
)
{
if
(
i
>=
MICRO_SEC_FRACTION_LEN
)
{
i
=
MICRO_SEC_FRACTION_LEN
;
}
times
=
MICRO_SEC_FRACTION_LEN
-
i
;
}
else
{
assert
(
timePrec
==
TSDB_TIME_PRECISION_NANO
);
if
(
i
>=
NANO_SEC_FRACTION_LEN
)
{
i
=
NANO_SEC_FRACTION_LEN
;
}
times
=
NANO_SEC_FRACTION_LEN
-
i
;
}
fraction
=
strnatoi
(
str
,
i
)
*
factor
[
times
];
...
...
@@ -202,7 +214,9 @@ int32_t parseTimezone(char* str, int64_t* tzOffset) {
* 2013-04-12T15:52:01.123+0800
*/
int32_t
parseTimeWithTz
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
)
{
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
1000000
;
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
?
1000000
:
1000000000
);
int64_t
tzOffset
=
0
;
struct
tm
tm
=
{
0
};
...
...
@@ -287,7 +301,8 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) {
}
}
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
1000000
;
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
?
1000000
:
1000000000
);
*
time
=
factor
*
seconds
+
fraction
;
return
0
;
...
...
@@ -315,37 +330,50 @@ int32_t parseLocaltimeWithDst(char* timestr, int64_t* time, int32_t timePrec) {
}
}
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
1000000
;
int64_t
factor
=
(
timePrec
==
TSDB_TIME_PRECISION_MILLI
)
?
1000
:
(
timePrec
==
TSDB_TIME_PRECISION_MICRO
?
1000000
:
1000000000
);
*
time
=
factor
*
seconds
+
fraction
;
return
0
;
}
static
int32_t
getDurationInUs
(
int64_t
val
,
char
unit
,
int64_t
*
result
)
{
*
result
=
val
;
int64_t
factor
=
1000L
;
int64_t
convertTimePrecision
(
int64_t
time
,
int32_t
fromPrecision
,
int32_t
toPrecision
)
{
assert
(
fromPrecision
==
TSDB_TIME_PRECISION_MILLI
||
fromPrecision
==
TSDB_TIME_PRECISION_MICRO
||
fromPrecision
==
TSDB_TIME_PRECISION_NANO
);
assert
(
toPrecision
==
TSDB_TIME_PRECISION_MILLI
||
toPrecision
==
TSDB_TIME_PRECISION_MICRO
||
toPrecision
==
TSDB_TIME_PRECISION_NANO
);
static
double
factors
[
3
][
3
]
=
{
{
1
.,
1000
.,
1000000
.},
{
1
.
0
/
1000
,
1
.,
1000
.},
{
1
.
0
/
1000000
,
1
.
0
/
1000
,
1
.}
};
return
(
int64_t
)((
double
)
time
*
factors
[
fromPrecision
][
toPrecision
]);
}
static
int32_t
getDuration
(
int64_t
val
,
char
unit
,
int64_t
*
result
,
int32_t
timePrecision
)
{
switch
(
unit
)
{
case
's'
:
(
*
result
)
*=
MILLISECOND_PER_SECOND
*
factor
;
(
*
result
)
=
convertTimePrecision
(
val
*
MILLISECOND_PER_SECOND
,
TSDB_TIME_PRECISION_MILLI
,
timePrecision
)
;
break
;
case
'm'
:
(
*
result
)
*=
MILLISECOND_PER_MINUTE
*
factor
;
(
*
result
)
=
convertTimePrecision
(
val
*
MILLISECOND_PER_MINUTE
,
TSDB_TIME_PRECISION_MILLI
,
timePrecision
)
;
break
;
case
'h'
:
(
*
result
)
*=
MILLISECOND_PER_HOUR
*
factor
;
(
*
result
)
=
convertTimePrecision
(
val
*
MILLISECOND_PER_HOUR
,
TSDB_TIME_PRECISION_MILLI
,
timePrecision
)
;
break
;
case
'd'
:
(
*
result
)
*=
MILLISECOND_PER_DAY
*
factor
;
(
*
result
)
=
convertTimePrecision
(
val
*
MILLISECOND_PER_DAY
,
TSDB_TIME_PRECISION_MILLI
,
timePrecision
)
;
break
;
case
'w'
:
(
*
result
)
*=
MILLISECOND_PER_WEEK
*
factor
;
(
*
result
)
=
convertTimePrecision
(
val
*
MILLISECOND_PER_WEEK
,
TSDB_TIME_PRECISION_MILLI
,
timePrecision
)
;
break
;
case
'a'
:
(
*
result
)
*=
factor
;
(
*
result
)
=
convertTimePrecision
(
val
,
TSDB_TIME_PRECISION_MILLI
,
timePrecision
)
;
break
;
case
'u'
:
(
*
result
)
=
convertTimePrecision
(
val
,
TSDB_TIME_PRECISION_MICRO
,
timePrecision
);
break
;
case
'b'
:
(
*
result
)
=
convertTimePrecision
(
val
,
TSDB_TIME_PRECISION_NANO
,
timePrecision
);
break
;
default:
{
return
-
1
;
...
...
@@ -357,6 +385,8 @@ static int32_t getDurationInUs(int64_t val, char unit, int64_t* result) {
}
/*
* b - nanoseconds;
* u - microseconds;
* a - Millionseconds
* s - Seconds
* m - Minutes
...
...
@@ -366,7 +396,7 @@ static int32_t getDurationInUs(int64_t val, char unit, int64_t* result) {
* n - Months (30 days)
* y - Years (365 days)
*/
int32_t
parseAbsoluteDuration
(
char
*
token
,
int32_t
tokenlen
,
int64_t
*
duration
)
{
int32_t
parseAbsoluteDuration
(
char
*
token
,
int32_t
tokenlen
,
int64_t
*
duration
,
int32_t
timePrecision
)
{
errno
=
0
;
char
*
endPtr
=
NULL
;
...
...
@@ -382,10 +412,10 @@ int32_t parseAbsoluteDuration(char* token, int32_t tokenlen, int64_t* duration)
return
-
1
;
}
return
getDuration
InUs
(
timestamp
,
unit
,
durat
ion
);
return
getDuration
(
timestamp
,
unit
,
duration
,
timePrecis
ion
);
}
int32_t
parseNatualDuration
(
const
char
*
token
,
int32_t
tokenLen
,
int64_t
*
duration
,
char
*
unit
)
{
int32_t
parseNatualDuration
(
const
char
*
token
,
int32_t
tokenLen
,
int64_t
*
duration
,
char
*
unit
,
int32_t
timePrecision
)
{
errno
=
0
;
/* get the basic numeric value */
...
...
@@ -399,7 +429,7 @@ int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* durati
return
0
;
}
return
getDuration
InUs
(
*
duration
,
*
unit
,
durat
ion
);
return
getDuration
(
*
duration
,
*
unit
,
duration
,
timePrecis
ion
);
}
int64_t
taosTimeAdd
(
int64_t
t
,
int64_t
duration
,
char
unit
,
int32_t
precision
)
{
...
...
src/plugins/http/inc/httpJson.h
浏览文件 @
e4f83886
...
...
@@ -64,8 +64,8 @@ void httpJsonOriginString(JsonBuf* buf, char* sVal, int32_t len);
void
httpJsonStringForTransMean
(
JsonBuf
*
buf
,
char
*
SVal
,
int32_t
maxLen
);
void
httpJsonInt64
(
JsonBuf
*
buf
,
int64_t
num
);
void
httpJsonUInt64
(
JsonBuf
*
buf
,
uint64_t
num
);
void
httpJsonTimestamp
(
JsonBuf
*
buf
,
int64_t
t
,
bool
us
);
void
httpJsonUtcTimestamp
(
JsonBuf
*
buf
,
int64_t
t
,
bool
us
);
void
httpJsonTimestamp
(
JsonBuf
*
buf
,
int64_t
t
,
int32_t
timePrecision
);
void
httpJsonUtcTimestamp
(
JsonBuf
*
buf
,
int64_t
t
,
int32_t
timePrecision
);
void
httpJsonInt
(
JsonBuf
*
buf
,
int32_t
num
);
void
httpJsonUInt
(
JsonBuf
*
buf
,
uint32_t
num
);
void
httpJsonFloat
(
JsonBuf
*
buf
,
float
num
);
...
...
src/plugins/http/src/httpJson.c
浏览文件 @
e4f83886
...
...
@@ -262,42 +262,92 @@ void httpJsonUInt64(JsonBuf* buf, uint64_t num) {
buf
->
lst
+=
snprintf
(
buf
->
lst
,
MAX_NUM_STR_SZ
,
"%"
PRIu64
,
num
);
}
void
httpJsonTimestamp
(
JsonBuf
*
buf
,
int64_t
t
,
bool
us
)
{
void
httpJsonTimestamp
(
JsonBuf
*
buf
,
int64_t
t
,
int32_t
timePrecision
)
{
char
ts
[
35
]
=
{
0
};
struct
tm
*
ptm
;
int32_t
precision
=
1000
;
if
(
us
)
{
precision
=
1000000
;
int32_t
fractionLen
;
char
*
format
=
NULL
;
time_t
quot
=
0
;
long
mod
=
0
;
switch
(
timePrecision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
{
quot
=
t
/
1000
;
fractionLen
=
5
;
format
=
".%03"
PRId64
;
mod
=
t
%
1000
;
break
;
}
time_t
tt
=
t
/
precision
;
ptm
=
localtime
(
&
tt
);
int32_t
length
=
(
int32_t
)
strftime
(
ts
,
35
,
"%Y-%m-%d %H:%M:%S"
,
ptm
);
if
(
us
)
{
length
+=
snprintf
(
ts
+
length
,
8
,
".%06"
PRId64
,
t
%
precision
);
}
else
{
length
+=
snprintf
(
ts
+
length
,
5
,
".%03"
PRId64
,
t
%
precision
);
case
TSDB_TIME_PRECISION_MICRO
:
{
quot
=
t
/
1000000
;
fractionLen
=
8
;
format
=
".%06"
PRId64
;
mod
=
t
%
1000000
;
break
;
}
case
TSDB_TIME_PRECISION_NANO
:
{
quot
=
t
/
1000000000
;
fractionLen
=
11
;
format
=
".%09"
PRId64
;
mod
=
t
%
1000000000
;
break
;
}
default:
assert
(
false
);
}
ptm
=
localtime
(
&
quot
);
int32_t
length
=
(
int32_t
)
strftime
(
ts
,
35
,
"%Y-%m-%d %H:%M:%S"
,
ptm
);
length
+=
snprintf
(
ts
+
length
,
fractionLen
,
format
,
mod
);
httpJsonString
(
buf
,
ts
,
length
);
}
void
httpJsonUtcTimestamp
(
JsonBuf
*
buf
,
int64_t
t
,
bool
us
)
{
void
httpJsonUtcTimestamp
(
JsonBuf
*
buf
,
int64_t
t
,
int32_t
timePrecision
)
{
char
ts
[
40
]
=
{
0
};
struct
tm
*
ptm
;
int32_t
precision
=
1000
;
if
(
us
)
{
precision
=
1000000
;
int32_t
fractionLen
;
char
*
format
=
NULL
;
time_t
quot
=
0
;
long
mod
=
0
;
switch
(
timePrecision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
{
quot
=
t
/
1000
;
fractionLen
=
5
;
format
=
".%03"
PRId64
;
mod
=
t
%
1000
;
break
;
}
time_t
tt
=
t
/
precision
;
ptm
=
localtime
(
&
tt
);
int32_t
length
=
(
int32_t
)
strftime
(
ts
,
40
,
"%Y-%m-%dT%H:%M:%S"
,
ptm
);
if
(
us
)
{
length
+=
snprintf
(
ts
+
length
,
8
,
".%06"
PRId64
,
t
%
precision
);
}
else
{
length
+=
snprintf
(
ts
+
length
,
5
,
".%03"
PRId64
,
t
%
precision
);
case
TSDB_TIME_PRECISION_MICRO
:
{
quot
=
t
/
1000000
;
fractionLen
=
8
;
format
=
".%06"
PRId64
;
mod
=
t
%
1000000
;
break
;
}
case
TSDB_TIME_PRECISION_NANO
:
{
quot
=
t
/
1000000000
;
fractionLen
=
11
;
format
=
".%09"
PRId64
;
mod
=
t
%
1000000000
;
break
;
}
default:
assert
(
false
);
}
ptm
=
localtime
(
&
quot
);
int32_t
length
=
(
int32_t
)
strftime
(
ts
,
40
,
"%Y-%m-%dT%H:%M:%S"
,
ptm
);
length
+=
snprintf
(
ts
+
length
,
fractionLen
,
format
,
mod
);
length
+=
(
int32_t
)
strftime
(
ts
+
length
,
40
-
length
,
"%z"
,
ptm
);
httpJsonString
(
buf
,
ts
,
length
);
...
...
src/plugins/http/src/httpRestJson.c
浏览文件 @
e4f83886
...
...
@@ -186,13 +186,11 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
if
(
timestampFormat
==
REST_TIMESTAMP_FMT_LOCAL_STRING
)
{
httpJsonTimestamp
(
jsonBuf
,
*
((
int64_t
*
)
row
[
i
]),
taos_result_precision
(
result
)
==
TSDB_TIME_PRECISION_MICRO
);
httpJsonTimestamp
(
jsonBuf
,
*
((
int64_t
*
)
row
[
i
]),
taos_result_precision
(
result
));
}
else
if
(
timestampFormat
==
REST_TIMESTAMP_FMT_TIMESTAMP
)
{
httpJsonInt64
(
jsonBuf
,
*
((
int64_t
*
)
row
[
i
]));
}
else
{
httpJsonUtcTimestamp
(
jsonBuf
,
*
((
int64_t
*
)
row
[
i
]),
taos_result_precision
(
result
)
==
TSDB_TIME_PRECISION_MICRO
);
httpJsonUtcTimestamp
(
jsonBuf
,
*
((
int64_t
*
)
row
[
i
]),
taos_result_precision
(
result
));
}
break
;
default:
...
...
src/query/inc/qExecutor.h
浏览文件 @
e4f83886
...
...
@@ -464,6 +464,7 @@ typedef struct SSWindowOperatorInfo {
TSKEY
prevTs
;
// previous timestamp
int32_t
numOfRows
;
// number of rows
int32_t
start
;
// start row index
bool
reptScan
;
// next round scan
}
SSWindowOperatorInfo
;
typedef
struct
SStateWindowOperatorInfo
{
...
...
@@ -473,7 +474,7 @@ typedef struct SStateWindowOperatorInfo {
int32_t
colIndex
;
// start row index
int32_t
start
;
char
*
prevData
;
// previous data
bool
reptScan
;
}
SStateWindowOperatorInfo
;
typedef
struct
SDistinctOperatorInfo
{
...
...
src/query/inc/qSqlparser.h
浏览文件 @
e4f83886
...
...
@@ -46,7 +46,7 @@ enum SQL_NODE_FROM_TYPE {
enum
SQL_EXPR_FLAG
{
EXPR_FLAG_TS_ERROR
=
1
,
EXPR_FLAG_
U
S_TIMESTAMP
=
2
,
EXPR_FLAG_
N
S_TIMESTAMP
=
2
,
EXPR_FLAG_TIMESTAMP_VAR
=
3
,
};
...
...
src/query/inc/sql.y
浏览文件 @
e4f83886
...
...
@@ -559,10 +559,8 @@ session_option(X) ::= SESSION LP ids(V) cpxName(Z) COMMA tmvar(Y) RP. {
X.gap = Y;
}
%type windowstate_option {SWindowStateVal}
windowstate_option(X) ::= . {X.col.n = 0;}
windowstate_option(X) ::= STATE_WINDOW LP ids(V) RP. {
X.col = V;
}
windowstate_option(X) ::= . { X.col.n = 0; X.col.z = NULL;}
windowstate_option(X) ::= STATE_WINDOW LP ids(V) RP. { X.col = V; }
%type fill_opt {SArray*}
%destructor fill_opt {taosArrayDestroy($$);}
...
...
src/query/src/qAggMain.c
浏览文件 @
e4f83886
...
...
@@ -3428,7 +3428,7 @@ static bool deriv_function_setup(SQLFunctionCtx *pCtx) {
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SDerivInfo
*
pDerivInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
pDerivInfo
->
ignoreNegative
=
pCtx
->
param
[
2
].
i64
;
pDerivInfo
->
ignoreNegative
=
pCtx
->
param
[
1
].
i64
;
pDerivInfo
->
prevTs
=
-
1
;
pDerivInfo
->
tsWindow
=
pCtx
->
param
[
0
].
i64
;
pDerivInfo
->
valueSet
=
false
;
...
...
@@ -3440,10 +3440,8 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
SDerivInfo
*
pDerivInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
void
*
data
=
GET_INPUT_DATA_LIST
(
pCtx
);
bool
isFirstBlock
=
(
pDerivInfo
->
valueSet
==
false
);
int32_t
notNullElems
=
0
;
int32_t
step
=
GET_FORWARD_DIRECTION_FACTOR
(
pCtx
->
order
);
int32_t
i
=
(
pCtx
->
order
==
TSDB_ORDER_ASC
)
?
0
:
pCtx
->
size
-
1
;
...
...
@@ -3469,12 +3467,12 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
}
}
pDerivInfo
->
prevValue
=
pData
[
i
];
pDerivInfo
->
prevTs
=
tsList
[
i
];
notNullElems
++
;
}
break
;
...
...
@@ -3496,12 +3494,12 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
}
}
pDerivInfo
->
prevValue
=
(
double
)
pData
[
i
];
pDerivInfo
->
prevTs
=
tsList
[
i
];
notNullElems
++
;
}
break
;
}
...
...
@@ -3522,12 +3520,12 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
}
}
pDerivInfo
->
prevValue
=
pData
[
i
];
pDerivInfo
->
prevTs
=
tsList
[
i
];
notNullElems
++
;
}
break
;
}
...
...
@@ -3549,12 +3547,12 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
}
}
pDerivInfo
->
prevValue
=
pData
[
i
];
pDerivInfo
->
prevTs
=
tsList
[
i
];
notNullElems
++
;
}
break
;
}
...
...
@@ -3575,12 +3573,12 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
*
pTimestamp
=
tsList
[
i
];
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
}
}
pDerivInfo
->
prevValue
=
pData
[
i
];
pDerivInfo
->
prevTs
=
tsList
[
i
];
notNullElems
++
;
}
break
;
}
...
...
@@ -3602,12 +3600,12 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
pOutput
+=
1
;
pTimestamp
+=
1
;
notNullElems
++
;
}
}
pDerivInfo
->
prevValue
=
pData
[
i
];
pDerivInfo
->
prevTs
=
tsList
[
i
];
notNullElems
++
;
}
break
;
}
...
...
@@ -3623,8 +3621,7 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
*/
assert
(
pCtx
->
hasNull
);
}
else
{
int32_t
forwardStep
=
(
isFirstBlock
)
?
notNullElems
-
1
:
notNullElems
;
GET_RES_INFO
(
pCtx
)
->
numOfRes
+=
forwardStep
;
GET_RES_INFO
(
pCtx
)
->
numOfRes
+=
notNullElems
;
}
}
...
...
@@ -4687,8 +4684,8 @@ static bool rate_function_setup(SQLFunctionCtx *pCtx) {
pInfo
->
correctionValue
=
0
;
pInfo
->
firstKey
=
INT64_MIN
;
pInfo
->
lastKey
=
INT64_MIN
;
pInfo
->
firstValue
=
INT64_MIN
;
pInfo
->
lastValue
=
INT64_MIN
;
pInfo
->
firstValue
=
(
double
)
INT64_MIN
;
pInfo
->
lastValue
=
(
double
)
INT64_MIN
;
pInfo
->
hasResult
=
0
;
pInfo
->
isIRate
=
(
pCtx
->
functionId
==
TSDB_FUNC_IRATE
);
...
...
@@ -5003,6 +5000,19 @@ void generateBlockDistResult(STableBlockDist *pTableBlockDist, char* result) {
min
=
totalBlocks
>
0
?
pTableBlockDist
->
minRows
:
0
;
max
=
totalBlocks
>
0
?
pTableBlockDist
->
maxRows
:
0
;
double
stdDev
=
0
;
if
(
totalBlocks
>
0
)
{
double
variance
=
0
;
for
(
int32_t
i
=
0
;
i
<
numSteps
;
i
++
)
{
SFileBlockInfo
*
blockInfo
=
taosArrayGet
(
blockInfos
,
i
);
int64_t
blocks
=
blockInfo
->
numBlocksOfStep
;
int32_t
rows
=
(
i
*
TSDB_BLOCK_DIST_STEP_ROWS
+
TSDB_BLOCK_DIST_STEP_ROWS
/
2
);
variance
+=
blocks
*
(
rows
-
avg
)
*
(
rows
-
avg
);
}
variance
=
variance
/
totalBlocks
;
stdDev
=
sqrt
(
variance
);
}
double
percents
[]
=
{
0
.
05
,
0
.
10
,
0
.
20
,
0
.
30
,
0
.
40
,
0
.
50
,
0
.
60
,
0
.
70
,
0
.
80
,
0
.
90
,
0
.
95
,
0
.
99
};
int32_t
percentiles
[]
=
{
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
};
assert
(
sizeof
(
percents
)
/
sizeof
(
double
)
==
sizeof
(
percentiles
)
/
sizeof
(
int32_t
));
...
...
@@ -5017,12 +5027,12 @@ void generateBlockDistResult(STableBlockDist *pTableBlockDist, char* result) {
"60th=[%d], 70th=[%d], 80th=[%d], 90th=[%d], 95th=[%d], 99th=[%d]
\n\t
"
"Min=[%"
PRId64
"(Rows)] Max=[%"
PRId64
"(Rows)] Avg=[%"
PRId64
"(Rows)] Stddev=[%.2f]
\n\t
"
"Rows=[%"
PRIu64
"], Blocks=[%"
PRId64
"], Size=[%.3f(Kb)] Comp=[%.2f]
\n\t
"
"RowsInMem=[%d]
\n\t
SeekHeaderTime=[%d(us)]
"
,
"RowsInMem=[%d]
\n\t
"
,
percentiles
[
0
],
percentiles
[
1
],
percentiles
[
2
],
percentiles
[
3
],
percentiles
[
4
],
percentiles
[
5
],
percentiles
[
6
],
percentiles
[
7
],
percentiles
[
8
],
percentiles
[
9
],
percentiles
[
10
],
percentiles
[
11
],
min
,
max
,
avg
,
0
.
0
,
min
,
max
,
avg
,
stdDev
,
totalRows
,
totalBlocks
,
totalLen
/
1024
.
0
,
compRatio
,
pTableBlockDist
->
numOfRowsInMemTable
,
pTableBlockDist
->
firstSeekTimeUs
);
pTableBlockDist
->
numOfRowsInMemTable
);
varDataSetLen
(
result
,
sz
);
UNUSED
(
sz
);
}
...
...
@@ -5290,7 +5300,7 @@ SAggFunctionInfo aAggs[] = {{
},
{
// 17
"ts
_dummy
"
,
"ts"
,
TSDB_FUNC_TS_DUMMY
,
TSDB_FUNC_TS_DUMMY
,
TSDB_BASE_FUNC_SO
|
TSDB_FUNCSTATE_NEED_TS
,
...
...
@@ -5384,7 +5394,7 @@ SAggFunctionInfo aAggs[] = {{
"diff"
,
TSDB_FUNC_DIFF
,
TSDB_FUNC_INVALID_ID
,
TSDB_FUNCSTATE_MO
|
TSDB_FUNCSTATE_STABLE
|
TSDB_FUNCSTATE_NEED_TS
,
TSDB_FUNCSTATE_MO
|
TSDB_FUNCSTATE_STABLE
|
TSDB_FUNCSTATE_NEED_TS
|
TSDB_FUNCSTATE_SELECTIVITY
,
diff_function_setup
,
diff_function
,
diff_function_f
,
...
...
@@ -5488,7 +5498,7 @@ SAggFunctionInfo aAggs[] = {{
"derivative"
,
// return table id and the corresponding tags for join match and subscribe
TSDB_FUNC_DERIVATIVE
,
TSDB_FUNC_INVALID_ID
,
TSDB_FUNCSTATE_MO
|
TSDB_FUNCSTATE_STABLE
|
TSDB_FUNCSTATE_NEED_TS
,
TSDB_FUNCSTATE_MO
|
TSDB_FUNCSTATE_STABLE
|
TSDB_FUNCSTATE_NEED_TS
|
TSDB_FUNCSTATE_SELECTIVITY
,
deriv_function_setup
,
deriv_function
,
noop2
,
...
...
src/query/src/qExecutor.c
浏览文件 @
e4f83886
...
...
@@ -30,6 +30,7 @@
#define IS_MASTER_SCAN(runtime) ((runtime)->scanFlag == MASTER_SCAN)
#define IS_REVERSE_SCAN(runtime) ((runtime)->scanFlag == REVERSE_SCAN)
#define IS_REPEAT_SCAN(runtime) ((runtime)->scanFlag == REPEAT_SCAN)
#define SET_MASTER_SCAN_FLAG(runtime) ((runtime)->scanFlag = MASTER_SCAN)
#define SET_REVERSE_SCAN_FLAG(runtime) ((runtime)->scanFlag = REVERSE_SCAN)
...
...
@@ -130,10 +131,10 @@ static void getNextTimeWindow(SQueryAttr* pQueryAttr, STimeWindow* tw) {
return
;
}
int64_t
key
=
tw
->
skey
/
1000
,
interval
=
pQueryAttr
->
interval
.
interval
;
if
(
pQueryAttr
->
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
key
/=
1000
;
}
int64_t
key
=
tw
->
skey
,
interval
=
pQueryAttr
->
interval
.
interval
;
//convert key to second
key
=
convertTimePrecision
(
key
,
pQueryAttr
->
precision
,
TSDB_TIME_PRECISION_MILLI
)
/
1000
;
if
(
pQueryAttr
->
interval
.
intervalUnit
==
'y'
)
{
interval
*=
12
;
}
...
...
@@ -145,17 +146,13 @@ static void getNextTimeWindow(SQueryAttr* pQueryAttr, STimeWindow* tw) {
int
mon
=
(
int
)(
tm
.
tm_year
*
12
+
tm
.
tm_mon
+
interval
*
factor
);
tm
.
tm_year
=
mon
/
12
;
tm
.
tm_mon
=
mon
%
12
;
tw
->
skey
=
mktime
(
&
tm
)
*
1000L
;
tw
->
skey
=
convertTimePrecision
(
mktime
(
&
tm
)
*
1000L
,
TSDB_TIME_PRECISION_MILLI
,
pQueryAttr
->
precision
)
;
mon
=
(
int
)(
mon
+
interval
);
tm
.
tm_year
=
mon
/
12
;
tm
.
tm_mon
=
mon
%
12
;
tw
->
ekey
=
mktime
(
&
tm
)
*
1000L
;
tw
->
ekey
=
convertTimePrecision
(
mktime
(
&
tm
)
*
1000L
,
TSDB_TIME_PRECISION_MILLI
,
pQueryAttr
->
precision
)
;
if
(
pQueryAttr
->
precision
==
TSDB_TIME_PRECISION_MICRO
)
{
tw
->
skey
*=
1000L
;
tw
->
ekey
*=
1000L
;
}
tw
->
ekey
-=
1
;
}
...
...
@@ -735,6 +732,7 @@ static void doApplyFunctions(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx
if
(
pCtx
[
k
].
preAggVals
.
isSet
&&
forwardStep
<
numOfTotal
)
{
pCtx
[
k
].
preAggVals
.
isSet
=
false
;
}
if
(
functionNeedToExecute
(
pRuntimeEnv
,
&
pCtx
[
k
],
functionId
))
{
aAggs
[
functionId
].
xFunction
(
&
pCtx
[
k
]);
}
...
...
@@ -918,7 +916,7 @@ void setInputDataBlock(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx, SSDataBlo
doSetInputDataBlockInfo
(
pOperator
,
pCtx
,
pBlock
,
order
);
}
}
else
{
if
(
pCtx
[
0
].
pInput
==
NULL
&&
pBlock
->
pDataBlock
!=
NULL
)
{
if
(
/*pCtx[0].pInput == NULL && */
pBlock
->
pDataBlock
!=
NULL
)
{
doSetInputDataBlock
(
pOperator
,
pCtx
,
pBlock
,
order
);
}
else
{
doSetInputDataBlockInfo
(
pOperator
,
pCtx
,
pBlock
,
order
);
...
...
@@ -1336,6 +1334,10 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf
int64_t
gap
=
pOperator
->
pRuntimeEnv
->
pQueryAttr
->
sw
.
gap
;
pInfo
->
numOfRows
=
0
;
if
(
IS_REPEAT_SCAN
(
pRuntimeEnv
)
&&
!
pInfo
->
reptScan
)
{
pInfo
->
reptScan
=
true
;
pInfo
->
prevTs
=
INT64_MIN
;
}
TSKEY
*
tsList
=
(
TSKEY
*
)
pColInfoData
->
pData
;
for
(
int32_t
j
=
0
;
j
<
pSDataBlock
->
info
.
rows
;
++
j
)
{
...
...
@@ -1345,7 +1347,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf
pInfo
->
prevTs
=
tsList
[
j
];
pInfo
->
numOfRows
=
1
;
pInfo
->
start
=
j
;
}
else
if
(
tsList
[
j
]
-
pInfo
->
prevTs
<=
gap
)
{
}
else
if
(
tsList
[
j
]
-
pInfo
->
prevTs
<=
gap
&&
(
tsList
[
j
]
-
pInfo
->
prevTs
)
>=
0
)
{
pInfo
->
curWindow
.
ekey
=
tsList
[
j
];
pInfo
->
prevTs
=
tsList
[
j
];
pInfo
->
numOfRows
+=
1
;
...
...
@@ -1681,8 +1683,6 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf
SQueryAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
pRuntimeEnv
->
prevGroupId
=
INT32_MIN
;
pRuntimeEnv
->
enableGroupData
=
false
;
pRuntimeEnv
->
pQueryAttr
=
pQueryAttr
;
pRuntimeEnv
->
pResultRowHashTable
=
taosHashInit
(
numOfTables
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
...
...
@@ -3094,7 +3094,7 @@ int32_t initResultRow(SResultRow *pResultRow) {
* +------------+-----------------result column 1-----------+-----------------result column 2-----------+
* + SResultRow | SResultRowCellInfo | intermediate buffer1 | SResultRowCellInfo | intermediate buffer 2|
* +------------+-------------------------------------------+-------------------------------------------+
* offset[0] offset[1]
* offset[0] offset[1]
offset[2]
*/
void
setDefaultOutputBuf
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOptrBasicInfo
*
pInfo
,
int64_t
uid
,
int32_t
stage
)
{
SQLFunctionCtx
*
pCtx
=
pInfo
->
pCtx
;
...
...
@@ -3323,7 +3323,7 @@ void setResultRowOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pRe
offset
+=
pCtx
[
i
].
outputBytes
;
int32_t
functionId
=
pCtx
[
i
].
functionId
;
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
||
functionId
==
TSDB_FUNC_DIFF
)
{
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
||
functionId
==
TSDB_FUNC_DIFF
||
functionId
==
TSDB_FUNC_DERIVATIVE
)
{
pCtx
[
i
].
ptsOutputBuf
=
pCtx
[
0
].
pOutput
;
}
...
...
@@ -3381,7 +3381,7 @@ void setResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SResultRow *pResult, SQLF
offset
+=
pCtx
[
i
].
outputBytes
;
int32_t
functionId
=
pCtx
[
i
].
functionId
;
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
||
functionId
==
TSDB_FUNC_DIFF
)
{
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
||
functionId
==
TSDB_FUNC_DIFF
||
functionId
==
TSDB_FUNC_DERIVATIVE
)
{
pCtx
[
i
].
ptsOutputBuf
=
pCtx
[
0
].
pOutput
;
}
...
...
@@ -3589,6 +3589,8 @@ static int32_t doCopyToSDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SGroupResInfo*
int32_t
step
=
-
1
;
qDebug
(
"QInfo:0x%"
PRIx64
" start to copy data from windowResInfo to output buf"
,
GET_QID
(
pRuntimeEnv
));
assert
(
orderType
==
TSDB_ORDER_ASC
||
orderType
==
TSDB_ORDER_DESC
);
if
(
orderType
==
TSDB_ORDER_ASC
)
{
start
=
pGroupResInfo
->
index
;
step
=
1
;
...
...
@@ -4115,6 +4117,7 @@ int32_t doInitQInfo(SQInfo* pQInfo, STSBuf* pTsBuf, void* tsdb, void* sourceOptr
pQueryAttr
->
interBufSize
=
getOutputInterResultBufSize
(
pQueryAttr
);
pRuntimeEnv
->
groupResInfo
.
totalGroup
=
(
int32_t
)
(
pQueryAttr
->
stableQuery
?
GET_NUM_OF_TABLEGROUP
(
pRuntimeEnv
)
:
0
);
pRuntimeEnv
->
enableGroupData
=
false
;
pRuntimeEnv
->
pQueryAttr
=
pQueryAttr
;
pRuntimeEnv
->
pTsBuf
=
pTsBuf
;
...
...
@@ -4570,7 +4573,7 @@ SOperatorInfo* createDataBlocksOptScanInfo(void* pTsdbQueryHandle, SQueryRuntime
}
SArray
*
getOrderCheckColumns
(
SQueryAttr
*
pQuery
)
{
int32_t
numOfCols
=
pQuery
->
pGroupbyExpr
->
numOfGroupCols
;
int32_t
numOfCols
=
pQuery
->
pGroupbyExpr
==
NULL
?
0
:
pQuery
->
pGroupbyExpr
->
numOfGroupCols
;
SArray
*
pOrderColumns
=
NULL
;
if
(
numOfCols
>
0
)
{
...
...
@@ -4609,7 +4612,7 @@ SArray* getOrderCheckColumns(SQueryAttr* pQuery) {
}
SArray
*
getResultGroupCheckColumns
(
SQueryAttr
*
pQuery
)
{
int32_t
numOfCols
=
pQuery
->
pGroupbyExpr
->
numOfGroupCols
;
int32_t
numOfCols
=
pQuery
->
pGroupbyExpr
==
NULL
?
0
:
pQuery
->
pGroupbyExpr
->
numOfGroupCols
;
SArray
*
pOrderColumns
=
NULL
;
if
(
numOfCols
>
0
)
{
...
...
@@ -5175,6 +5178,10 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
SColumnInfoData
*
pTsColInfoData
=
taosArrayGet
(
pSDataBlock
->
pDataBlock
,
0
);
TSKEY
*
tsList
=
(
TSKEY
*
)
pTsColInfoData
->
pData
;
if
(
IS_REPEAT_SCAN
(
pRuntimeEnv
)
&&
!
pInfo
->
reptScan
)
{
pInfo
->
reptScan
=
true
;
tfree
(
pInfo
->
prevData
);
}
pInfo
->
numOfRows
=
0
;
for
(
int32_t
j
=
0
;
j
<
pSDataBlock
->
info
.
rows
;
++
j
)
{
...
...
@@ -5761,6 +5768,7 @@ SOperatorInfo* createTimeIntervalOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOp
SOperatorInfo
*
createStatewindowOperatorInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
)
{
SStateWindowOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SStateWindowOperatorInfo
));
pInfo
->
colIndex
=
-
1
;
pInfo
->
reptScan
=
false
;
pInfo
->
binfo
.
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pRuntimeEnv
->
resultInfo
.
capacity
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
,
TSDB_DATA_TYPE_INT
);
...
...
@@ -5789,6 +5797,7 @@ SOperatorInfo* createSWindowOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperato
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
,
TSDB_DATA_TYPE_INT
);
pInfo
->
prevTs
=
INT64_MIN
;
pInfo
->
reptScan
=
false
;
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
pOperator
->
name
=
"SessionWindowAggOperator"
;
...
...
@@ -7213,7 +7222,7 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S
// todo refactor
pQInfo
->
query
.
queryBlockDist
=
(
numOfOutput
==
1
&&
pExprs
[
0
].
base
.
functionId
==
TSDB_FUNC_BLKINFO
);
qDebug
(
"qmsg:%p
QInfo:0x%"
PRIx64
"-%p created"
,
pQueryMsg
,
pQInfo
->
qId
,
pQInfo
);
qDebug
(
"qmsg:%p
vgId:%d, QInfo:0x%"
PRIx64
"-%p created"
,
pQueryMsg
,
pQInfo
->
query
.
vgId
,
pQInfo
->
qId
,
pQInfo
);
return
pQInfo
;
_cleanup_qinfo:
...
...
src/query/src/qSqlParser.c
浏览文件 @
e4f83886
...
...
@@ -139,19 +139,20 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) {
pSqlExpr
->
tokenId
=
optrType
;
pSqlExpr
->
type
=
SQL_NODE_VALUE
;
}
else
if
(
optrType
==
TK_NOW
)
{
// use
microsecond by default
pSqlExpr
->
value
.
i64
=
taosGetTimestamp
(
TSDB_TIME_PRECISION_
MICR
O
);
// use
nanosecond by default TODO set value after getting database precision
pSqlExpr
->
value
.
i64
=
taosGetTimestamp
(
TSDB_TIME_PRECISION_
NAN
O
);
pSqlExpr
->
value
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
pSqlExpr
->
tokenId
=
TK_TIMESTAMP
;
// TK_TIMESTAMP used to denote the time value is in microsecond
pSqlExpr
->
type
=
SQL_NODE_VALUE
;
pSqlExpr
->
flags
|=
1
<<
EXPR_FLAG_
U
S_TIMESTAMP
;
pSqlExpr
->
flags
|=
1
<<
EXPR_FLAG_
N
S_TIMESTAMP
;
}
else
if
(
optrType
==
TK_VARIABLE
)
{
int32_t
ret
=
parseAbsoluteDuration
(
pToken
->
z
,
pToken
->
n
,
&
pSqlExpr
->
value
.
i64
);
// use nanosecond by default TODO set value after getting database precision
int32_t
ret
=
parseAbsoluteDuration
(
pToken
->
z
,
pToken
->
n
,
&
pSqlExpr
->
value
.
i64
,
TSDB_TIME_PRECISION_NANO
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
}
pSqlExpr
->
flags
|=
1
<<
EXPR_FLAG_
U
S_TIMESTAMP
;
pSqlExpr
->
flags
|=
1
<<
EXPR_FLAG_
N
S_TIMESTAMP
;
pSqlExpr
->
flags
|=
1
<<
EXPR_FLAG_TIMESTAMP_VAR
;
pSqlExpr
->
value
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
pSqlExpr
->
tokenId
=
TK_TIMESTAMP
;
...
...
src/query/src/queryMain.c
浏览文件 @
e4f83886
...
...
@@ -132,7 +132,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi
numOfGroupByCols
=
0
;
}
qDebug
(
"qmsg:%p query stable, uid:%"
PRI
d
64
", tid:%d"
,
pQueryMsg
,
id
->
uid
,
id
->
tid
);
qDebug
(
"qmsg:%p query stable, uid:%"
PRI
u
64
", tid:%d"
,
pQueryMsg
,
id
->
uid
,
id
->
tid
);
code
=
tsdbQuerySTableByTagCond
(
tsdb
,
id
->
uid
,
pQueryMsg
->
window
.
skey
,
param
.
tagCond
,
pQueryMsg
->
tagCondLen
,
pQueryMsg
->
tagNameRelType
,
param
.
tbnameCond
,
&
tableGroupInfo
,
param
.
pGroupColIndex
,
numOfGroupByCols
);
...
...
src/query/src/sql.c
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
src/tsdb/inc/tsdbint.h
浏览文件 @
e4f83886
...
...
@@ -92,6 +92,7 @@ struct STsdbRepo {
pthread_mutex_t
mutex
;
bool
repoLocked
;
int32_t
code
;
// Commit code
bool
inCompact
;
// is in compact process?
};
#define REPO_ID(r) (r)->config.tsdbId
...
...
src/tsdb/src/tsdbCompact.c
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
src/tsdb/src/tsdbMain.c
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
src/tsdb/src/tsdbRead.c
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
src/util/inc/tutil.h
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
src/util/src/ttokenizer.c
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
src/util/src/tutil.c
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/examples/c/apitest.c
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/examples/c/demo.c
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/examples/c/prepare.c
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/examples/c/subscribe.c
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/mas/Jenkinsfile
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/pytest/cluster/clusterSetup.py
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/pytest/functions/showOfflineThresholdIs864000.py
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/script/fullGeneralSuite.sim
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/script/general/db/alter_option.sim
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/script/general/db/topic1.sim
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/script/general/parser/function.sim
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/script/general/parser/nestquery.sim
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/script/general/parser/precision_ns.sim
0 → 100644
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/script/general/parser/testSuite.sim
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/script/regressionSuite.sim
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
tests/tsim/src/simExe.c
浏览文件 @
e4f83886
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录