Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_50753323
TDengine
提交
45f855ca
T
TDengine
项目概览
qq_50753323
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
45f855ca
编写于
8月 28, 2020
作者:
S
Steven Li
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/develop' into feature/crash_gen
上级
72af08d9
70ff6014
变更
74
展开全部
隐藏空白更改
内联
并排
Showing
74 changed file
with
2494 addition
and
1727 deletion
+2494
-1727
README.md
README.md
+1
-1
cmake/version.inc
cmake/version.inc
+52
-25
documentation20/webdocs/markdowndocs/administrator-ch.md
documentation20/webdocs/markdowndocs/administrator-ch.md
+4
-4
packaging/release.sh
packaging/release.sh
+98
-165
src/client/inc/tscLocalMerge.h
src/client/inc/tscLocalMerge.h
+0
-1
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+6
-6
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+59
-19
src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h
src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h
+8
-0
src/client/src/taos.rc.in
src/client/src/taos.rc.in
+4
-4
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+2
-1
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+26
-22
src/client/src/tscLocalMerge.c
src/client/src/tscLocalMerge.c
+16
-42
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+20
-21
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+213
-180
src/client/src/tscServer.c
src/client/src/tscServer.c
+47
-49
src/client/src/tscSql.c
src/client/src/tscSql.c
+20
-14
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+88
-120
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+90
-47
src/common/inc/tname.h
src/common/inc/tname.h
+4
-1
src/common/inc/tvariant.h
src/common/inc/tvariant.h
+3
-1
src/common/src/tname.c
src/common/src/tname.c
+26
-2
src/common/src/tvariant.c
src/common/src/tvariant.c
+54
-13
src/connector/jdbc/.classpath
src/connector/jdbc/.classpath
+0
-17
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
...r/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
+6
-6
src/inc/taosdef.h
src/inc/taosdef.h
+2
-1
src/inc/taoserror.h
src/inc/taoserror.h
+2
-0
src/inc/taosmsg.h
src/inc/taosmsg.h
+4
-4
src/inc/ttokendef.h
src/inc/ttokendef.h
+1
-1
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+8
-13
src/kit/shell/src/shellMain.c
src/kit/shell/src/shellMain.c
+4
-5
src/mnode/src/mnodeDnode.c
src/mnode/src/mnodeDnode.c
+25
-28
src/mnode/src/mnodeMain.c
src/mnode/src/mnodeMain.c
+16
-5
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+5
-0
src/mnode/src/mnodeShow.c
src/mnode/src/mnodeShow.c
+1
-1
src/query/inc/qAst.h
src/query/inc/qAst.h
+1
-1
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+21
-20
src/query/inc/qSqlparser.h
src/query/inc/qSqlparser.h
+43
-42
src/query/inc/qTsbuf.h
src/query/inc/qTsbuf.h
+13
-12
src/query/inc/qUtil.h
src/query/inc/qUtil.h
+2
-1
src/query/inc/sql.y
src/query/inc/sql.y
+16
-16
src/query/inc/tsqlfunction.h
src/query/inc/tsqlfunction.h
+11
-11
src/query/src/qAst.c
src/query/src/qAst.c
+5
-5
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+491
-305
src/query/src/qParserImpl.c
src/query/src/qParserImpl.c
+56
-44
src/query/src/qResultbuf.c
src/query/src/qResultbuf.c
+9
-2
src/query/src/qTokenizer.c
src/query/src/qTokenizer.c
+3
-3
src/query/src/qTsbuf.c
src/query/src/qTsbuf.c
+48
-25
src/query/src/qUtil.c
src/query/src/qUtil.c
+24
-20
src/query/src/sql.c
src/query/src/sql.c
+12
-15
src/query/tests/tsBufTest.cpp
src/query/tests/tsBufTest.cpp
+75
-29
src/query/tests/unitTest.cpp
src/query/tests/unitTest.cpp
+4
-4
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+266
-245
src/util/inc/tcache.h
src/util/inc/tcache.h
+1
-11
src/util/inc/tlockfree.h
src/util/inc/tlockfree.h
+8
-0
src/util/inc/tstoken.h
src/util/inc/tstoken.h
+4
-4
src/util/src/hash.c
src/util/src/hash.c
+1
-1
src/util/src/tcache.c
src/util/src/tcache.c
+2
-2
src/util/src/version.c.in
src/util/src/version.c.in
+2
-2
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+5
-0
tests/script/general/parser/bug.sim
tests/script/general/parser/bug.sim
+0
-43
tests/script/general/parser/constCol.sim
tests/script/general/parser/constCol.sim
+354
-0
tests/script/general/parser/fill_stb.sim
tests/script/general/parser/fill_stb.sim
+7
-1
tests/script/general/parser/join.sim
tests/script/general/parser/join.sim
+4
-1
tests/script/general/parser/lastrow_query.sim
tests/script/general/parser/lastrow_query.sim
+24
-0
tests/script/general/parser/nchar.sim
tests/script/general/parser/nchar.sim
+1
-0
tests/script/general/parser/testSuite.sim
tests/script/general/parser/testSuite.sim
+1
-1
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+1
-1
tests/script/jenkins/unique.txt
tests/script/jenkins/unique.txt
+8
-32
tests/script/tmp/prepare.sim
tests/script/tmp/prepare.sim
+1
-0
tests/script/unique/account/usage.sim
tests/script/unique/account/usage.sim
+6
-5
tests/script/unique/mnode/mgmt21.sim
tests/script/unique/mnode/mgmt21.sim
+44
-0
tests/script/unique/mnode/testSuite.sim
tests/script/unique/mnode/testSuite.sim
+1
-0
tests/script/wtest.bat
tests/script/wtest.bat
+3
-3
未找到文件。
README.md
浏览文件 @
45f855ca
...
...
@@ -2,7 +2,7 @@
[
![Build status
](
https://ci.appveyor.com/api/projects/status/kf3pwh2or5afsgl9/branch/master?svg=true
)
](https://ci.appveyor.com/project/sangshuduo/tdengine-2n8ge/branch/master)
[
![Coverage Status
](
https://coveralls.io/repos/github/taosdata/TDengine/badge.svg?branch=develop
)
](https://coveralls.io/github/taosdata/TDengine?branch=develop)
[
![CII Best Practices
](
https://bestpractices.coreinfrastructure.org/projects/4201/badge
)
](https://bestpractices.coreinfrastructure.org/projects/4201)
![
Docker Pulls
](
https://img.shields.io/docker/pulls
/tdengine/tdengine
)
[
![Docker Pulls
](
https://img.shields.io/docker/pulls/tdengine/tdengine
)
](https://hub.docker.com/repository/docker
/tdengine/tdengine)
[
![TDengine
](
TDenginelogo.png
)
](https://www.taosdata.com)
...
...
cmake/version.inc
浏览文件 @
45f855ca
CMAKE_MINIMUM_REQUIRED
(
VERSION
2.8
)
PROJECT
(
TDengine
)
SET
(
TD_VER_1
"2"
)
SET
(
TD_VER_2
"0"
)
SET
(
TD_VER_3
"2"
)
SET
(
TD_VER_4
"3"
)
SET
(
TD_VER_GIT
"d711657139620f6c50f362597020705b8ad26bd2"
)
SET
(
TD_VER_GIT_INTERNAL
"1d74ae24c541ffbb280e8630883c0236cd45f8c7"
)
SET
(
TD_VER_VERTYPE
"stable"
)
SET
(
TD_VER_CPUTYPE
"x64"
)
SET
(
TD_VER_OSTYPE
"Linux"
)
IF
(
DEFINED
VERNUMBER
)
SET
(
TD_VER_NUMBER
$
{
VERNUMBER
})
ELSE
()
SET
(
TD_VER_NUMBER
"2.0.2.0"
)
ENDIF
()
SET
(
TD_VER_COMPATIBLE
"2.0.0.0"
)
STRING
(
TIMESTAMP
TD_VER_DATE
"%Y-%m-%d %H:%M:%S"
)
IF
(
DEFINED
VERCOMPATIBLE
)
SET
(
TD_VER_COMPATIBLE
$
{
VERCOMPATIBLE
})
ELSE
()
SET
(
TD_VER_COMPATIBLE
"2.0.0.0"
)
ENDIF
()
IF
(
TD_LINUX_64
)
SET
(
TD_VER_CPUTYPE
"x64"
)
IF
(
DEFINED
GITINFO
)
SET
(
TD_VER_GIT
$
{
GITINFO
})
ELSE
()
SET
(
TD_VER_GIT
"community"
)
ENDIF
()
IF
(
TD_LINUX_32
)
SET
(
TD_VER_CPUTYPE
"x86"
)
IF
(
DEFINED
GITINFOI
)
SET
(
TD_VER_GIT_INTERNAL
$
{
GITINFOI
})
ELSE
()
SET
(
TD_VER_GIT_INTERNAL
"internal"
)
ENDIF
()
IF
(
TD_ARM_64
)
SET
(
TD_VER_CPUTYPE
"aarch64"
)
IF
(
DEFINED
VERDATE
)
SET
(
TD_VER_DATE
$
{
VERDATE
})
ELSE
()
STRING
(
TIMESTAMP
TD_VER_DATE
"%Y-%m-%d %H:%M:%S"
)
ENDIF
()
IF
(
TD_ARM_32
)
SET
(
TD_VER_CPUTYPE
"aarch32"
)
IF
(
DEFINED
VERTYPE
)
SET
(
TD_VER_VERTYPE
$
{
VERTYPE
})
ELSE
()
SET
(
TD_VER_VERTYPE
"stable"
)
ENDIF
()
IF
(
TD_WINDOWS_64
)
SET
(
TD_VER_CPUTYPE
"x64"
)
IF
(
DEFINED
CPUTYPE
)
SET
(
TD_VER_CPUTYPE
$
{
CPUTYPE
})
ELSE
()
IF
(
TD_WINDOWS_32
)
SET
(
TD_VER_CPUTYPE
"x86"
)
ELSE
()
SET
(
TD_VER_CPUTYPE
"x64"
)
ENDIF
()
ENDIF
()
IF
(
TD_WINDOWS_32
)
SET
(
TD_VER_CPUTYPE
"x86"
)
IF
(
DEFINED
OSTYPE
)
SET
(
TD_VER_OSTYPE
$
{
OSTYPE
})
ELSE
()
SET
(
TD_VER_OSTYPE
"Linux"
)
ENDIF
()
MESSAGE
(
STATUS
"============= compile version parameter information start ============= "
)
MESSAGE
(
STATUS
"ver number:"
$
{
TD_VER_NUMBER
})
MESSAGE
(
STATUS
"compatible ver number:"
$
{
TD_VER_COMPATIBLE
})
MESSAGE
(
STATUS
"communit commit id:"
$
{
TD_VER_GIT
})
MESSAGE
(
STATUS
"internal commit id:"
$
{
TD_VER_GIT_INTERNAL
})
MESSAGE
(
STATUS
"build date:"
$
{
TD_VER_DATE
})
MESSAGE
(
STATUS
"ver type:"
$
{
TD_VER_VERTYPE
})
MESSAGE
(
STATUS
"ver cpu:"
$
{
TD_VER_CPUTYPE
})
MESSAGE
(
STATUS
"os type:"
$
{
TD_VER_OSTYPE
})
MESSAGE
(
STATUS
"============= compile version parameter information end ============= "
)
STRING
(
REPLACE
"."
"_"
TD_LIB_VER_NUMBER
$
{
TD_VER_NUMBER
})
CONFIGURE_FILE
(
"${TD_COMMUNITY_DIR}/src/util/src/version.c.in"
"${TD_COMMUNITY_DIR}/src/util/src/version.c"
)
documentation20/webdocs/markdowndocs/administrator-ch.md
浏览文件 @
45f855ca
...
...
@@ -153,10 +153,10 @@ TDengine系统的前台交互客户端应用程序为taos,它与taosd共享同
系统管理员可以在CLI界面里添加、删除用户,也可以修改密码。CLI里SQL语法如下:
```
CREATE USER <user_name> PASS <
‘password’
>;
CREATE USER <user_name> PASS <
'password'
>;
```
创建用户,并指定用户名和密码,密码需要用单引号引起来
创建用户,并指定用户名和密码,密码需要用单引号引起来
,单引号为英文半角
```
DROP USER <user_name>;
...
...
@@ -165,10 +165,10 @@ DROP USER <user_name>;
删除用户,限root用户使用
```
ALTER USER <user_name> PASS <
‘password’
>;
ALTER USER <user_name> PASS <
'password'
>;
```
修改用户密码, 为避免被转换为小写,密码需要用单引号引用
修改用户密码, 为避免被转换为小写,密码需要用单引号引用
,单引号为英文半角
```
SHOW USERS;
...
...
packaging/release.sh
浏览文件 @
45f855ca
...
...
@@ -12,6 +12,7 @@ set -e
# -l [full | lite]
# -s [static | dynamic]
# -n [2.0.0.3]
# -m [2.0.0.0]
# set parameters by default value
verMode
=
edge
# [cluster, edge]
...
...
@@ -21,8 +22,9 @@ osType=Linux # [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ni
pagMode
=
full
# [full | lite]
soMode
=
dynamic
# [static | dynamic]
verNumber
=
""
verNumberComp
=
"2.0.0.0"
while
getopts
"hv:V:c:o:l:s:n:"
arg
while
getopts
"hv:V:c:o:l:s:n:
m:
"
arg
do
case
$arg
in
v
)
...
...
@@ -49,6 +51,10 @@ do
#echo "verNumber=$OPTARG"
verNumber
=
$(
echo
$OPTARG
)
;;
m
)
#echo "verNumberComp=$OPTARG"
verNumberComp
=
$(
echo
$OPTARG
)
;;
o
)
#echo "osType=$OPTARG"
osType
=
$(
echo
$OPTARG
)
...
...
@@ -61,6 +67,7 @@ do
echo
" -l [full | lite] "
echo
" -s [static | dynamic] "
echo
" -n [version number] "
echo
" -m [compatible version number] "
exit
0
;;
?
)
#unknow option
...
...
@@ -70,216 +77,142 @@ do
esac
done
echo
"verMode=
${
verMode
}
verType=
${
verType
}
cpuType=
${
cpuType
}
osType=
${
osType
}
pagMode=
${
pagMode
}
soMode=
${
soMode
}
verNumber=
${
verNumber
}
"
echo
"verMode=
${
verMode
}
verType=
${
verType
}
cpuType=
${
cpuType
}
osType=
${
osType
}
pagMode=
${
pagMode
}
soMode=
${
soMode
}
verNumber=
${
verNumber
}
verNumberComp=
${
verNumberComp
}
"
curr_dir
=
$(
pwd
)
if
[
"
$osType
"
!=
"Darwin"
]
;
then
script_dir
=
"
$(
dirname
$(
readlink
-f
$0
))
"
top_dir
=
"
$(
readlink
-f
${
script_dir
}
/..
)
"
script_dir
=
"
$(
dirname
$(
readlink
-f
$0
))
"
top_dir
=
"
$(
readlink
-f
${
script_dir
}
/..
)
"
else
script_dir
=
`
dirname
$0
`
cd
${
script_dir
}
script_dir
=
"
$(
pwd
)
"
top_dir
=
${
script_dir
}
/..
script_dir
=
`
dirname
$0
`
cd
${
script_dir
}
script_dir
=
"
$(
pwd
)
"
top_dir
=
${
script_dir
}
/..
fi
versioninfo
=
"
${
top_dir
}
/src/util/src/version.c"
csudo
=
""
#if command -v sudo > /dev/null; then
#
csudo="sudo"
# csudo="sudo"
#fi
function
is_valid_version
()
{
[
-z
$1
]
&&
return
1
||
:
[
-z
$1
]
&&
return
1
||
:
rx
=
'^([0-9]+\.){3}(\*|[0-9]+)$'
if
[[
$1
=
~
$rx
]]
;
then
return
0
fi
return
1
rx
=
'^([0-9]+\.){3}(\*|[0-9]+)$'
if
[[
$1
=
~
$rx
]]
;
then
return
0
fi
return
1
}
function
vercomp
()
{
if
[[
$1
==
$2
]]
;
then
echo
0
exit
0
fi
local
IFS
=
.
local
i
ver1
=(
$1
)
ver2
=(
$2
)
# fill empty fields in ver1 with zeros
for
((
i
=
${#
ver1
[@]
}
;
i<
${#
ver2
[@]
}
;
i++
))
;
do
ver1[i]
=
0
done
for
((
i
=
0
;
i<
${#
ver1
[@]
}
;
i++
))
;
do
if
[[
-z
${
ver2
[i]
}
]]
;
then
# fill empty fields in ver2 with zeros
ver2[i]
=
0
fi
if
((
10#
${
ver1
[i]
}
>
10#
${
ver2
[i]
}
))
;
then
echo
1
exit
0
fi
if
((
10#
${
ver1
[i]
}
< 10#
${
ver2
[i]
}
))
;
then
echo
2
exit
0
fi
done
if
[[
$1
==
$2
]]
;
then
echo
0
}
# 1. Read version information
version
=
$(
cat
${
versioninfo
}
|
grep
" version"
|
cut
-d
'"'
-f2
)
compatible_version
=
$(
cat
${
versioninfo
}
|
grep
" compatible_version"
|
cut
-d
'"'
-f2
)
if
[
-z
${
verNumber
}
]
;
then
while
true
;
do
read
-p
"Do you want to release a new version? [y/N]: "
is_version_change
if
[[
(
"
${
is_version_change
}
"
==
"y"
)
||
(
"
${
is_version_change
}
"
==
"Y"
)
]]
;
then
read
-p
"Please enter the new version: "
tversion
while
true
;
do
if
(!
is_valid_version
$tversion
)
||
[
"
$(
vercomp
$tversion
$version
)
"
=
'2'
]
;
then
read
-p
"Please enter a correct version: "
tversion
continue
fi
version
=
${
tversion
}
break
done
echo
read
-p
"Enter the oldest compatible version: "
tversion
while
true
;
do
if
[
-z
$tversion
]
;
then
break
fi
if
(!
is_valid_version
$tversion
)
||
[
"
$(
vercomp
$version
$tversion
)
"
=
'2'
]
;
then
read
-p
"enter correct compatible version: "
tversion
else
compatible_version
=
$tversion
break
fi
done
exit
0
fi
local
IFS
=
.
local
i
ver1
=(
$1
)
ver2
=(
$2
)
# fill empty fields in ver1 with zeros
for
((
i
=
${#
ver1
[@]
}
;
i<
${#
ver2
[@]
}
;
i++
))
;
do
ver1[i]
=
0
done
break
elif
[[
(
"
${
is_version_change
}
"
==
"n"
)
||
(
"
${
is_version_change
}
"
==
"N"
)
]]
;
then
echo
"Use old version:
${
version
}
compatible version:
${
compatible_version
}
."
break
else
continue
for
((
i
=
0
;
i<
${#
ver1
[@]
}
;
i++
))
;
do
if
[[
-z
${
ver2
[i]
}
]]
;
then
# fill empty fields in ver2 with zeros
ver2[i]
=
0
fi
if
((
10#
${
ver1
[i]
}
>
10#
${
ver2
[i]
}
))
;
then
echo
1
exit
0
fi
if
((
10#
${
ver1
[i]
}
< 10#
${
ver2
[i]
}
))
;
then
echo
2
exit
0
fi
done
else
echo
"old version:
$version
, new version:
$verNumber
"
#if ( ! is_valid_version $verNumber ) || [[ "$(vercomp $version $verNumber)" == '2' ]]; then
# echo "please enter correct version"
# exit 0
#else
version
=
${
verNumber
}
#fi
fi
echo
0
}
# 1. check version information
if
((
!
is_valid_version
$verNumber
)
||
(
!
is_valid_version
$verNumberComp
)
||
[[
"
$(
vercomp
$verNumber
$verNumberComp
)
"
==
'2'
]])
;
then
echo
"please enter correct version"
exit
0
fi
echo
"=======================new version number:
${
ver
sion
}
======================================"
echo
"=======================new version number:
${
ver
Number
}
, compatible version:
${
verNumberComp
}
======================================"
# output the version info to the buildinfo file.
build_time
=
$(
date
+
"%F %R"
)
echo
"char version[12] =
\"
${
version
}
\"
;"
>
${
versioninfo
}
echo
"char compatible_version[12] =
\"
${
compatible_version
}
\"
;"
>>
${
versioninfo
}
echo
"char gitinfo[48] =
\"
$(
git rev-parse
--verify
HEAD
)
\"
;"
>>
${
versioninfo
}
if
[
"
$verMode
"
!=
"cluster"
]
;
then
echo
"char gitinfoOfInternal[48] =
\"\"
;"
>>
${
versioninfo
}
else
enterprise_dir
=
"
${
top_dir
}
/../enterprise"
cd
${
enterprise_dir
}
echo
"char gitinfoOfInternal[48] =
\"
$(
git rev-parse
--verify
HEAD
)
\"
;"
>>
${
versioninfo
}
cd
${
curr_dir
}
fi
echo
"char buildinfo[64] =
\"
Built by
${
USER
}
at
${
build_time
}
\"
;"
>>
${
versioninfo
}
echo
""
>>
${
versioninfo
}
tmp_version
=
$(
echo
$version
|
tr
-s
"."
"_"
)
if
[
"
$verMode
"
==
"cluster"
]
;
then
libtaos_info
=
${
tmp_version
}
_
${
osType
}
_
${
cpuType
}
else
libtaos_info
=
edge_
${
tmp_version
}
_
${
osType
}
_
${
cpuType
}
fi
if
[
"
$verType
"
==
"beta"
]
;
then
libtaos_info
=
${
libtaos_info
}
_
${
verType
}
fi
echo
"void libtaos_
${
libtaos_info
}
() {};"
>>
${
versioninfo
}
# get commint id from git
gitinfo
=
$(
git rev-parse
--verify
HEAD
)
enterprise_dir
=
"
${
top_dir
}
/../enterprise"
cd
${
enterprise_dir
}
gitinfoOfInternal
=
$(
git rev-parse
--verify
HEAD
)
cd
${
curr_dir
}
# 2. cmake executable file
compile_dir
=
"
${
top_dir
}
/debug"
if
[
-d
${
compile_dir
}
]
;
then
${
csudo
}
rm
-rf
${
compile_dir
}
${
csudo
}
rm
-rf
${
compile_dir
}
fi
if
[
"
$osType
"
!=
"Darwin"
]
;
then
${
csudo
}
mkdir
-p
${
compile_dir
}
${
csudo
}
mkdir
-p
${
compile_dir
}
else
mkdir
-p
${
compile_dir
}
mkdir
-p
${
compile_dir
}
fi
cd
${
compile_dir
}
# check support cpu type
if
[[
"
$cpuType
"
==
"x64"
]]
||
[[
"
$cpuType
"
==
"aarch64"
]]
||
[[
"
$cpuType
"
==
"aarch32"
]]
||
[[
"
$cpuType
"
==
"mips64"
]]
;
then
if
[
"
$verMode
"
!=
"cluster"
]
;
then
cmake ../
-DCPUTYPE
=
${
cpuType
}
-DPAGMODE
=
${
pagMode
}
-DOSTYPE
=
${
osType
}
-DSOMODE
=
${
so
Mode
}
else
cmake ../../
-DCPUTYPE
=
${
cpuType
}
-DOSTYPE
=
${
osType
}
-DSOMODE
=
${
soMode
}
fi
if
[
"
$verMode
"
!=
"cluster"
]
;
then
cmake ../
-DCPUTYPE
=
${
cpuType
}
-DOSTYPE
=
${
osType
}
-DSOMODE
=
${
soMode
}
-DVERTYPE
=
${
verType
}
-DVERDATE
=
"
${
build_time
}
"
-DGITINFO
=
${
gitinfo
}
-DGITINFOI
=
${
gitinfoOfInternal
}
-DVERNUMBER
=
${
verNumber
}
-DVERCOMPATIBLE
=
${
verNumberComp
}
-DPAGMODE
=
${
pag
Mode
}
else
cmake ../../
-DCPUTYPE
=
${
cpuType
}
-DOSTYPE
=
${
osType
}
-DSOMODE
=
${
soMode
}
-DVERTYPE
=
${
verType
}
-DVERDATE
=
"
${
build_time
}
"
-DGITINFO
=
${
gitinfo
}
-DGITINFOI
=
${
gitinfoOfInternal
}
-DVERNUMBER
=
${
verNumber
}
-DVERCOMPATIBLE
=
${
verNumberComp
}
fi
else
echo
"input cpuType=
${
cpuType
}
error!!!"
exit
1
echo
"input cpuType=
${
cpuType
}
error!!!"
exit
1
fi
make
cd
${
curr_dir
}
# 3. judge the operating system type, then Call the corresponding script for packaging
#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
#osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2)
#echo "osinfo: ${osinfo}"
# 3. Call the corresponding script for packaging
if
[
"
$osType
"
!=
"Darwin"
]
;
then
if
[[
"
$verMode
"
!=
"cluster"
]]
&&
[[
"
$cpuType
"
==
"x64"
]]
;
then
echo
"====do deb package for the ubuntu system===="
output_dir
=
"
${
top_dir
}
/debs"
if
[
-d
${
output_dir
}
]
;
then
${
csudo
}
rm
-rf
${
output_dir
}
fi
${
csudo
}
mkdir
-p
${
output_dir
}
cd
${
script_dir
}
/deb
${
csudo
}
./makedeb.sh
${
compile_dir
}
${
output_dir
}
${
version
}
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
echo
"====do rpm package for the centos system===="
output_dir
=
"
${
top_dir
}
/rpms"
if
[
-d
${
output_dir
}
]
;
then
${
csudo
}
rm
-rf
${
output_dir
}
fi
${
csudo
}
mkdir
-p
${
output_dir
}
cd
${
script_dir
}
/rpm
${
csudo
}
./makerpm.sh
${
compile_dir
}
${
output_dir
}
${
version
}
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
if
[[
"
$verMode
"
!=
"cluster"
]]
&&
[[
"
$cpuType
"
==
"x64"
]]
;
then
echo
"====do deb package for the ubuntu system===="
output_dir
=
"
${
top_dir
}
/debs"
if
[
-d
${
output_dir
}
]
;
then
${
csudo
}
rm
-rf
${
output_dir
}
fi
${
csudo
}
mkdir
-p
${
output_dir
}
cd
${
script_dir
}
/deb
${
csudo
}
./makedeb.sh
${
compile_dir
}
${
output_dir
}
${
verNumber
}
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
echo
"====do rpm package for the centos system===="
output_dir
=
"
${
top_dir
}
/rpms"
if
[
-d
${
output_dir
}
]
;
then
${
csudo
}
rm
-rf
${
output_dir
}
fi
${
csudo
}
mkdir
-p
${
output_dir
}
cd
${
script_dir
}
/rpm
${
csudo
}
./makerpm.sh
${
compile_dir
}
${
output_dir
}
${
verNumber
}
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
fi
echo
"====do tar.gz package for all systems===="
cd
${
script_dir
}
/tools
${
csudo
}
./makepkg.sh
${
compile_dir
}
${
ver
sion
}
"
${
build_time
}
"
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
${
pagMode
}
${
csudo
}
./makeclient.sh
${
compile_dir
}
${
ver
sion
}
"
${
build_time
}
"
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
${
pagMode
}
${
csudo
}
./makearbi.sh
${
compile_dir
}
${
ver
sion
}
"
${
build_time
}
"
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
${
pagMode
}
echo
"====do tar.gz package for all systems===="
cd
${
script_dir
}
/tools
${
csudo
}
./makepkg.sh
${
compile_dir
}
${
ver
Number
}
"
${
build_time
}
"
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
${
pagMode
}
${
csudo
}
./makeclient.sh
${
compile_dir
}
${
ver
Number
}
"
${
build_time
}
"
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
${
pagMode
}
${
csudo
}
./makearbi.sh
${
compile_dir
}
${
ver
Number
}
"
${
build_time
}
"
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
${
pagMode
}
else
cd
${
script_dir
}
/tools
./makeclient.sh
${
compile_dir
}
${
version
}
"
${
build_time
}
"
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
cd
${
script_dir
}
/tools
./makeclient.sh
${
compile_dir
}
${
verNumber
}
"
${
build_time
}
"
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
fi
# 4. Clean up temporary compile directories
#${csudo} rm -rf ${compile_dir}
src/client/inc/tscLocalMerge.h
浏览文件 @
45f855ca
...
...
@@ -87,7 +87,6 @@ typedef struct SRetrieveSupport {
SSqlObj
*
pParentSql
;
tFilePage
*
localBuffer
;
// temp buffer, there is a buffer for each vnode to
uint32_t
numOfRetry
;
// record the number of retry times
pthread_mutex_t
queryMutex
;
}
SRetrieveSupport
;
int32_t
tscLocalReducerEnvCreate
(
SSqlObj
*
pSql
,
tExtMemBuffer
***
pMemBuffer
,
tOrderDescriptor
**
pDesc
,
...
...
src/client/inc/tscUtil.h
浏览文件 @
45f855ca
...
...
@@ -138,10 +138,10 @@ bool tscIsProjectionQuery(SQueryInfo* pQueryInfo);
bool
tscIsTwoStageSTableQuery
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
bool
tscQueryTags
(
SQueryInfo
*
pQueryInfo
);
void
tscAddSpecialColumnForSelect
(
SQueryInfo
*
pQueryInfo
,
int32_t
outputColIndex
,
int16_t
functionId
,
SColumnIndex
*
pIndex
,
SSchema
*
pColSchema
,
int16_t
colType
);
SSqlExpr
*
tscAddSpecialColumnForSelect
(
SQueryInfo
*
pQueryInfo
,
int32_t
outputColIndex
,
int16_t
functionId
,
SColumnIndex
*
pIndex
,
SSchema
*
pColSchema
,
int16_t
colType
);
int32_t
tscSetTableFullName
(
STableMetaInfo
*
pTableMetaInfo
,
SS
QL
Token
*
pzTableName
,
SSqlObj
*
pSql
);
int32_t
tscSetTableFullName
(
STableMetaInfo
*
pTableMetaInfo
,
SS
tr
Token
*
pzTableName
,
SSqlObj
*
pSql
);
void
tscClearInterpInfo
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsInsertData
(
char
*
sqlstr
);
...
...
@@ -194,11 +194,11 @@ SColumn* tscColumnListInsert(SArray* pColList, SColumnIndex* colIndex);
SArray
*
tscColumnListClone
(
const
SArray
*
src
,
int16_t
tableIndex
);
void
tscColumnListDestroy
(
SArray
*
pColList
);
int32_t
tscValidateName
(
SS
QL
Token
*
pToken
);
int32_t
tscValidateName
(
SS
tr
Token
*
pToken
);
void
tscIncStreamExecutionCount
(
void
*
pStream
);
bool
tscValidateColumnId
(
STableMetaInfo
*
pTableMetaInfo
,
int32_t
colId
);
bool
tscValidateColumnId
(
STableMetaInfo
*
pTableMetaInfo
,
int32_t
colId
,
int32_t
numOfParams
);
// get starter position of metric query condition (query on tags) in SSqlCmd.payload
SCond
*
tsGetSTableQueryCond
(
STagCond
*
pCond
,
uint64_t
uid
);
...
...
@@ -217,7 +217,7 @@ STableMetaInfo* tscGetTableMetaInfoFromCmd(SSqlCmd *pCmd, int32_t subClauseIndex
STableMetaInfo
*
tscGetMetaInfo
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
SQueryInfo
*
tscGetQueryInfoDetail
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
);
int32_t
tscGetQueryInfoDetailSafely
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
SQueryInfo
**
pQueryInfo
);
SQueryInfo
*
tscGetQueryInfoDetailSafely
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
);
void
tscClearTableMetaInfo
(
STableMetaInfo
*
pTableMetaInfo
,
bool
removeFromCache
);
...
...
src/client/inc/tsclient.h
浏览文件 @
45f855ca
...
...
@@ -35,6 +35,40 @@ extern "C" {
#include "qTsbuf.h"
#include "tcmdtype.h"
#if 0
static UNUSED_FUNC void *u_malloc (size_t __size) {
uint32_t v = rand();
if (v % 5000 <= 0) {
return NULL;
} else {
return malloc(__size);
}
}
static UNUSED_FUNC void* u_calloc(size_t num, size_t __size) {
uint32_t v = rand();
if (v % 5000 <= 0) {
return NULL;
} else {
return calloc(num, __size);
}
}
static UNUSED_FUNC void* u_realloc(void* p, size_t __size) {
uint32_t v = rand();
if (v % 5000 <= 0) {
return NULL;
} else {
return realloc(p, __size);
}
}
#define calloc u_calloc
#define malloc u_malloc
#define realloc u_realloc
#endif
// forward declaration
struct
SSqlInfo
;
struct
SLocalReducer
;
...
...
@@ -195,9 +229,9 @@ typedef struct STableDataBlocks {
typedef
struct
SQueryInfo
{
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 type
char
slidingTimeUnit
;
STimeWindow
window
;
STimeWindow
window
;
// query time window
int64_t
intervalTime
;
// aggregation time interval
int64_t
slidingTime
;
// sliding window in mseconds
SSqlGroupbyExpr
groupbyExpr
;
// group by tags info
...
...
@@ -216,6 +250,7 @@ typedef struct SQueryInfo {
char
*
msg
;
// pointer to the pCmd->payload to keep error message temporarily
int64_t
clauseLimit
;
// limit for current sub clause
int64_t
prjOffset
;
// offset value in the original sql expression, only applied at client side
int32_t
udColumnId
;
// current user-defined constant output field column id, monotonically decreases from TSDB_UD_COLUMN_INDEX
}
SQueryInfo
;
typedef
struct
{
...
...
@@ -431,31 +466,36 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField
int32_t
bytes
=
pInfo
->
pSqlExpr
->
resBytes
;
char
*
pData
=
pRes
->
data
+
pInfo
->
pSqlExpr
->
offset
*
pRes
->
numOfRows
+
bytes
*
pRes
->
row
;
if
(
type
==
TSDB_DATA_TYPE_NCHAR
||
type
==
TSDB_DATA_TYPE_BINARY
)
{
int32_t
realLen
=
varDataLen
(
pData
);
assert
(
realLen
<=
bytes
-
VARSTR_HEADER_SIZE
);
if
(
isNull
(
pData
,
type
))
{
pRes
->
tsrow
[
columnIndex
]
=
NULL
;
// user defined constant value output columns
if
(
pInfo
->
pSqlExpr
->
colInfo
.
flag
==
TSDB_COL_UDC
)
{
if
(
type
==
TSDB_DATA_TYPE_NCHAR
||
type
==
TSDB_DATA_TYPE_BINARY
)
{
pData
=
pInfo
->
pSqlExpr
->
param
[
1
].
pz
;
pRes
->
length
[
columnIndex
]
=
pInfo
->
pSqlExpr
->
param
[
1
].
nLen
;
pRes
->
tsrow
[
columnIndex
]
=
(
pInfo
->
pSqlExpr
->
param
[
1
].
nType
==
TSDB_DATA_TYPE_NULL
)
?
NULL
:
pData
;
}
else
{
pRes
->
tsrow
[
columnIndex
]
=
((
tstr
*
)
pData
)
->
data
;
}
assert
(
bytes
==
tDataTypeDesc
[
type
].
nSize
);
if
(
realLen
<
pInfo
->
pSqlExpr
->
resBytes
-
VARSTR_HEADER_SIZE
)
{
// todo refactor
*
(
pData
+
realLen
+
VARSTR_HEADER_SIZE
)
=
0
;
pRes
->
tsrow
[
columnIndex
]
=
isNull
(
pData
,
type
)
?
NULL
:
&
pInfo
->
pSqlExpr
->
param
[
1
].
i64Key
;
pRes
->
length
[
columnIndex
]
=
bytes
;
}
pRes
->
length
[
columnIndex
]
=
realLen
;
}
else
{
assert
(
bytes
==
tDataTypeDesc
[
type
].
nSize
);
if
(
type
==
TSDB_DATA_TYPE_NCHAR
||
type
==
TSDB_DATA_TYPE_BINARY
)
{
int32_t
realLen
=
varDataLen
(
pData
);
assert
(
realLen
<=
bytes
-
VARSTR_HEADER_SIZE
);
pRes
->
tsrow
[
columnIndex
]
=
(
isNull
(
pData
,
type
))
?
NULL
:
((
tstr
*
)
pData
)
->
data
;
if
(
realLen
<
pInfo
->
pSqlExpr
->
resBytes
-
VARSTR_HEADER_SIZE
)
{
// todo refactor
*
(
pData
+
realLen
+
VARSTR_HEADER_SIZE
)
=
0
;
}
if
(
isNull
(
pData
,
type
))
{
pRes
->
tsrow
[
columnIndex
]
=
NULL
;
pRes
->
length
[
columnIndex
]
=
realLen
;
}
else
{
pRes
->
tsrow
[
columnIndex
]
=
pData
;
}
assert
(
bytes
==
tDataTypeDesc
[
type
].
nSize
);
pRes
->
length
[
columnIndex
]
=
bytes
;
pRes
->
tsrow
[
columnIndex
]
=
isNull
(
pData
,
type
)
?
NULL
:
pData
;
pRes
->
length
[
columnIndex
]
=
bytes
;
}
}
}
...
...
src/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h
浏览文件 @
45f855ca
...
...
@@ -89,6 +89,14 @@ JNIEXPORT jstring JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getErrMsgImp
JNIEXPORT
jlong
JNICALL
Java_com_taosdata_jdbc_TSDBJNIConnector_getResultSetImp
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
con
,
jlong
tres
);
/*
* Class: com_taosdata_jdbc_TSDBJNIConnector
* Method: isUpdateQueryImp
* Signature: (J)J
*/
JNIEXPORT
jint
JNICALL
Java_com_taosdata_jdbc_TSDBJNIConnector_isUpdateQueryImp
(
JNIEnv
*
env
,
jobject
jobj
,
jlong
con
,
jlong
tres
);
/*
* Class: com_taosdata_jdbc_TSDBJNIConnector
* Method: freeResultSetImp
...
...
src/client/src/taos.rc.in
浏览文件 @
45f855ca
1 VERSIONINFO
FILEVERSION ${TD_VER_
1}, ${TD_VER_2}, ${TD_VER_3
}
PRODUCTVERSION ${TD_VER_
1}, ${TD_VER_2}, ${TD_VER_3
}
FILEVERSION ${TD_VER_
NUMBER
}
PRODUCTVERSION ${TD_VER_
NUMBER
}
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
...
...
@@ -16,12 +16,12 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "Native C Driver for TDengine"
VALUE "FileVersion", "${TD_VER_
1}, ${TD_VER_2}, ${TD_VER_3
}"
VALUE "FileVersion", "${TD_VER_
NUMBER
}"
VALUE "InternalName", "taos.dll(${TD_VER_CPUTYPE})"
VALUE "LegalCopyright", "Copyright (C) 2020 TAOS Data"
VALUE "OriginalFilename", ""
VALUE "ProductName", "taos.dll(${TD_VER_CPUTYPE})"
VALUE "ProductVersion", "${TD_VER_
1}.${TD_VER_2}.${TD_VER_3}.${TD_VER_4
}"
VALUE "ProductVersion", "${TD_VER_
NUMBER
}"
END
END
BLOCK "VarFileInfo"
...
...
src/client/src/tscAsync.c
浏览文件 @
45f855ca
...
...
@@ -433,7 +433,8 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
tscError
(
"%p get tableMeta failed, code:%s"
,
pSql
,
tstrerror
(
code
));
goto
_error
;
}
else
{
tscDebug
(
"%p get tableMeta successfully"
,
pSql
);
const
char
*
msg
=
(
pCmd
->
command
==
TSDB_SQL_STABLEVGROUP
)
?
"vgroup-list"
:
"table-meta"
;
tscDebug
(
"%p get %s successfully"
,
pSql
,
msg
);
}
if
(
pSql
->
pStream
==
NULL
)
{
...
...
src/client/src/tscFunctionImpl.c
浏览文件 @
45f855ca
...
...
@@ -1813,23 +1813,19 @@ static void last_dist_func_second_merge(SQLFunctionCtx *pCtx) {
* NOTE: last_row does not use the interResultBuf to keep the result
*/
static
void
last_row_function
(
SQLFunctionCtx
*
pCtx
)
{
assert
(
pCtx
->
size
==
1
);
assert
(
pCtx
->
size
>=
1
);
char
*
pData
=
GET_INPUT_CHAR
(
pCtx
);
assignVal
(
pCtx
->
aOutputBuf
,
pData
,
pCtx
->
inputBytes
,
pCtx
->
inputType
);
// assign the last element in current data block
assignVal
(
pCtx
->
aOutputBuf
,
pData
+
(
pCtx
->
size
-
1
)
*
pCtx
->
inputBytes
,
pCtx
->
inputBytes
,
pCtx
->
inputType
);
SResultInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
pResInfo
->
hasResult
=
DATA_SET_FLAG
;
SLastrowInfo
*
pInfo
=
(
SLastrowInfo
*
)
pResInfo
->
interResultBuf
;
pInfo
->
ts
=
pCtx
->
ptsList
[
0
];
pInfo
->
hasResult
=
DATA_SET_FLAG
;
// set the result to final result buffer
// set the result to final result buffer in case of super table query
if
(
pResInfo
->
superTableQ
)
{
SLastrowInfo
*
pInfo1
=
(
SLastrowInfo
*
)(
pCtx
->
aOutputBuf
+
pCtx
->
inputBytes
);
pInfo1
->
ts
=
pCtx
->
ptsList
[
0
];
pInfo1
->
ts
=
pCtx
->
ptsList
[
pCtx
->
size
-
1
];
pInfo1
->
hasResult
=
DATA_SET_FLAG
;
DO_UPDATE_TAG_COLUMNS
(
pCtx
,
pInfo1
->
ts
);
...
...
@@ -2038,7 +2034,7 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) {
tValuePair
**
tvp
=
pRes
->
res
;
int32_t
step
=
QUERY_ASC_FORWARD_STEP
;
int32_t
len
=
GET_RES_INFO
(
pCtx
)
->
numOfRes
;
int32_t
len
=
(
int32_t
)(
GET_RES_INFO
(
pCtx
)
->
numOfRes
)
;
switch
(
type
)
{
case
TSDB_DATA_TYPE_INT
:
{
...
...
@@ -2412,10 +2408,10 @@ static void top_bottom_func_finalizer(SQLFunctionCtx *pCtx) {
// user specify the order of output by sort the result according to timestamp
if
(
pCtx
->
param
[
1
].
i64Key
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
__compar_fn_t
comparator
=
(
pCtx
->
param
[
2
].
i64Key
==
TSDB_ORDER_ASC
)
?
resAscComparFn
:
resDescComparFn
;
qsort
(
tvp
,
pResInfo
->
numOfRes
,
POINTER_BYTES
,
comparator
);
qsort
(
tvp
,
(
size_t
)
pResInfo
->
numOfRes
,
POINTER_BYTES
,
comparator
);
}
else
if
(
pCtx
->
param
[
1
].
i64Key
>
PRIMARYKEY_TIMESTAMP_COL_INDEX
)
{
__compar_fn_t
comparator
=
(
pCtx
->
param
[
2
].
i64Key
==
TSDB_ORDER_ASC
)
?
resDataAscComparFn
:
resDataDescComparFn
;
qsort
(
tvp
,
pResInfo
->
numOfRes
,
POINTER_BYTES
,
comparator
);
qsort
(
tvp
,
(
size_t
)
pResInfo
->
numOfRes
,
POINTER_BYTES
,
comparator
);
}
GET_TRUE_DATA_TYPE
();
...
...
@@ -2909,33 +2905,41 @@ static FORCE_INLINE void date_col_output_function_f(SQLFunctionCtx *pCtx, int32_
}
static
void
col_project_function
(
SQLFunctionCtx
*
pCtx
)
{
// the number of output rows should not affect the final number of rows, so set it to be 0
if
(
pCtx
->
numOfParams
==
2
)
{
return
;
}
INC_INIT_VAL
(
pCtx
,
pCtx
->
size
);
char
*
pData
=
GET_INPUT_CHAR
(
pCtx
);
if
(
pCtx
->
order
==
TSDB_ORDER_ASC
)
{
memcpy
(
pCtx
->
aOutputBuf
,
pData
,
(
size_t
)
pCtx
->
size
*
pCtx
->
inputBytes
);
memcpy
(
pCtx
->
aOutputBuf
,
pData
,
(
size_t
)
pCtx
->
size
*
pCtx
->
inputBytes
);
}
else
{
for
(
int32_t
i
=
0
;
i
<
pCtx
->
size
;
++
i
)
{
memcpy
(
pCtx
->
aOutputBuf
+
(
pCtx
->
size
-
1
-
i
)
*
pCtx
->
inputBytes
,
pData
+
i
*
pCtx
->
inputBytes
,
pCtx
->
inputBytes
);
}
}
pCtx
->
aOutputBuf
+=
pCtx
->
size
*
pCtx
->
outputBytes
;
}
static
void
col_project_function_f
(
SQLFunctionCtx
*
pCtx
,
int32_t
index
)
{
SResultInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
if
(
pCtx
->
numOfParams
==
2
)
{
// the number of output rows should not affect the final number of rows, so set it to be 0
return
;
}
// only one output
if
(
pCtx
->
param
[
0
].
i64Key
==
1
&&
pResInfo
->
numOfRes
>=
1
)
{
return
;
}
INC_INIT_VAL
(
pCtx
,
1
);
char
*
pData
=
GET_INPUT_CHAR_INDEX
(
pCtx
,
index
);
memcpy
(
pCtx
->
aOutputBuf
,
pData
,
pCtx
->
inputBytes
);
pCtx
->
aOutputBuf
+=
pCtx
->
inputBytes
;
}
...
...
@@ -3903,11 +3907,11 @@ static void ts_comp_function(SQLFunctionCtx *pCtx) {
// primary ts must be existed, so no need to check its existance
if
(
pCtx
->
order
==
TSDB_ORDER_ASC
)
{
tsBufAppend
(
pTSbuf
,
0
,
pCtx
->
tag
.
i64Key
,
input
,
pCtx
->
size
*
TSDB_KEYSIZE
);
tsBufAppend
(
pTSbuf
,
0
,
&
pCtx
->
tag
,
input
,
pCtx
->
size
*
TSDB_KEYSIZE
);
}
else
{
for
(
int32_t
i
=
pCtx
->
size
-
1
;
i
>=
0
;
--
i
)
{
char
*
d
=
GET_INPUT_CHAR_INDEX
(
pCtx
,
i
);
tsBufAppend
(
pTSbuf
,
0
,
pCtx
->
tag
.
i64Key
,
d
,
TSDB_KEYSIZE
);
tsBufAppend
(
pTSbuf
,
0
,
&
pCtx
->
tag
,
d
,
TSDB_KEYSIZE
);
}
}
...
...
@@ -3926,7 +3930,7 @@ static void ts_comp_function_f(SQLFunctionCtx *pCtx, int32_t index) {
STSBuf
*
pTSbuf
=
pInfo
->
pTSBuf
;
tsBufAppend
(
pTSbuf
,
0
,
pCtx
->
tag
.
i64Key
,
pData
,
TSDB_KEYSIZE
);
tsBufAppend
(
pTSbuf
,
0
,
&
pCtx
->
tag
,
pData
,
TSDB_KEYSIZE
);
SET_VAL
(
pCtx
,
pCtx
->
size
,
1
);
pResInfo
->
hasResult
=
DATA_SET_FLAG
;
...
...
src/client/src/tscLocalMerge.c
浏览文件 @
45f855ca
...
...
@@ -370,7 +370,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
TSKEY
stime
=
MIN
(
pQueryInfo
->
window
.
skey
,
pQueryInfo
->
window
.
ekey
)
;
TSKEY
stime
=
(
pQueryInfo
->
order
.
order
==
TSDB_ORDER_ASC
)
?
pQueryInfo
->
window
.
skey
:
pQueryInfo
->
window
.
ekey
;
int64_t
revisedSTime
=
taosGetIntervalStartTimestamp
(
stime
,
pQueryInfo
->
slidingTime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
slidingTimeUnit
,
tinfo
.
precision
);
...
...
@@ -843,28 +843,6 @@ void savePrevRecordAndSetupFillInfo(SLocalReducer *pLocalReducer, SQueryInfo *pQ
tColModelAppend
(
pModel
,
pLocalReducer
->
discardData
,
pLocalReducer
->
prevRowOfInput
,
0
,
1
,
1
);
}
static
void
reversedCopyFromInterpolationToDstBuf
(
SQueryInfo
*
pQueryInfo
,
SSqlRes
*
pRes
,
tFilePage
**
pResPages
,
SLocalReducer
*
pLocalReducer
)
{
assert
(
0
);
size_t
size
=
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fieldsInfo
,
i
);
int32_t
offset
=
tscFieldInfoGetOffset
(
pQueryInfo
,
i
);
assert
(
offset
==
getColumnModelOffset
(
pLocalReducer
->
resColModel
,
i
));
char
*
src
=
pResPages
[
i
]
->
data
+
(
pRes
->
numOfRows
-
1
)
*
pField
->
bytes
;
char
*
dst
=
pRes
->
data
+
pRes
->
numOfRows
*
offset
;
for
(
int32_t
j
=
0
;
j
<
pRes
->
numOfRows
;
++
j
)
{
memcpy
(
dst
,
src
,
(
size_t
)
pField
->
bytes
);
dst
+=
pField
->
bytes
;
src
-=
pField
->
bytes
;
}
}
}
static
void
genFinalResWithoutFill
(
SSqlRes
*
pRes
,
SLocalReducer
*
pLocalReducer
,
SQueryInfo
*
pQueryInfo
)
{
assert
(
pQueryInfo
->
intervalTime
==
0
||
pQueryInfo
->
fillType
==
TSDB_FILL_NONE
);
...
...
@@ -925,7 +903,8 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SFillInfo
*
pFillInfo
=
pLocalReducer
->
pFillInfo
;
int64_t
actualETime
=
MAX
(
pQueryInfo
->
window
.
skey
,
pQueryInfo
->
window
.
ekey
);
// todo extract function
int64_t
actualETime
=
(
pQueryInfo
->
order
.
order
==
TSDB_ORDER_ASC
)
?
pQueryInfo
->
window
.
ekey
:
pQueryInfo
->
window
.
skey
;
tFilePage
**
pResPages
=
malloc
(
POINTER_BYTES
*
pQueryInfo
->
fieldsInfo
.
numOfOutput
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
...
...
@@ -984,14 +963,10 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO
savePrevRecordAndSetupFillInfo
(
pLocalReducer
,
pQueryInfo
,
pFillInfo
);
}
if
(
pQueryInfo
->
order
.
order
==
TSDB_ORDER_ASC
)
{
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fieldsInfo
,
i
);
int16_t
offset
=
getColumnModelOffset
(
pLocalReducer
->
resColModel
,
i
);
memcpy
(
pRes
->
data
+
offset
*
pRes
->
numOfRows
,
pResPages
[
i
]
->
data
,
(
size_t
)(
pField
->
bytes
*
pRes
->
numOfRows
));
}
}
else
{
// todo bug??
reversedCopyFromInterpolationToDstBuf
(
pQueryInfo
,
pRes
,
pResPages
,
pLocalReducer
);
for
(
int32_t
i
=
0
;
i
<
pQueryInfo
->
fieldsInfo
.
numOfOutput
;
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fieldsInfo
,
i
);
int16_t
offset
=
getColumnModelOffset
(
pLocalReducer
->
resColModel
,
i
);
memcpy
(
pRes
->
data
+
offset
*
pRes
->
numOfRows
,
pResPages
[
i
]
->
data
,
(
size_t
)(
pField
->
bytes
*
pRes
->
numOfRows
));
}
pRes
->
numOfRowsGroup
+=
pRes
->
numOfRows
;
...
...
@@ -1248,8 +1223,6 @@ bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCur
printf
(
"final result before interpo:
\n
"
);
// tColModelDisplay(pLocalReducer->resColModel, pLocalReducer->pBufForInterpo, pResBuf->num, pResBuf->num);
#endif
// no interval query, no fill operation
if
(
pQueryInfo
->
intervalTime
==
0
||
pQueryInfo
->
fillType
==
TSDB_FILL_NONE
)
{
...
...
@@ -1257,7 +1230,9 @@ bool genFinalResults(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool noMoreCur
}
else
{
SFillInfo
*
pFillInfo
=
pLocalReducer
->
pFillInfo
;
if
(
pFillInfo
!=
NULL
)
{
taosFillSetStartInfo
(
pFillInfo
,
(
int32_t
)
pResBuf
->
num
,
pQueryInfo
->
window
.
ekey
);
TSKEY
ekey
=
(
pQueryInfo
->
order
.
order
==
TSDB_ORDER_ASC
)
?
pQueryInfo
->
window
.
ekey
:
pQueryInfo
->
window
.
skey
;
taosFillSetStartInfo
(
pFillInfo
,
(
int32_t
)
pResBuf
->
num
,
ekey
);
taosFillCopyInputDataFromOneFilePage
(
pFillInfo
,
pResBuf
);
}
...
...
@@ -1292,7 +1267,7 @@ static void resetEnvForNewResultset(SSqlRes *pRes, SSqlCmd *pCmd, SLocalReducer
// for group result interpolation, do not return if not data is generated
if
(
pQueryInfo
->
fillType
!=
TSDB_FILL_NONE
)
{
TSKEY
skey
=
MIN
(
pQueryInfo
->
window
.
skey
,
pQueryInfo
->
window
.
ekey
);
TSKEY
skey
=
(
pQueryInfo
->
order
.
order
==
TSDB_ORDER_ASC
)
?
pQueryInfo
->
window
.
skey
:
pQueryInfo
->
window
.
ekey
;
//
MIN(pQueryInfo->window.skey, pQueryInfo->window.ekey);
int64_t
newTime
=
taosGetIntervalStartTimestamp
(
skey
,
pQueryInfo
->
slidingTime
,
pQueryInfo
->
intervalTime
,
pQueryInfo
->
slidingTimeUnit
,
precision
);
taosResetFillInfo
(
pLocalReducer
->
pFillInfo
,
newTime
);
...
...
@@ -1345,7 +1320,7 @@ static bool doHandleLastRemainData(SSqlObj *pSql) {
// if fillType == TSDB_FILL_NONE, return directly
if
(
pQueryInfo
->
fillType
!=
TSDB_FILL_NONE
&&
((
pRes
->
numOfRowsGroup
<
pQueryInfo
->
limit
.
limit
&&
pQueryInfo
->
limit
.
limit
>
0
)
||
(
pQueryInfo
->
limit
.
limit
<
0
)))
{
int64_t
etime
=
(
pQueryInfo
->
window
.
skey
<
pQueryInfo
->
window
.
ekey
)
?
pQueryInfo
->
window
.
ekey
:
pQueryInfo
->
window
.
skey
;
int64_t
etime
=
(
pQueryInfo
->
order
.
order
==
TSDB_ORDER_ASC
)
?
pQueryInfo
->
window
.
ekey
:
pQueryInfo
->
window
.
skey
;
int32_t
rows
=
(
int32_t
)
getFilledNumOfRes
(
pFillInfo
,
etime
,
pLocalReducer
->
resColModel
->
capacity
);
if
(
rows
>
0
)
{
...
...
@@ -1402,13 +1377,12 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
tscResetForNextRetrieve
(
pRes
);
if
(
pSql
->
signature
!=
pSql
||
pRes
==
NULL
||
pRes
->
pLocalReducer
==
NULL
)
{
// all data has been processed
tscDebug
(
"%p %s call the drop local reducer"
,
pSql
,
__FUNCTION__
);
tscDestroyLocalReducer
(
pSql
);
return
0
;
tscError
(
"%p local merge abort due to error occurs, code:%s"
,
pSql
,
tstrerror
(
pRes
->
code
));
return
pRes
->
code
;
}
SLocalReducer
*
pLocalReducer
=
pRes
->
pLocalReducer
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
// set the data merge in progress
int32_t
prevStatus
=
...
...
@@ -1503,8 +1477,8 @@ int32_t tscDoLocalMerge(SSqlObj *pSql) {
* so the processing of previous group is completed.
*/
int32_t
numOfRes
=
finalizeRes
(
pQueryInfo
,
pLocalReducer
);
bool
sameGroup
=
isSameGroup
(
pCmd
,
pLocalReducer
,
pLocalReducer
->
prevRowOfInput
,
tmpBuffer
);
bool
sameGroup
=
isSameGroup
(
pCmd
,
pLocalReducer
,
pLocalReducer
->
prevRowOfInput
,
tmpBuffer
);
tFilePage
*
pResBuf
=
pLocalReducer
->
pResultBuf
;
/*
...
...
src/client/src/tscParseInsert.c
浏览文件 @
45f855ca
...
...
@@ -40,7 +40,7 @@ enum {
static
int32_t
tscAllocateMemIfNeed
(
STableDataBlocks
*
pDataBlock
,
int32_t
rowSize
,
int32_t
*
numOfRows
);
static
int32_t
tscToInteger
(
SS
QL
Token
*
pToken
,
int64_t
*
value
,
char
**
endPtr
)
{
static
int32_t
tscToInteger
(
SS
tr
Token
*
pToken
,
int64_t
*
value
,
char
**
endPtr
)
{
if
(
pToken
->
n
==
0
)
{
return
TK_ILLEGAL
;
}
...
...
@@ -73,7 +73,7 @@ static int32_t tscToInteger(SSQLToken *pToken, int64_t *value, char **endPtr) {
return
pToken
->
type
;
}
static
int32_t
tscToDouble
(
SS
QL
Token
*
pToken
,
double
*
value
,
char
**
endPtr
)
{
static
int32_t
tscToDouble
(
SS
tr
Token
*
pToken
,
double
*
value
,
char
**
endPtr
)
{
if
(
pToken
->
n
==
0
)
{
return
TK_ILLEGAL
;
}
...
...
@@ -89,9 +89,9 @@ static int32_t tscToDouble(SSQLToken *pToken, double *value, char **endPtr) {
return
pToken
->
type
;
}
int
tsParseTime
(
SS
QL
Token
*
pToken
,
int64_t
*
time
,
char
**
next
,
char
*
error
,
int16_t
timePrec
)
{
int
tsParseTime
(
SS
tr
Token
*
pToken
,
int64_t
*
time
,
char
**
next
,
char
*
error
,
int16_t
timePrec
)
{
int32_t
index
=
0
;
SS
QL
Token
sToken
;
SS
tr
Token
sToken
;
int64_t
interval
;
int64_t
useconds
=
0
;
char
*
pTokenEnd
=
*
next
;
...
...
@@ -128,7 +128,7 @@ int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int1
* time expression:
* e.g., now+12a, now-5h
*/
SS
QL
Token
valueToken
;
SS
tr
Token
valueToken
;
index
=
0
;
sToken
=
tStrGetToken
(
pTokenEnd
,
&
index
,
false
,
0
,
NULL
);
pTokenEnd
+=
index
;
...
...
@@ -163,7 +163,7 @@ int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int1
return
TSDB_CODE_SUCCESS
;
}
int32_t
tsParseOneColumnData
(
SSchema
*
pSchema
,
SS
QL
Token
*
pToken
,
char
*
payload
,
char
*
msg
,
char
**
str
,
bool
primaryKey
,
int32_t
tsParseOneColumnData
(
SSchema
*
pSchema
,
SS
tr
Token
*
pToken
,
char
*
payload
,
char
*
msg
,
char
**
str
,
bool
primaryKey
,
int16_t
timePrec
)
{
int64_t
iv
;
int32_t
numType
;
...
...
@@ -409,7 +409,7 @@ static int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start
int
tsParseOneRowData
(
char
**
str
,
STableDataBlocks
*
pDataBlocks
,
SSchema
schema
[],
SParsedDataColInfo
*
spd
,
char
*
error
,
int16_t
timePrec
,
int32_t
*
code
,
char
*
tmpTokenBuf
)
{
int32_t
index
=
0
;
SS
QL
Token
sToken
=
{
0
};
SS
tr
Token
sToken
=
{
0
};
char
*
payload
=
pDataBlocks
->
pData
+
pDataBlocks
->
size
;
// 1. set the parsed value from sql string
...
...
@@ -524,7 +524,7 @@ static int32_t rowDataCompar(const void *lhs, const void *rhs) {
int
tsParseValues
(
char
**
str
,
STableDataBlocks
*
pDataBlock
,
STableMeta
*
pTableMeta
,
int
maxRows
,
SParsedDataColInfo
*
spd
,
char
*
error
,
int32_t
*
code
,
char
*
tmpTokenBuf
)
{
int32_t
index
=
0
;
SS
QL
Token
sToken
;
SS
tr
Token
sToken
;
int16_t
numOfRows
=
0
;
...
...
@@ -734,8 +734,8 @@ static int32_t doParseInsertStatement(SSqlObj *pSql, void *pTableList, char **st
static
int32_t
tscCheckIfCreateTable
(
char
**
sqlstr
,
SSqlObj
*
pSql
)
{
int32_t
index
=
0
;
SS
QL
Token
sToken
=
{
0
};
SS
QL
Token
tableToken
=
{
0
};
SS
tr
Token
sToken
=
{
0
};
SS
tr
Token
tableToken
=
{
0
};
int32_t
code
=
TSDB_CODE_SUCCESS
;
const
int32_t
TABLE_INDEX
=
0
;
...
...
@@ -993,7 +993,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
code
;
}
int
validateTableName
(
char
*
tblName
,
int
len
,
SS
QL
Token
*
psTblToken
)
{
int
validateTableName
(
char
*
tblName
,
int
len
,
SS
tr
Token
*
psTblToken
)
{
tstrncpy
(
psTblToken
->
z
,
tblName
,
TSDB_TABLE_FNAME_LEN
);
psTblToken
->
n
=
len
;
...
...
@@ -1031,11 +1031,11 @@ int tsParseInsertSql(SSqlObj *pSql) {
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
assert
(
pQueryInfo
!=
NULL
);
STableMetaInfo
*
pTableMetaInfo
=
NULL
;
if
(
p
QueryInfo
->
numOfTables
==
0
)
{
pTableMetaInfo
=
tscAddEmptyMetaInfo
(
pQueryInfo
)
;
}
else
{
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
)
;
STableMetaInfo
*
pTableMetaInfo
=
(
pQueryInfo
->
numOfTables
==
0
)
?
tscAddEmptyMetaInfo
(
pQueryInfo
)
:
tscGetMetaInfo
(
pQueryInfo
,
0
)
;
if
(
p
TableMetaInfo
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
code
=
terrno
;
return
code
;
}
if
((
code
=
tscAllocPayload
(
pCmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
))
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -1057,7 +1057,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
while
(
1
)
{
int32_t
index
=
0
;
SS
QL
Token
sToken
=
tStrGetToken
(
str
,
&
index
,
false
,
0
,
NULL
);
SS
tr
Token
sToken
=
tStrGetToken
(
str
,
&
index
,
false
,
0
,
NULL
);
// no data in the sql string anymore.
if
(
sToken
.
n
==
0
)
{
...
...
@@ -1083,7 +1083,7 @@ int tsParseInsertSql(SSqlObj *pSql) {
pCmd
->
curSql
=
sToken
.
z
;
char
buf
[
TSDB_TABLE_FNAME_LEN
];
SS
QL
Token
sTblToken
;
SS
tr
Token
sTblToken
;
sTblToken
.
z
=
buf
;
// Check if the table name available or not
if
(
validateTableName
(
sToken
.
z
,
sToken
.
n
,
&
sTblToken
)
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -1285,15 +1285,14 @@ int tsInsertInitialCheck(SSqlObj *pSql) {
int32_t
index
=
0
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SS
QL
Token
sToken
=
tStrGetToken
(
pSql
->
sqlstr
,
&
index
,
false
,
0
,
NULL
);
SS
tr
Token
sToken
=
tStrGetToken
(
pSql
->
sqlstr
,
&
index
,
false
,
0
,
NULL
);
assert
(
sToken
.
type
==
TK_INSERT
||
sToken
.
type
==
TK_IMPORT
);
pCmd
->
count
=
0
;
pCmd
->
command
=
TSDB_SQL_INSERT
;
pSql
->
res
.
numOfRows
=
0
;
SQueryInfo
*
pQueryInfo
=
NULL
;
tscGetQueryInfoDetailSafely
(
pCmd
,
pCmd
->
clauseIndex
,
&
pQueryInfo
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetailSafely
(
pCmd
,
pCmd
->
clauseIndex
);
TSDB_QUERY_SET_TYPE
(
pQueryInfo
->
type
,
TSDB_QUERY_TYPE_INSERT
|
pCmd
->
insertType
);
...
...
src/client/src/tscPrepare.c
浏览文件 @
45f855ca
...
...
@@ -155,7 +155,7 @@ static int normalStmtPrepare(STscStmt* stmt) {
uint32_t
i
=
0
,
start
=
0
;
while
(
sql
[
i
]
!=
0
)
{
SS
QL
Token
token
=
{
0
};
SS
tr
Token
token
=
{
0
};
token
.
n
=
tSQLGetToken
(
sql
+
i
,
&
token
.
type
);
if
(
token
.
type
==
TK_QUESTION
)
{
...
...
src/client/src/tscSQLParser.c
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
src/client/src/tscServer.c
浏览文件 @
45f855ca
...
...
@@ -318,10 +318,10 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
pRes
->
rspLen
=
0
;
if
(
pRes
->
code
!=
TSDB_CODE_TSC_QUERY_CANCELLED
)
{
pRes
->
code
=
(
rpcMsg
->
code
!=
TSDB_CODE_SUCCESS
)
?
rpcMsg
->
code
:
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
}
else
{
if
(
pRes
->
code
==
TSDB_CODE_TSC_QUERY_CANCELLED
)
{
tscDebug
(
"%p query is cancelled, code:%s"
,
pSql
,
tstrerror
(
pRes
->
code
));
}
else
{
pRes
->
code
=
rpcMsg
->
code
;
}
if
(
pRes
->
code
==
TSDB_CODE_SUCCESS
)
{
...
...
@@ -458,35 +458,21 @@ void tscKillSTableQuery(SSqlObj *pSql) {
return
;
}
pSql
->
res
.
code
=
TSDB_CODE_TSC_QUERY_CANCELLED
;
for
(
int
i
=
0
;
i
<
pSql
->
numOfSubs
;
++
i
)
{
// NOTE: pSub may have been released already here
SSqlObj
*
pSub
=
pSql
->
pSubs
[
i
];
if
(
pSub
==
NULL
)
{
continue
;
}
/*
* here, we cannot set the command = TSDB_SQL_KILL_QUERY. Otherwise, it may cause
* sub-queries not correctly released and master sql object of super table query reaches an abnormal state.
*/
rpcCancelRequest
(
pSub
->
pRpcCtx
);
pSub
->
res
.
code
=
TSDB_CODE_TSC_QUERY_CANCELLED
;
tscQueueAsyncRes
(
pSub
);
}
/*
* 1. if the subqueries are not launched or partially launched, we need to waiting the launched
* query return to successfully free allocated resources.
* 2. if no any subqueries are launched yet, which means the super table query only in parse sql stage,
* set the res.code, and return.
*/
const
int64_t
MAX_WAITING_TIME
=
10000
;
// 10 Sec.
int64_t
stime
=
taosGetTimestampMs
();
while
(
pCmd
->
command
!=
TSDB_SQL_RETRIEVE_LOCALMERGE
&&
pCmd
->
command
!=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
)
{
taosMsleep
(
100
);
if
(
taosGetTimestampMs
()
-
stime
>
MAX_WAITING_TIME
)
{
break
;
if
(
pSub
->
pRpcCtx
!=
NULL
)
{
rpcCancelRequest
(
pSub
->
pRpcCtx
);
}
tscQueueAsyncRes
(
pSub
);
// async res? not other functions?
}
tscDebug
(
"%p super table query cancelled"
,
pSql
);
...
...
@@ -642,26 +628,29 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
tscError
(
"%p failed to malloc for query msg"
,
pSql
);
return
-
1
;
// todo add test for this
return
TSDB_CODE_TSC_INVALID_SQL
;
// todo add test for this
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableMeta
*
pTableMeta
=
pTableMetaInfo
->
pTableMeta
;
if
(
taosArrayGetSize
(
pQueryInfo
->
colList
)
<=
0
&&
!
tscQueryTags
(
pQueryInfo
))
{
tscError
(
"%p illegal value of numOfCols in query msg: %d"
,
pSql
,
tscGetNumOfColumns
(
pTableMeta
));
return
-
1
;
size_t
numOfSrcCols
=
taosArrayGetSize
(
pQueryInfo
->
colList
);
if
(
numOfSrcCols
<=
0
&&
!
tscQueryTags
(
pQueryInfo
))
{
tscError
(
"%p illegal value of numOfCols in query msg: %"
PRIu64
", table cols:%d"
,
pSql
,
numOfSrcCols
,
tscGetNumOfColumns
(
pTableMeta
));
return
TSDB_CODE_TSC_INVALID_SQL
;
}
if
(
pQueryInfo
->
intervalTime
<
0
)
{
tscError
(
"%p illegal value of aggregation time interval in query msg: %ld"
,
pSql
,
pQueryInfo
->
intervalTime
);
return
-
1
;
return
TSDB_CODE_TSC_INVALID_SQL
;
}
if
(
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
<
0
)
{
tscError
(
"%p illegal value of numOfGroupCols in query msg: %d"
,
pSql
,
pQueryInfo
->
groupbyExpr
.
numOfGroupCols
);
return
-
1
;
return
TSDB_CODE_TSC_INVALID_SQL
;
}
SQueryTableMsg
*
pQueryMsg
=
(
SQueryTableMsg
*
)
pCmd
->
payload
;
...
...
@@ -739,7 +728,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
if
(
pColFilter
->
lowerRelOptr
==
TSDB_RELATION_INVALID
&&
pColFilter
->
upperRelOptr
==
TSDB_RELATION_INVALID
)
{
tscError
(
"invalid filter info"
);
return
-
1
;
return
TSDB_CODE_TSC_INVALID_SQL
;
}
}
}
...
...
@@ -748,10 +737,10 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
for
(
int32_t
i
=
0
;
i
<
tscSqlExprNumOfExprs
(
pQueryInfo
);
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
if
(
!
tscValidateColumnId
(
pTableMetaInfo
,
pExpr
->
colInfo
.
colId
))
{
if
(
!
tscValidateColumnId
(
pTableMetaInfo
,
pExpr
->
colInfo
.
colId
,
pExpr
->
numOfParams
))
{
/* column id is not valid according to the cached table meta, the table meta is expired */
tscError
(
"%p table schema is not matched with parsed sql"
,
pSql
);
return
-
1
;
return
TSDB_CODE_TSC_INVALID_SQL
;
}
pSqlFuncExpr
->
colInfo
.
colId
=
htons
(
pExpr
->
colInfo
.
colId
);
...
...
@@ -948,8 +937,8 @@ int32_t tscBuildAcctMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SCMCreateAcctMsg
*
pAlterMsg
=
(
SCMCreateAcctMsg
*
)
pCmd
->
payload
;
SS
QL
Token
*
pName
=
&
pInfo
->
pDCLInfo
->
user
.
user
;
SS
QL
Token
*
pPwd
=
&
pInfo
->
pDCLInfo
->
user
.
passwd
;
SS
tr
Token
*
pName
=
&
pInfo
->
pDCLInfo
->
user
.
user
;
SS
tr
Token
*
pPwd
=
&
pInfo
->
pDCLInfo
->
user
.
passwd
;
strncpy
(
pAlterMsg
->
user
,
pName
->
z
,
pName
->
n
);
strncpy
(
pAlterMsg
->
pass
,
pPwd
->
z
,
pPwd
->
n
);
...
...
@@ -1151,13 +1140,13 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pShowMsg
->
type
=
pShowInfo
->
showType
;
if
(
pShowInfo
->
showType
!=
TSDB_MGMT_TABLE_VNODES
)
{
SS
QL
Token
*
pPattern
=
&
pShowInfo
->
pattern
;
SS
tr
Token
*
pPattern
=
&
pShowInfo
->
pattern
;
if
(
pPattern
->
type
>
0
)
{
// only show tables support wildcard query
strncpy
(
pShowMsg
->
payload
,
pPattern
->
z
,
pPattern
->
n
);
pShowMsg
->
payloadLen
=
htons
(
pPattern
->
n
);
}
}
else
{
SS
QL
Token
*
pEpAddr
=
&
pShowInfo
->
prefix
;
SS
tr
Token
*
pEpAddr
=
&
pShowInfo
->
prefix
;
assert
(
pEpAddr
->
n
>
0
&&
pEpAddr
->
type
>
0
);
strncpy
(
pShowMsg
->
payload
,
pEpAddr
->
z
,
pEpAddr
->
n
);
...
...
@@ -1299,7 +1288,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int
size
=
tscEstimateAlterTableMsgLength
(
pCmd
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
tscError
(
"%p failed to malloc for alter table msg"
,
pSql
);
return
-
1
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
SCMAlterTableMsg
*
pAlterTableMsg
=
(
SCMAlterTableMsg
*
)
pCmd
->
payload
;
...
...
@@ -1447,6 +1436,12 @@ int tscProcessRetrieveLocalMergeRsp(SSqlObj *pSql) {
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
int32_t
code
=
pRes
->
code
;
if
(
pRes
->
code
!=
TSDB_CODE_SUCCESS
)
{
tscQueueAsyncRes
(
pSql
);
return
code
;
}
pRes
->
code
=
tscDoLocalMerge
(
pSql
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
...
...
@@ -1457,7 +1452,7 @@ int tscProcessRetrieveLocalMergeRsp(SSqlObj *pSql) {
pRes
->
row
=
0
;
pRes
->
completed
=
(
pRes
->
numOfRows
==
0
);
int32_t
code
=
pRes
->
code
;
code
=
pRes
->
code
;
if
(
pRes
->
code
==
TSDB_CODE_SUCCESS
)
{
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
pRes
->
numOfRows
);
}
else
{
...
...
@@ -1651,7 +1646,7 @@ int tscBuildHeartBeatMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
pthread_mutex_unlock
(
&
pObj
->
mutex
);
tscError
(
"%p failed to malloc for heartbeat msg"
,
pSql
);
return
-
1
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
SCMHeartBeatMsg
*
pHeartbeat
=
(
SCMHeartBeatMsg
*
)
pCmd
->
payload
;
...
...
@@ -1721,7 +1716,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
assert
(
pTableMetaInfo
->
pTableMeta
==
NULL
);
pTableMetaInfo
->
pTableMeta
=
(
STableMeta
*
)
taosCachePut
(
tscCacheHandle
,
pTableMetaInfo
->
name
,
strlen
(
pTableMetaInfo
->
name
),
pTableMeta
,
size
,
tsTableMetaKeepTimer
);
strlen
(
pTableMetaInfo
->
name
),
pTableMeta
,
size
,
tsTableMetaKeepTimer
*
1000
);
// todo handle out of memory case
if
(
pTableMetaInfo
->
pTableMeta
==
NULL
)
{
...
...
@@ -1925,7 +1920,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
STableMeta
*
pTableMeta
=
tscCreateTableMetaFromMsg
(
pMetaMsg
,
&
size
);
pTableMetaInfo
->
pTableMeta
=
taosCachePut
(
tscCacheHandle
,
key
,
strlen
(
key
),
(
char
*
)
pTableMeta
,
size
,
tsTableMetaKeepTimer
);
tsTableMetaKeepTimer
*
1000
);
SSchema
*
pTableSchema
=
tscGetTableSchema
(
pTableMetaInfo
->
pTableMeta
);
if
(
pQueryInfo
->
colList
==
NULL
)
{
...
...
@@ -1965,8 +1960,12 @@ static void createHBObj(STscObj* pObj) {
pSql
->
fp
=
tscProcessHeartBeatRsp
;
SQueryInfo
*
pQueryInfo
=
NULL
;
tscGetQueryInfoDetailSafely
(
&
pSql
->
cmd
,
0
,
&
pQueryInfo
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetailSafely
(
&
pSql
->
cmd
,
0
);
if
(
pQueryInfo
==
NULL
)
{
pSql
->
res
.
code
=
terrno
;
return
;
}
pQueryInfo
->
command
=
TSDB_SQL_HB
;
pSql
->
cmd
.
command
=
pQueryInfo
->
command
;
...
...
@@ -2151,8 +2150,7 @@ static int32_t getTableMetaFromMgmt(SSqlObj *pSql, STableMetaInfo *pTableMetaInf
tscAddSubqueryInfo
(
&
pNew
->
cmd
);
SQueryInfo
*
pNewQueryInfo
=
NULL
;
tscGetQueryInfoDetailSafely
(
&
pNew
->
cmd
,
0
,
&
pNewQueryInfo
);
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetailSafely
(
&
pNew
->
cmd
,
0
);
pNew
->
cmd
.
autoCreated
=
pSql
->
cmd
.
autoCreated
;
// create table if not exists
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
&
pNew
->
cmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
+
pSql
->
cmd
.
payloadLen
))
{
...
...
@@ -2255,8 +2253,8 @@ int tscGetSTableVgroupInfo(SSqlObj *pSql, int32_t clauseIndex) {
pNew
->
cmd
.
command
=
TSDB_SQL_STABLEVGROUP
;
SQueryInfo
*
pNewQueryInfo
=
NULL
;
if
(
(
code
=
tscGetQueryInfoDetailSafely
(
&
pNew
->
cmd
,
0
,
&
pNewQueryInfo
))
!=
TSDB_CODE_SUCCESS
)
{
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetailSafely
(
&
pNew
->
cmd
,
0
)
;
if
(
pNewQueryInfo
==
NULL
)
{
tscFreeSqlObj
(
pNew
);
return
code
;
}
...
...
src/client/src/tscSql.c
浏览文件 @
45f855ca
...
...
@@ -655,28 +655,31 @@ int* taos_fetch_lengths(TAOS_RES *res) {
char
*
taos_get_client_info
()
{
return
version
;
}
void
taos_stop_query
(
TAOS_RES
*
res
)
{
if
(
res
==
NULL
)
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
res
;
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
return
;
}
SSqlObj
*
pSql
=
(
SSqlObj
*
)
res
;
tscDebug
(
"%p start to cancel query"
,
res
)
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
if
(
pSql
->
signature
!=
pSql
)
return
;
tscDebug
(
"%p start to cancel query"
,
res
);
// TODO there are multi-thread problem.
// It may have been released by the other thread already.
// The ref count may fix this problem.
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
// set the error code for master pSqlObj firstly
pSql
->
res
.
code
=
TSDB_CODE_TSC_QUERY_CANCELLED
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
if
(
tscIsTwoStageSTableQuery
(
pQueryInfo
,
0
))
{
assert
(
pSql
->
pRpcCtx
==
NULL
);
tscKillSTableQuery
(
pSql
);
}
else
{
if
(
pSql
->
cmd
.
command
<
TSDB_SQL_LOCAL
)
{
rpcCancelRequest
(
pSql
->
pRpcCtx
);
}
}
if
(
pSql
->
cmd
.
command
<
TSDB_SQL_LOCAL
)
{
rpcCancelRequest
(
pSql
->
pRpcCtx
);
}
pSql
->
res
.
code
=
TSDB_CODE_TSC_QUERY_CANCELLED
;
tscQueueAsyncRes
(
pSql
);
tscDebug
(
"%p query is cancelled"
,
res
);
}
...
...
@@ -824,8 +827,11 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
int
code
=
TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH
;
char
*
str
=
(
char
*
)
tblNameList
;
SQueryInfo
*
pQueryInfo
=
NULL
;
tscGetQueryInfoDetailSafely
(
pCmd
,
pCmd
->
clauseIndex
,
&
pQueryInfo
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetailSafely
(
pCmd
,
pCmd
->
clauseIndex
);
if
(
pQueryInfo
==
NULL
)
{
pSql
->
res
.
code
=
terrno
;
return
terrno
;
}
STableMetaInfo
*
pTableMetaInfo
=
tscAddEmptyMetaInfo
(
pQueryInfo
);
...
...
@@ -850,7 +856,7 @@ static int tscParseTblNameList(SSqlObj *pSql, const char *tblNameList, int32_t t
str
=
nextStr
+
1
;
len
=
(
int32_t
)
strtrim
(
tblName
);
SS
QL
Token
sToken
=
{.
n
=
len
,
.
type
=
TK_ID
,
.
z
=
tblName
};
SS
tr
Token
sToken
=
{.
n
=
len
,
.
type
=
TK_ID
,
.
z
=
tblName
};
tSQLGetToken
(
tblName
,
&
sToken
.
type
);
// Check if the table name available or not
...
...
src/client/src/tscSubquery.c
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
src/client/src/tscUtil.c
浏览文件 @
45f855ca
...
...
@@ -373,7 +373,7 @@ void tscFreeSqlObj(SSqlObj* pSql) {
if
(
pSql
==
NULL
||
pSql
->
signature
!=
pSql
)
{
return
;
}
tscDebug
(
"%p start to free sql object"
,
pSql
);
tscPartiallyFreeSqlObj
(
pSql
);
...
...
@@ -388,6 +388,7 @@ void tscFreeSqlObj(SSqlObj* pSql) {
taosTFree
(
pSql
->
sqlstr
);
tsem_destroy
(
&
pSql
->
rspSem
);
free
(
pSql
);
}
...
...
@@ -485,15 +486,6 @@ int32_t tscCopyDataBlockToPayload(SSqlObj* pSql, STableDataBlocks* pDataBlock) {
return
TSDB_CODE_SUCCESS
;
}
//void tscFreeUnusedDataBlocks(SDataBlockList* pList) {
// /* release additional memory consumption */
// for (int32_t i = 0; i < pList->nSize; ++i) {
// STableDataBlocks* pDataBlock = pList->pData[i];
// pDataBlock->pData = realloc(pDataBlock->pData, pDataBlock->size);
// pDataBlock->nAllocSize = (uint32_t)pDataBlock->size;
// }
//}
/**
* create the in-memory buffer for each table to keep the submitted data block
* @param initialSize
...
...
@@ -518,6 +510,11 @@ int32_t tscCreateDataBlock(size_t initialSize, int32_t rowSize, int32_t startOff
}
dataBuf
->
pData
=
calloc
(
1
,
dataBuf
->
nAllocSize
);
if
(
dataBuf
->
pData
==
NULL
)
{
tscError
(
"failed to allocated memory, reason:%s"
,
strerror
(
errno
));
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
dataBuf
->
ordered
=
true
;
dataBuf
->
prevTS
=
INT64_MIN
;
...
...
@@ -742,7 +739,7 @@ bool tscIsInsertData(char* sqlstr) {
int32_t
index
=
0
;
do
{
SS
QL
Token
t0
=
tStrGetToken
(
sqlstr
,
&
index
,
false
,
0
,
NULL
);
SS
tr
Token
t0
=
tStrGetToken
(
sqlstr
,
&
index
,
false
,
0
,
NULL
);
if
(
t0
.
type
!=
TK_LP
)
{
return
t0
.
type
==
TK_INSERT
||
t0
.
type
==
TK_IMPORT
;
}
...
...
@@ -926,17 +923,23 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo) {
}
static
SSqlExpr
*
doBuildSqlExpr
(
SQueryInfo
*
pQueryInfo
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
int16_t
size
,
int16_t
interSize
,
bool
isTagCol
)
{
int16_t
size
,
int16_t
interSize
,
int32_t
colType
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
pColIndex
->
tableIndex
);
SSqlExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
SSqlExpr
));
if
(
pExpr
==
NULL
)
{
return
NULL
;
}
pExpr
->
functionId
=
functionId
;
// set the correct columnIndex index
if
(
pColIndex
->
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
pExpr
->
colInfo
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
;
}
else
if
(
pColIndex
->
columnIndex
<=
TSDB_UD_COLUMN_INDEX
)
{
pExpr
->
colInfo
.
colId
=
pColIndex
->
columnIndex
;
}
else
{
if
(
isTagCol
)
{
if
(
TSDB_COL_IS_TAG
(
colType
)
)
{
SSchema
*
pSchema
=
tscGetTableTagSchema
(
pTableMetaInfo
->
pTableMeta
);
pExpr
->
colInfo
.
colId
=
pSchema
[
pColIndex
->
columnIndex
].
colId
;
tstrncpy
(
pExpr
->
colInfo
.
name
,
pSchema
[
pColIndex
->
columnIndex
].
name
,
sizeof
(
pExpr
->
colInfo
.
name
));
...
...
@@ -948,9 +951,9 @@ static SSqlExpr* doBuildSqlExpr(SQueryInfo* pQueryInfo, int16_t functionId, SCol
}
}
pExpr
->
colInfo
.
flag
=
isTagCol
?
TSDB_COL_TAG
:
TSDB_COL_NORMAL
;
pExpr
->
colInfo
.
flag
=
colType
;
pExpr
->
colInfo
.
colIndex
=
pColIndex
->
columnIndex
;
pExpr
->
resType
=
type
;
pExpr
->
resBytes
=
size
;
pExpr
->
interBytes
=
interSize
;
...
...
@@ -1060,8 +1063,11 @@ void tscSqlExprCopy(SArray* dst, const SArray* src, uint64_t uid, bool deepcopy)
if
(
deepcopy
)
{
SSqlExpr
*
p1
=
calloc
(
1
,
sizeof
(
SSqlExpr
));
if
(
p1
==
NULL
)
{
assert
(
0
);
}
*
p1
=
*
pExpr
;
for
(
int32_t
j
=
0
;
j
<
pExpr
->
numOfParams
;
++
j
)
{
tVariantAssign
(
&
p1
->
param
[
j
],
&
pExpr
->
param
[
j
]);
}
...
...
@@ -1097,16 +1103,22 @@ SColumn* tscColumnListInsert(SArray* pColumnList, SColumnIndex* pColIndex) {
if
(
i
>=
numOfCols
||
numOfCols
==
0
)
{
SColumn
*
b
=
calloc
(
1
,
sizeof
(
SColumn
));
if
(
b
==
NULL
)
{
return
NULL
;
}
b
->
colIndex
=
*
pColIndex
;
taosArrayInsert
(
pColumnList
,
i
,
&
b
);
}
else
{
SColumn
*
pCol
=
taosArrayGetP
(
pColumnList
,
i
);
if
(
i
<
numOfCols
&&
(
pCol
->
colIndex
.
columnIndex
>
col
||
pCol
->
colIndex
.
tableIndex
!=
pColIndex
->
tableIndex
))
{
SColumn
*
b
=
calloc
(
1
,
sizeof
(
SColumn
));
if
(
b
==
NULL
)
{
return
NULL
;
}
b
->
colIndex
=
*
pColIndex
;
taosArrayInsert
(
pColumnList
,
i
,
&
b
);
}
}
...
...
@@ -1128,7 +1140,10 @@ SColumn* tscColumnClone(const SColumn* src) {
assert
(
src
!=
NULL
);
SColumn
*
dst
=
calloc
(
1
,
sizeof
(
SColumn
));
if
(
dst
==
NULL
)
{
return
NULL
;
}
dst
->
colIndex
=
src
->
colIndex
;
dst
->
numOfFilters
=
src
->
numOfFilters
;
dst
->
filterInfo
=
tscFilterInfoClone
(
src
->
filterInfo
,
src
->
numOfFilters
);
...
...
@@ -1183,7 +1198,7 @@ void tscColumnListDestroy(SArray* pColumnList) {
* 'first_part.second_part'
*
*/
static
int32_t
validateQuoteToken
(
SS
QL
Token
*
pToken
)
{
static
int32_t
validateQuoteToken
(
SS
tr
Token
*
pToken
)
{
strdequote
(
pToken
->
z
);
pToken
->
n
=
(
uint32_t
)
strtrim
(
pToken
->
z
);
...
...
@@ -1199,7 +1214,7 @@ static int32_t validateQuoteToken(SSQLToken* pToken) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
tscValidateName
(
SS
QL
Token
*
pToken
)
{
int32_t
tscValidateName
(
SS
tr
Token
*
pToken
)
{
if
(
pToken
->
type
!=
TK_STRING
&&
pToken
->
type
!=
TK_ID
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
...
...
@@ -1286,12 +1301,12 @@ void tscIncStreamExecutionCount(void* pStream) {
ps
->
num
+=
1
;
}
bool
tscValidateColumnId
(
STableMetaInfo
*
pTableMetaInfo
,
int32_t
colId
)
{
bool
tscValidateColumnId
(
STableMetaInfo
*
pTableMetaInfo
,
int32_t
colId
,
int32_t
numOfParams
)
{
if
(
pTableMetaInfo
->
pTableMeta
==
NULL
)
{
return
false
;
}
if
(
colId
==
TSDB_TBNAME_COLUMN_INDEX
)
{
if
(
colId
==
TSDB_TBNAME_COLUMN_INDEX
||
(
colId
<=
TSDB_UD_COLUMN_INDEX
&&
numOfParams
==
2
)
)
{
return
true
;
}
...
...
@@ -1338,6 +1353,10 @@ void tscTagCondCopy(STagCond* dest, const STagCond* src) {
if
(
pCond
->
len
>
0
)
{
assert
(
pCond
->
cond
!=
NULL
);
c
.
cond
=
malloc
(
c
.
len
);
if
(
c
.
cond
==
NULL
)
{
assert
(
0
);
}
memcpy
(
c
.
cond
,
pCond
->
cond
,
c
.
len
);
}
...
...
@@ -1463,20 +1482,20 @@ STableMetaInfo* tscGetMetaInfo(SQueryInfo* pQueryInfo, int32_t tableIndex) {
return
pQueryInfo
->
pTableMetaInfo
[
tableIndex
];
}
int32_t
tscGetQueryInfoDetailSafely
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
,
SQueryInfo
**
pQueryInfo
)
{
SQueryInfo
*
tscGetQueryInfoDetailSafely
(
SSqlCmd
*
pCmd
,
int32_t
subClauseIndex
)
{
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
subClauseIndex
);
int32_t
ret
=
TSDB_CODE_SUCCESS
;
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
subClauseIndex
);
while
((
*
pQueryInfo
)
==
NULL
)
{
while
((
pQueryInfo
)
==
NULL
)
{
if
((
ret
=
tscAddSubqueryInfo
(
pCmd
))
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
NULL
;
}
(
*
pQueryInfo
)
=
tscGetQueryInfoDetail
(
pCmd
,
subClauseIndex
);
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
subClauseIndex
);
}
return
TSDB_CODE_SUCCESS
;
return
pQueryInfo
;
}
STableMetaInfo
*
tscGetTableMetaInfoByUid
(
SQueryInfo
*
pQueryInfo
,
uint64_t
uid
,
int32_t
*
index
)
{
...
...
@@ -1507,6 +1526,7 @@ void tscInitQueryInfo(SQueryInfo* pQueryInfo) {
assert
(
pQueryInfo
->
exprList
==
NULL
);
pQueryInfo
->
exprList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pQueryInfo
->
colList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pQueryInfo
->
udColumnId
=
TSDB_UD_COLUMN_INDEX
;
}
int32_t
tscAddSubqueryInfo
(
SSqlCmd
*
pCmd
)
{
...
...
@@ -1522,8 +1542,11 @@ int32_t tscAddSubqueryInfo(SSqlCmd* pCmd) {
pCmd
->
pQueryInfo
=
(
SQueryInfo
**
)
tmp
;
SQueryInfo
*
pQueryInfo
=
calloc
(
1
,
sizeof
(
SQueryInfo
));
if
(
pQueryInfo
==
NULL
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
tscInitQueryInfo
(
pQueryInfo
);
pQueryInfo
->
msg
=
pCmd
->
payload
;
// pointer to the parent error message buffer
pCmd
->
pQueryInfo
[
pCmd
->
numOfClause
++
]
=
pQueryInfo
;
...
...
@@ -1584,14 +1607,18 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST
SVgroupsInfo
*
vgroupList
,
SArray
*
pTagCols
)
{
void
*
pAlloc
=
realloc
(
pQueryInfo
->
pTableMetaInfo
,
(
pQueryInfo
->
numOfTables
+
1
)
*
POINTER_BYTES
);
if
(
pAlloc
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
NULL
;
}
pQueryInfo
->
pTableMetaInfo
=
pAlloc
;
pQueryInfo
->
pTableMetaInfo
[
pQueryInfo
->
numOfTables
]
=
calloc
(
1
,
sizeof
(
STableMetaInfo
));
STableMetaInfo
*
pTableMetaInfo
=
calloc
(
1
,
sizeof
(
STableMetaInfo
));
if
(
pTableMetaInfo
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
NULL
;
}
STableMetaInfo
*
pTableMetaInfo
=
pQueryInfo
->
pTableMetaInfo
[
pQueryInfo
->
numOfTables
];
assert
(
pTableMetaInfo
!=
NULL
);
pQueryInfo
->
pTableMetaInfo
[
pQueryInfo
->
numOfTables
]
=
pTableMetaInfo
;
if
(
name
!=
NULL
)
{
tstrncpy
(
pTableMetaInfo
->
name
,
name
,
sizeof
(
pTableMetaInfo
->
name
));
...
...
@@ -1602,10 +1629,18 @@ STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, ST
if
(
vgroupList
!=
NULL
)
{
size_t
size
=
sizeof
(
SVgroupsInfo
)
+
sizeof
(
SCMVgroupInfo
)
*
vgroupList
->
numOfVgroups
;
pTableMetaInfo
->
vgroupList
=
malloc
(
size
);
if
(
pTableMetaInfo
->
vgroupList
==
NULL
)
{
return
NULL
;
}
memcpy
(
pTableMetaInfo
->
vgroupList
,
vgroupList
,
size
);
}
pTableMetaInfo
->
tagColList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
if
(
pTableMetaInfo
->
tagColList
==
NULL
)
{
return
NULL
;
}
if
(
pTagCols
!=
NULL
)
{
tscColumnListCopy
(
pTableMetaInfo
->
tagColList
,
pTagCols
,
-
1
);
}
...
...
@@ -1671,8 +1706,7 @@ SSqlObj* createSimpleSubObj(SSqlObj* pSql, void (*fp)(), void* param, int32_t cm
return
NULL
;
}
SQueryInfo
*
pQueryInfo
=
NULL
;
tscGetQueryInfoDetailSafely
(
pCmd
,
0
,
&
pQueryInfo
);
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetailSafely
(
pCmd
,
0
);
assert
(
pSql
->
cmd
.
clauseIndex
==
0
);
STableMetaInfo
*
pMasterTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
&
pSql
->
cmd
,
pSql
->
cmd
.
clauseIndex
,
0
);
...
...
@@ -1754,6 +1788,7 @@ static void doSetSqlExprAndResultFieldInfo(SQueryInfo* pQueryInfo, SQueryInfo* p
SSqlObj
*
createSubqueryObj
(
SSqlObj
*
pSql
,
int16_t
tableIndex
,
void
(
*
fp
)(),
void
*
param
,
int32_t
cmd
,
SSqlObj
*
pPrevSql
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlObj
*
pNew
=
(
SSqlObj
*
)
calloc
(
1
,
sizeof
(
SSqlObj
));
if
(
pNew
==
NULL
)
{
tscError
(
"%p new subquery failed, tableIndex:%d"
,
pSql
,
tableIndex
);
...
...
@@ -1769,10 +1804,8 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
pNew
->
sqlstr
=
strdup
(
pSql
->
sqlstr
);
if
(
pNew
->
sqlstr
==
NULL
)
{
tscError
(
"%p new subquery failed, tableIndex:%d, vgroupIndex:%d"
,
pSql
,
tableIndex
,
pTableMetaInfo
->
vgroupIndex
);
free
(
pNew
);
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
NULL
;
goto
_error
;
}
SSqlCmd
*
pnCmd
=
&
pNew
->
cmd
;
...
...
@@ -1789,9 +1822,8 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
pnCmd
->
parseFinished
=
1
;
if
(
tscAddSubqueryInfo
(
pnCmd
)
!=
TSDB_CODE_SUCCESS
)
{
tscFreeSqlObj
(
pNew
);
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
NULL
;
goto
_error
;
}
SQueryInfo
*
pNewQueryInfo
=
tscGetQueryInfoDetail
(
pnCmd
,
0
);
...
...
@@ -1816,20 +1848,28 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
pNewQueryInfo
->
groupbyExpr
=
pQueryInfo
->
groupbyExpr
;
if
(
pQueryInfo
->
groupbyExpr
.
columnInfo
!=
NULL
)
{
pNewQueryInfo
->
groupbyExpr
.
columnInfo
=
taosArrayClone
(
pQueryInfo
->
groupbyExpr
.
columnInfo
);
if
(
pNewQueryInfo
->
groupbyExpr
.
columnInfo
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
goto
_error
;
}
}
tscTagCondCopy
(
&
pNewQueryInfo
->
tagCond
,
&
pQueryInfo
->
tagCond
);
if
(
pQueryInfo
->
fillType
!=
TSDB_FILL_NONE
)
{
pNewQueryInfo
->
fillVal
=
malloc
(
pQueryInfo
->
fieldsInfo
.
numOfOutput
*
sizeof
(
int64_t
));
if
(
pNewQueryInfo
->
fillVal
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
goto
_error
;
}
memcpy
(
pNewQueryInfo
->
fillVal
,
pQueryInfo
->
fillVal
,
pQueryInfo
->
fieldsInfo
.
numOfOutput
*
sizeof
(
int64_t
));
}
if
(
tscAllocPayload
(
pnCmd
,
TSDB_DEFAULT_PAYLOAD_SIZE
)
!=
TSDB_CODE_SUCCESS
)
{
tscError
(
"%p new subquery failed, tableIndex:%d, vgroupIndex:%d"
,
pSql
,
tableIndex
,
pTableMetaInfo
->
vgroupIndex
);
tscFreeSqlObj
(
pNew
);
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
NULL
;
goto
_error
;
}
tscColumnListCopy
(
pNewQueryInfo
->
colList
,
pQueryInfo
->
colList
,
(
int16_t
)
tableIndex
);
...
...
@@ -1872,16 +1912,15 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
if
(
pFinalInfo
->
pTableMeta
==
NULL
)
{
tscError
(
"%p new subquery failed since no tableMeta in cache, name:%s"
,
pSql
,
name
);
tscFreeSqlObj
(
pNew
);
if
(
pPrevSql
!=
NULL
)
{
if
(
pPrevSql
!=
NULL
)
{
// pass the previous error to client
assert
(
pPrevSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
);
terrno
=
pPrevSql
->
res
.
code
;
}
else
{
terrno
=
TSDB_CODE_TSC_APP_ERROR
;
}
return
NULL
;
goto
_error
;
}
assert
(
pNewQueryInfo
->
numOfTables
==
1
);
...
...
@@ -1906,6 +1945,10 @@ SSqlObj* createSubqueryObj(SSqlObj* pSql, int16_t tableIndex, void (*fp)(), void
}
return
pNew
;
_error:
tscFreeSqlObj
(
pNew
);
return
NULL
;
}
/**
...
...
src/common/inc/tname.h
浏览文件 @
45f855ca
...
...
@@ -4,6 +4,7 @@
#include "os.h"
#include "taosmsg.h"
#include "tstoken.h"
#include "tvariant.h"
typedef
struct
SDataStatis
{
int16_t
colId
;
...
...
@@ -24,10 +25,12 @@ void extractTableName(const char *tableId, char *name);
char
*
extractDBName
(
const
char
*
tableId
,
char
*
name
);
void
extractTableNameFromToken
(
SS
QLToken
*
pToken
,
SSQL
Token
*
pTable
);
void
extractTableNameFromToken
(
SS
trToken
*
pToken
,
SStr
Token
*
pTable
);
SSchema
tGetTableNameColumnSchema
();
SSchema
tGetUserSpecifiedColumnSchema
(
tVariant
*
pVal
,
SStrToken
*
exprStr
,
const
char
*
name
);
bool
tscValidateTableNameLength
(
size_t
len
);
SColumnFilterInfo
*
tscFilterInfoClone
(
const
SColumnFilterInfo
*
src
,
int32_t
numOfFilters
);
...
...
src/common/inc/tvariant.h
浏览文件 @
45f855ca
...
...
@@ -36,7 +36,7 @@ typedef struct tVariant {
};
}
tVariant
;
void
tVariantCreate
(
tVariant
*
pVar
,
SS
QL
Token
*
token
);
void
tVariantCreate
(
tVariant
*
pVar
,
SS
tr
Token
*
token
);
void
tVariantCreateFromString
(
tVariant
*
pVar
,
char
*
pz
,
uint32_t
len
,
uint32_t
type
);
...
...
@@ -46,6 +46,8 @@ void tVariantDestroy(tVariant *pV);
void
tVariantAssign
(
tVariant
*
pDst
,
const
tVariant
*
pSrc
);
int32_t
tVariantCompare
(
const
tVariant
*
p1
,
const
tVariant
*
p2
);
int32_t
tVariantToString
(
tVariant
*
pVar
,
char
*
dst
);
int32_t
tVariantDump
(
tVariant
*
pVariant
,
char
*
payload
,
int16_t
type
,
bool
includeLengthPrefix
);
...
...
src/common/src/tname.c
浏览文件 @
45f855ca
...
...
@@ -4,6 +4,7 @@
#include "tname.h"
#include "tstoken.h"
#include "ttokendef.h"
#include "tvariant.h"
// todo refactor
UNUSED_FUNC
static
FORCE_INLINE
const
char
*
skipSegments
(
const
char
*
input
,
char
delim
,
int32_t
num
)
{
...
...
@@ -43,7 +44,30 @@ SSchema tGetTableNameColumnSchema() {
s
.
bytes
=
TSDB_TABLE_NAME_LEN
-
1
+
VARSTR_HEADER_SIZE
;
s
.
type
=
TSDB_DATA_TYPE_BINARY
;
s
.
colId
=
TSDB_TBNAME_COLUMN_INDEX
;
strncpy
(
s
.
name
,
TSQL_TBNAME_L
,
TSDB_COL_NAME_LEN
);
tstrncpy
(
s
.
name
,
TSQL_TBNAME_L
,
TSDB_COL_NAME_LEN
);
return
s
;
}
SSchema
tGetUserSpecifiedColumnSchema
(
tVariant
*
pVal
,
SStrToken
*
exprStr
,
const
char
*
name
)
{
SSchema
s
=
{
0
};
s
.
type
=
pVal
->
nType
;
if
(
s
.
type
==
TSDB_DATA_TYPE_BINARY
||
s
.
type
==
TSDB_DATA_TYPE_NCHAR
)
{
s
.
bytes
=
(
int16_t
)(
pVal
->
nLen
+
VARSTR_HEADER_SIZE
);
}
else
{
s
.
bytes
=
tDataTypeDesc
[
pVal
->
nType
].
nSize
;
}
s
.
colId
=
TSDB_UD_COLUMN_INDEX
;
if
(
name
!=
NULL
)
{
tstrncpy
(
s
.
name
,
name
,
sizeof
(
s
.
name
));
}
else
{
size_t
len
=
strdequote
(
exprStr
->
z
);
size_t
tlen
=
MIN
(
sizeof
(
s
.
name
),
len
+
1
);
tstrncpy
(
s
.
name
,
exprStr
->
z
,
tlen
);
}
return
s
;
}
...
...
@@ -110,7 +134,7 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, in
* tablePrefix.columnName
* extract table name and save it in pTable, with only column name in pToken
*/
void
extractTableNameFromToken
(
SS
QLToken
*
pToken
,
SSQL
Token
*
pTable
)
{
void
extractTableNameFromToken
(
SS
trToken
*
pToken
,
SStr
Token
*
pTable
)
{
const
char
sep
=
TS_PATH_DELIMITER
[
0
];
if
(
pToken
==
pTable
||
pToken
==
NULL
||
pTable
==
NULL
)
{
...
...
src/common/src/tvariant.c
浏览文件 @
45f855ca
...
...
@@ -12,12 +12,10 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "tvariant.h"
#include "hash.h"
#include "hashfunc.h"
#include "os.h"
#include "hash.h"
#include "taos.h"
#include "taosdef.h"
#include "tstoken.h"
...
...
@@ -25,7 +23,7 @@
#include "tutil.h"
// todo support scientific expression number and oct number
void
tVariantCreate
(
tVariant
*
pVar
,
SS
QL
Token
*
token
)
{
tVariantCreateFromString
(
pVar
,
token
->
z
,
token
->
n
,
token
->
type
);
}
void
tVariantCreate
(
tVariant
*
pVar
,
SS
tr
Token
*
token
)
{
tVariantCreateFromString
(
pVar
,
token
->
z
,
token
->
n
,
token
->
type
);
}
void
tVariantCreateFromString
(
tVariant
*
pVar
,
char
*
pz
,
uint32_t
len
,
uint32_t
type
)
{
memset
(
pVar
,
0
,
sizeof
(
tVariant
));
...
...
@@ -102,10 +100,9 @@ void tVariantCreateFromBinary(tVariant *pVar, const char *pz, size_t len, uint32
}
case
TSDB_DATA_TYPE_NCHAR
:
{
// here we get the nchar length from raw binary bits length
size_t
lenInwchar
=
len
/
TSDB_NCHAR_SIZE
;
pVar
->
wpz
=
calloc
(
1
,
(
lenInwchar
+
1
)
*
TSDB_NCHAR_SIZE
);
wcsncpy
(
pVar
->
wpz
,
(
wchar_t
*
)
pz
,
lenInwchar
);
pVar
->
wpz
[
lenInwchar
]
=
0
;
memcpy
(
pVar
->
wpz
,
pz
,
lenInwchar
*
TSDB_NCHAR_SIZE
);
pVar
->
nLen
=
(
int32_t
)
len
;
break
;
...
...
@@ -169,6 +166,50 @@ void tVariantAssign(tVariant *pDst, const tVariant *pSrc) {
char
*
n
=
strdup
(
p
);
taosArrayPush
(
pDst
->
arr
,
&
n
);
}
return
;
}
pDst
->
nLen
=
tDataTypeDesc
[
pDst
->
nType
].
nSize
;
}
int32_t
tVariantCompare
(
const
tVariant
*
p1
,
const
tVariant
*
p2
)
{
if
(
p1
->
nType
==
TSDB_DATA_TYPE_NULL
&&
p2
->
nType
==
TSDB_DATA_TYPE_NULL
)
{
return
0
;
}
if
(
p1
->
nType
==
TSDB_DATA_TYPE_NULL
)
{
return
-
1
;
}
if
(
p2
->
nType
==
TSDB_DATA_TYPE_NULL
)
{
return
1
;
}
switch
(
p1
->
nType
)
{
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
{
if
(
p1
->
nLen
==
p2
->
nLen
)
{
return
memcmp
(
p1
->
pz
,
p2
->
pz
,
p1
->
nLen
);
}
else
{
return
p1
->
nLen
>
p2
->
nLen
?
1
:-
1
;
}
};
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_DOUBLE
:
if
(
p1
->
dKey
==
p2
->
dKey
)
{
return
0
;
}
else
{
return
p1
->
dKey
>
p2
->
dKey
?
1
:-
1
;
}
default:
if
(
p1
->
i64Key
==
p2
->
i64Key
)
{
return
0
;
}
else
{
return
p1
->
i64Key
>
p2
->
i64Key
?
1
:-
1
;
}
}
}
...
...
@@ -228,7 +269,7 @@ static int32_t doConvertToInteger(tVariant *pVariant, char *pDest, int32_t type,
errno = 0;
char *endPtr = NULL;
SS
QL
Token token = {0};
SS
tr
Token token = {0};
token.n = tSQLGetToken(pVariant->pz, &token.type);
if (token.type == TK_MINUS || token.type == TK_PLUS) {
...
...
@@ -277,7 +318,7 @@ static int32_t doConvertToInteger(tVariant *pVariant, char *pDest, int32_t type,
errno = 0;
wchar_t *endPtr = NULL;
SS
QL
Token token = {0};
SS
tr
Token token = {0};
token.n = tSQLGetToken(pVariant->pz, &token.type);
if (token.type == TK_MINUS || token.type == TK_PLUS) {
...
...
@@ -436,7 +477,7 @@ static int32_t toNchar(tVariant *pVariant, char **pDest, int32_t *pDestSize) {
}
static
FORCE_INLINE
int32_t
convertToDouble
(
char
*
pStr
,
int32_t
len
,
double
*
value
)
{
SS
QL
Token
stoken
=
{.
z
=
pStr
,
.
n
=
len
};
SS
tr
Token
stoken
=
{.
z
=
pStr
,
.
n
=
len
};
if
(
TK_ILLEGAL
==
isValidNumber
(
&
stoken
))
{
return
-
1
;
...
...
@@ -462,7 +503,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
errno
=
0
;
char
*
endPtr
=
NULL
;
SS
QL
Token
token
=
{
0
};
SS
tr
Token
token
=
{
0
};
token
.
n
=
tSQLGetToken
(
pVariant
->
pz
,
&
token
.
type
);
if
(
token
.
type
==
TK_MINUS
||
token
.
type
==
TK_PLUS
)
{
...
...
@@ -479,7 +520,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
return
0
;
}
SS
QL
Token
sToken
=
{.
z
=
pVariant
->
pz
,
.
n
=
pVariant
->
nLen
};
SS
tr
Token
sToken
=
{.
z
=
pVariant
->
pz
,
.
n
=
pVariant
->
nLen
};
if
(
TK_ILLEGAL
==
isValidNumber
(
&
sToken
))
{
return
-
1
;
}
...
...
@@ -515,7 +556,7 @@ static FORCE_INLINE int32_t convertToInteger(tVariant *pVariant, int64_t *result
errno
=
0
;
wchar_t
*
endPtr
=
NULL
;
SS
QL
Token
token
=
{
0
};
SS
tr
Token
token
=
{
0
};
token
.
n
=
tSQLGetToken
(
pVariant
->
pz
,
&
token
.
type
);
if
(
token
.
type
==
TK_MINUS
||
token
.
type
==
TK_PLUS
)
{
...
...
src/connector/jdbc/.classpath
浏览文件 @
45f855ca
...
...
@@ -28,22 +28,5 @@
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"src"
path=
"target/generated-sources/annotations"
>
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
<attribute
name=
"ignore_optional_problems"
value=
"true"
/>
<attribute
name=
"m2e-apt"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"src"
output=
"target/test-classes"
path=
"target/generated-test-sources/test-annotations"
>
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
<attribute
name=
"ignore_optional_problems"
value=
"true"
/>
<attribute
name=
"m2e-apt"
value=
"true"
/>
<attribute
name=
"test"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"output"
path=
"target/classes"
/>
</classpath>
src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java
浏览文件 @
45f855ca
...
...
@@ -52,7 +52,7 @@ public class TSDBStatement implements Statement {
if
(
isClosed
)
{
throw
new
SQLException
(
"Invalid method call on a closed statement."
);
}
// TODO make sure it is not a update query
pSql
=
this
.
connecter
.
executeQuery
(
sql
);
...
...
@@ -68,21 +68,21 @@ public class TSDBStatement implements Statement {
this
.
connecter
.
freeResultSet
(
pSql
);
return
null
;
}
if
(!
this
.
connecter
.
isUpdateQuery
(
pSql
))
{
return
new
TSDBResultSet
(
this
.
connecter
,
resultSetPointer
);
}
else
{
this
.
connecter
.
freeResultSet
(
pSql
);
return
null
;
}
}
public
int
executeUpdate
(
String
sql
)
throws
SQLException
{
if
(
isClosed
)
{
throw
new
SQLException
(
"Invalid method call on a closed statement."
);
}
// TODO check if current query is update query
pSql
=
this
.
connecter
.
executeQuery
(
sql
);
long
resultSetPointer
=
this
.
connecter
.
getResultSet
();
...
...
@@ -94,7 +94,7 @@ public class TSDBStatement implements Statement {
this
.
affectedRows
=
this
.
connecter
.
getAffectedRows
(
pSql
);
this
.
connecter
.
freeResultSet
(
pSql
);
return
this
.
affectedRows
;
}
...
...
@@ -192,7 +192,7 @@ public class TSDBStatement implements Statement {
if
(
isClosed
)
{
throw
new
SQLException
(
"Invalid method call on a closed statement."
);
}
return
this
.
affectedRows
;
}
...
...
src/inc/taosdef.h
浏览文件 @
45f855ca
...
...
@@ -286,7 +286,8 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size);
#define TSDB_MAX_REPLICA 5
#define TSDB_TBNAME_COLUMN_INDEX (-1)
#define TSDB_TBNAME_COLUMN_INDEX (-1)
#define TSDB_UD_COLUMN_INDEX (-100)
#define TSDB_MULTI_METERMETA_MAX_NUM 100000 // maximum batch size allowed to load metermeta
#define TSDB_MIN_CACHE_BLOCK_SIZE 1
...
...
src/inc/taoserror.h
浏览文件 @
45f855ca
...
...
@@ -140,6 +140,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_NOT_READY, 0, 0x033C, "Cluster no
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_ACCT_ALREADY_EXIST
,
0
,
0x0340
,
"Account already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_ACCT
,
0
,
0x0341
,
"Invalid account"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_ACCT_OPTION
,
0
,
0x0342
,
"Invalid account options"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_ACCT_EXPIRED
,
0
,
0x0343
,
"Account authorization has expired"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_USER_ALREADY_EXIST
,
0
,
0x0350
,
"User already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_USER
,
0
,
0x0351
,
"Invalid user"
)
...
...
@@ -222,6 +223,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_QRY_EXCEED_TAGS_LIMIT, 0, 0x0706, "Tag condit
TAOS_DEFINE_ERROR
(
TSDB_CODE_QRY_NOT_READY
,
0
,
0x0707
,
"Query not ready"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QRY_HAS_RSP
,
0
,
0x0708
,
"Query should response"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QRY_IN_EXEC
,
0
,
0x0709
,
"Multiple retrieval of this query"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW
,
0
,
0x070A
,
"Too many time window in query"
)
// grant
TAOS_DEFINE_ERROR
(
TSDB_CODE_GRANT_EXPIRED
,
0
,
0x0800
,
"License expired"
)
...
...
src/inc/taosmsg.h
浏览文件 @
45f855ca
...
...
@@ -133,7 +133,7 @@ enum _mgmt_table {
TSDB_MGMT_TABLE_MODULE
,
TSDB_MGMT_TABLE_QUERIES
,
TSDB_MGMT_TABLE_STREAMS
,
TSDB_MGMT_TABLE_
CONFIG
S
,
TSDB_MGMT_TABLE_
VARIABLE
S
,
TSDB_MGMT_TABLE_CONNS
,
TSDB_MGMT_TABLE_SCORES
,
TSDB_MGMT_TABLE_GRANTS
,
...
...
@@ -167,9 +167,9 @@ enum _mgmt_table {
#define TSDB_VN_WRITE_ACCCESS ((char)0x2)
#define TSDB_VN_ALL_ACCCESS (TSDB_VN_READ_ACCCESS | TSDB_VN_WRITE_ACCCESS)
#define TSDB_COL_NORMAL
0x0u
#define TSDB_COL_TAG
0x1u
#define TSDB_COL_
JOIN 0x2u
#define TSDB_COL_NORMAL
0x0u // the normal column of the table
#define TSDB_COL_TAG
0x1u // the tag column type
#define TSDB_COL_
UDC 0x2u // the user specified normal string column, it is a dummy column
extern
char
*
taosMsg
[];
...
...
src/inc/ttokendef.h
浏览文件 @
45f855ca
...
...
@@ -69,7 +69,7 @@
#define TK_QUERIES 51
#define TK_CONNECTIONS 52
#define TK_STREAMS 53
#define TK_
CONFIGS
54
#define TK_
VARIABLES
54
#define TK_SCORES 55
#define TK_GRANTS 56
#define TK_VNODES 57
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
45f855ca
...
...
@@ -25,6 +25,8 @@
#include "taosdef.h"
#include "taoserror.h"
#include "tglobal.h"
#include "tsclient.h"
#include <regex.h>
/**************** Global variables ****************/
...
...
@@ -64,11 +66,6 @@ TAOS *shellInit(SShellArguments *args) {
}
taos_init
();
/*
* set tsTableMetaKeepTimer = 3000ms
* means not save cache in shell
*/
tsTableMetaKeepTimer
=
3000
;
// Connect to the database.
TAOS
*
con
=
NULL
;
...
...
@@ -287,7 +284,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
st
=
taosGetTimestampUs
();
TAOS_RES
*
pSql
=
taos_query
(
con
,
command
);
result
=
pSql
;
// set it into the global variable
atomic_store_ptr
(
&
result
,
pSql
);
// set the global TAOS_RES pointer
if
(
taos_errno
(
pSql
))
{
taos_error
(
pSql
);
...
...
@@ -298,17 +295,16 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
fprintf
(
stdout
,
"Database changed.
\n\n
"
);
fflush
(
stdout
);
result
=
NULL
;
atomic_store_ptr
(
&
result
,
0
)
;
taos_free_result
(
pSql
);
return
;
}
int
num_fields
=
taos_field_count
(
pSql
);
if
(
num_fields
!=
0
)
{
// select and show kinds of commands
if
(
!
tscIsUpdateQuery
(
pSql
))
{
// select and show kinds of commands
int
error_no
=
0
;
int
numOfRows
=
shellDumpResult
(
pSql
,
fname
,
&
error_no
,
printMode
);
if
(
numOfRows
<
0
)
{
result
=
NULL
;
atomic_store_ptr
(
&
result
,
0
)
;
taos_free_result
(
pSql
);
return
;
}
...
...
@@ -331,7 +327,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
wordfree
(
&
full_path
);
}
result
=
NULL
;
atomic_store_ptr
(
&
result
,
0
)
;
taos_free_result
(
pSql
);
}
...
...
@@ -497,7 +493,6 @@ static int dumpResultToFile(const char* fname, TAOS_RES* tres) {
}
while
(
row
!=
NULL
);
result
=
NULL
;
//taos_free_result(tres);
fclose
(
fp
);
return
numOfRows
;
...
...
@@ -802,8 +797,8 @@ void write_history() {
}
void
taos_error
(
TAOS_RES
*
tres
)
{
atomic_store_ptr
(
&
result
,
0
);
fprintf
(
stderr
,
"
\n
DB error: %s
\n
"
,
taos_errstr
(
tres
));
result
=
NULL
;
taos_free_result
(
tres
);
}
...
...
src/kit/shell/src/shellMain.c
浏览文件 @
45f855ca
...
...
@@ -18,11 +18,10 @@
pthread_t
pid
;
// TODO: IMPLEMENT INTERRUPT HANDLER.
void
interruptHandler
(
int
signum
)
{
void
shellQueryInterruptHandler
(
int
signum
)
{
#ifdef LINUX
taos_stop_query
(
result
);
result
=
NULL
;
void
*
pResHandle
=
atomic_val_compare_exchange_64
(
&
result
,
result
,
0
);
taos_stop_query
(
pResHandle
)
;
#else
printf
(
"
\n
Receive ctrl+c or other signal, quit shell.
\n
"
);
exit
(
0
);
...
...
@@ -86,7 +85,7 @@ int main(int argc, char* argv[]) {
struct
sigaction
act
;
memset
(
&
act
,
0
,
sizeof
(
struct
sigaction
));
act
.
sa_handler
=
i
nterruptHandler
;
act
.
sa_handler
=
shellQueryI
nterruptHandler
;
sigaction
(
SIGTERM
,
&
act
,
NULL
);
sigaction
(
SIGINT
,
&
act
,
NULL
);
...
...
src/mnode/src/mnodeDnode.c
浏览文件 @
45f855ca
...
...
@@ -49,7 +49,7 @@ static int32_t mnodeProcessCreateDnodeMsg(SMnodeMsg *pMsg);
static
int32_t
mnodeProcessDropDnodeMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessCfgDnodeMsg
(
SMnodeMsg
*
pMsg
);
static
void
mnodeProcessCfgDnodeMsgRsp
(
SRpcMsg
*
rpcMsg
)
;
static
int32_t
mnodeProcessDnodeStatusMsg
(
SMnodeMsg
*
rpc
Msg
);
static
int32_t
mnodeProcessDnodeStatusMsg
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mnodeGetModuleMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeRetrieveModules
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeGetConfigMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
...
...
@@ -161,8 +161,8 @@ int32_t mnodeInitDnodes() {
mnodeAddPeerMsgHandle
(
TSDB_MSG_TYPE_DM_STATUS
,
mnodeProcessDnodeStatusMsg
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_MODULE
,
mnodeGetModuleMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_MODULE
,
mnodeRetrieveModules
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_
CONFIG
S
,
mnodeGetConfigMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_
CONFIG
S
,
mnodeRetrieveConfigs
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_
VARIABLE
S
,
mnodeGetConfigMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_
VARIABLE
S
,
mnodeRetrieveConfigs
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_VNODES
,
mnodeGetVnodeMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_VNODES
,
mnodeRetrieveVnodes
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_DNODE
,
mnodeGetDnodeMeta
);
...
...
@@ -733,7 +733,7 @@ static int32_t mnodeRetrieveDnodes(SShowObj *pShow, char *data, int32_t rows, vo
}
static
bool
mnodeCheckModuleInDnode
(
SDnodeObj
*
pDnode
,
int32_t
moduleType
)
{
uint32_t
status
=
pDnode
->
moduleStatus
&
(
1
<<
moduleType
);
uint32_t
status
=
pDnode
->
moduleStatus
&
(
1
u
<<
moduleType
);
return
status
>
0
;
}
...
...
@@ -758,7 +758,7 @@ static int32_t mnodeGetModuleMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p
pShow
->
bytes
[
cols
]
=
40
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"end
point"
);
strcpy
(
pSchema
[
cols
].
name
,
"end
_
point"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
...
...
@@ -792,7 +792,9 @@ static int32_t mnodeGetModuleMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p
int32_t
mnodeRetrieveModules
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
)
{
int32_t
numOfRows
=
0
;
char
*
pWrite
;
char
*
pWrite
;
char
*
moduleName
[
5
]
=
{
"MNODE"
,
"HTTP"
,
"MONITOR"
,
"MQTT"
,
"UNKNOWN"
};
while
(
numOfRows
<
rows
)
{
SDnodeObj
*
pDnode
=
NULL
;
...
...
@@ -807,28 +809,18 @@ int32_t mnodeRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pC
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
strncpy
(
pWrite
,
pDnode
->
dnodeEp
,
pShow
->
bytes
[
cols
]
-
1
);
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
pDnode
->
dnodeEp
,
pShow
->
bytes
[
cols
]
-
1
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
switch
(
moduleType
)
{
case
TSDB_MOD_MNODE
:
strcpy
(
pWrite
,
"mnode"
);
break
;
case
TSDB_MOD_HTTP
:
strcpy
(
pWrite
,
"http"
);
break
;
case
TSDB_MOD_MONITOR
:
strcpy
(
pWrite
,
"monitor"
);
break
;
default:
strcpy
(
pWrite
,
"unknown"
);
}
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
moduleName
[
moduleType
],
pShow
->
bytes
[
cols
]);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
bool
enable
=
mnodeCheckModuleInDnode
(
pDnode
,
moduleType
);
strcpy
(
pWrite
,
enable
?
"enable"
:
"disable"
);
char
*
v
=
enable
?
"enable"
:
"disable"
;
STR_TO_VARSTR
(
pWrite
,
v
);
cols
++
;
numOfRows
++
;
...
...
@@ -862,13 +854,13 @@ static int32_t mnodeGetConfigMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p
pShow
->
bytes
[
cols
]
=
TSDB_CFG_OPTION_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"config name"
);
tstrncpy
(
pSchema
[
cols
].
name
,
"name"
,
sizeof
(
pSchema
[
cols
].
name
)
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pShow
->
bytes
[
cols
]
=
TSDB_CFG_VALUE_LEN
+
VARSTR_HEADER_SIZE
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
[
cols
].
name
,
"config value"
);
tstrncpy
(
pSchema
[
cols
].
name
,
"value"
,
sizeof
(
pSchema
[
cols
].
name
)
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
...
...
@@ -903,27 +895,32 @@ static int32_t mnodeRetrieveConfigs(SShowObj *pShow, char *data, int32_t rows, v
int32_t
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
snprintf
(
pWrite
,
TSDB_CFG_OPTION_LEN
,
"%s"
,
cfg
->
option
);
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
cfg
->
option
,
TSDB_CFG_OPTION_LEN
);
cols
++
;
int32_t
t
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
switch
(
cfg
->
valType
)
{
case
TAOS_CFG_VTYPE_INT16
:
snprintf
(
pWrite
,
TSDB_CFG_VALUE_LEN
,
"%d"
,
*
((
int16_t
*
)
cfg
->
ptr
));
t
=
snprintf
(
varDataVal
(
pWrite
),
TSDB_CFG_VALUE_LEN
,
"%d"
,
*
((
int16_t
*
)
cfg
->
ptr
));
varDataSetLen
(
pWrite
,
t
);
numOfRows
++
;
break
;
case
TAOS_CFG_VTYPE_INT32
:
snprintf
(
pWrite
,
TSDB_CFG_VALUE_LEN
,
"%d"
,
*
((
int32_t
*
)
cfg
->
ptr
));
t
=
snprintf
(
varDataVal
(
pWrite
),
TSDB_CFG_VALUE_LEN
,
"%d"
,
*
((
int32_t
*
)
cfg
->
ptr
));
varDataSetLen
(
pWrite
,
t
);
numOfRows
++
;
break
;
case
TAOS_CFG_VTYPE_FLOAT
:
snprintf
(
pWrite
,
TSDB_CFG_VALUE_LEN
,
"%f"
,
*
((
float
*
)
cfg
->
ptr
));
t
=
snprintf
(
varDataVal
(
pWrite
),
TSDB_CFG_VALUE_LEN
,
"%f"
,
*
((
float
*
)
cfg
->
ptr
));
varDataSetLen
(
pWrite
,
t
);
numOfRows
++
;
break
;
case
TAOS_CFG_VTYPE_STRING
:
case
TAOS_CFG_VTYPE_IPSTR
:
case
TAOS_CFG_VTYPE_DIRECTORY
:
snprintf
(
pWrite
,
TSDB_CFG_VALUE_LEN
,
"%s"
,
(
char
*
)
cfg
->
ptr
);
STR_WITH_MAXSIZE_TO_VARSTR
(
pWrite
,
cfg
->
ptr
,
TSDB_CFG_VALUE_LEN
);
numOfRows
++
;
break
;
default:
...
...
src/mnode/src/mnodeMain.c
浏览文件 @
45f855ca
...
...
@@ -21,6 +21,7 @@
#include "tgrant.h"
#include "ttimer.h"
#include "tglobal.h"
#include "mnode.h"
#include "dnode.h"
#include "mnodeDef.h"
#include "mnodeInt.h"
...
...
@@ -107,13 +108,18 @@ int32_t mnodeStartSystem() {
tsMgmtIsRunning
=
true
;
mInfo
(
"mnode is initialized successfully"
);
sdbUpdateSync
();
return
0
;
}
int32_t
mnodeInitSystem
()
{
mnodeInitTimer
();
if
(
!
mnodeNeedStart
())
return
0
;
return
mnodeStartSystem
();
if
(
mnodeNeedStart
())
{
return
mnodeStartSystem
();
}
return
0
;
}
void
mnodeCleanupSystem
()
{
...
...
@@ -159,14 +165,19 @@ static void mnodeCleanupTimer() {
static
bool
mnodeNeedStart
()
{
struct
stat
dirstat
;
bool
fileExist
=
(
stat
(
tsMnodeDir
,
&
dirstat
)
==
0
);
char
mnodeFileName
[
TSDB_FILENAME_LEN
*
2
]
=
{
0
};
sprintf
(
mnodeFileName
,
"%s/wal/wal0"
,
tsMnodeDir
);
bool
fileExist
=
(
stat
(
mnodeFileName
,
&
dirstat
)
==
0
);
bool
asMaster
=
(
strcmp
(
tsFirst
,
tsLocalEp
)
==
0
);
if
(
asMaster
||
fileExist
)
{
mDebug
(
"mnode module start, asMaster:%d fileExist:%d"
,
asMaster
,
fileExist
);
return
true
;
}
else
{
mDebug
(
"mnode module won't start, asMaster:%d fileExist:%d"
,
asMaster
,
fileExist
);
return
false
;
}
return
false
;
}
bool
mnodeIsRunning
()
{
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
45f855ca
...
...
@@ -291,6 +291,11 @@ static void sdbConfirmForward(void *ahandle, void *param, int32_t code) {
}
void
sdbUpdateSync
()
{
if
(
!
mnodeIsRunning
())
{
mDebug
(
"mnode not start yet, update sync info later"
);
return
;
}
SSyncCfg
syncCfg
=
{
0
};
int32_t
index
=
0
;
...
...
src/mnode/src/mnodeShow.c
浏览文件 @
45f855ca
...
...
@@ -98,7 +98,7 @@ static char *mnodeGetShowType(int32_t showType) {
case
TSDB_MGMT_TABLE_MODULE
:
return
"show modules"
;
case
TSDB_MGMT_TABLE_QUERIES
:
return
"show queries"
;
case
TSDB_MGMT_TABLE_STREAMS
:
return
"show streams"
;
case
TSDB_MGMT_TABLE_
CONFIG
S
:
return
"show configs"
;
case
TSDB_MGMT_TABLE_
VARIABLE
S
:
return
"show configs"
;
case
TSDB_MGMT_TABLE_CONNS
:
return
"show connections"
;
case
TSDB_MGMT_TABLE_SCORES
:
return
"show scores"
;
case
TSDB_MGMT_TABLE_GRANTS
:
return
"show grants"
;
...
...
src/query/inc/qAst.h
浏览文件 @
45f855ca
...
...
@@ -80,7 +80,7 @@ void tExprTreeTraverse(tExprNode *pExpr, SSkipList *pSkipList, SArray *result, S
void
tExprTreeCalcTraverse
(
tExprNode
*
pExprs
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
cb
)(
void
*
,
const
char
*
,
int32_t
));
uint8_t
getBinaryExprOptr
(
SS
QL
Token
*
pToken
);
uint8_t
getBinaryExprOptr
(
SS
tr
Token
*
pToken
);
void
tExprNodeDestroy
(
tExprNode
*
pNode
,
void
(
*
fp
)(
void
*
));
void
exprTreeToBinary
(
SBufferWriter
*
bw
,
tExprNode
*
pExprTree
);
...
...
src/query/inc/qExecutor.h
浏览文件 @
45f855ca
...
...
@@ -33,6 +33,17 @@ struct SColumnFilterElem;
typedef
bool
(
*
__filter_func_t
)(
struct
SColumnFilterElem
*
pFilter
,
char
*
val1
,
char
*
val2
);
typedef
int32_t
(
*
__block_search_fn_t
)(
char
*
data
,
int32_t
num
,
int64_t
key
,
int32_t
order
);
typedef
struct
SPosInfo
{
int32_t
pageId
:
20
;
int32_t
rowId
:
12
;
}
SPosInfo
;
typedef
struct
SGroupResInfo
{
int32_t
groupId
;
int32_t
numOfDataPages
;
SPosInfo
pos
;
}
SGroupResInfo
;
typedef
struct
SSqlGroupbyExpr
{
int16_t
tableIndex
;
SArray
*
columnInfo
;
// SArray<SColIndex>, group by columns information
...
...
@@ -41,21 +52,12 @@ typedef struct SSqlGroupbyExpr {
int16_t
orderType
;
// order by type: asc/desc
}
SSqlGroupbyExpr
;
typedef
struct
SPosInfo
{
int32_t
pageId
;
int32_t
rowId
;
}
SPosInfo
;
typedef
struct
SWindowStatus
{
bool
closed
;
}
SWindowStatus
;
typedef
struct
SWindowResult
{
uint16_t
numOfRows
;
// number of rows of current time window
SWindowStatus
status
;
// this result status: closed or opened
SPosInfo
pos
;
// Position of current result in disk-based output buffer
uint16_t
numOfRows
;
// number of rows of current time window
bool
closed
;
// this result status: closed or opened
SResultInfo
*
resultInfo
;
// For each result column, there is a resultInfo
STimeWindow
window
;
// The time window that current result covers.
TSKEY
skey
;
// start key of current time window
}
SWindowResult
;
/**
...
...
@@ -79,6 +81,7 @@ typedef struct SWindowResInfo {
int64_t
startTime
;
// start time of the first time window for sliding query
int64_t
prevSKey
;
// previous (not completed) sliding window start key
int64_t
threshold
;
// threshold to halt query and return the generated results.
int64_t
interval
;
// time window interval
}
SWindowResInfo
;
typedef
struct
SColumnFilterElem
{
...
...
@@ -98,7 +101,7 @@ typedef struct STableQueryInfo { // todo merge with the STableQueryInfo struct
TSKEY
lastKey
;
int32_t
groupIndex
;
// group id in table list
int16_t
queryRangeSet
;
// denote if the query range is set, only available for interval query
int64_t
tag
;
tVariant
tag
;
STimeWindow
win
;
STSCursor
cur
;
void
*
pTable
;
// for retrieve the page id list
...
...
@@ -121,8 +124,9 @@ typedef struct SQueryCostInfo {
uint32_t
loadBlockStatis
;
uint32_t
discardBlocks
;
uint64_t
elapsedTime
;
uint64_t
comput
Time
;
uint64_t
firstStageMerge
Time
;
uint64_t
internalSupSize
;
uint64_t
numOfTimeWindows
;
}
SQueryCostInfo
;
typedef
struct
SQuery
{
...
...
@@ -189,21 +193,18 @@ typedef struct SQInfo {
int64_t
owner
;
// if it is in execution
void
*
tsdb
;
int32_t
vgId
;
STableGroupInfo
tableGroupInfo
;
// table
id list < only includes the STable list
>
STableGroupInfo
tableGroupInfo
;
// table
<tid, last_key> list SArray<STableKeyInfo
>
STableGroupInfo
tableqinfoGroupInfo
;
// this is a group array list, including SArray<STableQueryInfo*> structure
SQueryRuntimeEnv
runtimeEnv
;
int32_t
groupIndex
;
int32_t
offset
;
// offset in group result set of subgroup, todo refactor
SArray
*
arrTableIdInfo
;
int32_t
groupIndex
;
/*
* the query is executed position on which meter of the whole list.
* when the index reaches the last one of the list, it means the query is completed.
* We later may refactor to remove this attribution by using another flag to denote
* whether a multimeter query is completed or not.
*/
int32_t
tableIndex
;
int32_t
numOfGroupResultPages
;
SGroupResInfo
groupResInfo
;
void
*
pBuf
;
// allocated buffer for STableQueryInfo, sizeof(STableQueryInfo)*numOfTables;
pthread_mutex_t
lock
;
// used to synchronize the rsp/query threads
...
...
src/query/inc/qSqlparser.h
浏览文件 @
45f855ca
...
...
@@ -26,7 +26,7 @@ extern "C" {
#include "tstoken.h"
#include "tvariant.h"
#define ParseTOKENTYPE SS
QL
Token
#define ParseTOKENTYPE SS
tr
Token
extern
char
tTokenTypeSwitcher
[
13
];
#define toTSDBType(x) \
...
...
@@ -71,16 +71,16 @@ typedef struct SQuerySQL {
struct
tSQLExpr
*
pWhere
;
// where clause [optional]
tVariantList
*
pGroupby
;
// groupby clause, only for tags[optional]
tVariantList
*
pSortOrder
;
// orderby [optional]
SS
QL
Token
interval
;
// interval [optional]
SS
QL
Token
sliding
;
// sliding window [optional]
SS
tr
Token
interval
;
// interval [optional]
SS
tr
Token
sliding
;
// sliding window [optional]
SLimitVal
limit
;
// limit offset [optional]
SLimitVal
slimit
;
// group limit offset [optional]
tVariantList
*
fillType
;
// fill type[optional]
SS
QL
Token
selectToken
;
// sql string
SS
tr
Token
selectToken
;
// sql string
}
SQuerySQL
;
typedef
struct
SCreateTableSQL
{
struct
SS
QL
Token
name
;
// meter name, create table [meterName] xxx
struct
SS
tr
Token
name
;
// meter name, create table [meterName] xxx
bool
existCheck
;
int8_t
type
;
// create normal table/from super table/ stream
...
...
@@ -90,7 +90,7 @@ typedef struct SCreateTableSQL {
}
colInfo
;
struct
{
SS
QL
Token
stableName
;
// super table name, for using clause
SS
tr
Token
stableName
;
// super table name, for using clause
tVariantList
*
pTagVals
;
// create by using metric, tag value
STagData
tagdata
;
}
usingInfo
;
...
...
@@ -99,7 +99,7 @@ typedef struct SCreateTableSQL {
}
SCreateTableSQL
;
typedef
struct
SAlterTableSQL
{
SS
QL
Token
name
;
SS
tr
Token
name
;
int16_t
type
;
STagData
tagData
;
...
...
@@ -108,7 +108,7 @@ typedef struct SAlterTableSQL {
}
SAlterTableSQL
;
typedef
struct
SCreateDBInfo
{
SS
QL
Token
dbname
;
SS
tr
Token
dbname
;
int32_t
replica
;
int32_t
cacheBlockSize
;
int32_t
maxTablesPerVnode
;
...
...
@@ -121,7 +121,7 @@ typedef struct SCreateDBInfo {
int32_t
walLevel
;
int32_t
quorum
;
int32_t
compressionLevel
;
SS
QL
Token
precision
;
SS
tr
Token
precision
;
bool
ignoreExists
;
tVariantList
*
keep
;
...
...
@@ -136,33 +136,33 @@ typedef struct SCreateAcctSQL {
int64_t
maxStorage
;
int64_t
maxQueryTime
;
int32_t
maxConnections
;
SS
QL
Token
stat
;
SS
tr
Token
stat
;
}
SCreateAcctSQL
;
typedef
struct
SShowInfo
{
uint8_t
showType
;
SS
QL
Token
prefix
;
SS
QL
Token
pattern
;
SS
tr
Token
prefix
;
SS
tr
Token
pattern
;
}
SShowInfo
;
typedef
struct
SUserInfo
{
SS
QL
Token
user
;
SS
QL
Token
passwd
;
SS
QL
Token
privilege
;
SS
tr
Token
user
;
SS
tr
Token
passwd
;
SS
tr
Token
privilege
;
int16_t
type
;
}
SUserInfo
;
typedef
struct
tDCLSQL
{
int32_t
nTokens
;
/* Number of expressions on the list */
int32_t
nAlloc
;
/* Number of entries allocated below */
SS
QL
Token
*
a
;
/* one entry for element */
SS
tr
Token
*
a
;
/* one entry for element */
bool
existsCheck
;
union
{
SCreateDBInfo
dbOpt
;
SCreateAcctSQL
acctOpt
;
SShowInfo
showOpt
;
SS
QL
Token
ip
;
SS
tr
Token
ip
;
};
SUserInfo
user
;
...
...
@@ -194,14 +194,14 @@ typedef struct tSQLExpr {
// the full sql string of function(col, param), which is actually the raw
// field name, since the function name is kept in nSQLOptr already
SS
QL
Token
operand
;
SS
QL
Token
colInfo
;
// field id
SS
tr
Token
operand
;
SS
tr
Token
colInfo
;
// field id
tVariant
val
;
// value only for string, float, int
struct
tSQLExpr
*
pLeft
;
// left child
struct
tSQLExpr
*
pRight
;
// right child
struct
tSQLExprList
*
pParam
;
// function parameters
SStrToken
token
;
// original sql expr string
}
tSQLExpr
;
// used in select clause. select <tSQLExprList> from xxx
...
...
@@ -210,6 +210,7 @@ typedef struct tSQLExprItem {
char
*
aliasName
;
// alias name, null-terminated string
}
tSQLExprItem
;
// todo refactor by using SArray
typedef
struct
tSQLExprList
{
int32_t
nExpr
;
/* Number of expressions on the list */
int32_t
nAlloc
;
/* Number of entries allocated below */
...
...
@@ -242,7 +243,7 @@ tVariantList *tVariantListAppend(tVariantList *pList, tVariant *pVar, uint8_t so
tVariantList
*
tVariantListInsert
(
tVariantList
*
pList
,
tVariant
*
pVar
,
uint8_t
sortOrder
,
int32_t
index
);
tVariantList
*
tVariantListAppendToken
(
tVariantList
*
pList
,
SS
QL
Token
*
pAliasToken
,
uint8_t
sortOrder
);
tVariantList
*
tVariantListAppendToken
(
tVariantList
*
pList
,
SS
tr
Token
*
pAliasToken
,
uint8_t
sortOrder
);
void
tVariantListDestroy
(
tVariantList
*
pList
);
tFieldList
*
tFieldListAppend
(
tFieldList
*
pList
,
TAOS_FIELD
*
pField
);
...
...
@@ -253,61 +254,61 @@ tSQLExpr *tSQLExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optType);
void
tSQLExprDestroy
(
tSQLExpr
*
);
tSQLExprList
*
tSQLExprListAppend
(
tSQLExprList
*
pList
,
tSQLExpr
*
pNode
,
SS
QL
Token
*
pToken
);
tSQLExprList
*
tSQLExprListAppend
(
tSQLExprList
*
pList
,
tSQLExpr
*
pNode
,
SS
tr
Token
*
pToken
);
void
tSQLExprListDestroy
(
tSQLExprList
*
pList
);
SQuerySQL
*
tSetQuerySQLElems
(
SS
QL
Token
*
pSelectToken
,
tSQLExprList
*
pSelection
,
tVariantList
*
pFrom
,
tSQLExpr
*
pWhere
,
tVariantList
*
pGroupby
,
tVariantList
*
pSortOrder
,
SS
QL
Token
*
pInterval
,
SS
QL
Token
*
pSliding
,
tVariantList
*
pFill
,
SLimitVal
*
pLimit
,
SLimitVal
*
pGLimit
);
SQuerySQL
*
tSetQuerySQLElems
(
SS
tr
Token
*
pSelectToken
,
tSQLExprList
*
pSelection
,
tVariantList
*
pFrom
,
tSQLExpr
*
pWhere
,
tVariantList
*
pGroupby
,
tVariantList
*
pSortOrder
,
SS
tr
Token
*
pInterval
,
SS
tr
Token
*
pSliding
,
tVariantList
*
pFill
,
SLimitVal
*
pLimit
,
SLimitVal
*
pGLimit
);
SCreateTableSQL
*
tSetCreateSQLElems
(
tFieldList
*
pCols
,
tFieldList
*
pTags
,
SS
QL
Token
*
pMetricName
,
SCreateTableSQL
*
tSetCreateSQLElems
(
tFieldList
*
pCols
,
tFieldList
*
pTags
,
SS
tr
Token
*
pMetricName
,
tVariantList
*
pTagVals
,
SQuerySQL
*
pSelect
,
int32_t
type
);
void
tSQLExprNodeDestroy
(
tSQLExpr
*
pExpr
);
tSQLExpr
*
tSQLExprNodeClone
(
tSQLExpr
*
pExpr
);
SAlterTableSQL
*
tAlterTableSQLElems
(
SS
QL
Token
*
pMeterName
,
tFieldList
*
pCols
,
tVariantList
*
pVals
,
int32_t
type
);
SAlterTableSQL
*
tAlterTableSQLElems
(
SS
tr
Token
*
pMeterName
,
tFieldList
*
pCols
,
tVariantList
*
pVals
,
int32_t
type
);
tSQLExprListList
*
tSQLListListAppend
(
tSQLExprListList
*
pList
,
tSQLExprList
*
pExprList
);
void
destroyAllSelectClause
(
SSubclauseInfo
*
pSql
);
void
doDestroyQuerySql
(
SQuerySQL
*
pSql
);
SSqlInfo
*
setSQLInfo
(
SSqlInfo
*
pInfo
,
void
*
pSqlExprInfo
,
SS
QL
Token
*
pMeterName
,
int32_t
type
);
SSqlInfo
*
setSQLInfo
(
SSqlInfo
*
pInfo
,
void
*
pSqlExprInfo
,
SS
tr
Token
*
pMeterName
,
int32_t
type
);
SSubclauseInfo
*
setSubclause
(
SSubclauseInfo
*
pClause
,
void
*
pSqlExprInfo
);
SSubclauseInfo
*
appendSelectClause
(
SSubclauseInfo
*
pInfo
,
void
*
pSubclause
);
void
setCreatedTableName
(
SSqlInfo
*
pInfo
,
SS
QLToken
*
pMeterName
,
SSQL
Token
*
pIfNotExists
);
void
setCreatedTableName
(
SSqlInfo
*
pInfo
,
SS
trToken
*
pMeterName
,
SStr
Token
*
pIfNotExists
);
void
SQLInfoDestroy
(
SSqlInfo
*
pInfo
);
void
setDCLSQLElems
(
SSqlInfo
*
pInfo
,
int32_t
type
,
int32_t
nParams
,
...);
void
setDropDBTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
pToken
,
SSQL
Token
*
existsCheck
);
void
setShowOptions
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
prefix
,
SSQL
Token
*
pPatterns
);
void
setDropDBTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
pToken
,
SStr
Token
*
existsCheck
);
void
setShowOptions
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
prefix
,
SStr
Token
*
pPatterns
);
tDCLSQL
*
tTokenListAppend
(
tDCLSQL
*
pTokenList
,
SS
QL
Token
*
pToken
);
tDCLSQL
*
tTokenListAppend
(
tDCLSQL
*
pTokenList
,
SS
tr
Token
*
pToken
);
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
pToken
,
SCreateDBInfo
*
pDB
,
SSQL
Token
*
pIgExists
);
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
pToken
,
SCreateDBInfo
*
pDB
,
SStr
Token
*
pIgExists
);
void
setCreateAcctSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
pName
,
SSQL
Token
*
pPwd
,
SCreateAcctSQL
*
pAcctInfo
);
void
setCreateUserSQL
(
SSqlInfo
*
pInfo
,
SS
QLToken
*
pName
,
SSQL
Token
*
pPasswd
);
void
setKillSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QL
Token
*
ip
);
void
setAlterUserSQL
(
SSqlInfo
*
pInfo
,
int16_t
type
,
SS
QLToken
*
pName
,
SSQLToken
*
pPwd
,
SSQL
Token
*
pPrivilege
);
void
setCreateAcctSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
pName
,
SStr
Token
*
pPwd
,
SCreateAcctSQL
*
pAcctInfo
);
void
setCreateUserSQL
(
SSqlInfo
*
pInfo
,
SS
trToken
*
pName
,
SStr
Token
*
pPasswd
);
void
setKillSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
tr
Token
*
ip
);
void
setAlterUserSQL
(
SSqlInfo
*
pInfo
,
int16_t
type
,
SS
trToken
*
pName
,
SStrToken
*
pPwd
,
SStr
Token
*
pPrivilege
);
void
setDefaultCreateDbOption
(
SCreateDBInfo
*
pDBInfo
);
// prefix show db.tables;
void
setDBName
(
SS
QLToken
*
pCpxName
,
SSQL
Token
*
pDB
);
void
setDBName
(
SS
trToken
*
pCpxName
,
SStr
Token
*
pDB
);
tSQLExpr
*
tSQLExprIdValueCreate
(
SS
QL
Token
*
pToken
,
int32_t
optType
);
tSQLExpr
*
tSQLExprIdValueCreate
(
SS
tr
Token
*
pToken
,
int32_t
optType
);
tSQLExpr
*
tSQLExprCreateFunction
(
tSQLExprList
*
pList
,
SS
QLToken
*
pFuncToken
,
SSQL
Token
*
endToken
,
int32_t
optType
);
tSQLExpr
*
tSQLExprCreateFunction
(
tSQLExprList
*
pList
,
SS
trToken
*
pFuncToken
,
SStr
Token
*
endToken
,
int32_t
optType
);
void
tSQLSetColumnInfo
(
TAOS_FIELD
*
pField
,
SS
QL
Token
*
pName
,
TAOS_FIELD
*
pType
);
void
tSQLSetColumnInfo
(
TAOS_FIELD
*
pField
,
SS
tr
Token
*
pName
,
TAOS_FIELD
*
pType
);
void
tSQLSetColumnType
(
TAOS_FIELD
*
pField
,
SS
QL
Token
*
pToken
);
void
tSQLSetColumnType
(
TAOS_FIELD
*
pField
,
SS
tr
Token
*
pToken
);
void
*
ParseAlloc
(
void
*
(
*
mallocProc
)(
size_t
));
...
...
src/query/inc/qTsbuf.h
浏览文件 @
45f855ca
...
...
@@ -22,6 +22,7 @@ extern "C" {
#include "os.h"
#include "taosdef.h"
#include "tvariant.h"
#define MEM_BUF_SIZE (1 << 20)
#define TS_COMP_FILE_MAGIC 0x87F5EC4C
...
...
@@ -42,9 +43,9 @@ typedef struct STSRawBlock {
}
STSRawBlock
;
typedef
struct
STSElem
{
TSKEY
ts
;
int64_t
tag
;
int32_t
vnode
;
TSKEY
ts
;
tVariant
tag
;
int32_t
vnode
;
}
STSElem
;
typedef
struct
STSCursor
{
...
...
@@ -55,11 +56,11 @@ typedef struct STSCursor {
}
STSCursor
;
typedef
struct
STSBlock
{
int64_
t
tag
;
// tag value
int32_t
numOfElem
;
// number of elements
int32_t
compLen
;
// size after compressed
int32_t
padding
;
// 0xFFFFFFFF by default, after the payload
char
*
payload
;
// actual data that is compressed
tVarian
t
tag
;
// tag value
int32_t
numOfElem
;
// number of elements
int32_t
compLen
;
// size after compressed
int32_t
padding
;
// 0xFFFFFFFF by default, after the payload
char
*
payload
;
// actual data that is compressed
}
STSBlock
;
/*
...
...
@@ -84,8 +85,8 @@ typedef struct STSBuf {
uint32_t
fileSize
;
STSVnodeBlockInfoEx
*
pData
;
int32_t
numOfAlloc
;
int32_t
numOfVnodes
;
uint32_t
numOfAlloc
;
uint32_t
numOfVnodes
;
char
*
assistBuf
;
int32_t
bufSize
;
...
...
@@ -109,7 +110,7 @@ STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_
void
*
tsBufDestroy
(
STSBuf
*
pTSBuf
);
void
tsBufAppend
(
STSBuf
*
pTSBuf
,
int32_t
vnodeId
,
int64_t
tag
,
const
char
*
pData
,
int32_t
len
);
void
tsBufAppend
(
STSBuf
*
pTSBuf
,
int32_t
vnodeId
,
tVariant
*
tag
,
const
char
*
pData
,
int32_t
len
);
int32_t
tsBufMerge
(
STSBuf
*
pDestBuf
,
const
STSBuf
*
pSrcBuf
,
int32_t
vnodeIdx
);
STSBuf
*
tsBufClone
(
STSBuf
*
pTSBuf
);
...
...
@@ -122,7 +123,7 @@ void tsBufResetPos(STSBuf* pTSBuf);
STSElem
tsBufGetElem
(
STSBuf
*
pTSBuf
);
bool
tsBufNextPos
(
STSBuf
*
pTSBuf
);
STSElem
tsBufGetElemStartPos
(
STSBuf
*
pTSBuf
,
int32_t
vnodeId
,
int64_t
tag
);
STSElem
tsBufGetElemStartPos
(
STSBuf
*
pTSBuf
,
int32_t
vnodeId
,
tVariant
*
tag
);
STSCursor
tsBufGetCursor
(
STSBuf
*
pTSBuf
);
void
tsBufSetTraverseOrder
(
STSBuf
*
pTSBuf
,
int32_t
order
);
...
...
src/query/inc/qUtil.h
浏览文件 @
45f855ca
...
...
@@ -38,7 +38,8 @@ static FORCE_INLINE SWindowResult *getWindowResult(SWindowResInfo *pWindowResInf
return
&
pWindowResInfo
->
pResult
[
slot
];
}
#define curTimeWindow(_winres) ((_winres)->curIndex)
#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/inc/sql.y
浏览文件 @
45f855ca
...
...
@@ -2,8 +2,8 @@
//usage: lemon sql.y
%token_prefix TK_
%token_type {SS
QL
Token}
%default_type {SS
QL
Token}
%token_type {SS
tr
Token}
%default_type {SS
tr
Token}
%extra_argument {SSqlInfo* pInfo}
%fallback ID BOOL TINYINT SMALLINT INTEGER BIGINT FLOAT DOUBLE STRING TIMESTAMP BINARY NCHAR.
...
...
@@ -73,18 +73,18 @@ cmd ::= SHOW MODULES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_MODULE, 0, 0);
cmd ::= SHOW QUERIES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_QUERIES, 0, 0); }
cmd ::= SHOW CONNECTIONS.{ setShowOptions(pInfo, TSDB_MGMT_TABLE_CONNS, 0, 0);}
cmd ::= SHOW STREAMS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_STREAMS, 0, 0); }
cmd ::= SHOW
CONFIGS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_CONFIG
S, 0, 0); }
cmd ::= SHOW
VARIABLES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_VARIABLE
S, 0, 0); }
cmd ::= SHOW SCORES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_SCORES, 0, 0); }
cmd ::= SHOW GRANTS. { setShowOptions(pInfo, TSDB_MGMT_TABLE_GRANTS, 0, 0); }
cmd ::= SHOW VNODES. { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, 0, 0); }
cmd ::= SHOW VNODES IPTOKEN(X). { setShowOptions(pInfo, TSDB_MGMT_TABLE_VNODES, &X, 0); }
%type dbPrefix {SS
QL
Token}
%type dbPrefix {SS
tr
Token}
dbPrefix(A) ::=. {A.n = 0; A.type = 0;}
dbPrefix(A) ::= ids(X) DOT. {A = X; }
%type cpxName {SS
QL
Token}
%type cpxName {SS
tr
Token}
cpxName(A) ::= . {A.n = 0; }
cpxName(A) ::= DOT ids(Y). {A = Y; A.n += 1; }
...
...
@@ -101,19 +101,19 @@ cmd ::= SHOW dbPrefix(X) STABLES. {
}
cmd ::= SHOW dbPrefix(X) STABLES LIKE ids(Y). {
SS
QL
Token token;
SS
tr
Token token;
setDBName(&token, &X);
setShowOptions(pInfo, TSDB_MGMT_TABLE_METRIC, &token, &Y);
}
cmd ::= SHOW dbPrefix(X) VGROUPS. {
SS
QL
Token token;
SS
tr
Token token;
setDBName(&token, &X);
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, 0);
}
cmd ::= SHOW dbPrefix(X) VGROUPS ids(Y). {
SS
QL
Token token;
SS
tr
Token token;
setDBName(&token, &X);
setShowOptions(pInfo, TSDB_MGMT_TABLE_VGROUP, &token, &Y);
}
...
...
@@ -145,7 +145,7 @@ cmd ::= ALTER DNODE ids(X) ids(Y). { setDCLSQLElems(pInfo, TSDB_SQL
cmd ::= ALTER DNODE ids(X) ids(Y) ids(Z). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_DNODE, 3, &X, &Y, &Z); }
cmd ::= ALTER LOCAL ids(X). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 1, &X); }
cmd ::= ALTER LOCAL ids(X) ids(Y). { setDCLSQLElems(pInfo, TSDB_SQL_CFG_LOCAL, 2, &X, &Y); }
cmd ::= ALTER DATABASE ids(X) alter_db_optr(Y). { SS
QL
Token t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &X, &Y, &t);}
cmd ::= ALTER DATABASE ids(X) alter_db_optr(Y). { SS
tr
Token t = {0}; setCreateDBSQL(pInfo, TSDB_SQL_ALTER_DB, &X, &Y, &t);}
cmd ::= ALTER ACCOUNT ids(X) acct_optr(Z). { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &X, NULL, &Z);}
cmd ::= ALTER ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSQL(pInfo, TSDB_SQL_ALTER_ACCT, &X, &Y, &Z);}
...
...
@@ -153,15 +153,15 @@ cmd ::= ALTER ACCOUNT ids(X) PASS ids(Y) acct_optr(Z). { setCreateAcctSQL(p
// An IDENTIFIER can be a generic identifier, or one of several keywords.
// Any non-standard keyword can also be an identifier.
// And "ids" is an identifer-or-string.
%type ids {SS
QL
Token}
%type ids {SS
tr
Token}
ids(A) ::= ID(X). {A = X; }
ids(A) ::= STRING(X). {A = X; }
%type ifexists {SS
QL
Token}
%type ifexists {SS
tr
Token}
ifexists(X) ::= IF EXISTS. {X.n = 1;}
ifexists(X) ::= . {X.n = 0;}
%type ifnotexists {SS
QL
Token}
%type ifnotexists {SS
tr
Token}
ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
ifnotexists(X) ::= . {X.n = 0;}
...
...
@@ -416,7 +416,7 @@ selcollist(A) ::= sclp(P) STAR. {
// An option "AS <id>" phrase that can follow one of the expressions that
// define the result set, or one of the tables in the FROM clause.
//
%type as {SS
QL
Token}
%type as {SS
tr
Token}
as(X) ::= AS ids(Y). { X = Y; }
as(X) ::= ids(Y). { X = Y; }
as(X) ::= . { X.n = 0; }
...
...
@@ -458,10 +458,10 @@ tablelist(A) ::= tablelist(Y) COMMA ids(X) cpxName(Z) ids(F). {
}
// The value of interval should be the form of "number+[a,s,m,h,d,n,y]" or "now"
%type tmvar {SS
QL
Token}
%type tmvar {SS
tr
Token}
tmvar(A) ::= VARIABLE(X). {A = X;}
%type interval_opt {SS
QL
Token}
%type interval_opt {SS
tr
Token}
interval_opt(N) ::= INTERVAL LP tmvar(E) RP. {N = E; }
interval_opt(N) ::= . {N.n = 0; N.z = NULL; N.type = 0; }
...
...
@@ -482,7 +482,7 @@ fill_opt(N) ::= FILL LP ID(Y) RP. {
N = tVariantListAppendToken(NULL, &Y, -1);
}
%type sliding_opt {SS
QL
Token}
%type sliding_opt {SS
tr
Token}
sliding_opt(K) ::= SLIDING LP tmvar(E) RP. {K = E; }
sliding_opt(K) ::= . {K.n = 0; K.z = NULL; K.type = 0; }
...
...
src/query/inc/tsqlfunction.h
浏览文件 @
45f855ca
...
...
@@ -91,16 +91,16 @@ extern "C" {
#define QUERY_COND_REL_PREFIX_IN "IN|"
#define QUERY_COND_REL_PREFIX_LIKE "LIKE|"
#define QUERY_COND_REL_PREFIX_IN_LEN 3
#define QUERY_COND_REL_PREFIX_IN_LEN
3
#define QUERY_COND_REL_PREFIX_LIKE_LEN 5
#define QUERY_ASC_FORWARD_STEP 1
#define QUERY_ASC_FORWARD_STEP
1
#define QUERY_DESC_FORWARD_STEP -1
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
#define MAX_
RETRIEVE_ROWS_IN_INTERVAL_QUERY
10000000
#define TOP_BOTTOM_QUERY_LIMIT 100
#define MAX_
INTERVAL_TIME_WINDOW
10000000
#define TOP_BOTTOM_QUERY_LIMIT
100
enum
{
MASTER_SCAN
=
0x0u
,
...
...
@@ -137,13 +137,13 @@ typedef struct SInterpInfoDetail {
}
SInterpInfoDetail
;
typedef
struct
SResultInfo
{
int8_t
hasResult
;
// result generated, not NULL value
bool
initialized
;
// output buffer has been initialized
bool
complete
;
// query has completed
bool
superTableQ
;
// is super table query
int32_t
numOfRes
;
// num of output result in current buffer
int32_t
bufLen
;
// buffer size
void
*
interResultBuf
;
// output result buffer
int8_t
hasResult
;
// result generated, not NULL value
bool
initialized
;
// output buffer has been initialized
bool
complete
;
// query has completed
bool
superTableQ
;
// is super table query
uint32_t
bufLen
;
// buffer size
uint64_t
numOfRes
;
// num of output result in current buffer
void
*
interResultBuf
;
// output result buffer
}
SResultInfo
;
struct
SQLFunctionCtx
;
...
...
src/query/src/qAst.c
浏览文件 @
45f855ca
...
...
@@ -44,7 +44,7 @@
* ver 0.3, pipeline filter in the form of: (a+2)/9 > 14
*
*/
static
tExprNode
*
tExprNodeCreate
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
SS
QL
Token
*
pToken
);
static
tExprNode
*
tExprNodeCreate
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
SS
tr
Token
*
pToken
);
static
tExprNode
*
createSyntaxTree
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
str
,
int32_t
*
i
);
static
void
destroySyntaxTree
(
tExprNode
*
);
...
...
@@ -103,7 +103,7 @@ static void reviseBinaryExprIfNecessary(tExprNode **pLeft, tExprNode **pRight, u
}
}
static
tExprNode
*
tExprNodeCreate
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
SS
QL
Token
*
pToken
)
{
static
tExprNode
*
tExprNodeCreate
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
SS
tr
Token
*
pToken
)
{
/* if the token is not a value, return false */
if
(
pToken
->
type
==
TK_RP
||
(
pToken
->
type
!=
TK_INTEGER
&&
pToken
->
type
!=
TK_FLOAT
&&
pToken
->
type
!=
TK_ID
&&
pToken
->
type
!=
TK_TBNAME
&&
pToken
->
type
!=
TK_STRING
&&
pToken
->
type
!=
TK_BOOL
))
{
...
...
@@ -117,7 +117,7 @@ static tExprNode *tExprNodeCreate(SSchema *pSchema, int32_t numOfCols, SSQLToken
int32_t
i
=
0
;
if
(
pToken
->
type
==
TK_ID
)
{
do
{
SS
QL
Token
tableToken
=
{
0
};
SS
tr
Token
tableToken
=
{
0
};
extractTableNameFromToken
(
pToken
,
&
tableToken
);
size_t
len
=
strlen
(
pSchema
[
i
].
name
);
...
...
@@ -157,7 +157,7 @@ static tExprNode *tExprNodeCreate(SSchema *pSchema, int32_t numOfCols, SSQLToken
return
pNode
;
}
uint8_t
getBinaryExprOptr
(
SS
QL
Token
*
pToken
)
{
uint8_t
getBinaryExprOptr
(
SS
tr
Token
*
pToken
)
{
switch
(
pToken
->
type
)
{
case
TK_LT
:
return
TSDB_RELATION_LESS
;
...
...
@@ -234,7 +234,7 @@ uint8_t isQueryOnPrimaryKey(const char *primaryColumnName, const tExprNode *pLef
}
static
tExprNode
*
createSyntaxTree
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
str
,
int32_t
*
i
)
{
SS
QL
Token
t0
=
tStrGetToken
(
str
,
i
,
false
,
0
,
NULL
);
SS
tr
Token
t0
=
tStrGetToken
(
str
,
i
,
false
,
0
,
NULL
);
if
(
t0
.
n
==
0
)
{
return
NULL
;
}
...
...
src/query/src/qExecutor.c
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
src/query/src/qParserImpl.c
浏览文件 @
45f855ca
...
...
@@ -33,7 +33,7 @@ SSqlInfo qSQLParse(const char *pStr) {
int32_t
i
=
0
;
while
(
1
)
{
SS
QL
Token
t0
=
{
0
};
SS
tr
Token
t0
=
{
0
};
if
(
pStr
[
i
]
==
0
)
{
Parse
(
pParser
,
0
,
t0
,
&
sqlInfo
);
...
...
@@ -73,12 +73,12 @@ abort_parse:
return
sqlInfo
;
}
tSQLExprList
*
tSQLExprListAppend
(
tSQLExprList
*
pList
,
tSQLExpr
*
pNode
,
SS
QL
Token
*
pToken
)
{
tSQLExprList
*
tSQLExprListAppend
(
tSQLExprList
*
pList
,
tSQLExpr
*
pNode
,
SS
tr
Token
*
pToken
)
{
if
(
pList
==
NULL
)
{
pList
=
calloc
(
1
,
sizeof
(
tSQLExprList
));
}
if
(
pList
->
nAlloc
<=
pList
->
nExpr
)
{
//
if
(
pList
->
nAlloc
<=
pList
->
nExpr
)
{
pList
->
nAlloc
=
(
pList
->
nAlloc
<<
1
)
+
4
;
pList
->
a
=
realloc
(
pList
->
a
,
pList
->
nAlloc
*
sizeof
(
pList
->
a
[
0
]));
if
(
pList
->
a
==
0
)
{
...
...
@@ -117,41 +117,45 @@ void tSQLExprListDestroy(tSQLExprList *pList) {
free
(
pList
);
}
tSQLExpr
*
tSQLExprIdValueCreate
(
SSQLToken
*
pAliasToken
,
int32_t
optrType
)
{
tSQLExpr
*
nodePtr
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
tSQLExpr
*
tSQLExprIdValueCreate
(
SStrToken
*
pToken
,
int32_t
optrType
)
{
tSQLExpr
*
pSQLExpr
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
if
(
pToken
!=
NULL
)
{
pSQLExpr
->
token
=
*
pToken
;
}
if
(
optrType
==
TK_INTEGER
||
optrType
==
TK_STRING
||
optrType
==
TK_FLOAT
||
optrType
==
TK_BOOL
)
{
toTSDBType
(
p
Alias
Token
->
type
);
toTSDBType
(
pToken
->
type
);
tVariantCreate
(
&
nodePtr
->
val
,
pAlias
Token
);
nodePt
r
->
nSQLOptr
=
optrType
;
tVariantCreate
(
&
pSQLExpr
->
val
,
p
Token
);
pSQLExp
r
->
nSQLOptr
=
optrType
;
}
else
if
(
optrType
==
TK_NOW
)
{
// default use microsecond
nodePt
r
->
val
.
i64Key
=
taosGetTimestamp
(
TSDB_TIME_PRECISION_MICRO
);
nodePt
r
->
val
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
nodePt
r
->
nSQLOptr
=
TK_TIMESTAMP
;
// TK_TIMESTAMP used to denote the time value is in microsecond
pSQLExp
r
->
val
.
i64Key
=
taosGetTimestamp
(
TSDB_TIME_PRECISION_MICRO
);
pSQLExp
r
->
val
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
pSQLExp
r
->
nSQLOptr
=
TK_TIMESTAMP
;
// TK_TIMESTAMP used to denote the time value is in microsecond
}
else
if
(
optrType
==
TK_VARIABLE
)
{
int32_t
ret
=
getTimestampInUsFromStr
(
p
AliasToken
->
z
,
pAliasToken
->
n
,
&
nodePt
r
->
val
.
i64Key
);
int32_t
ret
=
getTimestampInUsFromStr
(
p
Token
->
z
,
pToken
->
n
,
&
pSQLExp
r
->
val
.
i64Key
);
UNUSED
(
ret
);
nodePt
r
->
val
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
nodePt
r
->
nSQLOptr
=
TK_TIMESTAMP
;
pSQLExp
r
->
val
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
pSQLExp
r
->
nSQLOptr
=
TK_TIMESTAMP
;
}
else
{
// it must be the column name (tk_id) if it is not the number
assert
(
optrType
==
TK_ID
||
optrType
==
TK_ALL
);
if
(
p
Alias
Token
!=
NULL
)
{
nodePtr
->
colInfo
=
*
pAlias
Token
;
if
(
pToken
!=
NULL
)
{
pSQLExpr
->
colInfo
=
*
p
Token
;
}
nodePt
r
->
nSQLOptr
=
optrType
;
pSQLExp
r
->
nSQLOptr
=
optrType
;
}
return
nodePt
r
;
return
pSQLExp
r
;
}
/*
* pList is the parameters for function with id(optType)
* function name is denoted by pFunctionToken
*/
tSQLExpr
*
tSQLExprCreateFunction
(
tSQLExprList
*
pList
,
SS
QLToken
*
pFuncToken
,
SSQL
Token
*
endToken
,
int32_t
optType
)
{
tSQLExpr
*
tSQLExprCreateFunction
(
tSQLExprList
*
pList
,
SS
trToken
*
pFuncToken
,
SStr
Token
*
endToken
,
int32_t
optType
)
{
if
(
pFuncToken
==
NULL
)
return
NULL
;
tSQLExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
...
...
@@ -163,6 +167,8 @@ tSQLExpr *tSQLExprCreateFunction(tSQLExprList *pList, SSQLToken *pFuncToken, SSQ
pExpr
->
operand
.
n
=
len
;
// raw field name
pExpr
->
operand
.
type
=
pFuncToken
->
type
;
pExpr
->
token
=
pExpr
->
operand
;
return
pExpr
;
}
...
...
@@ -173,8 +179,14 @@ tSQLExpr *tSQLExprCreateFunction(tSQLExprList *pList, SSQLToken *pFuncToken, SSQ
tSQLExpr
*
tSQLExprCreate
(
tSQLExpr
*
pLeft
,
tSQLExpr
*
pRight
,
int32_t
optrType
)
{
tSQLExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
tSQLExpr
));
if
(
optrType
==
TK_PLUS
||
optrType
==
TK_MINUS
||
optrType
==
TK_STAR
||
optrType
==
TK_DIVIDE
||
optrType
==
TK_REM
)
{
if
(
pRight
!=
NULL
&&
pLeft
!=
NULL
)
{
char
*
endPos
=
pRight
->
token
.
z
+
pRight
->
token
.
n
;
pExpr
->
token
.
z
=
pLeft
->
token
.
z
;
pExpr
->
token
.
n
=
(
uint32_t
)(
endPos
-
pExpr
->
token
.
z
);
pExpr
->
token
.
type
=
pLeft
->
token
.
type
;
}
if
(
optrType
==
TK_PLUS
||
optrType
==
TK_MINUS
||
optrType
==
TK_STAR
||
optrType
==
TK_DIVIDE
||
optrType
==
TK_REM
)
{
/*
* if a token is noted as the TK_TIMESTAMP, the time precision is microsecond
* Otherwise, the time precision is adaptive, determined by the time precision from databases.
...
...
@@ -373,7 +385,7 @@ void tVariantListDestroy(tVariantList *pList) {
free
(
pList
);
}
tVariantList
*
tVariantListAppendToken
(
tVariantList
*
pList
,
SS
QLToken
*
pAlias
Token
,
uint8_t
sortOrder
)
{
tVariantList
*
tVariantListAppendToken
(
tVariantList
*
pList
,
SS
trToken
*
p
Token
,
uint8_t
sortOrder
)
{
if
(
pList
==
NULL
)
{
pList
=
calloc
(
1
,
sizeof
(
tVariantList
));
}
...
...
@@ -382,9 +394,9 @@ tVariantList *tVariantListAppendToken(tVariantList *pList, SSQLToken *pAliasToke
return
pList
;
}
if
(
p
Alias
Token
)
{
if
(
pToken
)
{
tVariant
t
=
{
0
};
tVariantCreate
(
&
t
,
p
Alias
Token
);
tVariantCreate
(
&
t
,
pToken
);
tVariantListItem
*
pItem
=
&
pList
->
a
[
pList
->
nExpr
++
];
memcpy
(
pItem
,
&
t
,
sizeof
(
tVariant
));
...
...
@@ -420,7 +432,7 @@ void tFieldListDestroy(tFieldList *pList) {
free
(
pList
);
}
void
setDBName
(
SS
QLToken
*
pCpxName
,
SSQL
Token
*
pDB
)
{
void
setDBName
(
SS
trToken
*
pCpxName
,
SStr
Token
*
pDB
)
{
pCpxName
->
type
=
pDB
->
type
;
pCpxName
->
z
=
pDB
->
z
;
pCpxName
->
n
=
pDB
->
n
;
...
...
@@ -464,7 +476,7 @@ int32_t getTimestampInUsFromStrImpl(int64_t val, char unit, int64_t *result) {
return
0
;
}
void
tSQLSetColumnInfo
(
TAOS_FIELD
*
pField
,
SS
QL
Token
*
pName
,
TAOS_FIELD
*
pType
)
{
void
tSQLSetColumnInfo
(
TAOS_FIELD
*
pField
,
SS
tr
Token
*
pName
,
TAOS_FIELD
*
pType
)
{
int32_t
maxLen
=
sizeof
(
pField
->
name
)
/
sizeof
(
pField
->
name
[
0
]);
// truncate the column name
...
...
@@ -479,7 +491,7 @@ void tSQLSetColumnInfo(TAOS_FIELD *pField, SSQLToken *pName, TAOS_FIELD *pType)
pField
->
bytes
=
pType
->
bytes
;
}
void
tSQLSetColumnType
(
TAOS_FIELD
*
pField
,
SS
QL
Token
*
type
)
{
void
tSQLSetColumnType
(
TAOS_FIELD
*
pField
,
SS
tr
Token
*
type
)
{
pField
->
type
=
-
1
;
int32_t
LENGTH_SIZE_OF_STR
=
2
;
// in case of nchar and binary, there two bytes to keep the length of binary|nchar.
...
...
@@ -517,9 +529,9 @@ void tSQLSetColumnType(TAOS_FIELD *pField, SSQLToken *type) {
/*
* extract the select info out of sql string
*/
SQuerySQL
*
tSetQuerySQLElems
(
SS
QL
Token
*
pSelectToken
,
tSQLExprList
*
pSelection
,
tVariantList
*
pFrom
,
tSQLExpr
*
pWhere
,
tVariantList
*
pGroupby
,
tVariantList
*
pSortOrder
,
SS
QL
Token
*
pInterval
,
SS
QL
Token
*
pSliding
,
tVariantList
*
pFill
,
SLimitVal
*
pLimit
,
SLimitVal
*
pGLimit
)
{
SQuerySQL
*
tSetQuerySQLElems
(
SS
tr
Token
*
pSelectToken
,
tSQLExprList
*
pSelection
,
tVariantList
*
pFrom
,
tSQLExpr
*
pWhere
,
tVariantList
*
pGroupby
,
tVariantList
*
pSortOrder
,
SS
tr
Token
*
pInterval
,
SS
tr
Token
*
pSliding
,
tVariantList
*
pFill
,
SLimitVal
*
pLimit
,
SLimitVal
*
pGLimit
)
{
assert
(
pSelection
!=
NULL
);
SQuerySQL
*
pQuery
=
calloc
(
1
,
sizeof
(
SQuerySQL
));
...
...
@@ -611,7 +623,7 @@ void destroyAllSelectClause(SSubclauseInfo *pClause) {
taosTFree
(
pClause
->
pClause
);
}
SCreateTableSQL
*
tSetCreateSQLElems
(
tFieldList
*
pCols
,
tFieldList
*
pTags
,
SS
QL
Token
*
pStableName
,
SCreateTableSQL
*
tSetCreateSQLElems
(
tFieldList
*
pCols
,
tFieldList
*
pTags
,
SS
tr
Token
*
pStableName
,
tVariantList
*
pTagVals
,
SQuerySQL
*
pSelect
,
int32_t
type
)
{
SCreateTableSQL
*
pCreate
=
calloc
(
1
,
sizeof
(
SCreateTableSQL
));
...
...
@@ -644,7 +656,7 @@ SCreateTableSQL *tSetCreateSQLElems(tFieldList *pCols, tFieldList *pTags, SSQLTo
return
pCreate
;
}
SAlterTableSQL
*
tAlterTableSQLElems
(
SS
QL
Token
*
pMeterName
,
tFieldList
*
pCols
,
tVariantList
*
pVals
,
int32_t
type
)
{
SAlterTableSQL
*
tAlterTableSQLElems
(
SS
tr
Token
*
pMeterName
,
tFieldList
*
pCols
,
tVariantList
*
pVals
,
int32_t
type
)
{
SAlterTableSQL
*
pAlterTable
=
calloc
(
1
,
sizeof
(
SAlterTableSQL
));
pAlterTable
->
name
=
*
pMeterName
;
...
...
@@ -716,7 +728,7 @@ SSubclauseInfo* setSubclause(SSubclauseInfo* pSubclause, void *pSqlExprInfo) {
return
pSubclause
;
}
SSqlInfo
*
setSQLInfo
(
SSqlInfo
*
pInfo
,
void
*
pSqlExprInfo
,
SS
QL
Token
*
pMeterName
,
int32_t
type
)
{
SSqlInfo
*
setSQLInfo
(
SSqlInfo
*
pInfo
,
void
*
pSqlExprInfo
,
SS
tr
Token
*
pMeterName
,
int32_t
type
)
{
pInfo
->
type
=
type
;
if
(
type
==
TSDB_SQL_SELECT
)
{
...
...
@@ -745,7 +757,7 @@ SSubclauseInfo* appendSelectClause(SSubclauseInfo *pQueryInfo, void *pSubclause)
return
pQueryInfo
;
}
void
setCreatedTableName
(
SSqlInfo
*
pInfo
,
SS
QLToken
*
pMeterName
,
SSQL
Token
*
pIfNotExists
)
{
void
setCreatedTableName
(
SSqlInfo
*
pInfo
,
SS
trToken
*
pMeterName
,
SStr
Token
*
pIfNotExists
)
{
pInfo
->
pCreateTableInfo
->
name
=
*
pMeterName
;
pInfo
->
pCreateTableInfo
->
existCheck
=
(
pIfNotExists
->
n
!=
0
);
}
...
...
@@ -760,7 +772,7 @@ void tTokenListBuyMoreSpace(tDCLSQL *pTokenList) {
}
}
tDCLSQL
*
tTokenListAppend
(
tDCLSQL
*
pTokenList
,
SS
QL
Token
*
pToken
)
{
tDCLSQL
*
tTokenListAppend
(
tDCLSQL
*
pTokenList
,
SS
tr
Token
*
pToken
)
{
if
(
pToken
==
NULL
)
return
NULL
;
if
(
pTokenList
==
NULL
)
pTokenList
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
...
...
@@ -781,19 +793,19 @@ void setDCLSQLElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
va_start
(
va
,
nParam
);
while
(
nParam
--
>
0
)
{
SS
QLToken
*
pToken
=
va_arg
(
va
,
SSQL
Token
*
);
SS
trToken
*
pToken
=
va_arg
(
va
,
SStr
Token
*
);
pInfo
->
pDCLInfo
=
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pToken
);
}
va_end
(
va
);
}
void
setDropDBTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
pToken
,
SSQL
Token
*
existsCheck
)
{
void
setDropDBTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
pToken
,
SStr
Token
*
existsCheck
)
{
pInfo
->
type
=
type
;
pInfo
->
pDCLInfo
=
tTokenListAppend
(
pInfo
->
pDCLInfo
,
pToken
);
pInfo
->
pDCLInfo
->
existsCheck
=
(
existsCheck
->
n
==
1
);
}
void
setShowOptions
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
prefix
,
SSQL
Token
*
pPatterns
)
{
void
setShowOptions
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
prefix
,
SStr
Token
*
pPatterns
)
{
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
}
...
...
@@ -816,7 +828,7 @@ void setShowOptions(SSqlInfo *pInfo, int32_t type, SSQLToken* prefix, SSQLToken*
}
}
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
pToken
,
SCreateDBInfo
*
pDB
,
SSQL
Token
*
pIgExists
)
{
void
setCreateDBSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
pToken
,
SCreateDBInfo
*
pDB
,
SStr
Token
*
pIgExists
)
{
pInfo
->
type
=
type
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
...
...
@@ -827,7 +839,7 @@ void setCreateDBSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pToken, SCreateDBI
pInfo
->
pDCLInfo
->
dbOpt
.
ignoreExists
=
pIgExists
->
n
;
// sql.y has: ifnotexists(X) ::= IF NOT EXISTS. {X.n = 1;}
}
void
setCreateAcctSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QLToken
*
pName
,
SSQL
Token
*
pPwd
,
SCreateAcctSQL
*
pAcctInfo
)
{
void
setCreateAcctSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
trToken
*
pName
,
SStr
Token
*
pPwd
,
SCreateAcctSQL
*
pAcctInfo
)
{
pInfo
->
type
=
type
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
...
...
@@ -843,7 +855,7 @@ void setCreateAcctSQL(SSqlInfo *pInfo, int32_t type, SSQLToken *pName, SSQLToken
}
}
void
setCreateUserSQL
(
SSqlInfo
*
pInfo
,
SS
QLToken
*
pName
,
SSQL
Token
*
pPasswd
)
{
void
setCreateUserSQL
(
SSqlInfo
*
pInfo
,
SS
trToken
*
pName
,
SStr
Token
*
pPasswd
)
{
pInfo
->
type
=
TSDB_SQL_CREATE_USER
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
...
...
@@ -855,7 +867,7 @@ void setCreateUserSQL(SSqlInfo *pInfo, SSQLToken *pName, SSQLToken *pPasswd) {
pInfo
->
pDCLInfo
->
user
.
passwd
=
*
pPasswd
;
}
void
setAlterUserSQL
(
SSqlInfo
*
pInfo
,
int16_t
type
,
SS
QLToken
*
pName
,
SSQLToken
*
pPwd
,
SSQL
Token
*
pPrivilege
)
{
void
setAlterUserSQL
(
SSqlInfo
*
pInfo
,
int16_t
type
,
SS
trToken
*
pName
,
SStrToken
*
pPwd
,
SStr
Token
*
pPrivilege
)
{
pInfo
->
type
=
TSDB_SQL_ALTER_USER
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
...
...
@@ -880,7 +892,7 @@ void setAlterUserSQL(SSqlInfo *pInfo, int16_t type, SSQLToken *pName, SSQLToken*
}
}
void
setKillSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
QL
Token
*
ip
)
{
void
setKillSQL
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SS
tr
Token
*
ip
)
{
pInfo
->
type
=
type
;
if
(
pInfo
->
pDCLInfo
==
NULL
)
{
pInfo
->
pDCLInfo
=
calloc
(
1
,
sizeof
(
tDCLSQL
));
...
...
@@ -909,5 +921,5 @@ void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo) {
pDBInfo
->
quorum
=
-
1
;
pDBInfo
->
keep
=
NULL
;
memset
(
&
pDBInfo
->
precision
,
0
,
sizeof
(
SS
QL
Token
));
memset
(
&
pDBInfo
->
precision
,
0
,
sizeof
(
SS
tr
Token
));
}
src/query/src/qResultbuf.c
浏览文件 @
45f855ca
...
...
@@ -137,8 +137,15 @@ static char* doFlushPageToDisk(SDiskbasedResultBuf* pResultBuf, SPageInfo* pg) {
}
//3. write to disk.
fseek
(
pResultBuf
->
file
,
pg
->
info
.
offset
,
SEEK_SET
);
fwrite
(
t
,
size
,
1
,
pResultBuf
->
file
);
int32_t
ret
=
fseek
(
pResultBuf
->
file
,
pg
->
info
.
offset
,
SEEK_SET
);
if
(
ret
!=
0
)
{
// todo handle the error case
}
ret
=
(
int32_t
)
fwrite
(
t
,
size
,
1
,
pResultBuf
->
file
);
if
(
ret
!=
size
)
{
// todo handle the error case
}
if
(
pResultBuf
->
fileSize
<
pg
->
info
.
offset
+
pg
->
info
.
length
)
{
pResultBuf
->
fileSize
=
pg
->
info
.
offset
+
pg
->
info
.
length
;
...
...
src/query/src/qTokenizer.c
浏览文件 @
45f855ca
...
...
@@ -85,7 +85,7 @@ static SKeyword keywordTable[] = {
{
"QUERIES"
,
TK_QUERIES
},
{
"CONNECTIONS"
,
TK_CONNECTIONS
},
{
"STREAMS"
,
TK_STREAMS
},
{
"
CONFIGS"
,
TK_CONFIG
S
},
{
"
VARIABLES"
,
TK_VARIABLE
S
},
{
"SCORES"
,
TK_SCORES
},
{
"GRANTS"
,
TK_GRANTS
},
{
"DOT"
,
TK_DOT
},
...
...
@@ -580,8 +580,8 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) {
return
0
;
}
SS
QL
Token
tStrGetToken
(
char
*
str
,
int32_t
*
i
,
bool
isPrevOptr
,
uint32_t
numOfIgnoreToken
,
uint32_t
*
ignoreTokenTypes
)
{
SS
QL
Token
t0
=
{
0
};
SS
tr
Token
tStrGetToken
(
char
*
str
,
int32_t
*
i
,
bool
isPrevOptr
,
uint32_t
numOfIgnoreToken
,
uint32_t
*
ignoreTokenTypes
)
{
SS
tr
Token
t0
=
{
0
};
// here we reach the end of sql string, null-terminated string
if
(
str
[
*
i
]
==
0
)
{
...
...
src/query/src/qTsbuf.c
浏览文件 @
45f855ca
...
...
@@ -8,7 +8,6 @@ static void TSBufUpdateVnodeInfo(STSBuf* pTSBuf, int32_t index, STSVnodeBlockInf
static
STSBuf
*
allocResForTSBuf
(
STSBuf
*
pTSBuf
);
static
int32_t
STSBufUpdateHeader
(
STSBuf
*
pTSBuf
,
STSBufFileHeader
*
pHeader
);
/**
* todo error handling
* support auto closeable tmp file
...
...
@@ -76,7 +75,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
return
NULL
;
}
if
(
(
int32_t
)
header
.
numOfVnode
>
pTSBuf
->
numOfAlloc
)
{
if
(
header
.
numOfVnode
>
pTSBuf
->
numOfAlloc
)
{
pTSBuf
->
numOfAlloc
=
header
.
numOfVnode
;
STSVnodeBlockInfoEx
*
tmp
=
realloc
(
pTSBuf
->
pData
,
sizeof
(
STSVnodeBlockInfoEx
)
*
pTSBuf
->
numOfAlloc
);
if
(
tmp
==
NULL
)
{
...
...
@@ -225,14 +224,15 @@ static void writeDataToDisk(STSBuf* pTSBuf) {
}
STSBlock
*
pBlock
=
&
pTSBuf
->
block
;
pBlock
->
numOfElem
=
pTSBuf
->
tsData
.
len
/
TSDB_KEYSIZE
;
STSList
*
pTsData
=
&
pTSBuf
->
tsData
;
pBlock
->
numOfElem
=
pTsData
->
len
/
TSDB_KEYSIZE
;
pBlock
->
compLen
=
tsCompressTimestamp
(
pT
SBuf
->
tsData
.
rawBuf
,
pTSBuf
->
tsData
.
len
,
pTSBuf
->
tsData
.
len
/
TSDB_KEYSIZE
,
pBlock
->
payload
,
pTSBuf
->
tsData
.
allocSize
,
TWO_STAGE_COMP
,
pTSBuf
->
assistBuf
,
pTSBuf
->
bufSize
);
tsCompressTimestamp
(
pT
sData
->
rawBuf
,
pTsData
->
len
,
pTsData
->
len
/
TSDB_KEYSIZE
,
pBlock
->
payload
,
pTsData
->
allocSize
,
TWO_STAGE_COMP
,
pTSBuf
->
assistBuf
,
pTSBuf
->
bufSize
);
int64_t
r
=
fseek
(
pTSBuf
->
f
,
pTSBuf
->
fileSize
,
SEEK_SET
);
UNUSED
(
r
);
assert
(
r
==
0
);
/*
* format for output data:
...
...
@@ -241,16 +241,22 @@ static void writeDataToDisk(STSBuf* pTSBuf) {
*
* both side has the compressed length is used to support load data forwards/backwords.
*/
fwrite
(
&
pBlock
->
tag
,
sizeof
(
pBlock
->
tag
),
1
,
pTSBuf
->
f
);
int32_t
metaLen
=
0
;
metaLen
+=
(
int32_t
)
fwrite
(
&
pBlock
->
tag
.
nType
,
1
,
sizeof
(
pBlock
->
tag
.
nType
),
pTSBuf
->
f
);
metaLen
+=
(
int32_t
)
fwrite
(
&
pBlock
->
tag
.
nLen
,
1
,
sizeof
(
pBlock
->
tag
.
nLen
),
pTSBuf
->
f
);
if
(
pBlock
->
tag
.
nType
==
TSDB_DATA_TYPE_BINARY
||
pBlock
->
tag
.
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
metaLen
+=
(
int32_t
)
fwrite
(
pBlock
->
tag
.
pz
,
1
,
(
size_t
)
pBlock
->
tag
.
nLen
,
pTSBuf
->
f
);
}
else
if
(
pBlock
->
tag
.
nType
!=
TSDB_DATA_TYPE_NULL
)
{
metaLen
+=
(
int32_t
)
fwrite
(
&
pBlock
->
tag
.
i64Key
,
1
,
sizeof
(
int64_t
),
pTSBuf
->
f
);
}
fwrite
(
&
pBlock
->
numOfElem
,
sizeof
(
pBlock
->
numOfElem
),
1
,
pTSBuf
->
f
);
fwrite
(
&
pBlock
->
compLen
,
sizeof
(
pBlock
->
compLen
),
1
,
pTSBuf
->
f
);
fwrite
(
pBlock
->
payload
,
(
size_t
)
pBlock
->
compLen
,
1
,
pTSBuf
->
f
);
fwrite
(
&
pBlock
->
compLen
,
sizeof
(
pBlock
->
compLen
),
1
,
pTSBuf
->
f
);
int32_t
blockSize
=
sizeof
(
pBlock
->
tag
)
+
sizeof
(
pBlock
->
numOfElem
)
+
sizeof
(
pBlock
->
compLen
)
*
2
+
pBlock
->
compLen
;
int32_t
blockSize
=
metaLen
+
sizeof
(
pBlock
->
numOfElem
)
+
sizeof
(
pBlock
->
compLen
)
*
2
+
pBlock
->
compLen
;
pTSBuf
->
fileSize
+=
blockSize
;
pTSBuf
->
tsData
.
len
=
0
;
...
...
@@ -298,9 +304,24 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
ret
=
fseek
(
pTSBuf
->
f
,
-
offset
,
SEEK_CUR
);
UNUSED
(
ret
);
}
size_t
sz
=
fread
(
&
pBlock
->
tag
,
sizeof
(
pBlock
->
tag
),
1
,
pTSBuf
->
f
);
UNUSED
(
sz
);
fread
(
&
pBlock
->
tag
.
nType
,
sizeof
(
pBlock
->
tag
.
nType
),
1
,
pTSBuf
->
f
);
fread
(
&
pBlock
->
tag
.
nLen
,
sizeof
(
pBlock
->
tag
.
nLen
),
1
,
pTSBuf
->
f
);
// NOTE: mix types tags are not supported
size_t
sz
=
0
;
if
(
pBlock
->
tag
.
nType
==
TSDB_DATA_TYPE_BINARY
||
pBlock
->
tag
.
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
char
*
tp
=
realloc
(
pBlock
->
tag
.
pz
,
pBlock
->
tag
.
nLen
+
1
);
assert
(
tp
!=
NULL
);
memset
(
tp
,
0
,
pBlock
->
tag
.
nLen
+
1
);
pBlock
->
tag
.
pz
=
tp
;
sz
=
fread
(
pBlock
->
tag
.
pz
,
(
size_t
)
pBlock
->
tag
.
nLen
,
1
,
pTSBuf
->
f
);
}
else
if
(
pBlock
->
tag
.
nType
!=
TSDB_DATA_TYPE_NULL
)
{
sz
=
fread
(
&
pBlock
->
tag
.
i64Key
,
sizeof
(
int64_t
),
1
,
pTSBuf
->
f
);
}
sz
=
fread
(
&
pBlock
->
numOfElem
,
sizeof
(
pBlock
->
numOfElem
),
1
,
pTSBuf
->
f
);
UNUSED
(
sz
);
sz
=
fread
(
&
pBlock
->
compLen
,
sizeof
(
pBlock
->
compLen
),
1
,
pTSBuf
->
f
);
...
...
@@ -361,7 +382,7 @@ static int32_t setCheckTSOrder(STSBuf* pTSBuf, const char* pData, int32_t len) {
return
TSDB_CODE_SUCCESS
;
}
void
tsBufAppend
(
STSBuf
*
pTSBuf
,
int32_t
vnodeId
,
int64_t
tag
,
const
char
*
pData
,
int32_t
len
)
{
void
tsBufAppend
(
STSBuf
*
pTSBuf
,
int32_t
vnodeId
,
tVariant
*
tag
,
const
char
*
pData
,
int32_t
len
)
{
STSVnodeBlockInfoEx
*
pBlockInfo
=
NULL
;
STSList
*
ptsData
=
&
pTSBuf
->
tsData
;
...
...
@@ -375,15 +396,15 @@ void tsBufAppend(STSBuf* pTSBuf, int32_t vnodeId, int64_t tag, const char* pData
}
assert
(
pBlockInfo
->
info
.
vnode
==
vnodeId
);
if
(
pTSBuf
->
block
.
tag
!=
tag
&&
ptsData
->
len
>
0
)
{
if
(
(
tVariantCompare
(
&
pTSBuf
->
block
.
tag
,
tag
)
!=
0
)
&&
ptsData
->
len
>
0
)
{
// new arrived data with different tags value, save current value into disk first
writeDataToDisk
(
pTSBuf
);
}
else
{
expandBuffer
(
ptsData
,
len
);
}
pTSBuf
->
block
.
tag
=
tag
;
tVariantAssign
(
&
pTSBuf
->
block
.
tag
,
tag
)
;
memcpy
(
ptsData
->
rawBuf
+
ptsData
->
len
,
pData
,
(
size_t
)
len
);
// todo check return value
...
...
@@ -465,7 +486,7 @@ static int32_t tsBufFindBlock(STSBuf* pTSBuf, STSVnodeBlockInfo* pBlockInfo, int
return
0
;
}
static
int32_t
tsBufFindBlockByTag
(
STSBuf
*
pTSBuf
,
STSVnodeBlockInfo
*
pBlockInfo
,
int64_t
tag
)
{
static
int32_t
tsBufFindBlockByTag
(
STSBuf
*
pTSBuf
,
STSVnodeBlockInfo
*
pBlockInfo
,
tVariant
*
tag
)
{
bool
decomp
=
false
;
int64_t
offset
=
0
;
...
...
@@ -484,7 +505,7 @@ static int32_t tsBufFindBlockByTag(STSBuf* pTSBuf, STSVnodeBlockInfo* pBlockInfo
return
-
1
;
}
if
(
pTSBuf
->
block
.
tag
==
tag
)
{
if
(
tVariantCompare
(
&
pTSBuf
->
block
.
tag
,
tag
)
==
0
)
{
return
i
;
}
}
...
...
@@ -669,8 +690,8 @@ STSElem tsBufGetElem(STSBuf* pTSBuf) {
elem1
.
vnode
=
pTSBuf
->
pData
[
pCur
->
vgroupIndex
].
info
.
vnode
;
elem1
.
ts
=
*
(
TSKEY
*
)(
pTSBuf
->
tsData
.
rawBuf
+
pCur
->
tsIndex
*
TSDB_KEYSIZE
);
elem1
.
tag
=
pBlock
->
tag
;
tVariantAssign
(
&
elem1
.
tag
,
&
pBlock
->
tag
)
;
return
elem1
;
}
...
...
@@ -800,7 +821,7 @@ STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_
return
pTSBuf
;
}
STSElem
tsBufGetElemStartPos
(
STSBuf
*
pTSBuf
,
int32_t
vnodeId
,
int64_t
tag
)
{
STSElem
tsBufGetElemStartPos
(
STSBuf
*
pTSBuf
,
int32_t
vnodeId
,
tVariant
*
tag
)
{
STSElem
elem
=
{.
vnode
=
-
1
};
if
(
pTSBuf
==
NULL
)
{
...
...
@@ -881,7 +902,9 @@ void tsBufDisplay(STSBuf* pTSBuf) {
while
(
tsBufNextPos
(
pTSBuf
))
{
STSElem
elem
=
tsBufGetElem
(
pTSBuf
);
printf
(
"%d-%"
PRId64
"-%"
PRId64
"
\n
"
,
elem
.
vnode
,
elem
.
tag
,
elem
.
ts
);
if
(
elem
.
tag
.
nType
==
TSDB_DATA_TYPE_BIGINT
)
{
printf
(
"%d-%"
PRId64
"-%"
PRId64
"
\n
"
,
elem
.
vnode
,
elem
.
tag
.
i64Key
,
elem
.
ts
);
}
}
pTSBuf
->
cur
.
order
=
old
;
...
...
src/query/src/qUtil.c
浏览文件 @
45f855ca
...
...
@@ -45,8 +45,8 @@ int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRun
pWindowResInfo
->
curIndex
=
-
1
;
pWindowResInfo
->
size
=
0
;
pWindowResInfo
->
prevSKey
=
TSKEY_INITIAL_VAL
;
pRuntimeEnv
->
summary
.
internalSupSize
+=
sizeof
(
SWindowResult
)
*
threshold
;
SQueryCostInfo
*
pSummary
=
&
pRuntimeEnv
->
summary
;
// use the pointer arraylist
pWindowResInfo
->
pResult
=
calloc
(
threshold
,
sizeof
(
SWindowResult
));
...
...
@@ -54,8 +54,11 @@ int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRun
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
pRuntimeEnv
->
summary
.
internalSupSize
+=
sizeof
(
SWindowResult
)
*
threshold
;
pRuntimeEnv
->
summary
.
internalSupSize
+=
(
pRuntimeEnv
->
pQuery
->
numOfOutput
*
sizeof
(
SResultInfo
)
+
pRuntimeEnv
->
interBufSize
)
*
pWindowResInfo
->
capacity
;
pWindowResInfo
->
interval
=
pRuntimeEnv
->
pQuery
->
intervalTime
;
pSummary
->
internalSupSize
+=
sizeof
(
SWindowResult
)
*
threshold
;
pSummary
->
internalSupSize
+=
(
pRuntimeEnv
->
pQuery
->
numOfOutput
*
sizeof
(
SResultInfo
)
+
pRuntimeEnv
->
interBufSize
)
*
pWindowResInfo
->
capacity
;
pSummary
->
numOfTimeWindows
=
threshold
;
for
(
int32_t
i
=
0
;
i
<
pWindowResInfo
->
capacity
;
++
i
)
{
int32_t
code
=
createQueryResultInfo
(
pRuntimeEnv
->
pQuery
,
&
pWindowResInfo
->
pResult
[
i
],
pRuntimeEnv
->
stableQuery
,
pRuntimeEnv
->
interBufSize
);
...
...
@@ -126,8 +129,8 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SWindowResult
*
pResult
=
&
pWindowResInfo
->
pResult
[
i
];
if
(
pResult
->
status
.
closed
)
{
// remove the window slot from hash table
taosHashRemove
(
pWindowResInfo
->
hashList
,
(
const
char
*
)
&
pResult
->
window
.
skey
,
pWindowResInfo
->
type
);
if
(
pResult
->
closed
)
{
// remove the window slot from hash table
taosHashRemove
(
pWindowResInfo
->
hashList
,
(
const
char
*
)
&
pResult
->
skey
,
pWindowResInfo
->
type
);
}
else
{
break
;
}
...
...
@@ -149,12 +152,12 @@ void clearFirstNTimeWindow(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
pWindowResInfo
->
size
=
remain
;
for
(
int32_t
k
=
0
;
k
<
pWindowResInfo
->
size
;
++
k
)
{
SWindowResult
*
pResult
=
&
pWindowResInfo
->
pResult
[
k
];
int32_t
*
p
=
(
int32_t
*
)
taosHashGet
(
pWindowResInfo
->
hashList
,
(
const
char
*
)
&
pResult
->
window
.
skey
,
int32_t
*
p
=
(
int32_t
*
)
taosHashGet
(
pWindowResInfo
->
hashList
,
(
const
char
*
)
&
pResult
->
skey
,
tDataTypeDesc
[
pWindowResInfo
->
type
].
nSize
);
assert
(
p
!=
NULL
);
int32_t
v
=
(
*
p
-
num
);
assert
(
v
>=
0
&&
v
<=
pWindowResInfo
->
size
);
taosHashPut
(
pWindowResInfo
->
hashList
,
(
char
*
)
&
pResult
->
window
.
skey
,
tDataTypeDesc
[
pWindowResInfo
->
type
].
nSize
,
taosHashPut
(
pWindowResInfo
->
hashList
,
(
char
*
)
&
pResult
->
skey
,
tDataTypeDesc
[
pWindowResInfo
->
type
].
nSize
,
(
char
*
)
&
v
,
sizeof
(
int32_t
));
}
...
...
@@ -173,7 +176,7 @@ void clearClosedTimeWindow(SQueryRuntimeEnv *pRuntimeEnv) {
int32_t
numOfClosedTimeWindow
(
SWindowResInfo
*
pWindowResInfo
)
{
int32_t
i
=
0
;
while
(
i
<
pWindowResInfo
->
size
&&
pWindowResInfo
->
pResult
[
i
].
status
.
closed
)
{
while
(
i
<
pWindowResInfo
->
size
&&
pWindowResInfo
->
pResult
[
i
].
closed
)
{
++
i
;
}
...
...
@@ -184,11 +187,11 @@ void closeAllTimeWindow(SWindowResInfo *pWindowResInfo) {
assert
(
pWindowResInfo
->
size
>=
0
&&
pWindowResInfo
->
capacity
>=
pWindowResInfo
->
size
);
for
(
int32_t
i
=
0
;
i
<
pWindowResInfo
->
size
;
++
i
)
{
if
(
pWindowResInfo
->
pResult
[
i
].
status
.
closed
)
{
if
(
pWindowResInfo
->
pResult
[
i
].
closed
)
{
continue
;
}
pWindowResInfo
->
pResult
[
i
].
status
.
closed
=
true
;
pWindowResInfo
->
pResult
[
i
].
closed
=
true
;
}
}
...
...
@@ -204,7 +207,7 @@ void removeRedundantWindow(SWindowResInfo *pWindowResInfo, TSKEY lastKey, int32_
}
// get the result order
int32_t
resultOrder
=
(
pWindowResInfo
->
pResult
[
0
].
window
.
skey
<
pWindowResInfo
->
pResult
[
1
].
window
.
skey
)
?
1
:-
1
;
int32_t
resultOrder
=
(
pWindowResInfo
->
pResult
[
0
].
skey
<
pWindowResInfo
->
pResult
[
1
]
.
skey
)
?
1
:-
1
;
if
(
order
!=
resultOrder
)
{
return
;
...
...
@@ -212,11 +215,12 @@ void removeRedundantWindow(SWindowResInfo *pWindowResInfo, TSKEY lastKey, int32_
int32_t
i
=
0
;
if
(
order
==
QUERY_ASC_FORWARD_STEP
)
{
while
(
i
<
pWindowResInfo
->
size
&&
(
pWindowResInfo
->
pResult
[
i
].
window
.
ekey
<
lastKey
))
{
TSKEY
ekey
=
pWindowResInfo
->
pResult
[
i
].
skey
+
pWindowResInfo
->
interval
;
while
(
i
<
pWindowResInfo
->
size
&&
(
ekey
<
lastKey
))
{
++
i
;
}
}
else
if
(
order
==
QUERY_DESC_FORWARD_STEP
)
{
while
(
i
<
pWindowResInfo
->
size
&&
(
pWindowResInfo
->
pResult
[
i
].
window
.
skey
>
lastKey
))
{
while
(
i
<
pWindowResInfo
->
size
&&
(
pWindowResInfo
->
pResult
[
i
].
skey
>
lastKey
))
{
++
i
;
}
}
...
...
@@ -227,11 +231,11 @@ void removeRedundantWindow(SWindowResInfo *pWindowResInfo, TSKEY lastKey, int32_
}
bool
isWindowResClosed
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
)
{
return
(
getWindowResult
(
pWindowResInfo
,
slot
)
->
status
.
closed
==
true
);
return
(
getWindowResult
(
pWindowResInfo
,
slot
)
->
closed
==
true
);
}
void
closeTimeWindow
(
SWindowResInfo
*
pWindowResInfo
,
int32_t
slot
)
{
getWindowResult
(
pWindowResInfo
,
slot
)
->
status
.
closed
=
true
;
getWindowResult
(
pWindowResInfo
,
slot
)
->
closed
=
true
;
}
void
clearTimeWindowResBuf
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SWindowResult
*
pWindowRes
)
{
...
...
@@ -253,8 +257,8 @@ void clearTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pWindow
pWindowRes
->
numOfRows
=
0
;
pWindowRes
->
pos
=
(
SPosInfo
){
-
1
,
-
1
};
pWindowRes
->
status
.
closed
=
false
;
pWindowRes
->
window
=
TSWINDOW_INITIALIZER
;
pWindowRes
->
closed
=
false
;
pWindowRes
->
skey
=
TSKEY_INITIAL_VAL
;
}
/**
...
...
@@ -264,8 +268,8 @@ void clearTimeWindowResBuf(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *pWindow
*/
void
copyTimeWindowResBuf
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SWindowResult
*
dst
,
const
SWindowResult
*
src
)
{
dst
->
numOfRows
=
src
->
numOfRows
;
dst
->
window
=
src
->
window
;
dst
->
status
=
src
->
status
;
dst
->
skey
=
src
->
skey
;
dst
->
closed
=
src
->
closed
;
int32_t
nOutputCols
=
pRuntimeEnv
->
pQuery
->
numOfOutput
;
...
...
src/query/src/sql.c
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
src/query/tests/tsBufTest.cpp
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
src/query/tests/unitTest.cpp
浏览文件 @
45f855ca
...
...
@@ -16,7 +16,7 @@
namespace
{
int32_t
testValidateName
(
char
*
name
)
{
SS
QL
Token
token
=
{
0
};
SS
tr
Token
token
=
{
0
};
token
.
z
=
name
;
token
.
n
=
strlen
(
name
);
token
.
type
=
0
;
...
...
@@ -720,8 +720,8 @@ TEST(testCase, tGetToken_Test) {
EXPECT_FALSE
(
type
==
TK_HEX
);
}
static
SS
QL
Token
createStrToken
(
char
*
s
)
{
SS
QL
Token
t
=
{
0
};
//.type = TK_STRING, .z = s, .n = strlen(s)};
static
SS
tr
Token
createStrToken
(
char
*
s
)
{
SS
tr
Token
t
=
{
0
};
//.type = TK_STRING, .z = s, .n = strlen(s)};
t
.
type
=
TK_STRING
;
t
.
z
=
s
;
t
.
n
=
strlen
(
s
);
...
...
@@ -730,7 +730,7 @@ static SSQLToken createStrToken(char* s) {
}
TEST
(
testCase
,
isValidNumber_test
)
{
SS
QL
Token
t1
=
createStrToken
(
"123abc"
);
SS
tr
Token
t1
=
createStrToken
(
"123abc"
);
EXPECT_EQ
(
isValidNumber
(
&
t1
),
TK_ILLEGAL
);
...
...
src/tsdb/src/tsdbRead.c
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
src/util/inc/tcache.h
浏览文件 @
45f855ca
...
...
@@ -103,7 +103,7 @@ SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInSeconds, bool ext
* @param keepTime survival time in second
* @return cached element
*/
void
*
taosCachePut
(
SCacheObj
*
pCacheObj
,
const
void
*
key
,
size_t
keyLen
,
const
void
*
pData
,
size_t
dataSize
,
int
keepTimeInSeconds
);
void
*
taosCachePut
(
SCacheObj
*
pCacheObj
,
const
void
*
key
,
size_t
keyLen
,
const
void
*
pData
,
size_t
dataSize
,
int
durationMS
);
/**
* get data from cache
...
...
@@ -113,16 +113,6 @@ void *taosCachePut(SCacheObj *pCacheObj, const void *key, size_t keyLen, const v
*/
void
*
taosCacheAcquireByKey
(
SCacheObj
*
pCacheObj
,
const
void
*
key
,
size_t
keyLen
);
/**
* update the expire time of data in cache
* @param pCacheObj cache object
* @param key key
* @param keyLen keyLen
* @param expireTime new expire time of data
* @return
*/
//void* taosCacheUpdateExpireTimeByName(SCacheObj *pCacheObj, void *key, size_t keyLen, uint64_t expireTime);
/**
* Add one reference count for the exist data, and assign this data for a new owner.
* The new owner needs to invoke the taosCacheRelease when it does not need this data anymore.
...
...
src/util/inc/tlockfree.h
浏览文件 @
45f855ca
...
...
@@ -36,6 +36,14 @@ typedef void (*_ref_fn_t)(const void* pObj);
_ref_fn_t end; \
} _ref_func = {.begin = (s), .end = (e)};
// set the initial reference count value
#define T_REF_INIT_VAL(x, _v) \
do { \
assert(_v >= 0); \
atomic_store_32(&((x)->_ref.val), (_v)); \
} while (0)
// increase the reference count by 1
#define T_REF_INC(x) (atomic_add_fetch_32(&((x)->_ref.val), 1))
#define T_REF_INC_WITH_CB(x, p) \
...
...
src/util/inc/tstoken.h
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
src/util/src/hash.c
浏览文件 @
45f855ca
...
...
@@ -657,7 +657,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
}
int64_t
st
=
taosGetTimestampUs
();
void
*
pNewEntryList
=
realloc
(
pHashObj
->
hashList
,
sizeof
(
void
*
)
*
newSize
);
void
*
pNewEntryList
=
realloc
(
pHashObj
->
hashList
,
sizeof
(
void
*
)
*
newSize
);
if
(
pNewEntryList
==
NULL
)
{
// todo handle error
// uDebug("cache resize failed due to out of memory, capacity remain:%d", pHashObj->capacity);
return
;
...
...
src/util/src/tcache.c
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
src/util/src/version.c.in
浏览文件 @
45f855ca
char version[12] = "${TD_VER_
1}.${TD_VER_2}.${TD_VER_3}.${TD_VER_4
}";
char version[12] = "${TD_VER_
NUMBER
}";
char compatible_version[12] = "${TD_VER_COMPATIBLE}";
char gitinfo[48] = "${TD_VER_GIT}";
char gitinfoOfInternal[48] = "${TD_VER_GIT_INTERNAL}";
char buildinfo[64] = "Built at ${TD_VER_DATE}";
void libtaos_${TD_
VER_1}_${TD_VER_2}_${TD_VER_3}_${TD_VER_4
}_${TD_VER_OSTYPE}_${TD_VER_CPUTYPE}_${TD_VER_VERTYPE}() {};
void libtaos_${TD_
LIB_VER_NUMBER
}_${TD_VER_OSTYPE}_${TD_VER_CPUTYPE}_${TD_VER_VERTYPE}() {};
src/vnode/src/vnodeMain.c
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
tests/script/general/parser/bug.sim
已删除
100644 → 0
浏览文件 @
72af08d9
此差异已折叠。
点击以展开。
tests/script/general/parser/constCol.sim
0 → 100644
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
tests/script/general/parser/fill_stb.sim
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
tests/script/general/parser/join.sim
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
tests/script/general/parser/lastrow_query.sim
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
tests/script/general/parser/nchar.sim
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
tests/script/general/parser/testSuite.sim
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
tests/script/jenkins/basic.txt
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
tests/script/jenkins/unique.txt
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
tests/script/tmp/prepare.sim
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
tests/script/unique/account/usage.sim
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
tests/script/unique/mnode/mgmt21.sim
0 → 100644
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
tests/script/unique/mnode/testSuite.sim
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
tests/script/wtest.bat
浏览文件 @
45f855ca
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录