Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c4cfcef6
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c4cfcef6
编写于
4月 28, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stmt query
上级
54fe93f7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
161 addition
and
19 deletion
+161
-19
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-0
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+28
-0
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+63
-4
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+47
-7
tests/script/api/batchprepare.c
tests/script/api/batchprepare.c
+22
-8
未找到文件。
include/libs/nodes/querynodes.h
浏览文件 @
c4cfcef6
...
...
@@ -88,6 +88,7 @@ typedef struct SValueNode {
double
d
;
char
*
p
;
}
datum
;
int64_t
typeData
;
char
unit
;
}
SValueNode
;
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
c4cfcef6
...
...
@@ -1747,23 +1747,51 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) {
break
;
case
TSDB_DATA_TYPE_BOOL
:
code
=
tjsonGetBoolValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
b
);
*
(
bool
*
)
&
pNode
->
typeData
=
pNode
->
datum
.
b
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
code
=
tjsonGetBigIntValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
i
);
*
(
int8_t
*
)
&
pNode
->
typeData
=
pNode
->
datum
.
i
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
code
=
tjsonGetBigIntValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
i
);
*
(
int16_t
*
)
&
pNode
->
typeData
=
pNode
->
datum
.
i
;
break
;
case
TSDB_DATA_TYPE_INT
:
code
=
tjsonGetBigIntValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
i
);
*
(
int32_t
*
)
&
pNode
->
typeData
=
pNode
->
datum
.
i
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
code
=
tjsonGetBigIntValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
i
);
*
(
int64_t
*
)
&
pNode
->
typeData
=
pNode
->
datum
.
i
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
code
=
tjsonGetBigIntValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
i
);
*
(
int64_t
*
)
&
pNode
->
typeData
=
pNode
->
datum
.
i
;
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
code
=
tjsonGetUBigIntValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
u
);
*
(
uint8_t
*
)
&
pNode
->
typeData
=
pNode
->
datum
.
u
;
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
code
=
tjsonGetUBigIntValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
u
);
*
(
uint16_t
*
)
&
pNode
->
typeData
=
pNode
->
datum
.
u
;
break
;
case
TSDB_DATA_TYPE_UINT
:
code
=
tjsonGetUBigIntValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
u
);
*
(
uint32_t
*
)
&
pNode
->
typeData
=
pNode
->
datum
.
u
;
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
code
=
tjsonGetUBigIntValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
u
);
*
(
uint64_t
*
)
&
pNode
->
typeData
=
pNode
->
datum
.
u
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
code
=
tjsonGetDoubleValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
d
);
*
(
float
*
)
&
pNode
->
typeData
=
pNode
->
datum
.
d
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
code
=
tjsonGetDoubleValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
d
);
*
(
double
*
)
&
pNode
->
typeData
=
pNode
->
datum
.
d
;
break
;
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
c4cfcef6
...
...
@@ -867,21 +867,18 @@ void nodesClearList(SNodeList* pList) {
void
*
nodesGetValueFromNode
(
SValueNode
*
pNode
)
{
switch
(
pNode
->
node
.
resType
.
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
return
(
void
*
)
&
pNode
->
datum
.
b
;
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
return
(
void
*
)
&
pNode
->
datum
.
i
;
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
return
(
void
*
)
&
pNode
->
datum
.
u
;
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_DOUBLE
:
return
(
void
*
)
&
pNode
->
datum
.
d
;
return
(
void
*
)
&
pNode
->
typeData
;
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
...
...
@@ -893,6 +890,68 @@ void* nodesGetValueFromNode(SValueNode* pNode) {
return
NULL
;
}
int32_t
nodesSetValueNodeValue
(
SValueNode
*
pNode
,
void
*
value
)
{
switch
(
pNode
->
node
.
resType
.
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
pNode
->
datum
.
b
=
*
(
bool
*
)
value
;
*
(
bool
*
)
pNode
->
typeData
=
pNode
->
datum
.
b
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
pNode
->
datum
.
i
=
*
(
int8_t
*
)
value
;
*
(
int8_t
*
)
pNode
->
typeData
=
pNode
->
datum
.
i
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
pNode
->
datum
.
i
=
*
(
int16_t
*
)
value
;
*
(
int16_t
*
)
pNode
->
typeData
=
pNode
->
datum
.
i
;
break
;
case
TSDB_DATA_TYPE_INT
:
pNode
->
datum
.
i
=
*
(
int32_t
*
)
value
;
*
(
int32_t
*
)
pNode
->
typeData
=
pNode
->
datum
.
i
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
pNode
->
datum
.
i
=
*
(
int64_t
*
)
value
;
*
(
int64_t
*
)
pNode
->
typeData
=
pNode
->
datum
.
i
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
pNode
->
datum
.
i
=
*
(
int64_t
*
)
value
;
*
(
int64_t
*
)
pNode
->
typeData
=
pNode
->
datum
.
i
;
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
pNode
->
datum
.
u
=
*
(
int8_t
*
)
value
;
*
(
int8_t
*
)
pNode
->
typeData
=
pNode
->
datum
.
u
;
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
pNode
->
datum
.
u
=
*
(
int16_t
*
)
value
;
*
(
int16_t
*
)
pNode
->
typeData
=
pNode
->
datum
.
u
;
break
;
case
TSDB_DATA_TYPE_UINT
:
pNode
->
datum
.
u
=
*
(
int32_t
*
)
value
;
*
(
int32_t
*
)
pNode
->
typeData
=
pNode
->
datum
.
u
;
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
pNode
->
datum
.
u
=
*
(
uint64_t
*
)
value
;
*
(
uint64_t
*
)
pNode
->
typeData
=
pNode
->
datum
.
u
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
pNode
->
datum
.
d
=
*
(
float
*
)
value
;
*
(
float
*
)
pNode
->
typeData
=
pNode
->
datum
.
d
;
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
pNode
->
datum
.
d
=
*
(
double
*
)
value
;
*
(
double
*
)
pNode
->
typeData
=
pNode
->
datum
.
d
;
break
;
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
pNode
->
datum
.
p
=
(
char
*
)
value
;
break
;
default:
return
TSDB_CODE_QRY_APP_ERROR
;
}
return
TSDB_CODE_SUCCESS
;
}
char
*
nodesGetStrValueFromNode
(
SValueNode
*
pNode
)
{
switch
(
pNode
->
node
.
resType
.
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
{
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
c4cfcef6
...
...
@@ -473,27 +473,66 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
break
;
case
TSDB_DATA_TYPE_BOOL
:
pVal
->
datum
.
b
=
(
0
==
strcasecmp
(
pVal
->
literal
,
"true"
));
*
(
bool
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
b
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_TINYINT
:{
char
*
endPtr
=
NULL
;
pVal
->
datum
.
i
=
strtoll
(
pVal
->
literal
,
&
endPtr
,
10
);
*
(
int8_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
break
;
}
case
TSDB_DATA_TYPE_SMALLINT
:{
char
*
endPtr
=
NULL
;
pVal
->
datum
.
i
=
strtoll
(
pVal
->
literal
,
&
endPtr
,
10
);
*
(
int16_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
break
;
}
case
TSDB_DATA_TYPE_INT
:{
char
*
endPtr
=
NULL
;
pVal
->
datum
.
i
=
strtoll
(
pVal
->
literal
,
&
endPtr
,
10
);
*
(
int32_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
break
;
}
case
TSDB_DATA_TYPE_BIGINT
:
{
char
*
endPtr
=
NULL
;
pVal
->
datum
.
i
=
strtoll
(
pVal
->
literal
,
&
endPtr
,
10
);
*
(
int64_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
break
;
}
case
TSDB_DATA_TYPE_UTINYINT
:{
char
*
endPtr
=
NULL
;
pVal
->
datum
.
u
=
strtoull
(
pVal
->
literal
,
&
endPtr
,
10
);
*
(
uint8_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
u
;
break
;
}
case
TSDB_DATA_TYPE_USMALLINT
:{
char
*
endPtr
=
NULL
;
pVal
->
datum
.
u
=
strtoull
(
pVal
->
literal
,
&
endPtr
,
10
);
*
(
uint16_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
u
;
break
;
}
case
TSDB_DATA_TYPE_UINT
:{
char
*
endPtr
=
NULL
;
pVal
->
datum
.
u
=
strtoull
(
pVal
->
literal
,
&
endPtr
,
10
);
*
(
uint32_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
u
;
break
;
}
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
{
char
*
endPtr
=
NULL
;
pVal
->
datum
.
u
=
strtoull
(
pVal
->
literal
,
&
endPtr
,
10
);
*
(
uint64_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
u
;
break
;
}
case
TSDB_DATA_TYPE_FLOAT
:{
char
*
endPtr
=
NULL
;
pVal
->
datum
.
d
=
strtold
(
pVal
->
literal
,
&
endPtr
);
*
(
float
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
d
;
break
;
}
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_DOUBLE
:
{
char
*
endPtr
=
NULL
;
pVal
->
datum
.
d
=
strtold
(
pVal
->
literal
,
&
endPtr
);
*
(
double
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
d
;
break
;
}
case
TSDB_DATA_TYPE_VARCHAR
:
...
...
@@ -511,6 +550,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
TSDB_CODE_SUCCESS
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
*
(
int64_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
break
;
}
case
TSDB_DATA_TYPE_NCHAR
:
...
...
tests/script/api/batchprepare.c
浏览文件 @
c4cfcef6
...
...
@@ -11,7 +11,8 @@
int32_t
shortColList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_INT
};
int32_t
fullColList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_BOOL
,
TSDB_DATA_TYPE_TINYINT
,
TSDB_DATA_TYPE_UTINYINT
,
TSDB_DATA_TYPE_SMALLINT
,
TSDB_DATA_TYPE_USMALLINT
,
TSDB_DATA_TYPE_INT
,
TSDB_DATA_TYPE_UINT
,
TSDB_DATA_TYPE_BIGINT
,
TSDB_DATA_TYPE_UBIGINT
,
TSDB_DATA_TYPE_FLOAT
,
TSDB_DATA_TYPE_DOUBLE
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DATA_TYPE_NCHAR
};
int32_t
bindColTypeList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
};
int32_t
bindColTypeList
[]
=
{
TSDB_DATA_TYPE_TIMESTAMP
,
TSDB_DATA_TYPE_INT
,
TSDB_DATA_TYPE_FLOAT
};
int32_t
optrIdxList
[]
=
{
3
,
5
,
2
};
typedef
struct
{
char
*
oper
;
...
...
@@ -161,6 +162,8 @@ typedef struct {
int32_t
bindRowNum
;
//row num for once bind
int32_t
bindColTypeNum
;
int32_t
*
bindColTypeList
;
int32_t
optrIdxListNum
;
int32_t
*
optrIdxList
;
int32_t
runTimes
;
int32_t
caseIdx
;
// static case idx
int32_t
caseNum
;
// num in static case list
...
...
@@ -180,6 +183,8 @@ CaseCtrl gCaseCtrl = {
.
bindRowNum
=
0
,
// .bindColTypeNum = 0,
// .bindColTypeList = NULL,
// .optrIdxListNum = 0,
// .optrIdxList = NULL,
.
checkParamNum
=
false
,
.
printRes
=
true
,
.
runTimes
=
0
,
...
...
@@ -188,6 +193,11 @@ CaseCtrl gCaseCtrl = {
.
caseRunIdx
=
-
1
,
// .caseRunNum = -1,
.
optrIdxListNum
=
tListLen
(
optrIdxList
),
.
optrIdxList
=
optrIdxList
,
.
bindColTypeNum
=
tListLen
(
bindColTypeList
),
.
bindColTypeList
=
bindColTypeList
,
.
caseIdx
=
22
,
.
caseNum
=
1
,
.
caseRunNum
=
1
,
...
...
@@ -338,15 +348,19 @@ void generateInsertSQL(BindData *data) {
}
}
void
bpAppendOperatorParam
(
BindData
*
data
,
int32_t
*
len
,
int32_t
dataType
)
{
void
bpAppendOperatorParam
(
BindData
*
data
,
int32_t
*
len
,
int32_t
dataType
,
int32_t
idx
)
{
OperInfo
*
pInfo
=
NULL
;
if
(
TSDB_DATA_TYPE_VARCHAR
==
dataType
||
TSDB_DATA_TYPE_NCHAR
==
dataType
)
{
pInfo
=
&
operInfo
[
varoperatorList
[
rand
()
%
tListLen
(
varoperatorList
)
]];
if
(
gCaseCtrl
.
optrIdxListNum
>
0
)
{
pInfo
=
&
operInfo
[
gCaseCtrl
.
optrIdxList
[
idx
]];
}
else
{
pInfo
=
&
operInfo
[
operatorList
[
rand
()
%
tListLen
(
operatorList
)]];
if
(
TSDB_DATA_TYPE_VARCHAR
==
dataType
||
TSDB_DATA_TYPE_NCHAR
==
dataType
)
{
pInfo
=
&
operInfo
[
varoperatorList
[
rand
()
%
tListLen
(
varoperatorList
)]];
}
else
{
pInfo
=
&
operInfo
[
operatorList
[
rand
()
%
tListLen
(
operatorList
)]];
}
}
switch
(
pInfo
->
paramNum
)
{
case
2
:
if
(
pInfo
->
enclose
)
{
...
...
@@ -416,7 +430,7 @@ void generateQuerySQL(BindData *data, int32_t tblIdx) {
exit
(
1
);
}
bpAppendOperatorParam
(
data
,
&
len
,
data
->
pBind
[
c
].
buffer_type
);
bpAppendOperatorParam
(
data
,
&
len
,
data
->
pBind
[
c
].
buffer_type
,
c
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录