Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
7465d0c7
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7465d0c7
编写于
1月 11, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/develop' into feature/sync
上级
cf87f800
4bbef7c9
变更
136
展开全部
隐藏空白更改
内联
并排
Showing
136 changed file
with
6245 addition
and
3439 deletion
+6245
-3439
packaging/tools/install.sh
packaging/tools/install.sh
+2
-2
packaging/tools/install_power.sh
packaging/tools/install_power.sh
+2
-2
packaging/tools/post.sh
packaging/tools/post.sh
+2
-2
src/client/inc/tschemautil.h
src/client/inc/tschemautil.h
+2
-2
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-1
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+1
-2
src/client/src/tscLocal.c
src/client/src/tscLocal.c
+1
-1
src/client/src/tscLocalMerge.c
src/client/src/tscLocalMerge.c
+4
-4
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+122
-112
src/client/src/tscPrepare.c
src/client/src/tscPrepare.c
+10
-10
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+21
-20
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+33
-15
src/client/src/tscServer.c
src/client/src/tscServer.c
+5
-7
src/client/src/tscSql.c
src/client/src/tscSql.c
+16
-0
src/client/src/tscStream.c
src/client/src/tscStream.c
+23
-7
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+4
-3
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+2
-1
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+1
-1
src/common/inc/tvariant.h
src/common/inc/tvariant.h
+4
-3
src/common/src/tglobal.c
src/common/src/tglobal.c
+1
-1
src/common/src/ttypes.c
src/common/src/ttypes.c
+271
-154
src/common/src/tvariant.c
src/common/src/tvariant.c
+231
-276
src/cq/src/cqMain.c
src/cq/src/cqMain.c
+7
-2
src/dnode/src/dnodeSystem.c
src/dnode/src/dnodeSystem.c
+1
-1
src/inc/taos.h
src/inc/taos.h
+4
-0
src/inc/taosdef.h
src/inc/taosdef.h
+32
-17
src/inc/taoserror.h
src/inc/taoserror.h
+1
-0
src/inc/ttokendef.h
src/inc/ttokendef.h
+108
-106
src/inc/ttype.h
src/inc/ttype.h
+50
-21
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+16
-0
src/kit/taosdemox/insert.json
src/kit/taosdemox/insert.json
+2
-1
src/kit/taosdemox/taosdemox.c
src/kit/taosdemox/taosdemox.c
+76
-23
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+27
-7
src/os/inc/osString.h
src/os/inc/osString.h
+1
-1
src/os/inc/osSysinfo.h
src/os/inc/osSysinfo.h
+1
-0
src/os/src/detail/osString.c
src/os/src/detail/osString.c
+3
-3
src/os/src/linux/linuxEnv.c
src/os/src/linux/linuxEnv.c
+19
-1
src/query/inc/qArithmeticOperator.h
src/query/inc/qArithmeticOperator.h
+5
-5
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+1
-1
src/query/inc/qUtil.h
src/query/inc/qUtil.h
+3
-4
src/query/inc/queryLog.h
src/query/inc/queryLog.h
+1
-2
src/query/inc/sql.y
src/query/inc/sql.y
+7
-0
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+262
-182
src/query/src/qArithmeticOperator.c
src/query/src/qArithmeticOperator.c
+2735
-300
src/query/src/qAst.c
src/query/src/qAst.c
+24
-24
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+36
-69
src/query/src/qFilterfunc.c
src/query/src/qFilterfunc.c
+347
-510
src/query/src/qHistogram.c
src/query/src/qHistogram.c
+3
-3
src/query/src/qParserImpl.c
src/query/src/qParserImpl.c
+60
-50
src/query/src/qTokenizer.c
src/query/src/qTokenizer.c
+1
-0
src/query/src/qTsbuf.c
src/query/src/qTsbuf.c
+3
-3
src/query/src/sql.c
src/query/src/sql.c
+1158
-1146
src/query/tests/astTest.cpp
src/query/tests/astTest.cpp
+2
-2
src/query/tests/tsBufTest.cpp
src/query/tests/tsBufTest.cpp
+21
-21
src/query/tests/unitTest.cpp
src/query/tests/unitTest.cpp
+34
-34
src/tsdb/src/tsdbRWHelper.c
src/tsdb/src/tsdbRWHelper.c
+2
-2
src/util/inc/tstoken.h
src/util/inc/tstoken.h
+1
-2
src/util/src/tcompare.c
src/util/src/tcompare.c
+32
-2
tests/script/general/parser/alter.sim
tests/script/general/parser/alter.sim
+4
-4
tests/script/general/parser/alter1.sim
tests/script/general/parser/alter1.sim
+2
-2
tests/script/general/parser/alter_stable.sim
tests/script/general/parser/alter_stable.sim
+1
-1
tests/script/general/parser/auto_create_tb.sim
tests/script/general/parser/auto_create_tb.sim
+2
-2
tests/script/general/parser/auto_create_tb_drop_tb.sim
tests/script/general/parser/auto_create_tb_drop_tb.sim
+2
-2
tests/script/general/parser/binary_escapeCharacter.sim
tests/script/general/parser/binary_escapeCharacter.sim
+1
-1
tests/script/general/parser/col_arithmetic_operation.sim
tests/script/general/parser/col_arithmetic_operation.sim
+1
-1
tests/script/general/parser/columnValue.sim
tests/script/general/parser/columnValue.sim
+2
-1
tests/script/general/parser/columnValue_bigint.sim
tests/script/general/parser/columnValue_bigint.sim
+3
-3
tests/script/general/parser/columnValue_bool.sim
tests/script/general/parser/columnValue_bool.sim
+1
-1
tests/script/general/parser/columnValue_double.sim
tests/script/general/parser/columnValue_double.sim
+1
-1
tests/script/general/parser/columnValue_float.sim
tests/script/general/parser/columnValue_float.sim
+109
-96
tests/script/general/parser/columnValue_int.sim
tests/script/general/parser/columnValue_int.sim
+1
-1
tests/script/general/parser/columnValue_smallint.sim
tests/script/general/parser/columnValue_smallint.sim
+1
-1
tests/script/general/parser/columnValue_tinyint.sim
tests/script/general/parser/columnValue_tinyint.sim
+1
-1
tests/script/general/parser/columnValue_unsign.sim
tests/script/general/parser/columnValue_unsign.sim
+109
-0
tests/script/general/parser/commit.sim
tests/script/general/parser/commit.sim
+3
-3
tests/script/general/parser/create_db.sim
tests/script/general/parser/create_db.sim
+1
-1
tests/script/general/parser/create_mt.sim
tests/script/general/parser/create_mt.sim
+1
-1
tests/script/general/parser/create_tb.sim
tests/script/general/parser/create_tb.sim
+1
-1
tests/script/general/parser/dbtbnameValidate.sim
tests/script/general/parser/dbtbnameValidate.sim
+1
-1
tests/script/general/parser/fill.sim
tests/script/general/parser/fill.sim
+1
-1
tests/script/general/parser/fill_stb.sim
tests/script/general/parser/fill_stb.sim
+1
-1
tests/script/general/parser/fill_us.sim
tests/script/general/parser/fill_us.sim
+1
-1
tests/script/general/parser/first_last.sim
tests/script/general/parser/first_last.sim
+3
-3
tests/script/general/parser/first_last_query.sim
tests/script/general/parser/first_last_query.sim
+1
-1
tests/script/general/parser/function.sim
tests/script/general/parser/function.sim
+2
-2
tests/script/general/parser/groupby.sim
tests/script/general/parser/groupby.sim
+1
-1
tests/script/general/parser/import.sim
tests/script/general/parser/import.sim
+2
-2
tests/script/general/parser/import_commit1.sim
tests/script/general/parser/import_commit1.sim
+1
-1
tests/script/general/parser/import_commit2.sim
tests/script/general/parser/import_commit2.sim
+1
-1
tests/script/general/parser/import_commit3.sim
tests/script/general/parser/import_commit3.sim
+1
-1
tests/script/general/parser/insert_multiTbl.sim
tests/script/general/parser/insert_multiTbl.sim
+1
-1
tests/script/general/parser/insert_tb.sim
tests/script/general/parser/insert_tb.sim
+3
-3
tests/script/general/parser/interp.sim
tests/script/general/parser/interp.sim
+1
-1
tests/script/general/parser/interp_test.sim
tests/script/general/parser/interp_test.sim
+1
-1
tests/script/general/parser/join.sim
tests/script/general/parser/join.sim
+1
-1
tests/script/general/parser/join_multivnode.sim
tests/script/general/parser/join_multivnode.sim
+1
-1
tests/script/general/parser/lastrow.sim
tests/script/general/parser/lastrow.sim
+2
-2
tests/script/general/parser/lastrow_query.sim
tests/script/general/parser/lastrow_query.sim
+1
-1
tests/script/general/parser/limit.sim
tests/script/general/parser/limit.sim
+2
-2
tests/script/general/parser/limit1.sim
tests/script/general/parser/limit1.sim
+1
-1
tests/script/general/parser/limit1_stb.sim
tests/script/general/parser/limit1_stb.sim
+1
-1
tests/script/general/parser/limit1_tb.sim
tests/script/general/parser/limit1_tb.sim
+1
-1
tests/script/general/parser/limit1_tblocks100.sim
tests/script/general/parser/limit1_tblocks100.sim
+1
-1
tests/script/general/parser/limit2.sim
tests/script/general/parser/limit2.sim
+1
-1
tests/script/general/parser/limit2_query.sim
tests/script/general/parser/limit2_query.sim
+1
-1
tests/script/general/parser/limit2_tblocks100.sim
tests/script/general/parser/limit2_tblocks100.sim
+2
-2
tests/script/general/parser/limit_stb.sim
tests/script/general/parser/limit_stb.sim
+1
-1
tests/script/general/parser/limit_tb.sim
tests/script/general/parser/limit_tb.sim
+1
-1
tests/script/general/parser/mixed_blocks.sim
tests/script/general/parser/mixed_blocks.sim
+1
-1
tests/script/general/parser/nchar.sim
tests/script/general/parser/nchar.sim
+1
-1
tests/script/general/parser/null_char.sim
tests/script/general/parser/null_char.sim
+4
-7
tests/script/general/parser/projection_limit_offset.sim
tests/script/general/parser/projection_limit_offset.sim
+1
-1
tests/script/general/parser/selectResNum.sim
tests/script/general/parser/selectResNum.sim
+3
-3
tests/script/general/parser/select_across_vnodes.sim
tests/script/general/parser/select_across_vnodes.sim
+1
-1
tests/script/general/parser/select_from_cache_disk.sim
tests/script/general/parser/select_from_cache_disk.sim
+2
-2
tests/script/general/parser/select_with_tags.sim
tests/script/general/parser/select_with_tags.sim
+1
-1
tests/script/general/parser/set_tag_vals.sim
tests/script/general/parser/set_tag_vals.sim
+1
-1
tests/script/general/parser/single_row_in_tb.sim
tests/script/general/parser/single_row_in_tb.sim
+1
-1
tests/script/general/parser/single_row_in_tb_query.sim
tests/script/general/parser/single_row_in_tb_query.sim
+1
-1
tests/script/general/parser/sliding.sim
tests/script/general/parser/sliding.sim
+1
-1
tests/script/general/parser/slimit.sim
tests/script/general/parser/slimit.sim
+2
-2
tests/script/general/parser/slimit1.sim
tests/script/general/parser/slimit1.sim
+2
-2
tests/script/general/parser/slimit1_query.sim
tests/script/general/parser/slimit1_query.sim
+1
-1
tests/script/general/parser/slimit_alter_tags.sim
tests/script/general/parser/slimit_alter_tags.sim
+2
-2
tests/script/general/parser/slimit_query.sim
tests/script/general/parser/slimit_query.sim
+1
-1
tests/script/general/parser/tags_dynamically_specifiy.sim
tests/script/general/parser/tags_dynamically_specifiy.sim
+2
-2
tests/script/general/parser/tags_filter.sim
tests/script/general/parser/tags_filter.sim
+1
-1
tests/script/general/parser/tbnameIn.sim
tests/script/general/parser/tbnameIn.sim
+1
-1
tests/script/general/parser/tbnameIn_query.sim
tests/script/general/parser/tbnameIn_query.sim
+1
-1
tests/script/general/parser/testSuite.sim
tests/script/general/parser/testSuite.sim
+60
-60
tests/script/general/parser/timestamp.sim
tests/script/general/parser/timestamp.sim
+3
-3
tests/script/general/parser/timestamp_query.sim
tests/script/general/parser/timestamp_query.sim
+1
-1
tests/script/general/parser/topbot.sim
tests/script/general/parser/topbot.sim
+4
-4
tests/script/general/parser/union.sim
tests/script/general/parser/union.sim
+2
-2
tests/script/general/parser/where.sim
tests/script/general/parser/where.sim
+1
-1
tests/tsim/src/simExe.c
tests/tsim/src/simExe.c
+12
-0
未找到文件。
packaging/tools/install.sh
浏览文件 @
7465d0c7
...
...
@@ -348,7 +348,7 @@ function set_ipAsFqdn() {
}
function
local_fqdn_check
()
{
#serverFqdn=$(hostname
-f
)
#serverFqdn=$(hostname)
echo
echo
-e
-n
"System hostname is:
${
GREEN
}
$serverFqdn
${
NC
}
"
echo
...
...
@@ -911,7 +911,7 @@ function install_TDengine() {
## ==============================Main program starts from here============================
serverFqdn
=
$(
hostname
-f
)
serverFqdn
=
$(
hostname
)
if
[
"
$verType
"
==
"server"
]
;
then
# Install server and client
if
[
-x
${
bin_dir
}
/taosd
]
;
then
...
...
packaging/tools/install_power.sh
浏览文件 @
7465d0c7
...
...
@@ -345,7 +345,7 @@ function set_ipAsFqdn() {
}
function
local_fqdn_check
()
{
#serverFqdn=$(hostname
-f
)
#serverFqdn=$(hostname)
echo
echo
-e
-n
"System hostname is:
${
GREEN
}
$serverFqdn
${
NC
}
"
echo
...
...
@@ -881,7 +881,7 @@ function install_PowerDB() {
## ==============================Main program starts from here============================
serverFqdn
=
$(
hostname
-f
)
serverFqdn
=
$(
hostname
)
if
[
"
$verType
"
==
"server"
]
;
then
# Install server and client
if
[
-x
${
bin_dir
}
/powerd
]
;
then
...
...
packaging/tools/post.sh
浏览文件 @
7465d0c7
...
...
@@ -228,7 +228,7 @@ function set_ipAsFqdn() {
}
function
local_fqdn_check
()
{
#serverFqdn=$(hostname
-f
)
#serverFqdn=$(hostname)
echo
echo
-e
-n
"System hostname is:
${
GREEN
}
$serverFqdn
${
NC
}
"
echo
...
...
@@ -492,5 +492,5 @@ function install_TDengine() {
## ==============================Main program starts from here============================
serverFqdn
=
$(
hostname
-f
)
serverFqdn
=
$(
hostname
)
install_TDengine
src/client/inc/tschemautil.h
浏览文件 @
7465d0c7
...
...
@@ -26,7 +26,7 @@ extern "C" {
#define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS)
//struct SSchema;
#define VALIDNUMOFTAGS(x) ((x) >= 0 && (x) <= TSDB_MAX_TAGS)
/**
* get the number of tags of this table
...
...
@@ -91,7 +91,7 @@ SSchema* tscGetColumnSchemaById(STableMeta* pTableMeta, int16_t colId);
* @param numOfCols
* @return
*/
bool
isValidSchema
(
struct
SSchema
*
pSchema
,
int32_t
numOfCol
s
);
bool
isValidSchema
(
struct
SSchema
*
pSchema
,
int32_t
numOfCols
,
int32_t
numOfTag
s
);
/**
* get the schema for the "tbname" column. it is a built column
...
...
src/client/inc/tsclient.h
浏览文件 @
7465d0c7
...
...
@@ -460,7 +460,7 @@ static FORCE_INLINE void tscGetResultColumnChr(SSqlRes* pRes, SFieldInfo* pField
}
else
{
assert
(
bytes
==
tDataTypeDesc
[
type
].
nSize
);
pRes
->
tsrow
[
columnIndex
]
=
isNull
(
pData
,
type
)
?
NULL
:
(
unsigned
char
*
)
&
pInfo
->
pSqlExpr
->
param
[
1
].
i64
Key
;
pRes
->
tsrow
[
columnIndex
]
=
isNull
(
pData
,
type
)
?
NULL
:
(
unsigned
char
*
)
&
pInfo
->
pSqlExpr
->
param
[
1
].
i64
;
pRes
->
length
[
columnIndex
]
=
bytes
;
}
}
else
{
...
...
src/client/src/tscAsync.c
浏览文件 @
7465d0c7
...
...
@@ -388,7 +388,7 @@ void tscAsyncResultOnError(SSqlObj *pSql) {
}
assert
(
pSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
);
tscError
(
"%p
add into queued async res
, code:%s"
,
pSql
,
tstrerror
(
pSql
->
res
.
code
));
tscError
(
"%p
invoke user specified function due to error occured
, code:%s"
,
pSql
,
tstrerror
(
pSql
->
res
.
code
));
SSqlRes
*
pRes
=
&
pSql
->
res
;
if
(
pSql
->
fp
==
NULL
||
pSql
->
fetchFp
==
NULL
){
...
...
@@ -521,7 +521,6 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
}
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
code
);
return
;
}
...
...
src/client/src/tscLocal.c
浏览文件 @
7465d0c7
...
...
@@ -204,7 +204,7 @@ static int32_t tscProcessDescribeTable(SSqlObj *pSql) {
assert
(
tscGetMetaInfo
(
pQueryInfo
,
0
)
->
pTableMeta
!=
NULL
);
const
int32_t
NUM_OF_DESC_TABLE_COLUMNS
=
4
;
const
int32_t
TYPE_COLUMN_LENGTH
=
16
;
const
int32_t
TYPE_COLUMN_LENGTH
=
20
;
const
int32_t
NOTE_COLUMN_MIN_LENGTH
=
8
;
int32_t
noteFieldLen
=
NOTE_COLUMN_MIN_LENGTH
;
...
...
src/client/src/tscLocalMerge.c
浏览文件 @
7465d0c7
...
...
@@ -95,11 +95,11 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalReducer *pReducer, tOrderDesc
int32_t
functionId
=
pExpr
->
functionId
;
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
||
functionId
==
TSDB_FUNC_DIFF
)
{
pCtx
->
ptsOutputBuf
=
pReducer
->
pCtx
[
0
].
aOutputBuf
;
pCtx
->
param
[
2
].
i64
Key
=
pQueryInfo
->
order
.
order
;
pCtx
->
param
[
2
].
i64
=
pQueryInfo
->
order
.
order
;
pCtx
->
param
[
2
].
nType
=
TSDB_DATA_TYPE_BIGINT
;
pCtx
->
param
[
1
].
i64
Key
=
pQueryInfo
->
order
.
orderColId
;
pCtx
->
param
[
1
].
i64
=
pQueryInfo
->
order
.
orderColId
;
}
else
if
(
functionId
==
TSDB_FUNC_APERCT
)
{
pCtx
->
param
[
0
].
i64
Key
=
pExpr
->
param
[
0
].
i64Key
;
pCtx
->
param
[
0
].
i64
=
pExpr
->
param
[
0
].
i64
;
pCtx
->
param
[
0
].
nType
=
pExpr
->
param
[
0
].
nType
;
}
...
...
@@ -1064,7 +1064,7 @@ static void doExecuteSecondaryMerge(SSqlCmd *pCmd, SLocalReducer *pLocalReducer,
}
}
else
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
j
);
pCtx
->
param
[
0
].
i64
Key
=
pExpr
->
param
[
0
].
i64Key
;
pCtx
->
param
[
0
].
i64
=
pExpr
->
param
[
0
].
i64
;
}
pCtx
->
currentStage
=
MERGE_STAGE
;
...
...
src/client/src/tscParseInsert.c
浏览文件 @
7465d0c7
...
...
@@ -20,6 +20,7 @@
#include "os.h"
#include "ttype.h"
#include "hash.h"
#include "tscUtil.h"
#include "tschemautil.h"
...
...
@@ -40,46 +41,9 @@ enum {
static
int32_t
tscAllocateMemIfNeed
(
STableDataBlocks
*
pDataBlock
,
int32_t
rowSize
,
int32_t
*
numOfRows
);
static
int32_t
tscToInteger
(
SStrToken
*
pToken
,
int64_t
*
value
,
char
**
endPtr
)
{
if
(
pToken
->
n
==
0
)
{
return
TK_ILLEGAL
;
}
int32_t
radix
=
10
;
if
(
pToken
->
type
==
TK_HEX
)
{
radix
=
16
;
}
else
if
(
pToken
->
type
==
TK_BIN
)
{
radix
=
2
;
}
errno
=
0
;
*
value
=
strtoll
(
pToken
->
z
,
endPtr
,
radix
);
if
(
**
endPtr
==
'e'
||
**
endPtr
==
'E'
||
**
endPtr
==
'.'
)
{
errno
=
0
;
double
v
=
round
(
strtod
(
pToken
->
z
,
endPtr
));
if
(
v
>
INT64_MAX
||
v
<=
INT64_MIN
)
{
errno
=
ERANGE
;
}
else
{
*
value
=
(
int64_t
)
v
;
}
}
// not a valid integer number, return error
if
(
*
endPtr
-
pToken
->
z
!=
pToken
->
n
)
{
return
TK_ILLEGAL
;
}
return
pToken
->
type
;
}
static
int32_t
tscToDouble
(
SStrToken
*
pToken
,
double
*
value
,
char
**
endPtr
)
{
if
(
pToken
->
n
==
0
)
{
return
TK_ILLEGAL
;
}
errno
=
0
;
*
value
=
strtod
(
pToken
->
z
,
endPtr
);
*
value
=
strto
l
d
(
pToken
->
z
,
endPtr
);
// not a valid integer number, return error
if
((
*
endPtr
-
pToken
->
z
)
!=
pToken
->
n
)
{
...
...
@@ -163,86 +127,119 @@ int tsParseTime(SStrToken *pToken, int64_t *time, char **next, char *error, int1
return
TSDB_CODE_SUCCESS
;
}
// todo extract the null value check
static
bool
isNullStr
(
SStrToken
*
pToken
)
{
return
(
pToken
->
type
==
TK_NULL
)
||
((
pToken
->
type
==
TK_STRING
)
&&
(
pToken
->
n
!=
0
)
&&
(
strncasecmp
(
TSDB_DATA_NULL_STR_L
,
pToken
->
z
,
pToken
->
n
)
==
0
));
}
int32_t
tsParseOneColumnData
(
SSchema
*
pSchema
,
SStrToken
*
pToken
,
char
*
payload
,
char
*
msg
,
char
**
str
,
bool
primaryKey
,
int16_t
timePrec
)
{
int64_t
iv
;
int32_t
numType
;
char
*
endptr
=
NULL
;
errno
=
0
;
// clear the previous existed error information
int32_t
ret
;
char
*
endptr
=
NULL
;
if
(
IS_NUMERIC_TYPE
(
pSchema
->
type
)
&&
pToken
->
n
==
0
)
{
return
tscInvalidSQLErrMsg
(
msg
,
"invalid numeric data"
,
pToken
->
z
);
}
switch
(
pSchema
->
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
{
// bool
if
((
pToken
->
type
==
TK_BOOL
||
pToken
->
type
==
TK_STRING
)
&&
(
pToken
->
n
!=
0
))
{
if
(
strncmp
(
pToken
->
z
,
"true"
,
pToken
->
n
)
==
0
)
{
*
(
uint8_t
*
)
payload
=
TSDB_TRUE
;
}
else
if
(
strncmp
(
pToken
->
z
,
"false"
,
pToken
->
n
)
==
0
)
{
*
(
uint8_t
*
)
payload
=
TSDB_FALSE
;
}
else
if
(
strncasecmp
(
TSDB_DATA_NULL_STR_L
,
pToken
->
z
,
pToken
->
n
)
==
0
)
{
*
(
uint8_t
*
)
payload
=
TSDB_DATA_BOOL_NULL
;
if
(
isNullStr
(
pToken
))
{
*
((
uint8_t
*
)
payload
)
=
TSDB_DATA_BOOL_NULL
;
}
else
{
if
((
pToken
->
type
==
TK_BOOL
||
pToken
->
type
==
TK_STRING
)
&&
(
pToken
->
n
!=
0
))
{
if
(
strncmp
(
pToken
->
z
,
"true"
,
pToken
->
n
)
==
0
)
{
*
(
uint8_t
*
)
payload
=
TSDB_TRUE
;
}
else
if
(
strncmp
(
pToken
->
z
,
"false"
,
pToken
->
n
)
==
0
)
{
*
(
uint8_t
*
)
payload
=
TSDB_FALSE
;
}
else
{
return
tscSQLSyntaxErrMsg
(
msg
,
"invalid bool data"
,
pToken
->
z
);
}
}
else
if
(
pToken
->
type
==
TK_INTEGER
)
{
iv
=
strtoll
(
pToken
->
z
,
NULL
,
10
);
*
(
uint8_t
*
)
payload
=
(
int8_t
)((
iv
==
0
)
?
TSDB_FALSE
:
TSDB_TRUE
);
}
else
if
(
pToken
->
type
==
TK_FLOAT
)
{
double
dv
=
strtod
(
pToken
->
z
,
NULL
);
*
(
uint8_t
*
)
payload
=
(
int8_t
)((
dv
==
0
)
?
TSDB_FALSE
:
TSDB_TRUE
);
}
else
{
return
tsc
SQLSyntax
ErrMsg
(
msg
,
"invalid bool data"
,
pToken
->
z
);
return
tsc
InvalidSQL
ErrMsg
(
msg
,
"invalid bool data"
,
pToken
->
z
);
}
}
else
if
(
pToken
->
type
==
TK_INTEGER
)
{
iv
=
strtoll
(
pToken
->
z
,
NULL
,
10
);
*
(
uint8_t
*
)
payload
=
(
int8_t
)((
iv
==
0
)
?
TSDB_FALSE
:
TSDB_TRUE
);
}
else
if
(
pToken
->
type
==
TK_FLOAT
)
{
double
dv
=
strtod
(
pToken
->
z
,
NULL
);
*
(
uint8_t
*
)
payload
=
(
int8_t
)((
dv
==
0
)
?
TSDB_FALSE
:
TSDB_TRUE
);
}
else
if
(
pToken
->
type
==
TK_NULL
)
{
*
(
uint8_t
*
)
payload
=
TSDB_DATA_BOOL_NULL
;
}
else
{
return
tscInvalidSQLErrMsg
(
msg
,
"invalid bool data"
,
pToken
->
z
);
}
break
;
}
case
TSDB_DATA_TYPE_TINYINT
:
if
(
pToken
->
type
==
TK_NULL
)
{
*
((
int8_t
*
)
payload
)
=
TSDB_DATA_TINYINT_NULL
;
}
else
if
((
pToken
->
type
==
TK_STRING
)
&&
(
pToken
->
n
!=
0
)
&&
(
strncasecmp
(
TSDB_DATA_NULL_STR_L
,
pToken
->
z
,
pToken
->
n
)
==
0
))
{
*
((
int8_t
*
)
payload
)
=
TSDB_DATA_TINYINT_NULL
;
if
(
isNullStr
(
pToken
))
{
*
((
uint8_t
*
)
payload
)
=
TSDB_DATA_TINYINT_NULL
;
}
else
{
numType
=
tscToInteger
(
pToken
,
&
iv
,
&
endptr
);
if
(
TK_ILLEGAL
==
numType
)
{
ret
=
tStrToInteger
(
pToken
->
z
,
pToken
->
type
,
pToken
->
n
,
&
iv
,
true
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
tscInvalidSQLErrMsg
(
msg
,
"invalid tinyint data"
,
pToken
->
z
);
}
else
if
(
errno
==
ERANGE
||
iv
>
INT8_MAX
||
iv
<=
INT8_MIN
)
{
return
tscInvalidSQLErrMsg
(
msg
,
"tinyint data overflow"
,
pToken
->
z
);
}
else
if
(
!
IS_VALID_TINYINT
(
iv
))
{
return
tscInvalidSQLErrMsg
(
msg
,
"data overflow"
,
pToken
->
z
);
}
*
((
uint8_t
*
)
payload
)
=
(
uint8_t
)
iv
;
}
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
if
(
isNullStr
(
pToken
))
{
*
((
uint8_t
*
)
payload
)
=
TSDB_DATA_UTINYINT_NULL
;
}
else
{
ret
=
tStrToInteger
(
pToken
->
z
,
pToken
->
type
,
pToken
->
n
,
&
iv
,
false
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
tscInvalidSQLErrMsg
(
msg
,
"invalid unsigned tinyint data"
,
pToken
->
z
);
}
else
if
(
!
IS_VALID_UTINYINT
(
iv
))
{
return
tscInvalidSQLErrMsg
(
msg
,
"unsigned tinyint data overflow"
,
pToken
->
z
);
}
*
((
int8_t
*
)
payload
)
=
(
int8_t
)
iv
;
*
((
uint8_t
*
)
payload
)
=
(
u
int8_t
)
iv
;
}
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
if
(
pToken
->
type
==
TK_NULL
)
{
*
((
int16_t
*
)
payload
)
=
TSDB_DATA_SMALLINT_NULL
;
}
else
if
((
pToken
->
type
==
TK_STRING
)
&&
(
pToken
->
n
!=
0
)
&&
(
strncasecmp
(
TSDB_DATA_NULL_STR_L
,
pToken
->
z
,
pToken
->
n
)
==
0
))
{
if
(
isNullStr
(
pToken
))
{
*
((
int16_t
*
)
payload
)
=
TSDB_DATA_SMALLINT_NULL
;
}
else
{
numType
=
tscToInteger
(
pToken
,
&
iv
,
&
endptr
);
if
(
TK_ILLEGAL
==
numType
)
{
ret
=
tStrToInteger
(
pToken
->
z
,
pToken
->
type
,
pToken
->
n
,
&
iv
,
true
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
tscInvalidSQLErrMsg
(
msg
,
"invalid smallint data"
,
pToken
->
z
);
}
else
if
(
errno
==
ERANGE
||
iv
>
INT16_MAX
||
iv
<=
INT16_MIN
)
{
}
else
if
(
!
IS_VALID_SMALLINT
(
iv
)
)
{
return
tscInvalidSQLErrMsg
(
msg
,
"smallint data overflow"
,
pToken
->
z
);
}
*
((
int16_t
*
)
payload
)
=
(
int16_t
)
iv
;
}
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
if
(
isNullStr
(
pToken
))
{
*
((
uint16_t
*
)
payload
)
=
TSDB_DATA_USMALLINT_NULL
;
}
else
{
ret
=
tStrToInteger
(
pToken
->
z
,
pToken
->
type
,
pToken
->
n
,
&
iv
,
false
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
tscInvalidSQLErrMsg
(
msg
,
"invalid unsigned smallint data"
,
pToken
->
z
);
}
else
if
(
!
IS_VALID_USMALLINT
(
iv
))
{
return
tscInvalidSQLErrMsg
(
msg
,
"unsigned smallint data overflow"
,
pToken
->
z
);
}
*
((
uint16_t
*
)
payload
)
=
(
uint16_t
)
iv
;
}
break
;
case
TSDB_DATA_TYPE_INT
:
if
(
pToken
->
type
==
TK_NULL
)
{
*
((
int32_t
*
)
payload
)
=
TSDB_DATA_INT_NULL
;
}
else
if
((
pToken
->
type
==
TK_STRING
)
&&
(
pToken
->
n
!=
0
)
&&
(
strncasecmp
(
TSDB_DATA_NULL_STR_L
,
pToken
->
z
,
pToken
->
n
)
==
0
))
{
if
(
isNullStr
(
pToken
))
{
*
((
int32_t
*
)
payload
)
=
TSDB_DATA_INT_NULL
;
}
else
{
numType
=
tscToInteger
(
pToken
,
&
iv
,
&
endptr
);
if
(
TK_ILLEGAL
==
numType
)
{
ret
=
tStrToInteger
(
pToken
->
z
,
pToken
->
type
,
pToken
->
n
,
&
iv
,
true
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
tscInvalidSQLErrMsg
(
msg
,
"invalid int data"
,
pToken
->
z
);
}
else
if
(
errno
==
ERANGE
||
iv
>
INT32_MAX
||
iv
<=
INT32_MIN
)
{
}
else
if
(
!
IS_VALID_INT
(
iv
)
)
{
return
tscInvalidSQLErrMsg
(
msg
,
"int data overflow"
,
pToken
->
z
);
}
...
...
@@ -251,17 +248,30 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SStrToken *pToken, char *payload,
break
;
case
TSDB_DATA_TYPE_UINT
:
if
(
isNullStr
(
pToken
))
{
*
((
uint32_t
*
)
payload
)
=
TSDB_DATA_UINT_NULL
;
}
else
{
ret
=
tStrToInteger
(
pToken
->
z
,
pToken
->
type
,
pToken
->
n
,
&
iv
,
false
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
tscInvalidSQLErrMsg
(
msg
,
"invalid unsigned int data"
,
pToken
->
z
);
}
else
if
(
!
IS_VALID_UINT
(
iv
))
{
return
tscInvalidSQLErrMsg
(
msg
,
"unsigned int data overflow"
,
pToken
->
z
);
}
*
((
uint32_t
*
)
payload
)
=
(
uint32_t
)
iv
;
}
break
;
case
TSDB_DATA_TYPE_BIGINT
:
if
(
pToken
->
type
==
TK_NULL
)
{
*
((
int64_t
*
)
payload
)
=
TSDB_DATA_BIGINT_NULL
;
}
else
if
((
pToken
->
type
==
TK_STRING
)
&&
(
pToken
->
n
!=
0
)
&&
(
strncasecmp
(
TSDB_DATA_NULL_STR_L
,
pToken
->
z
,
pToken
->
n
)
==
0
))
{
if
(
isNullStr
(
pToken
))
{
*
((
int64_t
*
)
payload
)
=
TSDB_DATA_BIGINT_NULL
;
}
else
{
numType
=
tscToInteger
(
pToken
,
&
iv
,
&
endptr
);
if
(
TK_ILLEGAL
==
numType
)
{
ret
=
tStrToInteger
(
pToken
->
z
,
pToken
->
type
,
pToken
->
n
,
&
iv
,
true
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
tscInvalidSQLErrMsg
(
msg
,
"invalid bigint data"
,
pToken
->
z
);
}
else
if
(
errno
==
ERANGE
||
iv
==
INT64_MIN
)
{
}
else
if
(
!
IS_VALID_BIGINT
(
iv
)
)
{
return
tscInvalidSQLErrMsg
(
msg
,
"bigint data overflow"
,
pToken
->
z
);
}
...
...
@@ -269,11 +279,23 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SStrToken *pToken, char *payload,
}
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
if
(
isNullStr
(
pToken
))
{
*
((
uint64_t
*
)
payload
)
=
TSDB_DATA_UBIGINT_NULL
;
}
else
{
ret
=
tStrToInteger
(
pToken
->
z
,
pToken
->
type
,
pToken
->
n
,
&
iv
,
false
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
tscInvalidSQLErrMsg
(
msg
,
"invalid unsigned bigint data"
,
pToken
->
z
);
}
else
if
(
!
IS_VALID_UBIGINT
((
uint64_t
)
iv
))
{
return
tscInvalidSQLErrMsg
(
msg
,
"unsigned bigint data overflow"
,
pToken
->
z
);
}
*
((
uint64_t
*
)
payload
)
=
iv
;
}
break
;
case
TSDB_DATA_TYPE_FLOAT
:
if
(
pToken
->
type
==
TK_NULL
)
{
*
((
int32_t
*
)
payload
)
=
TSDB_DATA_FLOAT_NULL
;
}
else
if
((
pToken
->
type
==
TK_STRING
)
&&
(
pToken
->
n
!=
0
)
&&
(
strncasecmp
(
TSDB_DATA_NULL_STR_L
,
pToken
->
z
,
pToken
->
n
)
==
0
))
{
if
(
isNullStr
(
pToken
))
{
*
((
int32_t
*
)
payload
)
=
TSDB_DATA_FLOAT_NULL
;
}
else
{
double
dv
;
...
...
@@ -281,24 +303,16 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SStrToken *pToken, char *payload,
return
tscInvalidSQLErrMsg
(
msg
,
"illegal float data"
,
pToken
->
z
);
}
float
fv
=
(
float
)
dv
;
if
(((
dv
==
HUGE_VAL
||
dv
==
-
HUGE_VAL
)
&&
errno
==
ERANGE
)
||
(
fv
>
FLT_MAX
||
fv
<
-
FLT_MAX
))
{
if
(((
dv
==
HUGE_VAL
||
dv
==
-
HUGE_VAL
)
&&
errno
==
ERANGE
)
||
dv
>
FLT_MAX
||
dv
<
-
FLT_MAX
||
isinf
(
dv
)
||
isnan
(
dv
))
{
return
tscInvalidSQLErrMsg
(
msg
,
"illegal float data"
,
pToken
->
z
);
}
if
(
isinf
(
fv
)
||
isnan
(
fv
))
{
*
((
int32_t
*
)
payload
)
=
TSDB_DATA_FLOAT_NULL
;
}
*
((
float
*
)
payload
)
=
fv
;
*
((
float
*
)
payload
)
=
(
float
)
dv
;
}
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
if
(
pToken
->
type
==
TK_NULL
)
{
*
((
int64_t
*
)
payload
)
=
TSDB_DATA_DOUBLE_NULL
;
}
else
if
((
pToken
->
type
==
TK_STRING
)
&&
(
pToken
->
n
!=
0
)
&&
(
strncasecmp
(
TSDB_DATA_NULL_STR_L
,
pToken
->
z
,
pToken
->
n
)
==
0
))
{
if
(
isNullStr
(
pToken
))
{
*
((
int64_t
*
)
payload
)
=
TSDB_DATA_DOUBLE_NULL
;
}
else
{
double
dv
;
...
...
@@ -306,15 +320,11 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SStrToken *pToken, char *payload,
return
tscInvalidSQLErrMsg
(
msg
,
"illegal double data"
,
pToken
->
z
);
}
if
(((
dv
==
HUGE_VAL
||
dv
==
-
HUGE_VAL
)
&&
errno
==
ERANGE
)
||
(
dv
>
DBL_MAX
||
dv
<
-
DBL_MAX
))
{
if
(((
dv
==
HUGE_VAL
||
dv
==
-
HUGE_VAL
)
&&
errno
==
ERANGE
)
||
isinf
(
dv
)
||
isnan
(
dv
))
{
return
tscInvalidSQLErrMsg
(
msg
,
"illegal double data"
,
pToken
->
z
);
}
if
(
isinf
(
dv
)
||
isnan
(
dv
))
{
*
((
int64_t
*
)
payload
)
=
TSDB_DATA_DOUBLE_NULL
;
}
else
{
*
((
double
*
)
payload
)
=
dv
;
}
*
((
double
*
)
payload
)
=
dv
;
}
break
;
...
...
@@ -337,7 +347,7 @@ int32_t tsParseOneColumnData(SSchema *pSchema, SStrToken *pToken, char *payload,
setVardataNull
(
payload
,
TSDB_DATA_TYPE_NCHAR
);
}
else
{
// if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long'
size
_t
output
=
0
;
int32
_t
output
=
0
;
if
(
!
taosMbsToUcs4
(
pToken
->
z
,
pToken
->
n
,
varDataVal
(
payload
),
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
,
&
output
))
{
char
buf
[
512
]
=
{
0
};
snprintf
(
buf
,
tListLen
(
buf
),
"%s"
,
strerror
(
errno
));
...
...
src/client/src/tscPrepare.c
浏览文件 @
7465d0c7
...
...
@@ -84,35 +84,35 @@ static int normalStmtBindParam(STscStmt* stmt, TAOS_BIND* bind) {
var
->
nLen
=
0
;
if
(
tb
->
is_null
!=
NULL
&&
*
(
tb
->
is_null
))
{
var
->
nType
=
TSDB_DATA_TYPE_NULL
;
var
->
i64
Key
=
0
;
var
->
i64
=
0
;
continue
;
}
var
->
nType
=
tb
->
buffer_type
;
switch
(
tb
->
buffer_type
)
{
case
TSDB_DATA_TYPE_NULL
:
var
->
i64
Key
=
0
;
var
->
i64
=
0
;
break
;
case
TSDB_DATA_TYPE_BOOL
:
var
->
i64
Key
=
(
*
(
int8_t
*
)
tb
->
buffer
)
?
1
:
0
;
var
->
i64
=
(
*
(
int8_t
*
)
tb
->
buffer
)
?
1
:
0
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
var
->
i64
Key
=
*
(
int8_t
*
)
tb
->
buffer
;
var
->
i64
=
*
(
int8_t
*
)
tb
->
buffer
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
var
->
i64
Key
=
*
(
int16_t
*
)
tb
->
buffer
;
var
->
i64
=
*
(
int16_t
*
)
tb
->
buffer
;
break
;
case
TSDB_DATA_TYPE_INT
:
var
->
i64
Key
=
*
(
int32_t
*
)
tb
->
buffer
;
var
->
i64
=
*
(
int32_t
*
)
tb
->
buffer
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
var
->
i64
Key
=
*
(
int64_t
*
)
tb
->
buffer
;
var
->
i64
=
*
(
int64_t
*
)
tb
->
buffer
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
...
...
@@ -219,7 +219,7 @@ static char* normalStmtBuildSql(STscStmt* stmt) {
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_BIGINT
:
taosStringBuilderAppendInteger
(
&
sb
,
var
->
i64
Key
);
taosStringBuilderAppendInteger
(
&
sb
,
var
->
i64
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
...
...
@@ -616,7 +616,7 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) {
case
TSDB_DATA_TYPE_NCHAR
:
{
switch
(
bind
->
buffer_type
)
{
case
TSDB_DATA_TYPE_NCHAR
:
{
size
_t
output
=
0
;
int32
_t
output
=
0
;
if
(
!
taosMbsToUcs4
(
bind
->
buffer
,
*
bind
->
length
,
varDataVal
(
data
+
param
->
offset
),
param
->
bytes
-
VARSTR_HEADER_SIZE
,
&
output
))
{
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
...
...
@@ -678,7 +678,7 @@ static int doBindParam(char* data, SParamInfo* param, TAOS_BIND* bind) {
return
TSDB_CODE_SUCCESS
;
case
TSDB_DATA_TYPE_NCHAR
:
{
size
_t
output
=
0
;
int32
_t
output
=
0
;
if
(
!
taosMbsToUcs4
(
bind
->
buffer
,
*
bind
->
length
,
varDataVal
(
data
+
param
->
offset
),
param
->
bytes
-
VARSTR_HEADER_SIZE
,
&
output
))
{
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
7465d0c7
...
...
@@ -19,6 +19,7 @@
#define _GNU_SOURCE
#include "os.h"
#include "ttype.h"
#include "qAst.h"
#include "taos.h"
#include "taosmsg.h"
...
...
@@ -484,10 +485,10 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
case
TSDB_SQL_CREATE_USER
:
case
TSDB_SQL_ALTER_USER
:
{
const
char
*
msg5
=
"invalid user rights"
;
const
char
*
msg7
=
"not support options"
;
const
char
*
msg2
=
"invalid user/account name"
;
const
char
*
msg3
=
"name too long"
;
const
char
*
msg5
=
"invalid user rights"
;
const
char
*
msg7
=
"not support options"
;
pCmd
->
command
=
pInfo
->
type
;
...
...
@@ -950,7 +951,7 @@ static bool validateTableColumnInfo(SArray* pFieldList, SSqlCmd* pCmd) {
return
false
;
}
if
(
pField
->
type
<
TSDB_DATA_TYPE_BOOL
||
pField
->
type
>
TSDB_DATA_TYPE_NCHAR
)
{
if
(
!
isValidDataType
(
pField
->
type
)
)
{
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
return
false
;
}
...
...
@@ -1011,7 +1012,7 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC
return
false
;
}
if
(
p
->
type
<
TSDB_DATA_TYPE_BOOL
||
p
->
type
>
TSDB_DATA_TYPE_NCHAR
)
{
if
(
!
isValidDataType
(
p
->
type
)
)
{
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg5
);
return
false
;
}
...
...
@@ -1754,7 +1755,7 @@ static int32_t setExprInfoForFunctions(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS
// set reverse order scan data blocks for last query
if
(
functionID
==
TSDB_FUNC_LAST
)
{
pExpr
->
numOfParams
=
1
;
pExpr
->
param
[
0
].
i64
Key
=
TSDB_ORDER_DESC
;
pExpr
->
param
[
0
].
i64
=
TSDB_ORDER_DESC
;
pExpr
->
param
[
0
].
nType
=
TSDB_DATA_TYPE_INT
;
}
...
...
@@ -1945,7 +1946,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
index
.
columnIndex
);
int16_t
colType
=
pSchema
->
type
;
if
(
colType
<=
TSDB_DATA_TYPE_BOOL
||
colType
>=
TSDB_DATA_TYPE_BINARY
)
{
if
(
!
IS_NUMERIC_TYPE
(
colType
)
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
...
...
@@ -2105,7 +2106,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
if
(
!
TSDB_COL_IS_TAG
(
pIndex
->
flag
)
&&
pIndex
->
colIndex
<
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
))
{
// group by normal columns
SSqlExpr
*
pExpr
=
taosArrayGetP
(
pQueryInfo
->
exprList
,
colIndex
+
i
);
pExpr
->
numOfParams
=
1
;
pExpr
->
param
->
i64
Key
=
TSDB_ORDER_ASC
;
pExpr
->
param
->
i64
=
TSDB_ORDER_ASC
;
break
;
}
...
...
@@ -2182,7 +2183,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
// 2. valid the column type
int16_t
colType
=
pSchema
[
index
.
columnIndex
].
type
;
if
(
colType
==
TSDB_DATA_TYPE_BOOL
||
colType
>=
TSDB_DATA_TYPE_BINARY
)
{
if
(
!
IS_NUMERIC_TYPE
(
colType
)
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
...
...
@@ -2727,7 +2728,7 @@ int32_t tscTansformSQLFuncForSTableQuery(SQueryInfo* pQueryInfo) {
if
((
functionId
>=
TSDB_FUNC_SUM
&&
functionId
<=
TSDB_FUNC_TWA
)
||
(
functionId
>=
TSDB_FUNC_FIRST_DST
&&
functionId
<=
TSDB_FUNC_LAST_DST
)
||
(
functionId
>=
TSDB_FUNC_RATE
&&
functionId
<=
TSDB_FUNC_AVG_IRATE
))
{
if
(
getResultDataInfo
(
pSrcSchema
->
type
,
pSrcSchema
->
bytes
,
functionId
,
(
int32_t
)
pExpr
->
param
[
0
].
i64
Key
,
&
type
,
&
bytes
,
if
(
getResultDataInfo
(
pSrcSchema
->
type
,
pSrcSchema
->
bytes
,
functionId
,
(
int32_t
)
pExpr
->
param
[
0
].
i64
,
&
type
,
&
bytes
,
&
interBytes
,
0
,
true
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
...
...
@@ -2827,7 +2828,7 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery, bool
int32_t
factor
=
functionCompatList
[
tscSqlExprGet
(
pQueryInfo
,
startIdx
)
->
functionId
];
if
(
tscSqlExprGet
(
pQueryInfo
,
0
)
->
functionId
==
TSDB_FUNC_LAST_ROW
&&
(
joinQuery
||
intervalQuery
))
{
return
false
;
return
false
;
}
// diff function cannot be executed with other function
...
...
@@ -4396,8 +4397,8 @@ int32_t getTimeRange(STimeWindow* win, tSQLExpr* pRight, int32_t optr, int16_t t
*
* Additional check to avoid data overflow
*/
if
(
pRight
->
val
.
i64
Key
<=
INT64_MAX
/
1000
)
{
pRight
->
val
.
i64
Key
*=
1000
;
if
(
pRight
->
val
.
i64
<=
INT64_MAX
/
1000
)
{
pRight
->
val
.
i64
*=
1000
;
}
}
else
if
(
pRight
->
nSQLOptr
==
TK_FLOAT
&&
timePrecision
==
TSDB_TIME_PRECISION_MILLI
)
{
pRight
->
val
.
dKey
*=
1000
;
...
...
@@ -5380,22 +5381,22 @@ static int32_t setKeepOption(SSqlCmd* pCmd, SCreateDbMsg* pMsg, SCreateDBInfo* p
tVariantListItem
*
p0
=
taosArrayGet
(
pKeep
,
0
);
switch
(
s
)
{
case
1
:
{
pMsg
->
daysToKeep
=
htonl
((
int32_t
)
p0
->
pVar
.
i64
Key
);
pMsg
->
daysToKeep
=
htonl
((
int32_t
)
p0
->
pVar
.
i64
);
}
break
;
case
2
:
{
tVariantListItem
*
p1
=
taosArrayGet
(
pKeep
,
1
);
pMsg
->
daysToKeep
=
htonl
((
int32_t
)
p0
->
pVar
.
i64
Key
);
pMsg
->
daysToKeep1
=
htonl
((
int32_t
)
p1
->
pVar
.
i64
Key
);
pMsg
->
daysToKeep
=
htonl
((
int32_t
)
p0
->
pVar
.
i64
);
pMsg
->
daysToKeep1
=
htonl
((
int32_t
)
p1
->
pVar
.
i64
);
break
;
}
case
3
:
{
tVariantListItem
*
p1
=
taosArrayGet
(
pKeep
,
1
);
tVariantListItem
*
p2
=
taosArrayGet
(
pKeep
,
2
);
pMsg
->
daysToKeep
=
htonl
((
int32_t
)
p0
->
pVar
.
i64
Key
);
pMsg
->
daysToKeep1
=
htonl
((
int32_t
)
p1
->
pVar
.
i64
Key
);
pMsg
->
daysToKeep2
=
htonl
((
int32_t
)
p2
->
pVar
.
i64
Key
);
pMsg
->
daysToKeep
=
htonl
((
int32_t
)
p0
->
pVar
.
i64
);
pMsg
->
daysToKeep1
=
htonl
((
int32_t
)
p1
->
pVar
.
i64
);
pMsg
->
daysToKeep2
=
htonl
((
int32_t
)
p2
->
pVar
.
i64
);
break
;
}
default:
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg
);
}
...
...
@@ -5561,7 +5562,7 @@ static void doUpdateSqlFunctionForTagPrj(SQueryInfo* pQueryInfo) {
if
((
pExpr
->
functionId
!=
TSDB_FUNC_TAG_DUMMY
&&
pExpr
->
functionId
!=
TSDB_FUNC_TS_DUMMY
)
&&
!
(
pExpr
->
functionId
==
TSDB_FUNC_PRJ
&&
TSDB_COL_IS_UD_COL
(
pExpr
->
colInfo
.
flag
)))
{
SSchema
*
pColSchema
=
&
pSchema
[
pExpr
->
colInfo
.
colIndex
];
getResultDataInfo
(
pColSchema
->
type
,
pColSchema
->
bytes
,
pExpr
->
functionId
,
(
int32_t
)
pExpr
->
param
[
0
].
i64
Key
,
&
pExpr
->
resType
,
getResultDataInfo
(
pColSchema
->
type
,
pColSchema
->
bytes
,
pExpr
->
functionId
,
(
int32_t
)
pExpr
->
param
[
0
].
i64
,
&
pExpr
->
resType
,
&
pExpr
->
resBytes
,
&
pExpr
->
interBytes
,
tagLength
,
isSTable
);
}
}
...
...
@@ -6760,7 +6761,7 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSQLExpr* pS
// check for dividing by 0
if
((
*
pExpr
)
->
_node
.
optr
==
TSDB_BINARY_OP_DIVIDE
)
{
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
if
(
pRight
->
pVal
->
nType
==
TSDB_DATA_TYPE_INT
&&
pRight
->
pVal
->
i64
Key
==
0
)
{
if
(
pRight
->
pVal
->
nType
==
TSDB_DATA_TYPE_INT
&&
pRight
->
pVal
->
i64
==
0
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
}
else
if
(
pRight
->
pVal
->
nType
==
TSDB_DATA_TYPE_FLOAT
&&
pRight
->
pVal
->
dKey
==
0
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
7465d0c7
...
...
@@ -66,30 +66,24 @@ STableComInfo tscGetTableInfo(const STableMeta* pTableMeta) {
return
pTableMeta
->
tableInfo
;
}
bool
isValidSchema
(
struct
SSchema
*
pSchema
,
int32_t
numOfCols
)
{
if
(
!
VALIDNUMOFCOLS
(
numOfCols
))
{
return
false
;
}
/* first column must be the timestamp, which is a primary key */
if
(
pSchema
[
0
].
type
!=
TSDB_DATA_TYPE_TIMESTAMP
)
{
return
false
;
}
/* type is valid, length is valid */
static
bool
doValidateSchema
(
SSchema
*
pSchema
,
int32_t
numOfCols
,
int32_t
maxLen
)
{
int32_t
rowLen
=
0
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
// 1. valid types
if
(
pSchema
[
i
].
type
>
TSDB_DATA_TYPE_TIMESTAMP
||
pSchema
[
i
].
type
<
TSDB_DATA_TYPE_BOOL
)
{
if
(
!
isValidDataType
(
pSchema
[
i
].
type
)
)
{
return
false
;
}
// 2. valid length for each type
if
(
pSchema
[
i
].
type
==
TSDB_DATA_TYPE_
TIMESTAMP
)
{
if
(
pSchema
[
i
].
type
==
TSDB_DATA_TYPE_
BINARY
)
{
if
(
pSchema
[
i
].
bytes
>
TSDB_MAX_BINARY_LEN
)
{
return
false
;
}
}
else
if
(
pSchema
[
i
].
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
pSchema
[
i
].
bytes
>
TSDB_MAX_NCHAR_LEN
)
{
return
false
;
}
}
else
{
if
(
pSchema
[
i
].
bytes
!=
tDataTypeDesc
[
pSchema
[
i
].
type
].
nSize
)
{
return
false
;
...
...
@@ -106,8 +100,32 @@ bool isValidSchema(struct SSchema* pSchema, int32_t numOfCols) {
rowLen
+=
pSchema
[
i
].
bytes
;
}
// valid total length
return
(
rowLen
<=
TSDB_MAX_BYTES_PER_ROW
);
return
rowLen
<=
maxLen
;
}
bool
isValidSchema
(
struct
SSchema
*
pSchema
,
int32_t
numOfCols
,
int32_t
numOfTags
)
{
if
(
!
VALIDNUMOFCOLS
(
numOfCols
))
{
return
false
;
}
if
(
!
VALIDNUMOFTAGS
(
numOfTags
))
{
return
false
;
}
/* first column must be the timestamp, which is a primary key */
if
(
pSchema
[
0
].
type
!=
TSDB_DATA_TYPE_TIMESTAMP
)
{
return
false
;
}
if
(
!
doValidateSchema
(
pSchema
,
numOfCols
,
TSDB_MAX_BYTES_PER_ROW
))
{
return
false
;
}
if
(
!
doValidateSchema
(
&
pSchema
[
numOfCols
],
numOfTags
,
TSDB_MAX_TAGS_LEN
))
{
return
false
;
}
return
true
;
}
SSchema
*
tscGetTableColumnSchema
(
const
STableMeta
*
pTableMeta
,
int32_t
colIndex
)
{
...
...
src/client/src/tscServer.c
浏览文件 @
7465d0c7
...
...
@@ -755,12 +755,10 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SColumn
*
pCol
=
taosArrayGetP
(
pQueryInfo
->
colList
,
i
);
SSchema
*
pColSchema
=
&
pSchema
[
pCol
->
colIndex
.
columnIndex
];
if
(
pCol
->
colIndex
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMeta
)
||
pColSchema
->
type
<
TSDB_DATA_TYPE_BOOL
||
pColSchema
->
type
>
TSDB_DATA_TYPE_NCHAR
)
{
if
(
pCol
->
colIndex
.
columnIndex
>=
tscGetNumOfColumns
(
pTableMeta
)
||
!
isValidDataType
(
pColSchema
->
type
))
{
tscError
(
"%p tid:%d uid:%"
PRIu64
" id:%s, column index out of range, numOfColumns:%d, index:%d, column name:%s"
,
pSql
,
pTableMeta
->
id
.
tid
,
pTableMeta
->
id
.
uid
,
pTableMetaInfo
->
name
,
tscGetNumOfColumns
(
pTableMeta
),
pCol
->
colIndex
.
columnIndex
,
pColSchema
->
name
);
return
TSDB_CODE_TSC_INVALID_SQL
;
}
...
...
@@ -826,7 +824,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
memcpy
(
pMsg
,
pExpr
->
param
[
j
].
pz
,
pExpr
->
param
[
j
].
nLen
);
pMsg
+=
pExpr
->
param
[
j
].
nLen
;
}
else
{
pSqlFuncExpr
->
arg
[
j
].
argValue
.
i64
=
htobe64
(
pExpr
->
param
[
j
].
i64
Key
);
pSqlFuncExpr
->
arg
[
j
].
argValue
.
i64
=
htobe64
(
pExpr
->
param
[
j
].
i64
);
}
}
...
...
@@ -866,7 +864,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
memcpy
(
pMsg
,
pExpr
->
param
[
j
].
pz
,
pExpr
->
param
[
j
].
nLen
);
pMsg
+=
pExpr
->
param
[
j
].
nLen
;
}
else
{
pSqlFuncExpr1
->
arg
[
j
].
argValue
.
i64
=
htobe64
(
pExpr
->
param
[
j
].
i64
Key
);
pSqlFuncExpr1
->
arg
[
j
].
argValue
.
i64
=
htobe64
(
pExpr
->
param
[
j
].
i64
);
}
}
...
...
@@ -944,7 +942,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSchema
*
pColSchema
=
&
pSchema
[
pCol
->
colIndex
.
columnIndex
];
if
((
pCol
->
colIndex
.
columnIndex
>=
numOfTagColumns
||
pCol
->
colIndex
.
columnIndex
<
-
1
)
||
(
pColSchema
->
type
<
TSDB_DATA_TYPE_BOOL
||
pColSchema
->
type
>
TSDB_DATA_TYPE_NCHAR
))
{
(
!
isValidDataType
(
pColSchema
->
type
)
))
{
tscError
(
"%p tid:%d uid:%"
PRIu64
" id:%s, tag index out of range, totalCols:%d, numOfTags:%d, index:%d, column name:%s"
,
pSql
,
pTableMeta
->
id
.
tid
,
pTableMeta
->
id
.
uid
,
pTableMetaInfo
->
name
,
total
,
numOfTagColumns
,
pCol
->
colIndex
.
columnIndex
,
pColSchema
->
name
);
...
...
@@ -1830,7 +1828,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
assert
(
i
==
0
);
}
assert
(
pSchema
->
type
>=
TSDB_DATA_TYPE_BOOL
&&
pSchema
->
type
<=
TSDB_DATA_TYPE_NCHAR
);
assert
(
isValidDataType
(
pSchema
->
type
)
);
pSchema
++
;
}
...
...
src/client/src/tscSql.c
浏览文件 @
7465d0c7
...
...
@@ -788,18 +788,34 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields)
len
+=
sprintf
(
str
+
len
,
"%d"
,
*
((
int8_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
len
+=
sprintf
(
str
+
len
,
"%u"
,
*
((
uint8_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
len
+=
sprintf
(
str
+
len
,
"%d"
,
*
((
int16_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
len
+=
sprintf
(
str
+
len
,
"%u"
,
*
((
uint16_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_INT
:
len
+=
sprintf
(
str
+
len
,
"%d"
,
*
((
int32_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_UINT
:
len
+=
sprintf
(
str
+
len
,
"%u"
,
*
((
uint32_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_BIGINT
:
len
+=
sprintf
(
str
+
len
,
"%"
PRId64
,
*
((
int64_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
len
+=
sprintf
(
str
+
len
,
"%"
PRIu64
,
*
((
uint64_t
*
)
row
[
i
]));
break
;
case
TSDB_DATA_TYPE_FLOAT
:
{
float
fv
=
0
;
fv
=
GET_FLOAT_VAL
(
row
[
i
]);
...
...
src/client/src/tscStream.c
浏览文件 @
7465d0c7
...
...
@@ -65,15 +65,30 @@ static int64_t tscGetRetryDelayTime(SSqlStream* pStream, int64_t slidingTime, in
return
retryDelta
;
}
static
void
setRetryInfo
(
SSqlStream
*
pStream
,
int32_t
code
)
{
SSqlObj
*
pSql
=
pStream
->
pSql
;
pSql
->
res
.
code
=
code
;
int64_t
retryDelayTime
=
tscGetRetryDelayTime
(
pStream
,
pStream
->
interval
.
sliding
,
pStream
->
precision
);
tscDebug
(
"%p stream:%p, get table Meta failed, retry in %"
PRId64
"ms"
,
pSql
,
pStream
,
retryDelayTime
);
tscSetRetryTimer
(
pStream
,
pSql
,
retryDelayTime
);
}
static
void
doLaunchQuery
(
void
*
param
,
TAOS_RES
*
tres
,
int32_t
code
)
{
SSqlStream
*
pStream
=
(
SSqlStream
*
)
param
;
assert
(
pStream
->
pSql
==
tres
&&
code
==
TSDB_CODE_SUCCESS
);
assert
(
pStream
->
pSql
==
tres
);
SSqlObj
*
pSql
=
(
SSqlObj
*
)
tres
;
pSql
->
fp
=
doLaunchQuery
;
pSql
->
fp
=
doLaunchQuery
;
pSql
->
fetchFp
=
doLaunchQuery
;
pSql
->
res
.
completed
=
false
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
setRetryInfo
(
pStream
,
code
);
return
;
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
...
...
@@ -82,6 +97,10 @@ static void doLaunchQuery(void* param, TAOS_RES* tres, int32_t code) {
code
=
tscGetSTableVgroupInfo
(
pSql
,
0
);
}
if
(
code
==
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
return
;
}
// failed to get table Meta or vgroup list, retry in 10sec.
if
(
code
==
TSDB_CODE_SUCCESS
)
{
tscTansformSQLFuncForSTableQuery
(
pQueryInfo
);
...
...
@@ -91,11 +110,8 @@ static void doLaunchQuery(void* param, TAOS_RES* tres, int32_t code) {
pSql
->
fetchFp
=
tscProcessStreamQueryCallback
;
tscDoQuery
(
pSql
);
tscIncStreamExecutionCount
(
pStream
);
}
else
if
(
code
!=
TSDB_CODE_TSC_ACTION_IN_PROGRESS
)
{
pSql
->
res
.
code
=
code
;
int64_t
retryDelayTime
=
tscGetRetryDelayTime
(
pStream
,
pStream
->
interval
.
sliding
,
pStream
->
precision
);
tscDebug
(
"%p stream:%p, get table Meta failed, retry in %"
PRId64
"ms"
,
pSql
,
pStream
,
retryDelayTime
);
tscSetRetryTimer
(
pStream
,
pSql
,
retryDelayTime
);
}
else
{
setRetryInfo
(
pStream
,
code
);
}
}
...
...
src/client/src/tscSubquery.c
浏览文件 @
7465d0c7
...
...
@@ -465,7 +465,7 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
int16_t
colId
=
tscGetJoinTagColIdByUid
(
&
pQueryInfo
->
tagCond
,
pTableMetaInfo
->
pTableMeta
->
id
.
uid
);
// set the tag column id for executor to extract correct tag value
pExpr
->
param
[
0
]
=
(
tVariant
)
{.
i64
Key
=
colId
,
.
nType
=
TSDB_DATA_TYPE_BIGINT
,
.
nLen
=
sizeof
(
int64_t
)};
pExpr
->
param
[
0
]
=
(
tVariant
)
{.
i64
=
colId
,
.
nType
=
TSDB_DATA_TYPE_BIGINT
,
.
nLen
=
sizeof
(
int64_t
)};
pExpr
->
numOfParams
=
1
;
}
...
...
@@ -650,7 +650,7 @@ static void issueTSCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
0
);
int16_t
tagColId
=
tscGetJoinTagColIdByUid
(
&
pSupporter
->
tagCond
,
pTableMetaInfo
->
pTableMeta
->
id
.
uid
);
pExpr
->
param
->
i64
Key
=
tagColId
;
pExpr
->
param
->
i64
=
tagColId
;
pExpr
->
numOfParams
=
1
;
}
...
...
@@ -1547,7 +1547,7 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
int16_t
tagColId
=
tscGetJoinTagColIdByUid
(
&
pSupporter
->
tagCond
,
pTableMetaInfo
->
pTableMeta
->
id
.
uid
);
pExpr
->
param
->
i64
Key
=
tagColId
;
pExpr
->
param
->
i64
=
tagColId
;
pExpr
->
numOfParams
=
1
;
}
...
...
@@ -2120,6 +2120,7 @@ static SSqlObj *tscCreateSTableSubquery(SSqlObj *pSql, SRetrieveSupport *trsuppo
return
pNew
;
}
// todo there is are race condition in this function, while cancel is called by user.
void
tscRetrieveDataRes
(
void
*
param
,
TAOS_RES
*
tres
,
int
code
)
{
// the param may be null, since it may be done by other query threads. and the asyncOnError may enter in this
// function while kill query by a user.
...
...
src/client/src/tscUtil.c
浏览文件 @
7465d0c7
...
...
@@ -71,6 +71,7 @@ void tsSetSTableQueryCond(STagCond* pTagCond, uint64_t uid, SBufferWriter* bw) {
bool
tscQueryTags
(
SQueryInfo
*
pQueryInfo
)
{
int32_t
numOfCols
=
(
int32_t
)
tscSqlExprNumOfExprs
(
pQueryInfo
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SSqlExpr
*
pExpr
=
tscSqlExprGet
(
pQueryInfo
,
i
);
int32_t
functId
=
pExpr
->
functionId
;
...
...
@@ -314,7 +315,7 @@ void tscSetResRawPtr(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
}
else
{
for
(
int32_t
k
=
0
;
k
<
pRes
->
numOfRows
;
++
k
)
{
char
*
p
=
((
char
**
)
pRes
->
urow
)[
i
]
+
k
*
pInfo
->
field
.
bytes
;
memcpy
(
p
,
&
pInfo
->
pSqlExpr
->
param
[
1
].
i64
Key
,
pInfo
->
field
.
bytes
);
memcpy
(
p
,
&
pInfo
->
pSqlExpr
->
param
[
1
].
i64
,
pInfo
->
field
.
bytes
);
}
}
}
...
...
src/common/inc/tglobal.h
浏览文件 @
7465d0c7
...
...
@@ -191,7 +191,7 @@ extern int32_t monDebugFlag;
extern
int32_t
uDebugFlag
;
extern
int32_t
rpcDebugFlag
;
extern
int32_t
odbcDebugFlag
;
extern
int32_t
qDebugFlag
;
extern
u
int32_t
qDebugFlag
;
extern
int32_t
wDebugFlag
;
extern
int32_t
cqDebugFlag
;
extern
int32_t
debugFlag
;
...
...
src/common/inc/tvariant.h
浏览文件 @
7465d0c7
...
...
@@ -28,7 +28,8 @@ typedef struct tVariant {
uint32_t
nType
;
int32_t
nLen
;
// only used for string, for number, it is useless
union
{
int64_t
i64Key
;
int64_t
i64
;
uint64_t
u64
;
double
dKey
;
char
*
pz
;
wchar_t
*
wpz
;
...
...
@@ -36,9 +37,9 @@ typedef struct tVariant {
};
}
tVariant
;
void
tVariantCreate
(
tVariant
*
pVar
,
SStrToken
*
token
);
bool
tVariantIsValid
(
tVariant
*
pVar
);
void
tVariantCreate
FromString
(
tVariant
*
pVar
,
char
*
pz
,
uint32_t
len
,
uint32_t
type
);
void
tVariantCreate
(
tVariant
*
pVar
,
SStrToken
*
token
);
void
tVariantCreateFromBinary
(
tVariant
*
pVar
,
const
char
*
pz
,
size_t
len
,
uint32_t
type
);
...
...
src/common/src/tglobal.c
浏览文件 @
7465d0c7
...
...
@@ -219,7 +219,7 @@ int32_t odbcDebugFlag = 131;
int32_t
httpDebugFlag
=
131
;
int32_t
mqttDebugFlag
=
131
;
int32_t
monDebugFlag
=
131
;
int32_t
qDebugFlag
=
131
;
u
int32_t
qDebugFlag
=
131
;
int32_t
rpcDebugFlag
=
131
;
int32_t
uDebugFlag
=
131
;
int32_t
debugFlag
=
0
;
...
...
src/common/src/ttypes.c
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
src/common/src/tvariant.c
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
src/cq/src/cqMain.c
浏览文件 @
7465d0c7
...
...
@@ -295,6 +295,8 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) {
if
(
pObj
->
pStream
==
NULL
)
{
pObj
->
pStream
=
taos_open_stream
(
pContext
->
dbConn
,
pObj
->
sqlStr
,
cqProcessStreamRes
,
0
,
pObj
,
NULL
);
// TODO the pObj->pStream may be released if error happens
if
(
pObj
->
pStream
)
{
tscSetStreamDestTable
(
pObj
->
pStream
,
pObj
->
dstTable
);
pContext
->
num
++
;
...
...
@@ -306,11 +308,14 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) {
}
static
void
cqProcessStreamRes
(
void
*
param
,
TAOS_RES
*
tres
,
TAOS_ROW
row
)
{
SCqObj
*
pObj
=
(
SCqObj
*
)
param
;
SCqObj
*
pObj
=
(
SCqObj
*
)
param
;
if
(
tres
==
NULL
&&
row
==
NULL
)
{
taos_close_stream
(
pObj
->
pStream
);
pObj
->
pStream
=
NULL
;
return
;
}
SCqContext
*
pContext
=
pObj
->
pContext
;
STSchema
*
pSchema
=
pObj
->
pSchema
;
if
(
pObj
->
pStream
==
NULL
)
return
;
...
...
@@ -336,7 +341,7 @@ static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) {
val
=
((
char
*
)
val
)
-
sizeof
(
VarDataLenT
);
}
else
if
(
c
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
char
buf
[
TSDB_MAX_NCHAR_LEN
];
size
_t
len
=
taos_fetch_lengths
(
tres
)[
i
];
int32
_t
len
=
taos_fetch_lengths
(
tres
)[
i
];
taosMbsToUcs4
(
val
,
len
,
buf
,
sizeof
(
buf
),
&
len
);
memcpy
(
val
+
sizeof
(
VarDataLenT
),
buf
,
len
);
varDataLen
(
val
)
=
len
;
...
...
src/dnode/src/dnodeSystem.c
浏览文件 @
7465d0c7
...
...
@@ -160,7 +160,7 @@ static void signal_handler(int32_t signum, siginfo_t *sigInfo, void *context) {
syslog
(
LOG_INFO
,
"Shut down signal is %d"
,
signum
);
syslog
(
LOG_INFO
,
"Shutting down TDengine service..."
);
// clean the system.
dInfo
(
"shut down signal is %d, sender PID:%d
"
,
signum
,
sigInfo
->
si_pid
);
dInfo
(
"shut down signal is %d, sender PID:%d
cmdline:%s"
,
signum
,
sigInfo
->
si_pid
,
taosGetCmdlineByPID
(
sigInfo
->
si_pid
)
);
// protect the application from receive another signal
struct
sigaction
act
=
{{
0
}};
...
...
src/inc/taos.h
浏览文件 @
7465d0c7
...
...
@@ -42,6 +42,10 @@ typedef void **TAOS_ROW;
#define TSDB_DATA_TYPE_BINARY 8 // string
#define TSDB_DATA_TYPE_TIMESTAMP 9 // 8 bytes
#define TSDB_DATA_TYPE_NCHAR 10 // unicode string
#define TSDB_DATA_TYPE_UTINYINT 11 // 1 byte
#define TSDB_DATA_TYPE_USMALLINT 12 // 2 bytes
#define TSDB_DATA_TYPE_UINT 13 // 4 bytes
#define TSDB_DATA_TYPE_UBIGINT 14 // 8 bytes
typedef
enum
{
TSDB_OPTION_LOCALE
,
...
...
src/inc/taosdef.h
浏览文件 @
7465d0c7
...
...
@@ -60,7 +60,7 @@ typedef struct tstr {
// Bytes for each type.
extern
const
int32_t
TYPE_BYTES
[
1
1
];
extern
const
int32_t
TYPE_BYTES
[
1
5
];
// TODO: replace and remove code below
#define CHAR_BYTES sizeof(char)
...
...
@@ -92,6 +92,11 @@ extern const int32_t TYPE_BYTES[11];
#define TSDB_DATA_NCHAR_NULL 0xFFFFFFFF
#define TSDB_DATA_BINARY_NULL 0xFF
#define TSDB_DATA_UTINYINT_NULL 0xFF
#define TSDB_DATA_USMALLINT_NULL 0xFFFF
#define TSDB_DATA_UINT_NULL 0xFFFFFFFF
#define TSDB_DATA_UBIGINT_NULL 0xFFFFFFFFFFFFFFFFL
#define TSDB_DATA_NULL_STR "NULL"
#define TSDB_DATA_NULL_STR_L "null"
...
...
@@ -131,19 +136,16 @@ do { \
(src) = (void *)((char *)src + sizeof(type));\
} while(0)
#define GET_INT8_VAL(x) (*(int8_t *)(x))
#define GET_INT16_VAL(x) (*(int16_t *)(x))
#define GET_INT32_VAL(x) (*(int32_t *)(x))
#define GET_INT64_VAL(x) (*(int64_t *)(x))
#ifdef _TD_ARM_32
//#define __float_align_declear() float __underlyFloat = 0.0;
//#define __float_align_declear()
//#define GET_FLOAT_VAL_ALIGN(x) (*(int32_t*)&(__underlyFloat) = *(int32_t*)(x); __underlyFloat);
// notes: src must be float or double type variable !!!
//#define SET_FLOAT_VAL_ALIGN(dst, src) (*(int32_t*) dst = *(int32_t*)src);
//#define SET_DOUBLE_VAL_ALIGN(dst, src) (*(int64_t*) dst = *(int64_t*)src);
#define GET_INT8_VAL(x) (*(int8_t *)(x))
#define GET_INT16_VAL(x) (*(int16_t *)(x))
#define GET_INT32_VAL(x) (*(int32_t *)(x))
#define GET_INT64_VAL(x) (*(int64_t *)(x))
#define GET_UINT8_VAL(x) (*(uint8_t*) (x))
#define GET_UINT16_VAL(x) (*(uint16_t *)(x))
#define GET_UINT32_VAL(x) (*(uint32_t *)(x))
#define GET_UINT64_VAL(x) (*(uint64_t *)(x))
#ifdef _TD_ARM_32
float
taos_align_get_float
(
const
char
*
pBuf
);
double
taos_align_get_double
(
const
char
*
pBuf
);
...
...
@@ -171,14 +173,14 @@ typedef struct tDataTypeDescriptor {
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
);
int
(
*
decompFunc
)(
const
char
*
const
input
,
int
compressedSize
,
const
int
nelements
,
char
*
const
output
,
int
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int
bufferSize
);
void
(
*
getStatisFunc
)(
const
TSKEY
*
primaryKey
,
const
void
*
pData
,
int32_t
numofrow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minindex
,
int16_t
*
maxindex
,
int16_t
*
numofnull
);
void
(
*
getStatisFunc
)(
const
void
*
pData
,
int32_t
numofrow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minindex
,
int16_t
*
maxindex
,
int16_t
*
numofnull
);
}
tDataTypeDescriptor
;
extern
tDataTypeDescriptor
tDataTypeDesc
[
1
1
];
extern
tDataTypeDescriptor
tDataTypeDesc
[
1
5
];
bool
isValidDataType
(
int32_t
type
);
//bool isNull(const char *val, int32_t type);
static
FORCE_INLINE
bool
isNull
(
const
char
*
val
,
int32_t
type
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
...
...
@@ -200,6 +202,15 @@ static FORCE_INLINE bool isNull(const char *val, int32_t type) {
return
varDataLen
(
val
)
==
sizeof
(
int32_t
)
&&
*
(
uint32_t
*
)
varDataVal
(
val
)
==
TSDB_DATA_NCHAR_NULL
;
case
TSDB_DATA_TYPE_BINARY
:
return
varDataLen
(
val
)
==
sizeof
(
int8_t
)
&&
*
(
uint8_t
*
)
varDataVal
(
val
)
==
TSDB_DATA_BINARY_NULL
;
case
TSDB_DATA_TYPE_UTINYINT
:
return
*
(
uint8_t
*
)
val
==
TSDB_DATA_UTINYINT_NULL
;
case
TSDB_DATA_TYPE_USMALLINT
:
return
*
(
uint16_t
*
)
val
==
TSDB_DATA_USMALLINT_NULL
;
case
TSDB_DATA_TYPE_UINT
:
return
*
(
uint32_t
*
)
val
==
TSDB_DATA_UINT_NULL
;
case
TSDB_DATA_TYPE_UBIGINT
:
return
*
(
uint64_t
*
)
val
==
TSDB_DATA_UBIGINT_NULL
;
default:
return
false
;
};
...
...
@@ -213,6 +224,10 @@ void* getNullValue(int32_t type);
void
assignVal
(
char
*
val
,
const
char
*
src
,
int32_t
len
,
int32_t
type
);
void
tsDataSwap
(
void
*
pLeft
,
void
*
pRight
,
int32_t
type
,
int32_t
size
,
void
*
buf
);
int32_t
tStrToInteger
(
const
char
*
z
,
int16_t
type
,
int32_t
n
,
int64_t
*
value
,
bool
issigned
);
#define SET_DOUBLE_NULL(v) (*(uint64_t *)(v) = TSDB_DATA_DOUBLE_NULL)
// TODO: check if below is necessary
#define TSDB_RELATION_INVALID 0
#define TSDB_RELATION_LESS 1
...
...
src/inc/taoserror.h
浏览文件 @
7465d0c7
...
...
@@ -180,6 +180,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_TAG_NOT_EXIST, 0, 0x036A, "Tag does n
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_FIELD_ALREAY_EXIST
,
0
,
0x036B
,
"Field already exists"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_FIELD_NOT_EXIST
,
0
,
0x036C
,
"Field does not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_STABLE_NAME
,
0
,
0x036D
,
"Super table does not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG
,
0
,
0x036E
,
"Invalid create table message"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_DB_NOT_SELECTED
,
0
,
0x0380
,
"Database not specified or available"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_DB_ALREADY_EXIST
,
0
,
0x0381
,
"Database already exists"
)
...
...
src/inc/ttokendef.h
浏览文件 @
7465d0c7
...
...
@@ -117,112 +117,114 @@
#define TK_CACHELAST 99
#define TK_LP 100
#define TK_RP 101
#define TK_TAGS 102
#define TK_USING 103
#define TK_AS 104
#define TK_COMMA 105
#define TK_NULL 106
#define TK_SELECT 107
#define TK_UNION 108
#define TK_ALL 109
#define TK_FROM 110
#define TK_VARIABLE 111
#define TK_INTERVAL 112
#define TK_FILL 113
#define TK_SLIDING 114
#define TK_ORDER 115
#define TK_BY 116
#define TK_ASC 117
#define TK_DESC 118
#define TK_GROUP 119
#define TK_HAVING 120
#define TK_LIMIT 121
#define TK_OFFSET 122
#define TK_SLIMIT 123
#define TK_SOFFSET 124
#define TK_WHERE 125
#define TK_NOW 126
#define TK_RESET 127
#define TK_QUERY 128
#define TK_ADD 129
#define TK_COLUMN 130
#define TK_TAG 131
#define TK_CHANGE 132
#define TK_SET 133
#define TK_KILL 134
#define TK_CONNECTION 135
#define TK_STREAM 136
#define TK_COLON 137
#define TK_ABORT 138
#define TK_AFTER 139
#define TK_ATTACH 140
#define TK_BEFORE 141
#define TK_BEGIN 142
#define TK_CASCADE 143
#define TK_CLUSTER 144
#define TK_CONFLICT 145
#define TK_COPY 146
#define TK_DEFERRED 147
#define TK_DELIMITERS 148
#define TK_DETACH 149
#define TK_EACH 150
#define TK_END 151
#define TK_EXPLAIN 152
#define TK_FAIL 153
#define TK_FOR 154
#define TK_IGNORE 155
#define TK_IMMEDIATE 156
#define TK_INITIALLY 157
#define TK_INSTEAD 158
#define TK_MATCH 159
#define TK_KEY 160
#define TK_OF 161
#define TK_RAISE 162
#define TK_REPLACE 163
#define TK_RESTRICT 164
#define TK_ROW 165
#define TK_STATEMENT 166
#define TK_TRIGGER 167
#define TK_VIEW 168
#define TK_COUNT 169
#define TK_SUM 170
#define TK_AVG 171
#define TK_MIN 172
#define TK_MAX 173
#define TK_FIRST 174
#define TK_LAST 175
#define TK_TOP 176
#define TK_BOTTOM 177
#define TK_STDDEV 178
#define TK_PERCENTILE 179
#define TK_APERCENTILE 180
#define TK_LEASTSQUARES 181
#define TK_HISTOGRAM 182
#define TK_DIFF 183
#define TK_SPREAD 184
#define TK_TWA 185
#define TK_INTERP 186
#define TK_LAST_ROW 187
#define TK_RATE 188
#define TK_IRATE 189
#define TK_SUM_RATE 190
#define TK_SUM_IRATE 191
#define TK_AVG_RATE 192
#define TK_AVG_IRATE 193
#define TK_TBID 194
#define TK_SEMI 195
#define TK_NONE 196
#define TK_PREV 197
#define TK_LINEAR 198
#define TK_IMPORT 199
#define TK_METRIC 200
#define TK_TBNAME 201
#define TK_JOIN 202
#define TK_METRICS 203
#define TK_STABLE 204
#define TK_INSERT 205
#define TK_INTO 206
#define TK_VALUES 207
#define TK_UNSIGNED 102
#define TK_TAGS 103
#define TK_USING 104
#define TK_AS 105
#define TK_COMMA 106
#define TK_NULL 107
#define TK_SELECT 108
#define TK_UNION 109
#define TK_ALL 110
#define TK_FROM 111
#define TK_VARIABLE 112
#define TK_INTERVAL 113
#define TK_FILL 114
#define TK_SLIDING 115
#define TK_ORDER 116
#define TK_BY 117
#define TK_ASC 118
#define TK_DESC 119
#define TK_GROUP 120
#define TK_HAVING 121
#define TK_LIMIT 122
#define TK_OFFSET 123
#define TK_SLIMIT 124
#define TK_SOFFSET 125
#define TK_WHERE 126
#define TK_NOW 127
#define TK_RESET 128
#define TK_QUERY 129
#define TK_ADD 130
#define TK_COLUMN 131
#define TK_TAG 132
#define TK_CHANGE 133
#define TK_SET 134
#define TK_KILL 135
#define TK_CONNECTION 136
#define TK_STREAM 137
#define TK_COLON 138
#define TK_ABORT 139
#define TK_AFTER 140
#define TK_ATTACH 141
#define TK_BEFORE 142
#define TK_BEGIN 143
#define TK_CASCADE 144
#define TK_CLUSTER 145
#define TK_CONFLICT 146
#define TK_COPY 147
#define TK_DEFERRED 148
#define TK_DELIMITERS 149
#define TK_DETACH 150
#define TK_EACH 151
#define TK_END 152
#define TK_EXPLAIN 153
#define TK_FAIL 154
#define TK_FOR 155
#define TK_IGNORE 156
#define TK_IMMEDIATE 157
#define TK_INITIALLY 158
#define TK_INSTEAD 159
#define TK_MATCH 160
#define TK_KEY 161
#define TK_OF 162
#define TK_RAISE 163
#define TK_REPLACE 164
#define TK_RESTRICT 165
#define TK_ROW 166
#define TK_STATEMENT 167
#define TK_TRIGGER 168
#define TK_VIEW 169
#define TK_COUNT 170
#define TK_SUM 171
#define TK_AVG 172
#define TK_MIN 173
#define TK_MAX 174
#define TK_FIRST 175
#define TK_LAST 176
#define TK_TOP 177
#define TK_BOTTOM 178
#define TK_STDDEV 179
#define TK_PERCENTILE 180
#define TK_APERCENTILE 181
#define TK_LEASTSQUARES 182
#define TK_HISTOGRAM 183
#define TK_DIFF 184
#define TK_SPREAD 185
#define TK_TWA 186
#define TK_INTERP 187
#define TK_LAST_ROW 188
#define TK_RATE 189
#define TK_IRATE 190
#define TK_SUM_RATE 191
#define TK_SUM_IRATE 192
#define TK_AVG_RATE 193
#define TK_AVG_IRATE 194
#define TK_TBID 195
#define TK_SEMI 196
#define TK_NONE 197
#define TK_PREV 198
#define TK_LINEAR 199
#define TK_IMPORT 200
#define TK_METRIC 201
#define TK_TBNAME 202
#define TK_JOIN 203
#define TK_METRICS 204
#define TK_STABLE 205
#define TK_INSERT 206
#define TK_INTO 207
#define TK_VALUES 208
#define TK_SPACE 300
...
...
src/inc/ttype.h
浏览文件 @
7465d0c7
...
...
@@ -8,27 +8,56 @@ extern "C" {
#include "taosdef.h"
#define GET_TYPED_DATA(_v, _finalType, _type, _data) \
switch (_type) { \
case TSDB_DATA_TYPE_BOOL: \
case TSDB_DATA_TYPE_TINYINT: \
(_v) = (_finalType)GET_INT8_VAL(_data); \
break; \
case TSDB_DATA_TYPE_SMALLINT: \
(_v) = (_finalType)GET_INT16_VAL(_data); \
break; \
case TSDB_DATA_TYPE_BIGINT: \
(_v) = (_finalType)(GET_INT64_VAL(_data)); \
break; \
case TSDB_DATA_TYPE_FLOAT: \
(_v) = (_finalType)GET_FLOAT_VAL(_data); \
break; \
case TSDB_DATA_TYPE_DOUBLE: \
(_v) = (_finalType)GET_DOUBLE_VAL(_data); \
break; \
default: \
(_v) = (_finalType)GET_INT32_VAL(_data); \
break; \
}
do { \
switch (_type) { \
case TSDB_DATA_TYPE_BOOL: \
case TSDB_DATA_TYPE_TINYINT: \
(_v) = (_finalType)GET_INT8_VAL(_data); \
break; \
case TSDB_DATA_TYPE_UTINYINT: \
(_v) = (_finalType)GET_UINT8_VAL(_data); \
break; \
case TSDB_DATA_TYPE_SMALLINT: \
(_v) = (_finalType)GET_INT16_VAL(_data); \
break; \
case TSDB_DATA_TYPE_USMALLINT: \
(_v) = (_finalType)GET_UINT16_VAL(_data); \
break; \
case TSDB_DATA_TYPE_BIGINT: \
(_v) = (_finalType)(GET_INT64_VAL(_data)); \
break; \
case TSDB_DATA_TYPE_UBIGINT: \
(_v) = (_finalType)(GET_UINT64_VAL(_data)); \
break; \
case TSDB_DATA_TYPE_FLOAT: \
(_v) = (_finalType)GET_FLOAT_VAL(_data); \
break; \
case TSDB_DATA_TYPE_DOUBLE: \
(_v) = (_finalType)GET_DOUBLE_VAL(_data); \
break; \
case TSDB_DATA_TYPE_UINT: \
(_v) = (_finalType)GET_UINT32_VAL(_data); \
break; \
default: \
(_v) = (_finalType)GET_INT32_VAL(_data); \
break; \
} \
} while (0)
#define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT)
#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT)
#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE)
#define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t)))
#define IS_VALID_TINYINT(_t) ((_t) > INT8_MIN && (_t) <= INT8_MAX)
#define IS_VALID_SMALLINT(_t) ((_t) > INT16_MIN && (_t) <= INT16_MAX)
#define IS_VALID_INT(_t) ((_t) > INT32_MIN && (_t) <= INT32_MAX)
#define IS_VALID_BIGINT(_t) ((_t) > INT64_MIN && (_t) <= INT64_MAX)
#define IS_VALID_UTINYINT(_t) ((_t) >= 0 && (_t) < UINT8_MAX)
#define IS_VALID_USMALLINT(_t) ((_t) >= 0 && (_t) < UINT16_MAX)
#define IS_VALID_UINT(_t) ((_t) >= 0 && (_t) < UINT32_MAX)
#define IS_VALID_UBIGINT(_t) ((_t) >= 0 && (_t) < UINT64_MAX)
#ifdef __cplusplus
}
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
7465d0c7
...
...
@@ -603,15 +603,27 @@ static void printField(const char* val, TAOS_FIELD* field, int width, int32_t le
case
TSDB_DATA_TYPE_TINYINT
:
printf
(
"%*d"
,
width
,
*
((
int8_t
*
)
val
));
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
printf
(
"%*u"
,
width
,
*
((
uint8_t
*
)
val
));
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
printf
(
"%*d"
,
width
,
*
((
int16_t
*
)
val
));
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
printf
(
"%*u"
,
width
,
*
((
uint16_t
*
)
val
));
break
;
case
TSDB_DATA_TYPE_INT
:
printf
(
"%*d"
,
width
,
*
((
int32_t
*
)
val
));
break
;
case
TSDB_DATA_TYPE_UINT
:
printf
(
"%*u"
,
width
,
*
((
uint32_t
*
)
val
));
break
;
case
TSDB_DATA_TYPE_BIGINT
:
printf
(
"%*"
PRId64
,
width
,
*
((
int64_t
*
)
val
));
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
printf
(
"%*"
PRIu64
,
width
,
*
((
uint64_t
*
)
val
));
break
;
case
TSDB_DATA_TYPE_FLOAT
:
printf
(
"%*.5f"
,
width
,
GET_FLOAT_VAL
(
val
));
break
;
...
...
@@ -679,15 +691,19 @@ static int calcColWidth(TAOS_FIELD* field, int precision) {
return
MAX
(
5
,
width
);
// 'false'
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
return
MAX
(
4
,
width
);
// '-127'
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
return
MAX
(
6
,
width
);
// '-32767'
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
return
MAX
(
11
,
width
);
// '-2147483648'
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
return
MAX
(
21
,
width
);
// '-9223372036854775807'
case
TSDB_DATA_TYPE_FLOAT
:
...
...
src/kit/taosdemox/insert.json
浏览文件 @
7465d0c7
...
...
@@ -5,7 +5,8 @@
"port"
:
6030
,
"user"
:
"root"
,
"password"
:
"taosdata"
,
"thread_count"
:
2
,
"thread_count"
:
4
,
"thread_count_create_tbl"
:
1
,
"result_file"
:
"./insert_res.txt"
,
"databases"
:
[{
"dbinfo"
:
{
...
...
src/kit/taosdemox/taosdemox.c
浏览文件 @
7465d0c7
...
...
@@ -93,9 +93,6 @@ extern char configDir[];
#define MAX_QUERY_SQL_COUNT 10
#define MAX_QUERY_SQL_LENGTH 256
#define MAX_LINE_COUNT_IN_MEM 10000
typedef
enum
CREATE_SUB_TALBE_MOD_EN
{
PRE_CREATE_SUBTBL
,
AUTO_CREATE_SUBTBL
,
...
...
@@ -259,6 +256,7 @@ typedef struct SDbs_S {
bool
queryMode
;
int
threadCount
;
int
threadCountByCreateTbl
;
int
dbCount
;
SDataBase
db
[
MAX_DB_COUNT
];
...
...
@@ -1418,7 +1416,6 @@ static int getAllChildNameOfSuperTable(TAOS * taos, char* dbName, char* sTblName
char
command
[
BUFFER_SIZE
]
=
"
\0
"
;
TAOS_RES
*
res
;
TAOS_ROW
row
=
NULL
;
int
count
=
0
;
char
*
childTblName
=
*
childTblNameOfSuperTbl
;
...
...
@@ -1433,12 +1430,13 @@ static int getAllChildNameOfSuperTable(TAOS * taos, char* dbName, char* sTblName
exit
(
-
1
);
}
int
childTblCount
=
10000
;
count
=
0
;
int
childTblCount
=
10000
;
int
count
=
0
;
childTblName
=
(
char
*
)
calloc
(
1
,
childTblCount
*
TSDB_TABLE_NAME_LEN
);
char
*
pTblName
=
childTblName
;
while
((
row
=
taos_fetch_row
(
res
))
!=
NULL
)
{
strncpy
(
pTblName
,
(
char
*
)
row
[
0
],
TSDB_TABLE_NAME_LEN
);
int32_t
*
len
=
taos_fetch_lengths
(
res
);
strncpy
(
pTblName
,
(
char
*
)
row
[
0
],
len
[
0
]);
//printf("==== sub table name: %s\n", pTblName);
count
++
;
if
(
count
>=
childTblCount
-
1
)
{
...
...
@@ -1829,38 +1827,64 @@ static void createChildTables() {
if
((
AUTO_CREATE_SUBTBL
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
autoCreateTable
)
||
(
TBL_ALREADY_EXISTS
==
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblExists
))
{
continue
;
}
startMultiThreadCreateChildTable
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
colsOfCreatChildTable
,
g_Dbs
.
threadCount
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblCount
,
g_Dbs
.
db
[
i
].
dbName
,
&
(
g_Dbs
.
db
[
i
].
superTbls
[
j
]));
startMultiThreadCreateChildTable
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
colsOfCreatChildTable
,
g_Dbs
.
threadCount
ByCreateTbl
,
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblCount
,
g_Dbs
.
db
[
i
].
dbName
,
&
(
g_Dbs
.
db
[
i
].
superTbls
[
j
]));
g_totalChildTables
+=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblCount
;
}
}
}
/*
static int taosGetLineNum(const char *fileName)
{
int lineNum = 0;
char cmd[1024] = { 0 };
char buf[1024] = { 0 };
sprintf(cmd, "wc -l %s", fileName);
FILE *fp = popen(cmd, "r");
if (fp == NULL) {
fprintf(stderr, "ERROR: failed to execute:%s, error:%s\n", cmd, strerror(errno));
return lineNum;
}
if (fgets(buf, sizeof(buf), fp)) {
int index = strchr((const char*)buf, ' ') - buf;
buf[index] = '\0';
lineNum = atoi(buf);
}
pclose(fp);
return lineNum;
}
*/
/*
Read 10000 lines at most. If more than 10000 lines, continue to read after using
*/
int
readTagFromCsvFileToMem
(
SSuperTable
*
sup
t
erTblInfo
)
{
int
readTagFromCsvFileToMem
(
SSuperTable
*
superTblInfo
)
{
size_t
n
=
0
;
ssize_t
readLen
=
0
;
char
*
line
=
NULL
;
FILE
*
fp
=
fopen
(
sup
t
erTblInfo
->
tagsFile
,
"r"
);
FILE
*
fp
=
fopen
(
superTblInfo
->
tagsFile
,
"r"
);
if
(
fp
==
NULL
)
{
printf
(
"Failed to open tags file: %s, reason:%s
\n
"
,
sup
t
erTblInfo
->
tagsFile
,
strerror
(
errno
));
printf
(
"Failed to open tags file: %s, reason:%s
\n
"
,
superTblInfo
->
tagsFile
,
strerror
(
errno
));
return
-
1
;
}
if
(
sup
t
erTblInfo
->
tagDataBuf
)
{
free
(
sup
t
erTblInfo
->
tagDataBuf
);
sup
t
erTblInfo
->
tagDataBuf
=
NULL
;
if
(
superTblInfo
->
tagDataBuf
)
{
free
(
superTblInfo
->
tagDataBuf
);
superTblInfo
->
tagDataBuf
=
NULL
;
}
supterTblInfo
->
tagDataBuf
=
calloc
(
supterTblInfo
->
lenOfTagOfOneRow
*
MAX_LINE_COUNT_IN_MEM
,
1
);
if
(
supterTblInfo
->
tagDataBuf
==
NULL
)
{
int
tagCount
=
10000
;
int
count
=
0
;
char
*
tagDataBuf
=
calloc
(
1
,
superTblInfo
->
lenOfTagOfOneRow
*
tagCount
);
if
(
tagDataBuf
==
NULL
)
{
printf
(
"Failed to calloc, reason:%s
\n
"
,
strerror
(
errno
));
fclose
(
fp
);
return
-
1
;
}
while
((
readLen
=
getline
(
&
line
,
&
n
,
fp
))
!=
-
1
)
{
if
((
'\r'
==
line
[
readLen
-
1
])
||
(
'\n'
==
line
[
readLen
-
1
]))
{
line
[
--
readLen
]
=
0
;
...
...
@@ -1870,20 +1894,35 @@ int readTagFromCsvFileToMem(SSuperTable * supterTblInfo) {
continue
;
}
memcpy
(
supterTblInfo
->
tagDataBuf
+
supterTblInfo
->
tagSampleCount
*
supt
erTblInfo
->
lenOfTagOfOneRow
,
line
,
readLen
);
supterTblInfo
->
tagSampleC
ount
++
;
memcpy
(
tagDataBuf
+
count
*
sup
erTblInfo
->
lenOfTagOfOneRow
,
line
,
readLen
);
c
ount
++
;
if
(
supterTblInfo
->
tagSampleCount
>=
MAX_LINE_COUNT_IN_MEM
)
{
break
;
if
(
count
>=
tagCount
-
1
)
{
char
*
tmp
=
realloc
(
tagDataBuf
,
(
size_t
)
tagCount
*
1
.
5
*
superTblInfo
->
lenOfTagOfOneRow
);
if
(
tmp
!=
NULL
)
{
tagDataBuf
=
tmp
;
tagCount
=
(
int
)(
tagCount
*
1
.
5
);
memset
(
tagDataBuf
+
count
*
superTblInfo
->
lenOfTagOfOneRow
,
0
,
(
size_t
)((
tagCount
-
count
)
*
superTblInfo
->
lenOfTagOfOneRow
));
}
else
{
// exit, if allocate more memory failed
printf
(
"realloc fail for save tag val from %s
\n
"
,
superTblInfo
->
tagsFile
);
tmfree
(
tagDataBuf
);
free
(
line
);
fclose
(
fp
);
return
-
1
;
}
}
}
superTblInfo
->
tagDataBuf
=
tagDataBuf
;
superTblInfo
->
tagSampleCount
=
count
;
free
(
line
);
fclose
(
fp
);
return
0
;
}
int
readSampleFromJsonFileToMem
(
SSuperTable
*
sup
t
erTblInfo
)
{
int
readSampleFromJsonFileToMem
(
SSuperTable
*
superTblInfo
)
{
// TODO
return
0
;
}
...
...
@@ -2138,6 +2177,16 @@ static bool getMetaFromInsertJsonFile(cJSON* root) {
printf
(
"failed to read json, threads not found"
);
goto
PARSE_OVER
;
}
cJSON
*
threads2
=
cJSON_GetObjectItem
(
root
,
"thread_count_create_tbl"
);
if
(
threads2
&&
threads2
->
type
==
cJSON_Number
)
{
g_Dbs
.
threadCountByCreateTbl
=
threads2
->
valueint
;
}
else
if
(
!
threads2
)
{
g_Dbs
.
threadCountByCreateTbl
=
1
;
}
else
{
printf
(
"failed to read json, threads2 not found"
);
goto
PARSE_OVER
;
}
cJSON
*
dbs
=
cJSON_GetObjectItem
(
root
,
"databases"
);
if
(
!
dbs
||
dbs
->
type
!=
cJSON_Array
)
{
...
...
@@ -3008,6 +3057,10 @@ void postFreeResource() {
free
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleDataBuf
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
sampleDataBuf
=
NULL
;
}
if
(
0
!=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagDataBuf
)
{
free
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagDataBuf
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
tagDataBuf
=
NULL
;
}
if
(
0
!=
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblName
)
{
free
(
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblName
);
g_Dbs
.
db
[
i
].
superTbls
[
j
].
childTblName
=
NULL
;
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
7465d0c7
...
...
@@ -35,12 +35,9 @@
#include "mnodeAcct.h"
#include "mnodeDb.h"
#include "mnodeDnode.h"
#include "mnodeMnode.h"
#include "mnodeProfile.h"
#include "mnodeSdb.h"
#include "mnodeShow.h"
#include "mnodeTable.h"
#include "mnodeUser.h"
#include "mnodeVgroup.h"
#include "mnodeWrite.h"
#include "mnodeRead.h"
...
...
@@ -1003,7 +1000,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
SCMCreateTableMsg
*
pCreate1
=
pMsg
->
rpcMsg
.
pCont
;
if
(
pCreate1
->
numOfTables
==
0
)
{
// todo return to error message
return
TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG
;
}
SCreateTableMsg
*
pCreate
=
(
SCreateTableMsg
*
)((
char
*
)
pCreate1
+
sizeof
(
SCMCreateTableMsg
));
...
...
@@ -1032,16 +1029,39 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
mError
(
"msg:%p, app:%p table:%s, failed to create, no schema input"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pCreate
->
tableId
);
return
TSDB_CODE_MND_INVALID_TABLE_NAME
;
}
memcpy
(
pStable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
SSchema
));
if
(
pStable
->
numOfColumns
>
TSDB_MAX_COLUMNS
||
pStable
->
numOfTags
>
TSDB_MAX_TAGS
)
{
mError
(
"msg:%p, app:%p table:%s, failed to create, too many columns"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pCreate
->
tableId
);
return
TSDB_CODE_MND_INVALID_TABLE_NAME
;
}
pStable
->
nextColId
=
0
;
// TODO extract method to valid the schema
int32_t
schemaLen
=
0
;
int32_t
tagLen
=
0
;
for
(
int32_t
col
=
0
;
col
<
numOfCols
;
col
++
)
{
SSchema
*
tschema
=
pStable
->
schema
;
tschema
[
col
].
colId
=
pStable
->
nextColId
++
;
tschema
[
col
].
bytes
=
htons
(
tschema
[
col
].
bytes
);
// todo 1. check the length of each column; 2. check the total length of all columns
assert
(
tschema
[
col
].
type
>=
TSDB_DATA_TYPE_BOOL
&&
tschema
[
col
].
type
<=
TSDB_DATA_TYPE_NCHAR
);
if
(
col
<
pStable
->
numOfTables
)
{
schemaLen
+=
tschema
[
col
].
bytes
;
}
else
{
tagLen
+=
tschema
[
col
].
bytes
;
}
if
(
!
isValidDataType
(
tschema
[
col
].
type
))
{
mError
(
"msg:%p, app:%p table:%s, failed to create, invalid data type in schema"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pCreate
->
tableId
);
return
TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG
;
}
}
if
(
schemaLen
>
(
TSDB_MAX_BYTES_PER_ROW
||
tagLen
>
TSDB_MAX_TAGS_LEN
))
{
mError
(
"msg:%p, app:%p table:%s, failed to create, schema is too long"
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pCreate
->
tableId
);
return
TSDB_CODE_MND_INVALID_CREATE_TABLE_MSG
;
}
pMsg
->
pTable
=
(
STableObj
*
)
pStable
;
...
...
src/os/inc/osString.h
浏览文件 @
7465d0c7
...
...
@@ -47,7 +47,7 @@ extern "C" {
// USE_LIBICONV
int32_t
taosUcs4ToMbs
(
void
*
ucs4
,
int32_t
ucs4_max_len
,
char
*
mbs
);
bool
taosMbsToUcs4
(
char
*
mbs
,
size_t
mbs_len
,
char
*
ucs4
,
int32_t
ucs4_max_len
,
size_
t
*
len
);
bool
taosMbsToUcs4
(
char
*
mbs
,
size_t
mbs_len
,
char
*
ucs4
,
int32_t
ucs4_max_len
,
in
t
*
len
);
int
tasoUcs4Compare
(
void
*
f1_ucs4
,
void
*
f2_ucs4
,
int
bytes
);
bool
taosValidateEncodec
(
const
char
*
encodec
);
char
*
taosCharsetReplace
(
char
*
charsetstr
);
...
...
src/os/inc/osSysinfo.h
浏览文件 @
7465d0c7
...
...
@@ -32,6 +32,7 @@ void taosPrintOsInfo();
int
taosSystem
(
const
char
*
cmd
)
;
void
taosKillSystem
();
bool
taosGetSystemUid
(
char
*
uid
);
char
*
taosGetCmdlineByPID
(
int
pid
);
// TAOS_OS_FUNC_SYSINFO_CORE
void
taosSetCoreDump
();
...
...
src/os/src/detail/osString.c
浏览文件 @
7465d0c7
...
...
@@ -46,7 +46,7 @@ int32_t taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs) {
return
(
int32_t
)(
ucs4_max_len
-
outLen
);
}
bool
taosMbsToUcs4
(
char
*
mbs
,
size_t
mbsLength
,
char
*
ucs4
,
int32_t
ucs4_max_len
,
size
_t
*
len
)
{
bool
taosMbsToUcs4
(
char
*
mbs
,
size_t
mbsLength
,
char
*
ucs4
,
int32_t
ucs4_max_len
,
int32
_t
*
len
)
{
memset
(
ucs4
,
0
,
ucs4_max_len
);
iconv_t
cd
=
iconv_open
(
DEFAULT_UNICODE_ENCODEC
,
tsCharset
);
size_t
ucs4_input_len
=
mbsLength
;
...
...
@@ -58,7 +58,7 @@ bool taosMbsToUcs4(char *mbs, size_t mbsLength, char *ucs4, int32_t ucs4_max_len
iconv_close
(
cd
);
if
(
len
!=
NULL
)
{
*
len
=
ucs4_max_len
-
outLeft
;
*
len
=
(
int32_t
)(
ucs4_max_len
-
outLeft
)
;
}
return
true
;
...
...
@@ -92,7 +92,7 @@ int32_t taosUcs4ToMbs(void *ucs4, int32_t ucs4_max_len, char *mbs) {
return
len
;
}
bool
taosMbsToUcs4
(
char
*
mbs
,
size_t
mbsLength
,
char
*
ucs4
,
int32_t
ucs4_max_len
,
size
_t
*
len
)
{
bool
taosMbsToUcs4
(
char
*
mbs
,
size_t
mbsLength
,
char
*
ucs4
,
int32_t
ucs4_max_len
,
int32
_t
*
len
)
{
memset
(
ucs4
,
0
,
ucs4_max_len
);
mbstate_t
state
=
{
0
};
int32_t
retlen
=
mbsnrtowcs
((
wchar_t
*
)
ucs4
,
(
const
char
**
)
&
mbs
,
mbsLength
,
ucs4_max_len
/
4
,
&
state
);
...
...
src/os/src/linux/linuxEnv.c
浏览文件 @
7465d0c7
...
...
@@ -39,4 +39,22 @@ void osInit() {
strcpy
(
tsDnodeDir
,
""
);
strcpy
(
tsMnodeDir
,
""
);
strcpy
(
tsOsName
,
"Linux"
);
}
\ No newline at end of file
}
char
cmdline
[
1024
];
char
*
taosGetCmdlineByPID
(
int
pid
)
{
sprintf
(
cmdline
,
"/proc/%d/cmdline"
,
pid
);
FILE
*
f
=
fopen
(
cmdline
,
"r"
);
if
(
f
){
size_t
size
;
size
=
fread
(
cmdline
,
sizeof
(
char
),
1024
,
f
);
if
(
size
>
0
){
if
(
'\n'
==
cmdline
[
size
-
1
])
cmdline
[
size
-
1
]
=
'\0'
;
}
fclose
(
f
);
}
return
cmdline
;
}
src/query/inc/qArithmeticOperator.h
浏览文件 @
7465d0c7
...
...
@@ -13,17 +13,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_
TSYNTAXTREEFUNCTION
_H
#define TDENGINE_
TSYNTAXTREEFUNCTION
_H
#ifndef TDENGINE_
QARITHMETICOPERATOR
_H
#define TDENGINE_
QARITHMETICOPERATOR
_H
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
void
(
*
_
bi_consumer_fn_t
)(
void
*
left
,
void
*
right
,
int32_t
numOfLeft
,
int32_t
numOfRight
,
void
*
outpu
t
,
int32_t
order
);
typedef
void
(
*
_
arithmetic_operator_fn_t
)(
void
*
left
,
int32_t
numLeft
,
int32_t
leftType
,
void
*
right
,
int32_t
numRigh
t
,
int32_t
rightType
,
void
*
output
,
int32_t
order
);
_
bi_consumer_fn_t
getArithmeticOperatorFn
(
int32_t
leftType
,
int32_t
rightType
,
int32_t
o
ptr
);
_
arithmetic_operator_fn_t
getArithmeticOperatorFn
(
int32_t
arithmeticO
ptr
);
#ifdef __cplusplus
}
...
...
src/query/inc/qExecutor.h
浏览文件 @
7465d0c7
...
...
@@ -30,7 +30,7 @@
#include "tsqlfunction.h"
struct
SColumnFilterElem
;
typedef
bool
(
*
__filter_func_t
)(
struct
SColumnFilterElem
*
pFilter
,
c
har
*
val1
,
char
*
val2
);
typedef
bool
(
*
__filter_func_t
)(
struct
SColumnFilterElem
*
pFilter
,
c
onst
char
*
val1
,
const
char
*
val2
,
int16_t
type
);
typedef
int32_t
(
*
__block_search_fn_t
)(
char
*
data
,
int32_t
num
,
int64_t
key
,
int32_t
order
);
typedef
struct
SResultRowPool
{
...
...
src/query/inc/qUtil.h
浏览文件 @
7465d0c7
...
...
@@ -60,11 +60,10 @@ static FORCE_INLINE char *getPosInResultPage(SQueryRuntimeEnv *pRuntimeEnv, int3
pQuery
->
pExpr1
[
columnIndex
].
bytes
*
realRowId
;
}
bool
isNull
_filter
(
SColumnFilterElem
*
pFilter
,
char
*
minval
,
char
*
maxval
);
bool
notNull
_filter
(
SColumnFilterElem
*
pFilter
,
char
*
minval
,
char
*
maxval
);
bool
isNull
Operator
(
SColumnFilterElem
*
pFilter
,
const
char
*
minval
,
const
char
*
maxval
,
int16_t
type
);
bool
notNull
Operator
(
SColumnFilterElem
*
pFilter
,
const
char
*
minval
,
const
char
*
maxval
,
int16_t
type
);
__filter_func_t
*
getRangeFilterFuncArray
(
int32_t
type
);
__filter_func_t
*
getValueFilterFuncArray
(
int32_t
type
);
__filter_func_t
getFilterOperator
(
int32_t
lowerOptr
,
int32_t
upperOptr
);
SResultRowPool
*
initResultRowPool
(
size_t
size
);
SResultRow
*
getNewResultRow
(
SResultRowPool
*
p
);
...
...
src/query/inc/queryLog.h
浏览文件 @
7465d0c7
...
...
@@ -22,8 +22,7 @@ extern "C" {
#include "tlog.h"
extern
int32_t
qDebugFlag
;
extern
int8_t
tscEmbedded
;
extern
uint32_t
qDebugFlag
;
#define qFatal(...) do { if (qDebugFlag & DEBUG_FATAL) { taosPrintLog("QRY FATAL ", 255, __VA_ARGS__); }} while(0)
#define qError(...) do { if (qDebugFlag & DEBUG_ERROR) { taosPrintLog("QRY ERROR ", 255, __VA_ARGS__); }} while(0)
...
...
src/query/inc/sql.y
浏览文件 @
7465d0c7
...
...
@@ -291,6 +291,13 @@ typename(A) ::= ids(X) LP signed(Y) RP. {
}
}
// define the unsigned number type
typename(A) ::= ids(X) UNSIGNED(Z). {
X.type = 0;
X.n = ((Z.z + Z.n) - X.z);
tSqlSetColumnType (&A, &X);
}
%type signed {int64_t}
signed(A) ::= INTEGER(X). { A = strtol(X.z, NULL, 10); }
signed(A) ::= PLUS INTEGER(X). { A = strtol(X.z, NULL, 10); }
...
...
src/query/src/qAggMain.c
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
src/query/src/qArithmeticOperator.c
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
src/query/src/qAst.c
浏览文件 @
7465d0c7
...
...
@@ -197,76 +197,76 @@ void arithmeticTreeTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput,
* exprLeft + exprRight
* the type of returned value of one expression is always double float precious
*/
_
bi_consumer_fn_t
fp
=
getArithmeticOperatorFn
(
TSDB_DATA_TYPE_DOUBLE
,
TSDB_DATA_TYPE_DOUBLE
,
pExprs
->
_node
.
optr
);
fp
(
pLeftOutput
,
pRightOutput
,
numOfRows
,
numOfRows
,
pOutput
,
TSDB_ORDER_ASC
);
_
arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExprs
->
_node
.
optr
);
OperatorFn
(
pLeftOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
pRightOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
// exprLeft + columnRight
_
bi_consumer_fn_t
fp
=
getArithmeticOperatorFn
(
TSDB_DATA_TYPE_DOUBLE
,
pRight
->
pSchema
->
type
,
pExprs
->
_node
.
optr
);
_
arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExprs
->
_node
.
optr
);
// set input buffer
char
*
pInputData
=
getSourceDataBlock
(
param
,
pRight
->
pSchema
->
name
,
pRight
->
pSchema
->
colId
);
if
(
order
==
TSDB_ORDER_DESC
)
{
reverseCopy
(
pdata
,
pInputData
,
pRight
->
pSchema
->
type
,
numOfRows
);
fp
(
pLeftOutput
,
pdata
,
numOfRows
,
numOfRows
,
pOutput
,
TSDB_ORDER_ASC
);
OperatorFn
(
pLeftOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
pdata
,
numOfRows
,
pRight
->
pSchema
->
type
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
{
fp
(
pLeftOutput
,
pInputData
,
numOfRows
,
numOfRows
,
pOutput
,
TSDB_ORDER_ASC
);
OperatorFn
(
pLeftOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
pInputData
,
numOfRows
,
pRight
->
pSchema
->
type
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
// exprLeft + 12
_
bi_consumer_fn_t
fp
=
getArithmeticOperatorFn
(
TSDB_DATA_TYPE_DOUBLE
,
pRight
->
pVal
->
nType
,
pExprs
->
_node
.
optr
);
fp
(
pLeftOutput
,
&
pRight
->
pVal
->
i64Key
,
numOfRows
,
1
,
pOutput
,
TSDB_ORDER_ASC
);
_
arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExprs
->
_node
.
optr
);
OperatorFn
(
pLeftOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
&
pRight
->
pVal
->
i64
,
1
,
pRight
->
pVal
->
nType
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
else
if
(
pLeft
->
nodeType
==
TSQL_NODE_COL
)
{
// column data specified on left-hand-side
char
*
pLeftInputData
=
getSourceDataBlock
(
param
,
pLeft
->
pSchema
->
name
,
pLeft
->
pSchema
->
colId
);
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
)
{
// columnLeft + expr2
_
bi_consumer_fn_t
fp
=
getArithmeticOperatorFn
(
pLeft
->
pSchema
->
type
,
TSDB_DATA_TYPE_DOUBLE
,
pExprs
->
_node
.
optr
);
_
arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExprs
->
_node
.
optr
);
if
(
order
==
TSDB_ORDER_DESC
)
{
reverseCopy
(
pdata
,
pLeftInputData
,
pLeft
->
pSchema
->
type
,
numOfRows
);
fp
(
pdata
,
pRightOutput
,
numOfRows
,
numOfRows
,
pOutput
,
TSDB_ORDER_ASC
);
OperatorFn
(
pdata
,
numOfRows
,
pLeft
->
pSchema
->
type
,
pRightOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
{
fp
(
pLeftInputData
,
pRightOutput
,
numOfRows
,
numOfRows
,
pOutput
,
TSDB_ORDER_ASC
);
OperatorFn
(
pLeftInputData
,
numOfRows
,
pLeft
->
pSchema
->
type
,
pRightOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
// columnLeft + columnRight
// column data specified on right-hand-side
char
*
pRightInputData
=
getSourceDataBlock
(
param
,
pRight
->
pSchema
->
name
,
pRight
->
pSchema
->
colId
);
_
bi_consumer_fn_t
fp
=
getArithmeticOperatorFn
(
pLeft
->
pSchema
->
type
,
pRight
->
pSchema
->
type
,
pExprs
->
_node
.
optr
);
_
arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExprs
->
_node
.
optr
);
// both columns are descending order, do not reverse the source data
fp
(
pLeftInputData
,
pRightInputData
,
numOfRows
,
numOfRows
,
pOutput
,
order
);
OperatorFn
(
pLeftInputData
,
numOfRows
,
pLeft
->
pSchema
->
type
,
pRightInputData
,
numOfRows
,
pRight
->
pSchema
->
type
,
pOutput
,
order
);
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
// columnLeft + 12
_
bi_consumer_fn_t
fp
=
getArithmeticOperatorFn
(
pLeft
->
pSchema
->
type
,
pRight
->
pVal
->
nType
,
pExprs
->
_node
.
optr
);
_
arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExprs
->
_node
.
optr
);
if
(
order
==
TSDB_ORDER_DESC
)
{
reverseCopy
(
pdata
,
pLeftInputData
,
pLeft
->
pSchema
->
type
,
numOfRows
);
fp
(
pdata
,
&
pRight
->
pVal
->
i64Key
,
numOfRows
,
1
,
pOutput
,
TSDB_ORDER_ASC
);
OperatorFn
(
pdata
,
numOfRows
,
pLeft
->
pSchema
->
type
,
&
pRight
->
pVal
->
i64
,
1
,
pRight
->
pVal
->
nType
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
{
fp
(
pLeftInputData
,
&
pRight
->
pVal
->
i64Key
,
numOfRows
,
1
,
pOutput
,
TSDB_ORDER_ASC
);
OperatorFn
(
pLeftInputData
,
numOfRows
,
pLeft
->
pSchema
->
type
,
&
pRight
->
pVal
->
i64
,
1
,
pRight
->
pVal
->
nType
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
}
else
{
// column data specified on left-hand-side
if
(
pRight
->
nodeType
==
TSQL_NODE_EXPR
)
{
// 12 + expr2
_
bi_consumer_fn_t
fp
=
getArithmeticOperatorFn
(
pLeft
->
pVal
->
nType
,
TSDB_DATA_TYPE_DOUBLE
,
pExprs
->
_node
.
optr
);
fp
(
&
pLeft
->
pVal
->
i64Key
,
pRightOutput
,
1
,
numOfRows
,
pOutput
,
TSDB_ORDER_ASC
);
_
arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExprs
->
_node
.
optr
);
OperatorFn
(
&
pLeft
->
pVal
->
i64
,
1
,
pLeft
->
pVal
->
nType
,
pRightOutput
,
numOfRows
,
TSDB_DATA_TYPE_DOUBLE
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_COL
)
{
// 12 + columnRight
// column data specified on right-hand-side
char
*
pRightInputData
=
getSourceDataBlock
(
param
,
pRight
->
pSchema
->
name
,
pRight
->
pSchema
->
colId
);
_
bi_consumer_fn_t
fp
=
getArithmeticOperatorFn
(
pLeft
->
pVal
->
nType
,
pRight
->
pSchema
->
type
,
pExprs
->
_node
.
optr
);
_
arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExprs
->
_node
.
optr
);
if
(
order
==
TSDB_ORDER_DESC
)
{
reverseCopy
(
pdata
,
pRightInputData
,
pRight
->
pSchema
->
type
,
numOfRows
);
fp
(
&
pLeft
->
pVal
->
i64Key
,
pdata
,
numOfRows
,
1
,
pOutput
,
TSDB_ORDER_ASC
);
OperatorFn
(
&
pLeft
->
pVal
->
i64
,
1
,
pLeft
->
pVal
->
nType
,
pdata
,
numOfRows
,
pRight
->
pSchema
->
type
,
pOutput
,
TSDB_ORDER_ASC
);
}
else
{
fp
(
&
pLeft
->
pVal
->
i64Key
,
pRightInputData
,
1
,
numOfRows
,
pOutput
,
TSDB_ORDER_ASC
);
OperatorFn
(
&
pLeft
->
pVal
->
i64
,
1
,
pLeft
->
pVal
->
nType
,
pRightInputData
,
numOfRows
,
pRight
->
pSchema
->
type
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
else
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
// 12 + 12
_
bi_consumer_fn_t
fp
=
getArithmeticOperatorFn
(
pLeft
->
pVal
->
nType
,
pRight
->
pVal
->
nType
,
pExprs
->
_node
.
optr
);
fp
(
&
pLeft
->
pVal
->
i64Key
,
&
pRight
->
pVal
->
i64Key
,
1
,
1
,
pOutput
,
TSDB_ORDER_ASC
);
_
arithmetic_operator_fn_t
OperatorFn
=
getArithmeticOperatorFn
(
pExprs
->
_node
.
optr
);
OperatorFn
(
&
pLeft
->
pVal
->
i64
,
1
,
pLeft
->
pVal
->
nType
,
&
pRight
->
pVal
->
i64
,
1
,
pRight
->
pVal
->
nType
,
pOutput
,
TSDB_ORDER_ASC
);
}
}
...
...
@@ -285,7 +285,7 @@ static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) {
tbufWriteInt32
(
bw
,
pVal
->
nLen
);
tbufWrite
(
bw
,
pVal
->
pz
,
pVal
->
nLen
);
}
else
{
tbufWriteInt64
(
bw
,
pVal
->
i64
Key
);
tbufWriteInt64
(
bw
,
pVal
->
i64
);
}
}
else
if
(
expr
->
nodeType
==
TSQL_NODE_COL
)
{
...
...
@@ -355,7 +355,7 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) {
pVal
->
pz
=
calloc
(
1
,
pVal
->
nLen
+
1
);
tbufReadToBuffer
(
br
,
pVal
->
pz
,
pVal
->
nLen
);
}
else
{
pVal
->
i64
Key
=
tbufReadInt64
(
br
);
pVal
->
i64
=
tbufReadInt64
(
br
);
}
}
else
if
(
pExpr
->
nodeType
==
TSQL_NODE_COL
)
{
...
...
src/query/src/qExecutor.c
浏览文件 @
7465d0c7
...
...
@@ -212,22 +212,22 @@ bool doFilterData(SQuery *pQuery, int32_t elemPos) {
bool
isnull
=
isNull
(
pElem
,
pFilterInfo
->
info
.
type
);
if
(
isnull
)
{
if
(
pFilterElem
->
fp
==
isNull
_filte
r
)
{
if
(
pFilterElem
->
fp
==
isNull
Operato
r
)
{
qualified
=
true
;
break
;
}
else
{
continue
;
}
}
else
{
if
(
pFilterElem
->
fp
==
notNull
_filte
r
)
{
if
(
pFilterElem
->
fp
==
notNull
Operato
r
)
{
qualified
=
true
;
break
;
}
else
if
(
pFilterElem
->
fp
==
isNull
_filte
r
)
{
}
else
if
(
pFilterElem
->
fp
==
isNull
Operato
r
)
{
continue
;
}
}
if
(
pFilterElem
->
fp
(
pFilterElem
,
pElem
,
pElem
))
{
if
(
pFilterElem
->
fp
(
pFilterElem
,
pElem
,
pElem
,
pFilterInfo
->
info
.
type
))
{
qualified
=
true
;
break
;
}
...
...
@@ -759,7 +759,7 @@ static void doUpdateResultRowIndex(SResultRowInfo*pResultRowInfo, TSKEY lastKey,
}
if
(
i
==
pResultRowInfo
->
size
-
1
)
{
pResultRowInfo
->
curIndex
=
i
;
pResultRowInfo
->
curIndex
=
i
;
}
else
{
pResultRowInfo
->
curIndex
=
i
+
1
;
// current not closed result object
}
...
...
@@ -1372,7 +1372,7 @@ static int32_t doTSJoinFilter(SQueryRuntimeEnv *pRuntimeEnv, int32_t offset) {
#if defined(_DEBUG_VIEW)
printf
(
"elem in comp ts file:%"
PRId64
", key:%"
PRId64
", tag:%"
PRIu64
", query order:%d, ts order:%d, traverse:%d, index:%d
\n
"
,
elem
.
ts
,
key
,
elem
.
tag
.
i64
Key
,
pQuery
->
order
.
order
,
pRuntimeEnv
->
pTsBuf
->
tsOrder
,
elem
.
ts
,
key
,
elem
.
tag
.
i64
,
pQuery
->
order
.
order
,
pRuntimeEnv
->
pTsBuf
->
tsOrder
,
pRuntimeEnv
->
pTsBuf
->
cur
.
order
,
pRuntimeEnv
->
pTsBuf
->
cur
.
tsIndex
);
#endif
...
...
@@ -1412,7 +1412,7 @@ static bool functionNeedToExecute(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx
// denote the order type
if
((
functionId
==
TSDB_FUNC_LAST_DST
||
functionId
==
TSDB_FUNC_LAST
))
{
return
pCtx
->
param
[
0
].
i64
Key
==
pQuery
->
order
.
order
;
return
pCtx
->
param
[
0
].
i64
==
pQuery
->
order
.
order
;
}
// in the supplementary scan, only the following functions need to be executed
...
...
@@ -1781,9 +1781,9 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData, TSKEY
* top/bottom values emerge, so does diff function
*/
if
(
functionId
==
TSDB_FUNC_TWA
)
{
pCtx
->
param
[
1
].
i64
Key
=
pQuery
->
window
.
skey
;
pCtx
->
param
[
1
].
i64
=
pQuery
->
window
.
skey
;
pCtx
->
param
[
1
].
nType
=
TSDB_DATA_TYPE_BIGINT
;
pCtx
->
param
[
2
].
i64
Key
=
pQuery
->
window
.
ekey
;
pCtx
->
param
[
2
].
i64
=
pQuery
->
window
.
ekey
;
pCtx
->
param
[
2
].
nType
=
TSDB_DATA_TYPE_BIGINT
;
}
...
...
@@ -1813,7 +1813,7 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void* inputData, TSKEY
}
}
}
else
if
(
functionId
==
TSDB_FUNC_TS_COMP
)
{
pCtx
->
param
[
0
].
i64
Key
=
vgId
;
pCtx
->
param
[
0
].
i64
=
vgId
;
pCtx
->
param
[
0
].
nType
=
TSDB_DATA_TYPE_BIGINT
;
}
...
...
@@ -1952,12 +1952,12 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order
int32_t
f
=
pQuery
->
pExpr1
[
0
].
base
.
functionId
;
assert
(
f
==
TSDB_FUNC_TS
||
f
==
TSDB_FUNC_TS_DUMMY
);
pCtx
->
param
[
2
].
i64
Key
=
order
;
pCtx
->
param
[
2
].
i64
=
order
;
pCtx
->
param
[
2
].
nType
=
TSDB_DATA_TYPE_BIGINT
;
pCtx
->
param
[
3
].
i64
Key
=
functionId
;
pCtx
->
param
[
3
].
i64
=
functionId
;
pCtx
->
param
[
3
].
nType
=
TSDB_DATA_TYPE_BIGINT
;
pCtx
->
param
[
1
].
i64
Key
=
pQuery
->
order
.
orderColId
;
pCtx
->
param
[
1
].
i64
=
pQuery
->
order
.
orderColId
;
}
if
(
functionId
==
TSDB_FUNC_ARITHM
)
{
...
...
@@ -2478,7 +2478,7 @@ static bool needToLoadDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis *pDat
// if isNULL query exists, load the null data column
for
(
int32_t
j
=
0
;
j
<
pFilterInfo
->
numOfFilters
;
++
j
)
{
SColumnFilterElem
*
pFilterElem
=
&
pFilterInfo
->
pFilters
[
j
];
if
(
pFilterElem
->
fp
==
isNull
_filte
r
)
{
if
(
pFilterElem
->
fp
==
isNull
Operato
r
)
{
return
true
;
}
}
...
...
@@ -2493,13 +2493,13 @@ static bool needToLoadDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis *pDat
float
maxval
=
(
float
)(
*
(
double
*
)(
&
pDataBlockst
->
max
));
for
(
int32_t
i
=
0
;
i
<
pFilterInfo
->
numOfFilters
;
++
i
)
{
if
(
pFilterInfo
->
pFilters
[
i
].
fp
(
&
pFilterInfo
->
pFilters
[
i
],
(
char
*
)
&
minval
,
(
char
*
)
&
maxval
))
{
if
(
pFilterInfo
->
pFilters
[
i
].
fp
(
&
pFilterInfo
->
pFilters
[
i
],
(
char
*
)
&
minval
,
(
char
*
)
&
maxval
,
TSDB_DATA_TYPE_FLOAT
))
{
return
true
;
}
}
}
else
{
for
(
int32_t
i
=
0
;
i
<
pFilterInfo
->
numOfFilters
;
++
i
)
{
if
(
pFilterInfo
->
pFilters
[
i
].
fp
(
&
pFilterInfo
->
pFilters
[
i
],
(
char
*
)
&
pDataBlockst
->
min
,
(
char
*
)
&
pDataBlockst
->
max
))
{
if
(
pFilterInfo
->
pFilters
[
i
].
fp
(
&
pFilterInfo
->
pFilters
[
i
],
(
char
*
)
&
pDataBlockst
->
min
,
(
char
*
)
&
pDataBlockst
->
max
,
pFilterInfo
->
info
.
type
))
{
return
true
;
}
}
...
...
@@ -2966,7 +2966,7 @@ void setTagVal(SQueryRuntimeEnv *pRuntimeEnv, void *pTable, void *tsdb) {
pExprInfo
->
base
.
arg
->
argValue
.
i64
,
pRuntimeEnv
->
pCtx
[
0
].
tag
.
pz
);
}
else
{
qDebug
(
"QInfo:%p set tag value for join comparison, colId:%"
PRId64
", val:%"
PRId64
,
pQInfo
,
pExprInfo
->
base
.
arg
->
argValue
.
i64
,
pRuntimeEnv
->
pCtx
[
0
].
tag
.
i64
Key
);
pExprInfo
->
base
.
arg
->
argValue
.
i64
,
pRuntimeEnv
->
pCtx
[
0
].
tag
.
i64
);
}
}
}
...
...
@@ -3946,7 +3946,7 @@ int32_t setAdditionalInfo(SQInfo *pQInfo, void* pTable, STableQueryInfo *pTableQ
if
(
pTag
->
nType
==
TSDB_DATA_TYPE_BINARY
||
pTag
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
qError
(
"QInfo:%p failed to find tag:%s in ts_comp"
,
pQInfo
,
pTag
->
pz
);
}
else
{
qError
(
"QInfo:%p failed to find tag:%"
PRId64
" in ts_comp"
,
pQInfo
,
pTag
->
i64
Key
);
qError
(
"QInfo:%p failed to find tag:%"
PRId64
" in ts_comp"
,
pQInfo
,
pTag
->
i64
);
}
return
false
;
...
...
@@ -3957,7 +3957,7 @@ int32_t setAdditionalInfo(SQInfo *pQInfo, void* pTable, STableQueryInfo *pTableQ
if
(
pTag
->
nType
==
TSDB_DATA_TYPE_BINARY
||
pTag
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
qDebug
(
"QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d"
,
pQInfo
,
pTag
->
pz
,
pTableQueryInfo
->
cur
.
blockIndex
,
pTableQueryInfo
->
cur
.
tsIndex
);
}
else
{
qDebug
(
"QInfo:%p find tag:%"
PRId64
" start pos in ts_comp, blockIndex:%d, tsIndex:%d"
,
pQInfo
,
pTag
->
i64
Key
,
pTableQueryInfo
->
cur
.
blockIndex
,
pTableQueryInfo
->
cur
.
tsIndex
);
qDebug
(
"QInfo:%p find tag:%"
PRId64
" start pos in ts_comp, blockIndex:%d, tsIndex:%d"
,
pQInfo
,
pTag
->
i64
,
pTableQueryInfo
->
cur
.
blockIndex
,
pTableQueryInfo
->
cur
.
tsIndex
);
}
}
else
{
...
...
@@ -3966,7 +3966,7 @@ int32_t setAdditionalInfo(SQInfo *pQInfo, void* pTable, STableQueryInfo *pTableQ
if
(
pTag
->
nType
==
TSDB_DATA_TYPE_BINARY
||
pTag
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
qDebug
(
"QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d"
,
pQInfo
,
pTag
->
pz
,
pTableQueryInfo
->
cur
.
blockIndex
,
pTableQueryInfo
->
cur
.
tsIndex
);
}
else
{
qDebug
(
"QInfo:%p find tag:%"
PRId64
" start pos in ts_comp, blockIndex:%d, tsIndex:%d"
,
pQInfo
,
pTag
->
i64
Key
,
pTableQueryInfo
->
cur
.
blockIndex
,
pTableQueryInfo
->
cur
.
tsIndex
);
qDebug
(
"QInfo:%p find tag:%"
PRId64
" start pos in ts_comp, blockIndex:%d, tsIndex:%d"
,
pQInfo
,
pTag
->
i64
,
pTableQueryInfo
->
cur
.
blockIndex
,
pTableQueryInfo
->
cur
.
tsIndex
);
}
}
}
...
...
@@ -4930,7 +4930,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
if
(
pTag
->
nType
==
TSDB_DATA_TYPE_BINARY
||
pTag
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
qError
(
"QInfo:%p failed to find tag:%s in ts_comp"
,
pQInfo
,
pTag
->
pz
);
}
else
{
qError
(
"QInfo:%p failed to find tag:%"
PRId64
" in ts_comp"
,
pQInfo
,
pTag
->
i64
Key
);
qError
(
"QInfo:%p failed to find tag:%"
PRId64
" in ts_comp"
,
pQInfo
,
pTag
->
i64
);
}
return
false
;
...
...
@@ -4941,7 +4941,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
qDebug
(
"QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d"
,
pQInfo
,
pTag
->
pz
,
cur
.
blockIndex
,
cur
.
tsIndex
);
}
else
{
qDebug
(
"QInfo:%p find tag:%"
PRId64
" start pos in ts_comp, blockIndex:%d, tsIndex:%d"
,
pQInfo
,
pTag
->
i64
Key
,
qDebug
(
"QInfo:%p find tag:%"
PRId64
" start pos in ts_comp, blockIndex:%d, tsIndex:%d"
,
pQInfo
,
pTag
->
i64
,
cur
.
blockIndex
,
cur
.
tsIndex
);
}
}
...
...
@@ -4955,7 +4955,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
if
(
pTag
->
nType
==
TSDB_DATA_TYPE_BINARY
||
pTag
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
qError
(
"QInfo:%p failed to find tag:%s in ts_comp"
,
pQInfo
,
pTag
->
pz
);
}
else
{
qError
(
"QInfo:%p failed to find tag:%"
PRId64
" in ts_comp"
,
pQInfo
,
pTag
->
i64
Key
);
qError
(
"QInfo:%p failed to find tag:%"
PRId64
" in ts_comp"
,
pQInfo
,
pTag
->
i64
);
}
return
false
;
...
...
@@ -4964,7 +4964,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
if
(
pTag
->
nType
==
TSDB_DATA_TYPE_BINARY
||
pTag
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
qDebug
(
"QInfo:%p find tag:%s start pos in ts_comp, blockIndex:%d, tsIndex:%d"
,
pQInfo
,
pTag
->
pz
,
cur
.
blockIndex
,
cur
.
tsIndex
);
}
else
{
qDebug
(
"QInfo:%p find tag:%"
PRId64
" start pos in ts_comp, blockIndex:%d, tsIndex:%d"
,
pQInfo
,
pTag
->
i64
Key
,
cur
.
blockIndex
,
cur
.
tsIndex
);
qDebug
(
"QInfo:%p find tag:%"
PRId64
" start pos in ts_comp, blockIndex:%d, tsIndex:%d"
,
pQInfo
,
pTag
->
i64
,
cur
.
blockIndex
,
cur
.
tsIndex
);
}
}
...
...
@@ -4974,7 +4974,7 @@ static bool multiTableMultioutputHelper(SQInfo *pQInfo, int32_t index) {
if
(
pTag
->
nType
==
TSDB_DATA_TYPE_BINARY
||
pTag
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
qDebug
(
"QInfo:%p continue scan ts_comp file, tag:%s blockIndex:%d, tsIndex:%d"
,
pQInfo
,
pTag
->
pz
,
cur
.
blockIndex
,
cur
.
tsIndex
);
}
else
{
qDebug
(
"QInfo:%p continue scan ts_comp file, tag:%"
PRId64
" blockIndex:%d, tsIndex:%d"
,
pQInfo
,
pTag
->
i64
Key
,
cur
.
blockIndex
,
cur
.
tsIndex
);
qDebug
(
"QInfo:%p continue scan ts_comp file, tag:%"
PRId64
" blockIndex:%d, tsIndex:%d"
,
pQInfo
,
pTag
->
i64
,
cur
.
blockIndex
,
cur
.
tsIndex
);
}
}
}
...
...
@@ -6025,7 +6025,11 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
pColInfo
->
bytes
=
htons
(
pColInfo
->
bytes
);
pColInfo
->
numOfFilters
=
htons
(
pColInfo
->
numOfFilters
);
assert
(
pColInfo
->
type
>=
TSDB_DATA_TYPE_BOOL
&&
pColInfo
->
type
<=
TSDB_DATA_TYPE_NCHAR
);
if
(
!
isValidDataType
(
pColInfo
->
type
))
{
qDebug
(
"qmsg:%p, invalid data type in source column, index:%d, type:%d"
,
pQueryMsg
,
col
,
pColInfo
->
type
);
code
=
TSDB_CODE_QRY_INVALID_MSG
;
goto
_cleanup
;
}
int32_t
numOfFilters
=
pColInfo
->
numOfFilters
;
if
(
numOfFilters
>
0
)
{
...
...
@@ -6111,7 +6115,7 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
if
(
pQueryMsg
->
secondStageOutput
)
{
pExprMsg
=
(
SSqlFuncMsg
*
)
pMsg
;
*
pSecStageExpr
=
calloc
(
pQueryMsg
->
secondStageOutput
,
POINTER_BYTES
);
for
(
int32_t
i
=
0
;
i
<
pQueryMsg
->
secondStageOutput
;
++
i
)
{
(
*
pSecStageExpr
)[
i
]
=
pExprMsg
;
...
...
@@ -6445,55 +6449,18 @@ static int32_t createFilterInfo(void *pQInfo, SQuery *pQuery) {
int32_t
lower
=
pSingleColFilter
->
filterInfo
.
lowerRelOptr
;
int32_t
upper
=
pSingleColFilter
->
filterInfo
.
upperRelOptr
;
if
(
lower
==
TSDB_RELATION_INVALID
&&
upper
==
TSDB_RELATION_INVALID
)
{
qError
(
"QInfo:%p invalid filter info"
,
pQInfo
);
return
TSDB_CODE_QRY_INVALID_MSG
;
}
int16_t
type
=
pQuery
->
colList
[
i
].
type
;
int16_t
bytes
=
pQuery
->
colList
[
i
].
bytes
;
// todo refactor
__filter_func_t
*
rangeFilterArray
=
getRangeFilterFuncArray
(
type
);
__filter_func_t
*
filterArray
=
getValueFilterFuncArray
(
type
);
if
(
rangeFilterArray
==
NULL
&&
filterArray
==
NULL
)
{
qError
(
"QInfo:%p failed to get filter function, invalid data type:%d"
,
pQInfo
,
type
);
pSingleColFilter
->
fp
=
getFilterOperator
(
lower
,
upper
);
if
(
pSingleColFilter
->
fp
==
NULL
)
{
qError
(
"QInfo:%p invalid filter info"
,
pQInfo
);
return
TSDB_CODE_QRY_INVALID_MSG
;
}
if
((
lower
==
TSDB_RELATION_GREATER_EQUAL
||
lower
==
TSDB_RELATION_GREATER
)
&&
(
upper
==
TSDB_RELATION_LESS_EQUAL
||
upper
==
TSDB_RELATION_LESS
))
{
assert
(
rangeFilterArray
!=
NULL
);
if
(
lower
==
TSDB_RELATION_GREATER_EQUAL
)
{
if
(
upper
==
TSDB_RELATION_LESS_EQUAL
)
{
pSingleColFilter
->
fp
=
rangeFilterArray
[
4
];
}
else
{
pSingleColFilter
->
fp
=
rangeFilterArray
[
2
];
}
}
else
{
if
(
upper
==
TSDB_RELATION_LESS_EQUAL
)
{
pSingleColFilter
->
fp
=
rangeFilterArray
[
3
];
}
else
{
pSingleColFilter
->
fp
=
rangeFilterArray
[
1
];
}
}
}
else
{
// set callback filter function
assert
(
filterArray
!=
NULL
);
if
(
lower
!=
TSDB_RELATION_INVALID
)
{
pSingleColFilter
->
fp
=
filterArray
[
lower
];
if
(
upper
!=
TSDB_RELATION_INVALID
)
{
qError
(
"pQInfo:%p failed to get filter function, invalid filter condition: %d"
,
pQInfo
,
type
);
return
TSDB_CODE_QRY_INVALID_MSG
;
}
}
else
{
pSingleColFilter
->
fp
=
filterArray
[
upper
];
}
}
assert
(
pSingleColFilter
->
fp
!=
NULL
);
pSingleColFilter
->
bytes
=
bytes
;
pSingleColFilter
->
bytes
=
pQuery
->
colList
[
i
].
bytes
;
}
j
++
;
...
...
@@ -6796,7 +6763,7 @@ static int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQ
UNUSED
(
ret
);
}
pQuery
->
precision
=
tsdbGetCfg
(
tsdb
)
->
precision
;
if
((
QUERY_IS_ASC_QUERY
(
pQuery
)
&&
(
pQuery
->
window
.
skey
>
pQuery
->
window
.
ekey
))
||
...
...
src/query/src/qFilterfunc.c
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
src/query/src/qHistogram.c
浏览文件 @
7465d0c7
...
...
@@ -174,11 +174,11 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
if
((
*
pHisto
)
->
numOfElems
>=
1
&&
idx
<
(
*
pHisto
)
->
numOfEntries
)
{
if
(
idx
>
0
)
{
assert
((
*
pHisto
)
->
elems
[
idx
-
1
].
val
<=
val
);
}
else
{
assert
((
*
pHisto
)
->
elems
[
idx
].
val
>
val
);
}
assert
((
*
pHisto
)
->
elems
[
idx
].
val
>
val
);
}
else
if
((
*
pHisto
)
->
numOfElems
>
0
)
{
assert
((
*
pHisto
)
->
elems
[(
*
pHisto
)
->
numOfEntries
].
val
<
val
);
assert
((
*
pHisto
)
->
elems
[(
*
pHisto
)
->
numOfEntries
].
val
<
=
val
);
}
histogramCreateBin
(
*
pHisto
,
idx
,
val
);
...
...
src/query/src/qParserImpl.c
浏览文件 @
7465d0c7
...
...
@@ -129,11 +129,11 @@ tSQLExpr *tSqlExprIdValueCreate(SStrToken *pToken, int32_t optrType) {
pSqlExpr
->
nSQLOptr
=
optrType
;
}
else
if
(
optrType
==
TK_NOW
)
{
// use microsecond by default
pSqlExpr
->
val
.
i64
Key
=
taosGetTimestamp
(
TSDB_TIME_PRECISION_MICRO
);
pSqlExpr
->
val
.
i64
=
taosGetTimestamp
(
TSDB_TIME_PRECISION_MICRO
);
pSqlExpr
->
val
.
nType
=
TSDB_DATA_TYPE_BIGINT
;
pSqlExpr
->
nSQLOptr
=
TK_TIMESTAMP
;
// TK_TIMESTAMP used to denote the time value is in microsecond
}
else
if
(
optrType
==
TK_VARIABLE
)
{
int32_t
ret
=
parseAbsoluteDuration
(
pToken
->
z
,
pToken
->
n
,
&
pSqlExpr
->
val
.
i64
Key
);
int32_t
ret
=
parseAbsoluteDuration
(
pToken
->
z
,
pToken
->
n
,
&
pSqlExpr
->
val
.
i64
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
}
...
...
@@ -200,25 +200,25 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
switch
(
optrType
)
{
case
TK_PLUS
:
{
pExpr
->
val
.
i64
Key
=
pLeft
->
val
.
i64Key
+
pRight
->
val
.
i64Key
;
pExpr
->
val
.
i64
=
pLeft
->
val
.
i64
+
pRight
->
val
.
i64
;
break
;
}
case
TK_MINUS
:
{
pExpr
->
val
.
i64
Key
=
pLeft
->
val
.
i64Key
-
pRight
->
val
.
i64Key
;
pExpr
->
val
.
i64
=
pLeft
->
val
.
i64
-
pRight
->
val
.
i64
;
break
;
}
case
TK_STAR
:
{
pExpr
->
val
.
i64
Key
=
pLeft
->
val
.
i64Key
*
pRight
->
val
.
i64Key
;
pExpr
->
val
.
i64
=
pLeft
->
val
.
i64
*
pRight
->
val
.
i64
;
break
;
}
case
TK_DIVIDE
:
{
pExpr
->
nSQLOptr
=
TK_FLOAT
;
pExpr
->
val
.
nType
=
TSDB_DATA_TYPE_DOUBLE
;
pExpr
->
val
.
dKey
=
(
double
)
pLeft
->
val
.
i64
Key
/
pRight
->
val
.
i64Key
;
pExpr
->
val
.
dKey
=
(
double
)
pLeft
->
val
.
i64
/
pRight
->
val
.
i64
;
break
;
}
case
TK_REM
:
{
pExpr
->
val
.
i64
Key
=
pLeft
->
val
.
i64Key
%
pRight
->
val
.
i64Key
;
pExpr
->
val
.
i64
=
pLeft
->
val
.
i64
%
pRight
->
val
.
i64
;
break
;
}
}
...
...
@@ -231,8 +231,8 @@ tSQLExpr *tSqlExprCreate(tSQLExpr *pLeft, tSQLExpr *pRight, int32_t optrType) {
pExpr
->
val
.
nType
=
TSDB_DATA_TYPE_DOUBLE
;
pExpr
->
nSQLOptr
=
TK_FLOAT
;
double
left
=
(
pLeft
->
val
.
nType
==
TSDB_DATA_TYPE_DOUBLE
)
?
pLeft
->
val
.
dKey
:
pLeft
->
val
.
i64
Key
;
double
right
=
(
pRight
->
val
.
nType
==
TSDB_DATA_TYPE_DOUBLE
)
?
pRight
->
val
.
dKey
:
pRight
->
val
.
i64
Key
;
double
left
=
(
pLeft
->
val
.
nType
==
TSDB_DATA_TYPE_DOUBLE
)
?
pLeft
->
val
.
dKey
:
pLeft
->
val
.
i64
;
double
right
=
(
pRight
->
val
.
nType
==
TSDB_DATA_TYPE_DOUBLE
)
?
pRight
->
val
.
dKey
:
pRight
->
val
.
i64
;
switch
(
optrType
)
{
case
TK_PLUS
:
{
...
...
@@ -384,7 +384,7 @@ void tSqlSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType)
pField
->
name
[
pName
->
n
]
=
0
;
pField
->
type
=
pType
->
type
;
if
(
pField
->
type
<
TSDB_DATA_TYPE_BOOL
||
pField
->
type
>
TSDB_DATA_TYPE_NCHAR
){
if
(
!
isValidDataType
(
pField
->
type
)
){
pField
->
bytes
=
0
;
}
else
{
pField
->
bytes
=
pType
->
bytes
;
...
...
@@ -393,50 +393,60 @@ void tSqlSetColumnInfo(TAOS_FIELD *pField, SStrToken *pName, TAOS_FIELD *pType)
}
void
tSqlSetColumnType
(
TAOS_FIELD
*
pField
,
SStrToken
*
type
)
{
// set the field type invalid
pField
->
type
=
-
1
;
pField
->
name
[
0
]
=
0
;
for
(
int32_t
i
=
0
;
i
<
tListLen
(
tDataTypeDesc
);
++
i
)
{
if
((
strncasecmp
(
type
->
z
,
tDataTypeDesc
[
i
].
aName
,
tDataTypeDesc
[
i
].
nameLen
)
==
0
)
&&
(
type
->
n
==
tDataTypeDesc
[
i
].
nameLen
))
{
pField
->
type
=
i
;
pField
->
bytes
=
tDataTypeDesc
[
i
].
nSize
;
if
(
i
==
TSDB_DATA_TYPE_NCHAR
)
{
/*
* for nchar, the TOKENTYPE is the number of character, so the length is the
* number of bytes in UCS-4 format, which is 4 times larger than the
* number of characters
*/
if
(
type
->
type
==
0
)
{
pField
->
bytes
=
0
;
}
else
{
int32_t
bytes
=
-
(
int32_t
)(
type
->
type
);
if
(
bytes
>
(
TSDB_MAX_NCHAR_LEN
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
)
{
// we have to postpone reporting the error because it cannot be done here
// as pField->bytes is int16_t, use 'TSDB_MAX_NCHAR_LEN + 1' to avoid overflow
bytes
=
TSDB_MAX_NCHAR_LEN
+
1
;
}
else
{
bytes
=
bytes
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
;
}
pField
->
bytes
=
(
int16_t
)
bytes
;
}
}
else
if
(
i
==
TSDB_DATA_TYPE_BINARY
)
{
/* for binary, the TOKENTYPE is the length of binary */
if
(
type
->
type
==
0
)
{
pField
->
bytes
=
0
;
}
else
{
int32_t
bytes
=
-
(
int32_t
)(
type
->
type
);
if
(
bytes
>
TSDB_MAX_BINARY_LEN
-
VARSTR_HEADER_SIZE
)
{
// refer comment for NCHAR above
bytes
=
TSDB_MAX_BINARY_LEN
+
1
;
}
else
{
bytes
+=
VARSTR_HEADER_SIZE
;
}
pField
->
bytes
=
(
int16_t
)
bytes
;
}
}
int32_t
i
=
0
;
while
(
i
<
tListLen
(
tDataTypeDesc
))
{
if
((
type
->
n
==
tDataTypeDesc
[
i
].
nameLen
)
&&
(
strncasecmp
(
type
->
z
,
tDataTypeDesc
[
i
].
aName
,
tDataTypeDesc
[
i
].
nameLen
)
==
0
))
{
break
;
}
i
+=
1
;
}
if
(
i
==
tListLen
(
tDataTypeDesc
))
{
return
;
}
pField
->
type
=
i
;
pField
->
bytes
=
tDataTypeDesc
[
i
].
nSize
;
if
(
i
==
TSDB_DATA_TYPE_NCHAR
)
{
/*
* for nchar, the TOKENTYPE is the number of character, so the length is the
* number of bytes in UCS-4 format, which is 4 times larger than the number of characters
*/
if
(
type
->
type
==
0
)
{
pField
->
bytes
=
0
;
}
else
{
int32_t
bytes
=
-
(
int32_t
)(
type
->
type
);
if
(
bytes
>
(
TSDB_MAX_NCHAR_LEN
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
)
{
// we have to postpone reporting the error because it cannot be done here
// as pField->bytes is int16_t, use 'TSDB_MAX_NCHAR_LEN + 1' to avoid overflow
bytes
=
TSDB_MAX_NCHAR_LEN
+
1
;
}
else
{
bytes
=
bytes
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
;
}
pField
->
bytes
=
(
int16_t
)
bytes
;
}
}
else
if
(
i
==
TSDB_DATA_TYPE_BINARY
)
{
/* for binary, the TOKENTYPE is the length of binary */
if
(
type
->
type
==
0
)
{
pField
->
bytes
=
0
;
}
else
{
int32_t
bytes
=
-
(
int32_t
)(
type
->
type
);
if
(
bytes
>
TSDB_MAX_BINARY_LEN
-
VARSTR_HEADER_SIZE
)
{
// refer comment for NCHAR above
bytes
=
TSDB_MAX_BINARY_LEN
+
1
;
}
else
{
bytes
+=
VARSTR_HEADER_SIZE
;
}
pField
->
bytes
=
(
int16_t
)
bytes
;
}
}
}
...
...
src/query/src/qTokenizer.c
浏览文件 @
7465d0c7
...
...
@@ -129,6 +129,7 @@ static SKeyword keywordTable[] = {
{
"PRECISION"
,
TK_PRECISION
},
{
"LP"
,
TK_LP
},
{
"RP"
,
TK_RP
},
{
"UNSIGNED"
,
TK_UNSIGNED
},
{
"TAGS"
,
TK_TAGS
},
{
"USING"
,
TK_USING
},
{
"AS"
,
TK_AS
},
...
...
src/query/src/qTsbuf.c
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
src/query/src/sql.c
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
src/query/tests/astTest.cpp
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
src/query/tests/tsBufTest.cpp
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
src/query/tests/unitTest.cpp
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
src/tsdb/src/tsdbRWHelper.c
浏览文件 @
7465d0c7
...
...
@@ -753,8 +753,8 @@ static int tsdbWriteBlockToFile(SRWHelper *pHelper, SFile *pFile, SDataCols *pDa
pCompCol
->
type
=
pDataCol
->
type
;
if
(
tDataTypeDesc
[
pDataCol
->
type
].
getStatisFunc
)
{
(
*
tDataTypeDesc
[
pDataCol
->
type
].
getStatisFunc
)(
(
TSKEY
*
)(
pDataCols
->
cols
[
0
].
pData
),
pDataCol
->
pData
,
rowsToWrite
,
&
(
pCompCol
->
min
),
&
(
pCompCol
->
ma
x
),
&
(
pCompCol
->
sum
),
&
(
pCompCol
->
minIndex
),
&
(
pCompCol
->
maxIndex
),
&
(
pCompCol
->
numOfNull
));
pDataCol
->
pData
,
rowsToWrite
,
&
(
pCompCol
->
min
),
&
(
pCompCol
->
max
),
&
(
pCompCol
->
sum
),
&
(
pCompCol
->
minInde
x
),
&
(
pCompCol
->
maxIndex
),
&
(
pCompCol
->
numOfNull
));
}
nColsNotAllNull
++
;
}
...
...
src/util/inc/tstoken.h
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
src/util/src/tcompare.c
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/alter.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/alter1.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/alter_stable.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/auto_create_tb.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/auto_create_tb_drop_tb.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/binary_escapeCharacter.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/col_arithmetic_operation.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/columnValue.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/columnValue_bigint.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/columnValue_bool.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/columnValue_double.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/columnValue_float.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/columnValue_int.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/columnValue_smallint.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/columnValue_tinyint.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/columnValue_unsign.sim
0 → 100644
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/commit.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/create_db.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/create_mt.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/create_tb.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/dbtbnameValidate.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/fill.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/fill_stb.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/fill_us.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/first_last.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/first_last_query.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/function.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/groupby.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/import.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/import_commit1.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/import_commit2.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/import_commit3.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/insert_multiTbl.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/insert_tb.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/interp.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/interp_test.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/join.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/join_multivnode.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/lastrow.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/lastrow_query.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/limit.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/limit1.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/limit1_stb.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/limit1_tb.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/limit1_tblocks100.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/limit2.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/limit2_query.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/limit2_tblocks100.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/limit_stb.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/limit_tb.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/mixed_blocks.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/nchar.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/null_char.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/projection_limit_offset.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/selectResNum.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/select_across_vnodes.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/select_from_cache_disk.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/select_with_tags.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/set_tag_vals.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/single_row_in_tb.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/single_row_in_tb_query.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/sliding.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/slimit.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/slimit1.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/slimit1_query.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/slimit_alter_tags.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/slimit_query.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/tags_dynamically_specifiy.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/tags_filter.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/tbnameIn.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/tbnameIn_query.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/testSuite.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/timestamp.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/timestamp_query.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/topbot.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/union.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/script/general/parser/where.sim
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
tests/tsim/src/simExe.c
浏览文件 @
7465d0c7
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录