Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
86b6c42c
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
86b6c42c
编写于
10月 29, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-10564] refactor and add test cases.
上级
505b95a4
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
703 addition
and
522 deletion
+703
-522
include/common/tvariant.h
include/common/tvariant.h
+2
-2
source/common/src/tvariant.c
source/common/src/tvariant.c
+38
-38
source/libs/function/src/taggfunction.c
source/libs/function/src/taggfunction.c
+78
-78
source/libs/function/src/texpr.c
source/libs/function/src/texpr.c
+9
-9
source/libs/function/src/ttszip.c
source/libs/function/src/ttszip.c
+3
-3
source/libs/parser/src/astGenerator.c
source/libs/parser/src/astGenerator.c
+7
-7
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+104
-95
source/libs/parser/test/parserTests.cpp
source/libs/parser/test/parserTests.cpp
+438
-266
source/libs/parser/test/tokenizerTest.cpp
source/libs/parser/test/tokenizerTest.cpp
+24
-24
未找到文件。
include/common/tvariant.h
浏览文件 @
86b6c42c
...
...
@@ -27,8 +27,8 @@ typedef struct SVariant {
uint32_t
nType
;
int32_t
nLen
;
// only used for string, for number, it is useless
union
{
int64_t
i
64
;
uint64_t
u
64
;
int64_t
i
;
uint64_t
u
;
double
d
;
char
*
pz
;
wchar_t
*
wpz
;
...
...
source/common/src/tvariant.c
浏览文件 @
86b6c42c
...
...
@@ -82,9 +82,9 @@ void taosVariantCreate(SVariant *pVar, char* z, int32_t n, int32_t type) {
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
{
if
(
strncasecmp
(
z
,
"true"
,
4
)
==
0
)
{
pVar
->
i
64
=
TSDB_TRUE
;
pVar
->
i
=
TSDB_TRUE
;
}
else
if
(
strncasecmp
(
z
,
"false"
,
5
)
==
0
)
{
pVar
->
i
64
=
TSDB_FALSE
;
pVar
->
i
=
TSDB_FALSE
;
}
else
{
return
;
}
...
...
@@ -106,7 +106,7 @@ void taosVariantCreate(SVariant *pVar, char* z, int32_t n, int32_t type) {
base
=
2
;
}
ret
=
toInteger
(
z
,
n
,
base
,
&
pVar
->
i
64
,
&
sign
);
ret
=
toInteger
(
z
,
n
,
base
,
&
pVar
->
i
,
&
sign
);
if
(
ret
!=
0
)
{
pVar
->
nType
=
-
1
;
// -1 means error type
return
;
...
...
@@ -127,7 +127,7 @@ void taosVariantCreate(SVariant *pVar, char* z, int32_t n, int32_t type) {
}
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
assert
(
0
);
pVar
->
i
64
=
taosGetTimestamp
(
TSDB_TIME_PRECISION_NANO
);
pVar
->
i
=
taosGetTimestamp
(
TSDB_TIME_PRECISION_NANO
);
break
;
}
...
...
@@ -151,43 +151,43 @@ void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uin
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
{
pVar
->
nLen
=
tDataTypes
[
type
].
bytes
;
pVar
->
i
64
=
GET_INT8_VAL
(
pz
);
pVar
->
i
=
GET_INT8_VAL
(
pz
);
break
;
}
case
TSDB_DATA_TYPE_UTINYINT
:
{
pVar
->
nLen
=
tDataTypes
[
type
].
bytes
;
pVar
->
u
64
=
GET_UINT8_VAL
(
pz
);
pVar
->
u
=
GET_UINT8_VAL
(
pz
);
break
;
}
case
TSDB_DATA_TYPE_SMALLINT
:
{
pVar
->
nLen
=
tDataTypes
[
type
].
bytes
;
pVar
->
i
64
=
GET_INT16_VAL
(
pz
);
pVar
->
i
=
GET_INT16_VAL
(
pz
);
break
;
}
case
TSDB_DATA_TYPE_USMALLINT
:
{
pVar
->
nLen
=
tDataTypes
[
type
].
bytes
;
pVar
->
u
64
=
GET_UINT16_VAL
(
pz
);
pVar
->
u
=
GET_UINT16_VAL
(
pz
);
break
;
}
case
TSDB_DATA_TYPE_INT
:
{
pVar
->
nLen
=
tDataTypes
[
type
].
bytes
;
pVar
->
i
64
=
GET_INT32_VAL
(
pz
);
pVar
->
i
=
GET_INT32_VAL
(
pz
);
break
;
}
case
TSDB_DATA_TYPE_UINT
:
{
pVar
->
nLen
=
tDataTypes
[
type
].
bytes
;
pVar
->
u
64
=
GET_UINT32_VAL
(
pz
);
pVar
->
u
=
GET_UINT32_VAL
(
pz
);
break
;
}
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
pVar
->
nLen
=
tDataTypes
[
type
].
bytes
;
pVar
->
i
64
=
GET_INT64_VAL
(
pz
);
pVar
->
i
=
GET_INT64_VAL
(
pz
);
break
;
}
case
TSDB_DATA_TYPE_UBIGINT
:
{
pVar
->
nLen
=
tDataTypes
[
type
].
bytes
;
pVar
->
u
64
=
GET_UINT64_VAL
(
pz
);
pVar
->
u
=
GET_UINT64_VAL
(
pz
);
break
;
}
case
TSDB_DATA_TYPE_DOUBLE
:
{
...
...
@@ -217,7 +217,7 @@ void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uin
}
default:
pVar
->
i
64
=
GET_INT32_VAL
(
pz
);
pVar
->
i
=
GET_INT32_VAL
(
pz
);
pVar
->
nLen
=
tDataTypes
[
TSDB_DATA_TYPE_INT
].
bytes
;
}
...
...
@@ -271,7 +271,7 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) {
}
if
(
IS_NUMERIC_TYPE
(
pSrc
->
nType
)
||
(
pSrc
->
nType
==
TSDB_DATA_TYPE_BOOL
))
{
pDst
->
i
64
=
pSrc
->
i64
;
pDst
->
i
=
pSrc
->
i
;
}
else
if
(
pSrc
->
nType
==
TSDB_DATA_TYPE_POINTER_ARRAY
)
{
// this is only for string array
size_t
num
=
taosArrayGetSize
(
pSrc
->
arr
);
pDst
->
arr
=
taosArrayInit
(
num
,
sizeof
(
char
*
));
...
...
@@ -322,16 +322,16 @@ int32_t taosVariantCompare(const SVariant* p1, const SVariant* p2) {
return
p1
->
d
>
p2
->
d
?
1
:-
1
;
}
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
p1
->
nType
))
{
if
(
p1
->
u
64
==
p2
->
u64
)
{
if
(
p1
->
u
==
p2
->
u
)
{
return
0
;
}
else
{
return
p1
->
u
64
>
p2
->
u64
?
1
:-
1
;
return
p1
->
u
>
p2
->
u
?
1
:-
1
;
}
}
else
{
if
(
p1
->
i
64
==
p2
->
i64
)
{
if
(
p1
->
i
==
p2
->
i
)
{
return
0
;
}
else
{
return
p1
->
i
64
>
p2
->
i64
?
1
:-
1
;
return
p1
->
i
>
p2
->
i
?
1
:-
1
;
}
}
}
...
...
@@ -362,12 +362,12 @@ int32_t taosVariantToString(SVariant *pVar, char *dst) {
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_UINT
:
return
sprintf
(
dst
,
"%d"
,
(
int32_t
)
pVar
->
i
64
);
return
sprintf
(
dst
,
"%d"
,
(
int32_t
)
pVar
->
i
);
case
TSDB_DATA_TYPE_BIGINT
:
return
sprintf
(
dst
,
"%"
PRId64
,
pVar
->
i
64
);
return
sprintf
(
dst
,
"%"
PRId64
,
pVar
->
i
);
case
TSDB_DATA_TYPE_UBIGINT
:
return
sprintf
(
dst
,
"%"
PRIu64
,
pVar
->
u
64
);
return
sprintf
(
dst
,
"%"
PRIu64
,
pVar
->
u
);
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_DOUBLE
:
return
sprintf
(
dst
,
"%.9lf"
,
pVar
->
d
);
...
...
@@ -426,11 +426,11 @@ static int32_t toBinary(SVariant *pVariant, char **pDest, int32_t *pDestSize) {
}
else
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
pVariant
->
nType
))
{
sprintf
(
pBuf
==
NULL
?
*
pDest
:
pBuf
,
"%"
PRId64
,
pVariant
->
i
64
);
sprintf
(
pBuf
==
NULL
?
*
pDest
:
pBuf
,
"%"
PRId64
,
pVariant
->
i
);
}
else
if
(
pVariant
->
nType
==
TSDB_DATA_TYPE_DOUBLE
||
pVariant
->
nType
==
TSDB_DATA_TYPE_FLOAT
)
{
sprintf
(
pBuf
==
NULL
?
*
pDest
:
pBuf
,
"%lf"
,
pVariant
->
d
);
}
else
if
(
pVariant
->
nType
==
TSDB_DATA_TYPE_BOOL
)
{
sprintf
(
pBuf
==
NULL
?
*
pDest
:
pBuf
,
"%s"
,
(
pVariant
->
i
64
==
TSDB_TRUE
)
?
"TRUE"
:
"FALSE"
);
sprintf
(
pBuf
==
NULL
?
*
pDest
:
pBuf
,
"%s"
,
(
pVariant
->
i
==
TSDB_TRUE
)
?
"TRUE"
:
"FALSE"
);
}
else
if
(
pVariant
->
nType
==
0
)
{
// null data
setNull
(
pBuf
==
NULL
?
*
pDest
:
pBuf
,
TSDB_DATA_TYPE_BINARY
,
0
);
}
...
...
@@ -452,16 +452,16 @@ static int32_t toNchar(SVariant *pVariant, char **pDest, int32_t *pDestSize) {
// convert the number to string, than convert it to wchar string.
if
(
IS_SIGNED_NUMERIC_TYPE
(
pVariant
->
nType
))
{
nLen
=
sprintf
(
pDst
,
"%"
PRId64
,
pVariant
->
i
64
);
nLen
=
sprintf
(
pDst
,
"%"
PRId64
,
pVariant
->
i
);
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
pVariant
->
nType
))
{
nLen
=
sprintf
(
pDst
,
"%"
PRIu64
,
pVariant
->
u
64
);
nLen
=
sprintf
(
pDst
,
"%"
PRIu64
,
pVariant
->
u
);
}
else
if
(
pVariant
->
nType
==
TSDB_DATA_TYPE_DOUBLE
||
pVariant
->
nType
==
TSDB_DATA_TYPE_FLOAT
)
{
nLen
=
sprintf
(
pDst
,
"%lf"
,
pVariant
->
d
);
}
else
if
(
pVariant
->
nType
==
TSDB_DATA_TYPE_BINARY
)
{
pDst
=
pVariant
->
pz
;
nLen
=
pVariant
->
nLen
;
}
else
if
(
pVariant
->
nType
==
TSDB_DATA_TYPE_BOOL
)
{
nLen
=
sprintf
(
pDst
,
"%s"
,
(
pVariant
->
i
64
==
TSDB_TRUE
)
?
"TRUE"
:
"FALSE"
);
nLen
=
sprintf
(
pDst
,
"%s"
,
(
pVariant
->
i
==
TSDB_TRUE
)
?
"TRUE"
:
"FALSE"
);
}
if
(
*
pDest
==
pVariant
->
pz
)
{
...
...
@@ -519,9 +519,9 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result
#if 0
errno = 0;
if (IS_SIGNED_NUMERIC_TYPE(pVariant->nType) || (pVariant->nType == TSDB_DATA_TYPE_BOOL)) {
*result = pVariant->i
64
;
*result = pVariant->i;
} else if (IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) {
*result = pVariant->u
64
;
*result = pVariant->u;
} else if (IS_FLOAT_TYPE(pVariant->nType)) {
*result = (int64_t) pVariant->d;
} else if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
...
...
@@ -639,9 +639,9 @@ static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result
static
int32_t
convertToBool
(
SVariant
*
pVariant
,
int64_t
*
pDest
)
{
if
(
pVariant
->
nType
==
TSDB_DATA_TYPE_BOOL
)
{
*
pDest
=
pVariant
->
i
64
;
// in order to be compatible to null of bool
*
pDest
=
pVariant
->
i
;
// in order to be compatible to null of bool
}
else
if
(
IS_NUMERIC_TYPE
(
pVariant
->
nType
))
{
*
pDest
=
((
pVariant
->
i
64
!=
0
)
?
TSDB_TRUE
:
TSDB_FALSE
);
*
pDest
=
((
pVariant
->
i
!=
0
)
?
TSDB_TRUE
:
TSDB_FALSE
);
}
else
if
(
pVariant
->
nType
==
TSDB_DATA_TYPE_FLOAT
||
pVariant
->
nType
==
TSDB_DATA_TYPE_DOUBLE
)
{
*
pDest
=
((
pVariant
->
d
!=
0
)
?
TSDB_TRUE
:
TSDB_FALSE
);
}
else
if
(
pVariant
->
nType
==
TSDB_DATA_TYPE_BINARY
)
{
...
...
@@ -791,12 +791,12 @@ int32_t tVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool inc
*
converted
=
true
;
}
if
(
pVariant
->
i
64
>
FLT_MAX
||
pVariant
->
i64
<
-
FLT_MAX
)
{
SET_EXT_INFO
(
converted
,
pVariant
->
i
64
,
-
FLT_MAX
,
FLT_MAX
,
extInfo
);
if
(
pVariant
->
i
>
FLT_MAX
||
pVariant
->
i
<
-
FLT_MAX
)
{
SET_EXT_INFO
(
converted
,
pVariant
->
i
,
-
FLT_MAX
,
FLT_MAX
,
extInfo
);
return
-
1
;
}
SET_FLOAT_VAL
(
payload
,
pVariant
->
i
64
);
SET_FLOAT_VAL
(
payload
,
pVariant
->
i
);
}
else
if
(
IS_FLOAT_TYPE
(
pVariant
->
nType
))
{
if
(
converted
)
{
*
converted
=
true
;
...
...
@@ -836,7 +836,7 @@ int32_t tVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool inc
SET_DOUBLE_VAL
(
payload
,
value
);
}
}
else
if
(
pVariant
->
nType
==
TSDB_DATA_TYPE_BOOL
||
IS_SIGNED_NUMERIC_TYPE
(
pVariant
->
nType
)
||
IS_UNSIGNED_NUMERIC_TYPE
(
pVariant
->
nType
))
{
SET_DOUBLE_VAL
(
payload
,
pVariant
->
i
64
);
SET_DOUBLE_VAL
(
payload
,
pVariant
->
i
);
}
else
if
(
IS_FLOAT_TYPE
(
pVariant
->
nType
))
{
SET_DOUBLE_VAL
(
payload
,
pVariant
->
d
);
}
else
if
(
pVariant
->
nType
==
TSDB_DATA_TYPE_NULL
)
{
...
...
@@ -885,7 +885,7 @@ int32_t tVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool inc
if
(
pVariant
->
nType
==
TSDB_DATA_TYPE_NULL
)
{
*
((
int64_t
*
)
payload
)
=
TSDB_DATA_BIGINT_NULL
;
}
else
{
*
((
int64_t
*
)
payload
)
=
pVariant
->
i
64
;
*
((
int64_t
*
)
payload
)
=
pVariant
->
i
;
}
break
;
}
...
...
@@ -951,7 +951,7 @@ int32_t taosVariantTypeSetType(SVariant *pVariant, char type) {
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
{
// bool
if
(
convertToBool
(
pVariant
,
&
pVariant
->
i
64
)
<
0
)
{
if
(
convertToBool
(
pVariant
,
&
pVariant
->
i
)
<
0
)
{
return
-
1
;
}
...
...
@@ -962,7 +962,7 @@ int32_t taosVariantTypeSetType(SVariant *pVariant, char type) {
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
{
convertToInteger
(
pVariant
,
&
(
pVariant
->
i
64
),
type
,
true
,
true
,
NULL
);
convertToInteger
(
pVariant
,
&
(
pVariant
->
i
),
type
,
true
,
true
,
NULL
);
pVariant
->
nType
=
TSDB_DATA_TYPE_BIGINT
;
break
;
}
...
...
@@ -989,7 +989,7 @@ int32_t taosVariantTypeSetType(SVariant *pVariant, char type) {
free
(
pVariant
->
pz
);
pVariant
->
d
=
v
;
}
else
if
(
pVariant
->
nType
>=
TSDB_DATA_TYPE_BOOL
&&
pVariant
->
nType
<=
TSDB_DATA_TYPE_BIGINT
)
{
double
tmp
=
(
double
)
pVariant
->
i
64
;
double
tmp
=
(
double
)
pVariant
->
i
;
pVariant
->
d
=
tmp
;
}
...
...
source/libs/function/src/taggfunction.c
浏览文件 @
86b6c42c
此差异已折叠。
点击以展开。
source/libs/function/src/texpr.c
浏览文件 @
86b6c42c
...
...
@@ -228,7 +228,7 @@ void arithmeticTreeTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput,
} else if (pRight->nodeType == TEXPR_VALUE_NODE) { // exprLeft + 12
_arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr);
OperatorFn(pLeftOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, &pRight->pVal->i
64
, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC);
OperatorFn(pLeftOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, &pRight->pVal->i, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC);
}
} else if (pLeft->nodeType == TEXPR_COL_NODE) {
// column data specified on left-hand-side
...
...
@@ -255,16 +255,16 @@ void arithmeticTreeTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput,
if (order == TSDB_ORDER_DESC) {
reverseCopy(pdata, pLeftInputData, pLeft->pSchema->type, numOfRows);
OperatorFn(pdata, numOfRows, pLeft->pSchema->type, &pRight->pVal->i
64
, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC);
OperatorFn(pdata, numOfRows, pLeft->pSchema->type, &pRight->pVal->i, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC);
} else {
OperatorFn(pLeftInputData, numOfRows, pLeft->pSchema->type, &pRight->pVal->i
64
, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC);
OperatorFn(pLeftInputData, numOfRows, pLeft->pSchema->type, &pRight->pVal->i, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC);
}
}
} else {
// column data specified on left-hand-side
if (pRight->nodeType == TEXPR_BINARYEXPR_NODE) { // 12 + expr2
_arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr);
OperatorFn(&pLeft->pVal->i
64
, 1, pLeft->pVal->nType, pRightOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pOutput, TSDB_ORDER_ASC);
OperatorFn(&pLeft->pVal->i, 1, pLeft->pVal->nType, pRightOutput, numOfRows, TSDB_DATA_TYPE_DOUBLE, pOutput, TSDB_ORDER_ASC);
} else if (pRight->nodeType == TEXPR_COL_NODE) { // 12 + columnRight
// column data specified on right-hand-side
...
...
@@ -273,14 +273,14 @@ void arithmeticTreeTraverse(tExprNode *pExprs, int32_t numOfRows, char *pOutput,
if (order == TSDB_ORDER_DESC) {
reverseCopy(pdata, pRightInputData, pRight->pSchema->type, numOfRows);
OperatorFn(&pLeft->pVal->i
64
, 1, pLeft->pVal->nType, pdata, numOfRows, pRight->pSchema->type, pOutput, TSDB_ORDER_ASC);
OperatorFn(&pLeft->pVal->i, 1, pLeft->pVal->nType, pdata, numOfRows, pRight->pSchema->type, pOutput, TSDB_ORDER_ASC);
} else {
OperatorFn(&pLeft->pVal->i
64
, 1, pLeft->pVal->nType, pRightInputData, numOfRows, pRight->pSchema->type, pOutput, TSDB_ORDER_ASC);
OperatorFn(&pLeft->pVal->i, 1, pLeft->pVal->nType, pRightInputData, numOfRows, pRight->pSchema->type, pOutput, TSDB_ORDER_ASC);
}
} else if (pRight->nodeType == TEXPR_VALUE_NODE) { // 12 + 12
_arithmetic_operator_fn_t OperatorFn = getArithmeticOperatorFn(pExprs->_node.optr);
OperatorFn(&pLeft->pVal->i
64, 1, pLeft->pVal->nType, &pRight->pVal->i64
, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC);
OperatorFn(&pLeft->pVal->i
, 1, pLeft->pVal->nType, &pRight->pVal->i
, 1, pRight->pVal->nType, pOutput, TSDB_ORDER_ASC);
}
}
...
...
@@ -302,7 +302,7 @@ static void exprTreeToBinaryImpl(SBufferWriter* bw, tExprNode* expr) {
tbufWriteInt32
(
bw
,
pVal
->
nLen
);
tbufWrite
(
bw
,
pVal
->
pz
,
pVal
->
nLen
);
}
else
{
tbufWriteInt64
(
bw
,
pVal
->
i
64
);
tbufWriteInt64
(
bw
,
pVal
->
i
);
}
}
else
if
(
expr
->
nodeType
==
TEXPR_COL_NODE
)
{
...
...
@@ -371,7 +371,7 @@ static tExprNode* exprTreeFromBinaryImpl(SBufferReader* br) {
pVal
->
pz
=
calloc
(
1
,
pVal
->
nLen
+
1
);
tbufReadToBuffer
(
br
,
pVal
->
pz
,
pVal
->
nLen
);
}
else
{
pVal
->
i
64
=
tbufReadInt64
(
br
);
pVal
->
i
=
tbufReadInt64
(
br
);
}
}
else
if
(
pExpr
->
nodeType
==
TEXPR_COL_NODE
)
{
...
...
source/libs/function/src/ttszip.c
浏览文件 @
86b6c42c
...
...
@@ -276,7 +276,7 @@ static void writeDataToDisk(STSBuf* pTSBuf) {
metaLen
+=
(
int32_t
)
fwrite
(
&
tfloat
,
1
,
(
size_t
)
pBlock
->
tag
.
nLen
,
pTSBuf
->
f
);
}
else
if
(
pBlock
->
tag
.
nType
!=
TSDB_DATA_TYPE_NULL
)
{
metaLen
+=
(
int32_t
)
fwrite
(
&
pBlock
->
tag
.
nLen
,
1
,
sizeof
(
pBlock
->
tag
.
nLen
),
pTSBuf
->
f
);
metaLen
+=
(
int32_t
)
fwrite
(
&
pBlock
->
tag
.
i
64
,
1
,
(
size_t
)
pBlock
->
tag
.
nLen
,
pTSBuf
->
f
);
metaLen
+=
(
int32_t
)
fwrite
(
&
pBlock
->
tag
.
i
,
1
,
(
size_t
)
pBlock
->
tag
.
nLen
,
pTSBuf
->
f
);
}
else
{
trueLen
=
0
;
metaLen
+=
(
int32_t
)
fwrite
(
&
trueLen
,
1
,
sizeof
(
pBlock
->
tag
.
nLen
),
pTSBuf
->
f
);
...
...
@@ -364,7 +364,7 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) {
pBlock
->
tag
.
d
=
(
double
)
tfloat
;
UNUSED
(
sz
);
}
else
if
(
pBlock
->
tag
.
nType
!=
TSDB_DATA_TYPE_NULL
)
{
//TODO check the return value
sz
=
fread
(
&
pBlock
->
tag
.
i
64
,
(
size_t
)
pBlock
->
tag
.
nLen
,
1
,
pTSBuf
->
f
);
sz
=
fread
(
&
pBlock
->
tag
.
i
,
(
size_t
)
pBlock
->
tag
.
nLen
,
1
,
pTSBuf
->
f
);
UNUSED
(
sz
);
}
...
...
@@ -984,7 +984,7 @@ void tsBufDisplay(STSBuf* pTSBuf) {
while
(
tsBufNextPos
(
pTSBuf
))
{
STSElem
elem
=
tsBufGetElem
(
pTSBuf
);
if
(
elem
.
tag
->
nType
==
TSDB_DATA_TYPE_BIGINT
)
{
printf
(
"%d-%"
PRId64
"-%"
PRId64
"
\n
"
,
elem
.
id
,
elem
.
tag
->
i
64
,
elem
.
ts
);
printf
(
"%d-%"
PRId64
"-%"
PRId64
"
\n
"
,
elem
.
id
,
elem
.
tag
->
i
,
elem
.
ts
);
}
}
...
...
source/libs/parser/src/astGenerator.c
浏览文件 @
86b6c42c
...
...
@@ -375,25 +375,25 @@ void tSqlExprEvaluate(tSqlExpr* pExpr) {
switch
(
optrType
)
{
case
TK_PLUS
:
{
pExpr
->
value
.
i
64
=
pLeft
->
value
.
i64
+
pRight
->
value
.
i64
;
pExpr
->
value
.
i
=
pLeft
->
value
.
i
+
pRight
->
value
.
i
;
break
;
}
case
TK_MINUS
:
{
pExpr
->
value
.
i
64
=
pLeft
->
value
.
i64
-
pRight
->
value
.
i64
;
pExpr
->
value
.
i
=
pLeft
->
value
.
i
-
pRight
->
value
.
i
;
break
;
}
case
TK_STAR
:
{
pExpr
->
value
.
i
64
=
pLeft
->
value
.
i64
*
pRight
->
value
.
i64
;
pExpr
->
value
.
i
=
pLeft
->
value
.
i
*
pRight
->
value
.
i
;
break
;
}
case
TK_DIVIDE
:
{
pExpr
->
tokenId
=
TK_FLOAT
;
pExpr
->
value
.
nType
=
TSDB_DATA_TYPE_DOUBLE
;
pExpr
->
value
.
d
=
(
double
)
pLeft
->
value
.
i
64
/
pRight
->
value
.
i64
;
pExpr
->
value
.
d
=
(
double
)
pLeft
->
value
.
i
/
pRight
->
value
.
i
;
break
;
}
case
TK_REM
:
{
pExpr
->
value
.
i
64
=
pLeft
->
value
.
i64
%
pRight
->
value
.
i64
;
pExpr
->
value
.
i
=
pLeft
->
value
.
i
%
pRight
->
value
.
i
;
break
;
}
default:
...
...
@@ -411,8 +411,8 @@ void tSqlExprEvaluate(tSqlExpr* pExpr) {
pExpr
->
tokenId
=
TK_FLOAT
;
pExpr
->
type
=
SQL_NODE_VALUE
;
double
left
=
(
pLeft
->
value
.
nType
==
TSDB_DATA_TYPE_DOUBLE
)
?
pLeft
->
value
.
d
:
pLeft
->
value
.
i
64
;
double
right
=
(
pRight
->
value
.
nType
==
TSDB_DATA_TYPE_DOUBLE
)
?
pRight
->
value
.
d
:
pRight
->
value
.
i
64
;
double
left
=
(
pLeft
->
value
.
nType
==
TSDB_DATA_TYPE_DOUBLE
)
?
pLeft
->
value
.
d
:
pLeft
->
value
.
i
;
double
right
=
(
pRight
->
value
.
nType
==
TSDB_DATA_TYPE_DOUBLE
)
?
pRight
->
value
.
d
:
pRight
->
value
.
i
;
switch
(
optrType
)
{
case
TK_PLUS
:
{
...
...
source/libs/parser/src/astValidate.c
浏览文件 @
86b6c42c
此差异已折叠。
点击以展开。
source/libs/parser/test/parserTests.cpp
浏览文件 @
86b6c42c
此差异已折叠。
点击以展开。
source/libs/parser/test/tokenizerTest.cpp
浏览文件 @
86b6c42c
...
...
@@ -37,22 +37,22 @@ SToken createToken(char* s) {
}
// namespace
static
void
_init_tvariant_bool
(
SVariant
*
t
)
{
t
->
i
64
=
TSDB_FALSE
;
t
->
i
=
TSDB_FALSE
;
t
->
nType
=
TSDB_DATA_TYPE_BOOL
;
}
static
void
_init_tvariant_tinyint
(
SVariant
*
t
)
{
t
->
i
64
=
-
27
;
t
->
i
=
-
27
;
t
->
nType
=
TSDB_DATA_TYPE_TINYINT
;
}
static
void
_init_tvariant_int
(
SVariant
*
t
)
{
t
->
i
64
=
-
23997659
;
t
->
i
=
-
23997659
;
t
->
nType
=
TSDB_DATA_TYPE_INT
;
}
static
void
_init_tvariant_bigint
(
SVariant
*
t
)
{
t
->
i
64
=
-
3333333333333
;
t
->
i
=
-
3333333333333
;
t
->
nType
=
TSDB_DATA_TYPE_BIGINT
;
}
...
...
@@ -359,19 +359,19 @@ TEST(testCase, tvariant_convert) {
_init_tvariant_bool(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
EXPECT_EQ(t.i
64
, 0);
EXPECT_EQ(t.i, 0);
_init_tvariant_bool(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0);
EXPECT_EQ(t.i
64
, 0);
EXPECT_EQ(t.i, 0);
_init_tvariant_bool(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_SMALLINT), 0);
EXPECT_EQ(t.i
64
, 0);
EXPECT_EQ(t.i, 0);
_init_tvariant_bool(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0);
EXPECT_EQ(t.i
64
, 0);
EXPECT_EQ(t.i, 0);
_init_tvariant_bool(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0);
...
...
@@ -394,23 +394,23 @@ TEST(testCase, tvariant_convert) {
// 2. tinyint to other data types
_init_tvariant_tinyint(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
EXPECT_EQ(t.i
64
, 1);
EXPECT_EQ(t.i, 1);
_init_tvariant_tinyint(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0);
EXPECT_EQ(t.i
64
, -27);
EXPECT_EQ(t.i, -27);
_init_tvariant_tinyint(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_SMALLINT), 0);
EXPECT_EQ(t.i
64
, -27);
EXPECT_EQ(t.i, -27);
_init_tvariant_tinyint(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_INT), 0);
EXPECT_EQ(t.i
64
, -27);
EXPECT_EQ(t.i, -27);
_init_tvariant_tinyint(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0);
EXPECT_EQ(t.i
64
, -27);
EXPECT_EQ(t.i, -27);
_init_tvariant_tinyint(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0);
...
...
@@ -434,7 +434,7 @@ TEST(testCase, tvariant_convert) {
// types//////////////////////////////////////////////////////////////////
_init_tvariant_int(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
EXPECT_EQ(t.i
64
, 1);
EXPECT_EQ(t.i, 1);
_init_tvariant_int(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0);
...
...
@@ -444,11 +444,11 @@ TEST(testCase, tvariant_convert) {
_init_tvariant_int(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_INT), 0);
EXPECT_EQ(t.i
64
, -23997659);
EXPECT_EQ(t.i, -23997659);
_init_tvariant_int(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0);
EXPECT_EQ(t.i
64
, -23997659);
EXPECT_EQ(t.i, -23997659);
_init_tvariant_int(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0);
...
...
@@ -472,7 +472,7 @@ TEST(testCase, tvariant_convert) {
// type//////////////////////////////////////////////////////////////////////////////
_init_tvariant_bigint(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
EXPECT_EQ(t.i
64
, 1);
EXPECT_EQ(t.i, 1);
_init_tvariant_bigint(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_TINYINT), 0);
...
...
@@ -485,7 +485,7 @@ TEST(testCase, tvariant_convert) {
_init_tvariant_bigint(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0);
EXPECT_EQ(t.i
64
, -3333333333333);
EXPECT_EQ(t.i, -3333333333333);
_init_tvariant_bigint(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0);
...
...
@@ -509,11 +509,11 @@ TEST(testCase, tvariant_convert) {
// types////////////////////////////////////////////////////////////////////////
_init_tvariant_float(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
EXPECT_EQ(t.i
64
, 1);
EXPECT_EQ(t.i, 1);
_init_tvariant_float(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0);
EXPECT_EQ(t.i
64
, -8991212199);
EXPECT_EQ(t.i, -8991212199);
_init_tvariant_float(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0);
...
...
@@ -539,14 +539,14 @@ TEST(testCase, tvariant_convert) {
t.nLen = strlen(t.pz);
t.nType = TSDB_DATA_TYPE_BINARY;
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
EXPECT_EQ(t.i
64
, 1);
EXPECT_EQ(t.i, 1);
_init_tvariant_binary(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), -1);
_init_tvariant_binary(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0);
EXPECT_EQ(t.i
64
, 200000);
EXPECT_EQ(t.i, 200000);
_init_tvariant_binary(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0);
...
...
@@ -572,14 +572,14 @@ TEST(testCase, tvariant_convert) {
t.nLen = wcslen(t.wpz);
t.nType = TSDB_DATA_TYPE_NCHAR;
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
EXPECT_EQ(t.i
64
, 0);
EXPECT_EQ(t.i, 0);
_init_tvariant_nchar(&t);
EXPECT_LE(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BOOL), 0);
_init_tvariant_nchar(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_BIGINT), 0);
EXPECT_EQ(t.i
64
, -2000000);
EXPECT_EQ(t.i, -2000000);
_init_tvariant_nchar(&t);
EXPECT_EQ(taosVariantTypeSetType(&t, TSDB_DATA_TYPE_FLOAT), 0);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录