Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
58d3ac9d
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看板
未验证
提交
58d3ac9d
编写于
5月 12, 2022
作者:
D
dapan1121
提交者:
GitHub
5月 12, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12403 from taosdata/feature/qnode
feat: stmt query test
上级
3967f79b
9de1d221
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
189 addition
and
136 deletion
+189
-136
include/common/ttypes.h
include/common/ttypes.h
+1
-0
source/client/inc/clientStmt.h
source/client/inc/clientStmt.h
+1
-0
source/client/src/clientStmt.c
source/client/src/clientStmt.c
+7
-3
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+8
-6
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+1
-1
source/libs/scalar/inc/sclInt.h
source/libs/scalar/inc/sclInt.h
+1
-0
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+7
-15
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+26
-2
tests/script/api/batchprepare.c
tests/script/api/batchprepare.c
+137
-109
未找到文件。
include/common/ttypes.h
浏览文件 @
58d3ac9d
...
...
@@ -50,6 +50,7 @@ typedef struct {
#define varDataLenByData(v) (*(VarDataLenT *)(((char *)(v)) - VARSTR_HEADER_SIZE))
#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT)(_len))
#define IS_VAR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON))
#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR))
#define varDataNetLen(v) (htons(((VarDataLenT *)(v))[0]))
#define varDataNetTLen(v) (sizeof(VarDataLenT) + varDataNetLen(v))
...
...
source/client/inc/clientStmt.h
浏览文件 @
58d3ac9d
...
...
@@ -71,6 +71,7 @@ typedef struct SStmtBindInfo {
typedef
struct
SStmtExecInfo
{
int32_t
affectedRows
;
bool
emptyRes
;
SRequestObj
*
pRequest
;
SHashObj
*
pVgHash
;
SHashObj
*
pBlockHash
;
...
...
source/client/src/clientStmt.c
浏览文件 @
58d3ac9d
...
...
@@ -279,6 +279,7 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool freeRequest) {
}
pStmt
->
exec
.
autoCreateTbl
=
false
;
pStmt
->
exec
.
emptyRes
=
false
;
if
(
keepTable
)
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -628,8 +629,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) {
STMT_ERR_RET
(
stmtRestoreQueryFields
(
pStmt
));
}
bool
emptyResult
=
false
;
STMT_RET
(
qStmtBindParam
(
pStmt
->
sql
.
pQueryPlan
,
bind
,
colIdx
,
pStmt
->
exec
.
pRequest
->
requestId
,
&
emptyResult
));
STMT_RET
(
qStmtBindParam
(
pStmt
->
sql
.
pQueryPlan
,
bind
,
colIdx
,
pStmt
->
exec
.
pRequest
->
requestId
,
&
pStmt
->
exec
.
emptyRes
));
}
STableDataBlocks
**
pDataBlock
=
(
STableDataBlocks
**
)
taosHashGet
(
pStmt
->
exec
.
pBlockHash
,
pStmt
->
bInfo
.
tbFName
,
strlen
(
pStmt
->
bInfo
.
tbFName
));
...
...
@@ -736,7 +736,11 @@ int stmtExec(TAOS_STMT *stmt) {
STMT_ERR_RET
(
stmtSwitchStatus
(
pStmt
,
STMT_EXECUTE
));
if
(
STMT_TYPE_QUERY
==
pStmt
->
sql
.
type
)
{
scheduleQuery
(
pStmt
->
exec
.
pRequest
,
pStmt
->
sql
.
pQueryPlan
,
pStmt
->
sql
.
nodeList
,
NULL
);
if
(
pStmt
->
exec
.
emptyRes
)
{
pStmt
->
exec
.
pRequest
->
type
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
}
else
{
scheduleQuery
(
pStmt
->
exec
.
pRequest
,
pStmt
->
sql
.
pQueryPlan
,
pStmt
->
sql
.
nodeList
,
NULL
);
}
}
else
{
STMT_ERR_RET
(
qBuildStmtOutput
(
pStmt
->
sql
.
pQuery
,
pStmt
->
exec
.
pVgHash
,
pStmt
->
exec
.
pBlockHash
));
launchQueryImpl
(
pStmt
->
exec
.
pRequest
,
pStmt
->
sql
.
pQuery
,
TSDB_CODE_SUCCESS
,
true
,
(
autoCreateTbl
?
(
void
**
)
&
pRsp
:
NULL
));
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
58d3ac9d
...
...
@@ -1069,8 +1069,9 @@ static void destroyInsertParseContext(SInsertParseContext* pCxt) {
// [...];
static
int32_t
parseInsertBody
(
SInsertParseContext
*
pCxt
)
{
int32_t
tbNum
=
0
;
char
tbFName
[
TSDB_TABLE_FNAME_LEN
];
bool
autoCreateTbl
=
false
;
char
tbFName
[
TSDB_TABLE_FNAME_LEN
];
bool
autoCreateTbl
=
false
;
STableMeta
*
pMeta
=
NULL
;
// for each table
while
(
1
)
{
...
...
@@ -1127,10 +1128,12 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
CHECK_CODE
(
getDataBlockFromList
(
pCxt
->
pTableBlockHashObj
,
tbFName
,
strlen
(
tbFName
),
TSDB_DEFAULT_PAYLOAD_SIZE
,
sizeof
(
SSubmitBlk
),
getTableInfo
(
pCxt
->
pTableMeta
).
rowSize
,
pCxt
->
pTableMeta
,
&
dataBuf
,
NULL
,
&
pCxt
->
createTblReq
));
pMeta
=
pCxt
->
pTableMeta
;
pCxt
->
pTableMeta
=
NULL
;
if
(
TK_NK_LP
==
sToken
.
type
)
{
// pSql -> field1_name, ...)
CHECK_CODE
(
parseBoundColumns
(
pCxt
,
&
dataBuf
->
boundColumnInfo
,
getTableColumnSchema
(
p
Cxt
->
pTable
Meta
)));
CHECK_CODE
(
parseBoundColumns
(
pCxt
,
&
dataBuf
->
boundColumnInfo
,
getTableColumnSchema
(
pMeta
)));
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
}
...
...
@@ -1166,8 +1169,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
memcpy
(
tags
,
&
pCxt
->
tags
,
sizeof
(
pCxt
->
tags
));
(
*
pCxt
->
pStmtCb
->
setInfoFn
)(
pCxt
->
pStmtCb
->
pStmt
,
pCxt
->
pTableMeta
,
tags
,
tbFName
,
autoCreateTbl
,
pCxt
->
pVgroupsHashObj
,
pCxt
->
pTableBlockHashObj
);
(
*
pCxt
->
pStmtCb
->
setInfoFn
)(
pCxt
->
pStmtCb
->
pStmt
,
pMeta
,
tags
,
tbFName
,
autoCreateTbl
,
pCxt
->
pVgroupsHashObj
,
pCxt
->
pTableBlockHashObj
);
memset
(
&
pCxt
->
tags
,
0
,
sizeof
(
pCxt
->
tags
));
pCxt
->
pVgroupsHashObj
=
NULL
;
...
...
source/libs/planner/src/planner.c
浏览文件 @
58d3ac9d
...
...
@@ -224,7 +224,7 @@ static int32_t calcConstList(SNodeList* pList) {
}
static
bool
isEmptyResultCond
(
SNode
**
pCond
)
{
if
(
QUERY_NODE_VALUE
!=
nodeType
(
*
pCond
))
{
if
(
NULL
==
*
pCond
||
QUERY_NODE_VALUE
!=
nodeType
(
*
pCond
))
{
return
false
;
}
if
(((
SValueNode
*
)
*
pCond
)
->
datum
.
b
)
{
...
...
source/libs/scalar/inc/sclInt.h
浏览文件 @
58d3ac9d
...
...
@@ -49,6 +49,7 @@ typedef struct SScalarCtx {
int32_t
doConvertDataType
(
SValueNode
*
pValueNode
,
SScalarParam
*
out
);
SColumnInfoData
*
createColumnInfoData
(
SDataType
*
pType
,
int32_t
numOfRows
);
void
sclConvertToTsValueNode
(
int8_t
precision
,
SValueNode
*
valueNode
);
#define GET_PARAM_TYPE(_c) ((_c)->columnData->info.type)
#define GET_PARAM_BYTES(_c) ((_c)->columnData->info.bytes)
...
...
source/libs/scalar/src/filter.c
浏览文件 @
58d3ac9d
...
...
@@ -3505,19 +3505,6 @@ int32_t fltAddValueNodeToConverList(SFltTreeStat *stat, SValueNode* pNode) {
return
TSDB_CODE_SUCCESS
;
}
void
fltConvertToTsValueNode
(
SFltTreeStat
*
stat
,
SValueNode
*
valueNode
)
{
char
*
timeStr
=
valueNode
->
datum
.
p
;
if
(
convertStringToTimestamp
(
valueNode
->
node
.
resType
.
type
,
valueNode
->
datum
.
p
,
stat
->
precision
,
&
valueNode
->
datum
.
i
)
!=
TSDB_CODE_SUCCESS
)
{
valueNode
->
datum
.
i
=
0
;
}
taosMemoryFree
(
timeStr
);
valueNode
->
typeData
=
valueNode
->
datum
.
i
;
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
valueNode
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_TIMESTAMP
].
bytes
;
}
EDealRes
fltReviseRewriter
(
SNode
**
pNode
,
void
*
pContext
)
{
SFltTreeStat
*
stat
=
(
SFltTreeStat
*
)
pContext
;
...
...
@@ -3566,7 +3553,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
fltConvertToTsValueNode
(
stat
,
valueNode
);
sclConvertToTsValueNode
(
stat
->
precision
,
valueNode
);
return
DEAL_RES_CONTINUE
;
}
...
...
@@ -3614,6 +3601,11 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
if
(
FILTER_GET_FLAG
(
stat
->
info
->
options
,
FLT_OPTION_TIMESTAMP
)
&&
node
->
opType
>=
OP_TYPE_NOT_EQUAL
)
{
stat
->
scalarMode
=
true
;
return
DEAL_RES_CONTINUE
;
}
if
(
NULL
==
node
->
pRight
)
{
if
(
scalarGetOperatorParamNum
(
node
->
opType
)
>
1
)
{
fltError
(
"invalid operator, pRight:%p, nodeType:%d, opType:%d"
,
node
->
pRight
,
nodeType
(
node
),
node
->
opType
);
...
...
@@ -3695,7 +3687,7 @@ int32_t fltReviseNodes(SFilterInfo *pInfo, SNode** pNode, SFltTreeStat *pStat) {
for
(
int32_t
i
=
0
;
i
<
nodeNum
;
++
i
)
{
SValueNode
*
valueNode
=
*
(
SValueNode
**
)
taosArrayGet
(
pStat
->
nodeList
,
i
);
fltConvertToTsValueNode
(
pStat
,
valueNode
);
sclConvertToTsValueNode
(
pStat
->
precision
,
valueNode
);
}
_return:
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
58d3ac9d
...
...
@@ -8,6 +8,7 @@
#include "tdatablock.h"
#include "scalar.h"
#include "tudf.h"
#include "ttime.h"
int32_t
scalarGetOperatorParamNum
(
EOperatorType
type
)
{
if
(
OP_TYPE_IS_NULL
==
type
||
OP_TYPE_IS_NOT_NULL
==
type
||
OP_TYPE_IS_TRUE
==
type
||
OP_TYPE_IS_NOT_TRUE
==
type
...
...
@@ -19,6 +20,19 @@ int32_t scalarGetOperatorParamNum(EOperatorType type) {
return
2
;
}
void
sclConvertToTsValueNode
(
int8_t
precision
,
SValueNode
*
valueNode
)
{
char
*
timeStr
=
valueNode
->
datum
.
p
;
if
(
convertStringToTimestamp
(
valueNode
->
node
.
resType
.
type
,
valueNode
->
datum
.
p
,
precision
,
&
valueNode
->
datum
.
i
)
!=
TSDB_CODE_SUCCESS
)
{
valueNode
->
datum
.
i
=
0
;
}
taosMemoryFree
(
timeStr
);
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
valueNode
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_TIMESTAMP
].
bytes
;
}
SColumnInfoData
*
createColumnInfoData
(
SDataType
*
pType
,
int32_t
numOfRows
)
{
SColumnInfoData
*
pColumnData
=
taosMemoryCalloc
(
1
,
sizeof
(
SColumnInfoData
));
if
(
pColumnData
==
NULL
)
{
...
...
@@ -535,7 +549,7 @@ EDealRes sclRewriteBasedOnOptr(SNode** pNode, SScalarCtx *ctx, EOperatorType opT
}
EDealRes
sclRewrite
OperatorForNullValue
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
EDealRes
sclRewrite
NonConstOperator
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
SOperatorNode
*
node
=
(
SOperatorNode
*
)
*
pNode
;
if
(
node
->
pLeft
&&
(
QUERY_NODE_VALUE
==
nodeType
(
node
->
pLeft
)))
{
...
...
@@ -543,6 +557,11 @@ EDealRes sclRewriteOperatorForNullValue(SNode** pNode, SScalarCtx *ctx) {
if
(
SCL_IS_NULL_VALUE_NODE
(
valueNode
)
&&
(
node
->
opType
!=
OP_TYPE_IS_NULL
&&
node
->
opType
!=
OP_TYPE_IS_NOT_NULL
))
{
return
sclRewriteBasedOnOptr
(
pNode
,
ctx
,
node
->
opType
);
}
if
(
IS_STR_DATA_TYPE
(
valueNode
->
node
.
resType
.
type
)
&&
node
->
pRight
&&
nodesIsExprNode
(
node
->
pRight
)
&&
((
SExprNode
*
)
node
->
pRight
)
->
resType
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
sclConvertToTsValueNode
(((
SExprNode
*
)
node
->
pRight
)
->
resType
.
precision
,
valueNode
);
}
}
if
(
node
->
pRight
&&
(
QUERY_NODE_VALUE
==
nodeType
(
node
->
pRight
)))
{
...
...
@@ -550,6 +569,11 @@ EDealRes sclRewriteOperatorForNullValue(SNode** pNode, SScalarCtx *ctx) {
if
(
SCL_IS_NULL_VALUE_NODE
(
valueNode
)
&&
(
node
->
opType
!=
OP_TYPE_IS_NULL
&&
node
->
opType
!=
OP_TYPE_IS_NOT_NULL
))
{
return
sclRewriteBasedOnOptr
(
pNode
,
ctx
,
node
->
opType
);
}
if
(
IS_STR_DATA_TYPE
(
valueNode
->
node
.
resType
.
type
)
&&
node
->
pLeft
&&
nodesIsExprNode
(
node
->
pLeft
)
&&
((
SExprNode
*
)
node
->
pLeft
)
->
resType
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
sclConvertToTsValueNode
(((
SExprNode
*
)
node
->
pLeft
)
->
resType
.
precision
,
valueNode
);
}
}
if
(
node
->
pRight
&&
(
QUERY_NODE_NODE_LIST
==
nodeType
(
node
->
pRight
)))
{
...
...
@@ -672,7 +696,7 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) {
SOperatorNode
*
node
=
(
SOperatorNode
*
)
*
pNode
;
if
((
!
SCL_IS_CONST_NODE
(
node
->
pLeft
))
||
(
!
SCL_IS_CONST_NODE
(
node
->
pRight
)))
{
return
sclRewrite
OperatorForNullValue
(
pNode
,
ctx
);
return
sclRewrite
NonConstOperator
(
pNode
,
ctx
);
}
SScalarParam
output
=
{.
columnData
=
taosMemoryCalloc
(
1
,
sizeof
(
SColumnInfoData
))};
...
...
tests/script/api/batchprepare.c
浏览文件 @
58d3ac9d
...
...
@@ -20,6 +20,11 @@ typedef struct {
bool
enclose
;
}
OperInfo
;
typedef
struct
{
char
*
funcName
;
int32_t
paramNum
;
}
FuncInfo
;
typedef
enum
{
BP_BIND_TAG
=
1
,
BP_BIND_COL
,
...
...
@@ -44,6 +49,13 @@ OperInfo operInfo[] = {
int32_t
operatorList
[]
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
};
int32_t
varoperatorList
[]
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
};
FuncInfo
funcInfo
[]
=
{
{
"count"
,
1
},
{
"sum"
,
1
},
{
"min"
,
1
},
{
"sin"
,
1
},
};
char
*
bpStbPrefix
=
"st"
;
char
*
bpTbPrefix
=
"t"
;
int32_t
bpDefaultStbId
=
1
;
...
...
@@ -154,7 +166,7 @@ CaseCfg gCase[] = {
{
"insert:AUTO1-FULL"
,
tListLen
(
fullColList
),
fullColList
,
TTYPE_INSERT
,
true
,
true
,
insertAUTOTest1
,
10
,
10
,
2
,
0
,
0
,
0
,
1
,
-
1
},
{
"query:SUBT-COLUMN"
,
tListLen
(
fullColList
),
fullColList
,
TTYPE_QUERY
,
false
,
false
,
queryColumnTest
,
10
,
10
,
1
,
3
,
0
,
0
,
1
,
2
},
{
"query:SUBT-MISC"
,
tListLen
(
fullColList
),
fullColList
,
TTYPE_QUERY
,
false
,
false
,
queryMiscTest
,
10
,
10
,
1
,
3
,
0
,
0
,
1
,
2
},
{
"query:SUBT-MISC"
,
tListLen
(
fullColList
),
fullColList
,
TTYPE_QUERY
,
false
,
false
,
queryMiscTest
,
2
,
10
,
1
,
3
,
0
,
0
,
1
,
2
},
};
...
...
@@ -179,6 +191,8 @@ typedef struct {
int32_t
*
bindTagTypeList
;
int32_t
optrIdxListNum
;
int32_t
*
optrIdxList
;
int32_t
funcIdxListNum
;
int32_t
*
funcIdxList
;
int32_t
runTimes
;
int32_t
caseIdx
;
// static case idx
int32_t
caseNum
;
// num in static case list
...
...
@@ -186,7 +200,7 @@ typedef struct {
int32_t
caseRunNum
;
// total run case num
}
CaseCtrl
;
#if
1
#if
0
CaseCtrl gCaseCtrl = { // default
.bindNullNum = 0,
.printCreateTblSql = false,
...
...
@@ -203,6 +217,8 @@ CaseCtrl gCaseCtrl = { // default
.bindTagTypeList = NULL,
.optrIdxListNum = 0,
.optrIdxList = NULL,
.funcIdxListNum = 0,
.funcIdxList = NULL,
.checkParamNum = false,
.printRes = false,
.runTimes = 0,
...
...
@@ -241,7 +257,7 @@ CaseCtrl gCaseCtrl = {
};
#endif
#if
0
#if
1
CaseCtrl
gCaseCtrl
=
{
// query case with specified col&oper
.
bindNullNum
=
0
,
.
printCreateTblSql
=
false
,
...
...
@@ -255,14 +271,14 @@ CaseCtrl gCaseCtrl = { // query case with specified col&oper
.
optrIdxListNum
=
0
,
.
optrIdxList
=
NULL
,
.
checkParamNum
=
false
,
.printRes =
fals
e,
.
printRes
=
tru
e
,
.
runTimes
=
0
,
.
caseRunIdx
=
-
1
,
.
optrIdxListNum
=
0
,
.
optrIdxList
=
NULL
,
.
bindColTypeNum
=
0
,
.
bindColTypeList
=
NULL
,
.caseIdx = 2
3
,
.
caseIdx
=
2
4
,
.
caseNum
=
1
,
.
caseRunNum
=
1
,
};
...
...
@@ -513,9 +529,81 @@ void bpAppendOperatorParam(BindData *data, int32_t *len, int32_t dataType, int32
}
break
;
default:
printf
(
"!!!invalid paramNum:%d
\n
"
,
pInfo
->
paramNum
);
printf
(
"!!!invalid operator paramNum:%d
\n
"
,
pInfo
->
paramNum
);
exit
(
1
);
}
}
void
bpAppendFunctionParam
(
BindData
*
data
,
int32_t
*
len
,
int32_t
dataType
,
int32_t
idx
)
{
FuncInfo
*
pInfo
=
NULL
;
if
(
gCaseCtrl
.
funcIdxListNum
>
0
)
{
pInfo
=
&
funcInfo
[
gCaseCtrl
.
funcIdxList
[
idx
]];
}
else
{
pInfo
=
&
funcInfo
[
rand
()
%
tListLen
(
funcInfo
)];
}
switch
(
pInfo
->
paramNum
)
{
case
1
:
*
len
+=
sprintf
(
data
->
sql
+
*
len
,
" %s(?)"
,
pInfo
->
funcName
);
break
;
default:
printf
(
"!!!invalid function paramNum:%d
\n
"
,
pInfo
->
paramNum
);
exit
(
1
);
}
}
int32_t
bpAppendColumnName
(
BindData
*
data
,
int32_t
type
,
int32_t
len
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
return
sprintf
(
data
->
sql
+
len
,
"booldata"
);
break
;
case
TSDB_DATA_TYPE_TINYINT
:
return
sprintf
(
data
->
sql
+
len
,
"tinydata"
);
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
return
sprintf
(
data
->
sql
+
len
,
"smalldata"
);
break
;
case
TSDB_DATA_TYPE_INT
:
return
sprintf
(
data
->
sql
+
len
,
"intdata"
);
break
;
case
TSDB_DATA_TYPE_BIGINT
:
return
sprintf
(
data
->
sql
+
len
,
"bigdata"
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
return
sprintf
(
data
->
sql
+
len
,
"floatdata"
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
return
sprintf
(
data
->
sql
+
len
,
"doubledata"
);
break
;
case
TSDB_DATA_TYPE_VARCHAR
:
return
sprintf
(
data
->
sql
+
len
,
"binarydata"
);
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
return
sprintf
(
data
->
sql
+
len
,
"ts"
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
return
sprintf
(
data
->
sql
+
len
,
"nchardata"
);
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
return
sprintf
(
data
->
sql
+
len
,
"utinydata"
);
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
return
sprintf
(
data
->
sql
+
len
,
"usmalldata"
);
break
;
case
TSDB_DATA_TYPE_UINT
:
return
sprintf
(
data
->
sql
+
len
,
"uintdata"
);
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
return
sprintf
(
data
->
sql
+
len
,
"ubigdata"
);
break
;
default:
printf
(
"!!!invalid col type:%d"
,
type
);
exit
(
1
);
}
return
0
;
}
void
generateQueryCondSQL
(
BindData
*
data
,
int32_t
tblIdx
)
{
...
...
@@ -525,53 +613,7 @@ void generateQueryCondSQL(BindData *data, int32_t tblIdx) {
if
(
c
)
{
len
+=
sprintf
(
data
->
sql
+
len
,
" and "
);
}
switch
(
data
->
pBind
[
c
].
buffer_type
)
{
case
TSDB_DATA_TYPE_BOOL
:
len
+=
sprintf
(
data
->
sql
+
len
,
"booldata"
);
break
;
case
TSDB_DATA_TYPE_TINYINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"tinydata"
);
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"smalldata"
);
break
;
case
TSDB_DATA_TYPE_INT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"intdata"
);
break
;
case
TSDB_DATA_TYPE_BIGINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"bigdata"
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"floatdata"
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
len
+=
sprintf
(
data
->
sql
+
len
,
"doubledata"
);
break
;
case
TSDB_DATA_TYPE_VARCHAR
:
len
+=
sprintf
(
data
->
sql
+
len
,
"binarydata"
);
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
len
+=
sprintf
(
data
->
sql
+
len
,
"ts"
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
len
+=
sprintf
(
data
->
sql
+
len
,
"nchardata"
);
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"utinydata"
);
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"usmalldata"
);
break
;
case
TSDB_DATA_TYPE_UINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"uintdata"
);
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"ubigdata"
);
break
;
default:
printf
(
"!!!invalid col type:%d"
,
data
->
pBind
[
c
].
buffer_type
);
exit
(
1
);
}
len
+=
bpAppendColumnName
(
data
,
data
->
pBind
[
c
].
buffer_type
,
len
);
bpAppendOperatorParam
(
data
,
&
len
,
data
->
pBind
[
c
].
buffer_type
,
c
);
}
...
...
@@ -582,64 +624,50 @@ void generateQueryCondSQL(BindData *data, int32_t tblIdx) {
}
}
void
bpGenerateConstInOpSQL
(
BindData
*
data
,
int32_t
tblIdx
)
{
int32_t
len
=
0
;
len
=
sprintf
(
data
->
sql
,
"select "
);
for
(
int
c
=
0
;
c
<
gCurCase
->
bindColNum
;
++
c
)
{
if
(
c
)
{
len
+=
sprintf
(
data
->
sql
+
len
,
", "
);
}
len
+=
bpAppendColumnName
(
data
,
data
->
pBind
[
c
].
buffer_type
,
len
);
bpAppendOperatorParam
(
data
,
&
len
,
data
->
pBind
[
c
].
buffer_type
,
c
);
}
void
generateQueryMiscSQL
(
BindData
*
data
,
int32_t
tblIdx
)
{
int32_t
len
=
sprintf
(
data
->
sql
,
"select * from %s%d where "
,
bpTbPrefix
,
tblIdx
);
if
(
!
gCurCase
->
fullCol
)
{
for
(
int
c
=
0
;
c
<
gCurCase
->
bindColNum
;
++
c
)
{
if
(
c
)
{
len
+=
sprintf
(
data
->
sql
+
len
,
" and "
);
}
switch
(
data
->
pBind
[
c
].
buffer_type
)
{
case
TSDB_DATA_TYPE_BOOL
:
len
+=
sprintf
(
data
->
sql
+
len
,
"booldata"
);
break
;
case
TSDB_DATA_TYPE_TINYINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"tinydata"
);
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"smalldata"
);
break
;
case
TSDB_DATA_TYPE_INT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"intdata"
);
break
;
case
TSDB_DATA_TYPE_BIGINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"bigdata"
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"floatdata"
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
len
+=
sprintf
(
data
->
sql
+
len
,
"doubledata"
);
break
;
case
TSDB_DATA_TYPE_VARCHAR
:
len
+=
sprintf
(
data
->
sql
+
len
,
"binarydata"
);
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
len
+=
sprintf
(
data
->
sql
+
len
,
"ts"
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
len
+=
sprintf
(
data
->
sql
+
len
,
"nchardata"
);
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"utinydata"
);
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"usmalldata"
);
break
;
case
TSDB_DATA_TYPE_UINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"uintdata"
);
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
len
+=
sprintf
(
data
->
sql
+
len
,
"ubigdata"
);
break
;
default:
printf
(
"!!!invalid col type:%d"
,
data
->
pBind
[
c
].
buffer_type
);
exit
(
1
);
}
bpAppendOperatorParam
(
data
,
&
len
,
data
->
pBind
[
c
].
buffer_type
,
c
);
len
+=
sprintf
(
data
->
sql
+
len
,
" from %s%d"
,
bpTbPrefix
,
tblIdx
);
}
void
bpGenerateConstInFuncSQL
(
BindData
*
data
,
int32_t
tblIdx
)
{
int32_t
len
=
0
;
len
=
sprintf
(
data
->
sql
,
"select "
);
for
(
int
c
=
0
;
c
<
gCurCase
->
bindColNum
;
++
c
)
{
if
(
c
)
{
len
+=
sprintf
(
data
->
sql
+
len
,
", "
);
}
bpAppendFunctionParam
(
data
,
&
len
,
data
->
pBind
[
c
].
buffer_type
,
c
);
}
len
+=
sprintf
(
data
->
sql
+
len
,
" from %s%d"
,
bpTbPrefix
,
tblIdx
);
}
void
generateQueryMiscSQL
(
BindData
*
data
,
int32_t
tblIdx
)
{
switch
(
tblIdx
)
{
case
0
:
bpGenerateConstInOpSQL
(
data
,
tblIdx
);
break
;
case
1
:
//TODO FILL TEST
default:
bpGenerateConstInFuncSQL
(
data
,
tblIdx
);
break
;
}
if
(
gCaseCtrl
.
printStmtSql
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录