Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5b835514
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
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看板
提交
5b835514
编写于
4月 19, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' into feature/3.0_liaohj
上级
2305b058
0b71a286
变更
74
展开全部
隐藏空白更改
内联
并排
Showing
74 changed file
with
2743 addition
and
1907 deletion
+2743
-1907
.gitignore
.gitignore
+1
-0
include/common/tmsg.h
include/common/tmsg.h
+36
-48
include/common/trow.h
include/common/trow.h
+13
-8
include/common/ttypes.h
include/common/ttypes.h
+2
-2
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+3
-0
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-0
include/libs/planner/planner.h
include/libs/planner/planner.h
+5
-0
include/os/osThread.h
include/os/osThread.h
+4
-9
include/util/tdef.h
include/util/tdef.h
+20
-21
source/client/src/clientMain.c
source/client/src/clientMain.c
+1
-0
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+5
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+86
-28
source/common/src/trow.c
source/common/src/trow.c
+48
-7
source/common/src/ttime.c
source/common/src/ttime.c
+10
-2
source/common/src/ttypes.c
source/common/src/ttypes.c
+51
-51
source/dnode/mgmt/mgmt_mnode/src/mmFile.c
source/dnode/mgmt/mgmt_mnode/src/mmFile.c
+1
-1
source/dnode/mgmt/test/vnode/CMakeLists.txt
source/dnode/mgmt/test/vnode/CMakeLists.txt
+10
-10
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+11
-10
source/dnode/mnode/impl/src/mndBnode.c
source/dnode/mnode/impl/src/mndBnode.c
+5
-5
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+4
-0
source/dnode/mnode/impl/src/mndFunc.c
source/dnode/mnode/impl/src/mndFunc.c
+104
-91
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+9
-9
source/dnode/mnode/impl/src/mndQnode.c
source/dnode/mnode/impl/src/mndQnode.c
+4
-4
source/dnode/mnode/impl/src/mndSnode.c
source/dnode/mnode/impl/src/mndSnode.c
+4
-4
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+141
-175
source/dnode/mnode/impl/test/func/func.cpp
source/dnode/mnode/impl/test/func/func.cpp
+62
-104
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+3
-7
source/dnode/vnode/src/meta/metaTDBImpl.c
source/dnode/vnode/src/meta/metaTDBImpl.c
+13
-13
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+29
-8
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+4
-4
source/dnode/vnode/src/tsdb/tsdbFile.c
source/dnode/vnode/src/tsdb/tsdbFile.c
+4
-4
source/dnode/vnode/src/tsdb/tsdbMain.c
source/dnode/vnode/src/tsdb/tsdbMain.c
+7
-13
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+5
-5
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+8
-8
source/dnode/vnode/src/vnd/vnodeOpen.c
source/dnode/vnode/src/vnd/vnodeOpen.c
+1
-2
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+34
-21
source/libs/nodes/src/nodesTraverseFuncs.c
source/libs/nodes/src/nodesTraverseFuncs.c
+285
-64
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+1
-1
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+2
-1
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+2
-2
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+10
-9
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+0
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+68
-50
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+470
-924
source/libs/parser/test/parserTestUtil.h
source/libs/parser/test/parserTestUtil.h
+6
-1
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+104
-0
source/libs/planner/test/planStmtTest.cpp
source/libs/planner/test/planStmtTest.cpp
+54
-0
source/libs/planner/test/planTestUtil.cpp
source/libs/planner/test/planTestUtil.cpp
+205
-0
source/libs/planner/test/planTestUtil.h
source/libs/planner/test/planTestUtil.h
+35
-0
source/libs/planner/test/plannerTest.cpp
source/libs/planner/test/plannerTest.cpp
+4
-4
source/libs/scalar/inc/sclvector.h
source/libs/scalar/inc/sclvector.h
+5
-0
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+15
-12
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+24
-67
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+10
-2
source/os/src/osFile.c
source/os/src/osFile.c
+3
-0
source/os/src/osThread.c
source/os/src/osThread.c
+25
-33
tests/script/tmp/data.sim
tests/script/tmp/data.sim
+1
-0
tests/script/tsim/bnode/basic1.sim
tests/script/tsim/bnode/basic1.sim
+2
-2
tests/script/tsim/db/alter_option.sim
tests/script/tsim/db/alter_option.sim
+1
-1
tests/script/tsim/db/basic6.sim
tests/script/tsim/db/basic6.sim
+0
-1
tests/script/tsim/dnode/basic1.sim
tests/script/tsim/dnode/basic1.sim
+2
-2
tests/script/tsim/mnode/basic1.sim
tests/script/tsim/mnode/basic1.sim
+2
-2
tests/script/tsim/qnode/basic1.sim
tests/script/tsim/qnode/basic1.sim
+2
-2
tests/script/tsim/query/explain.sim
tests/script/tsim/query/explain.sim
+1
-1
tests/script/tsim/query/session.sim
tests/script/tsim/query/session.sim
+10
-17
tests/script/tsim/query/time_process.sim
tests/script/tsim/query/time_process.sim
+133
-0
tests/script/tsim/snode/basic1.sim
tests/script/tsim/snode/basic1.sim
+2
-2
tests/script/tsim/user/basic1.sim
tests/script/tsim/user/basic1.sim
+19
-19
tests/system-test/2-query/between.py
tests/system-test/2-query/between.py
+205
-0
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+17
-0
tests/system-test/test.py
tests/system-test/test.py
+198
-0
tests/tsim/inc/simInt.h
tests/tsim/inc/simInt.h
+3
-3
tests/tsim/src/simExe.c
tests/tsim/src/simExe.c
+68
-5
tools/shell/src/shellEngine.c
tools/shell/src/shellEngine.c
+0
-5
未找到文件。
.gitignore
浏览文件 @
5b835514
...
@@ -5,6 +5,7 @@ compile_commands.json
...
@@ -5,6 +5,7 @@ compile_commands.json
.tasks
.tasks
.vimspector.json
.vimspector.json
.vscode/
.vscode/
.vscode
.idea/
.idea/
cmake-build-debug/
cmake-build-debug/
cmake-build-release/
cmake-build-release/
...
...
include/common/tmsg.h
浏览文件 @
5b835514
...
@@ -70,11 +70,7 @@ typedef uint16_t tmsg_t;
...
@@ -70,11 +70,7 @@ typedef uint16_t tmsg_t;
#define TSDB_IE_TYPE_DNODE_EXT 6
#define TSDB_IE_TYPE_DNODE_EXT 6
#define TSDB_IE_TYPE_DNODE_STATE 7
#define TSDB_IE_TYPE_DNODE_STATE 7
enum
{
enum
{
CONN_TYPE__QUERY
=
1
,
CONN_TYPE__TMQ
,
CONN_TYPE__MAX
};
CONN_TYPE__QUERY
=
1
,
CONN_TYPE__TMQ
,
CONN_TYPE__MAX
};
enum
{
enum
{
HEARTBEAT_KEY_DBINFO
=
1
,
HEARTBEAT_KEY_DBINFO
=
1
,
...
@@ -257,22 +253,16 @@ typedef struct {
...
@@ -257,22 +253,16 @@ typedef struct {
SSubmitRspBlock
failedBlocks
[];
SSubmitRspBlock
failedBlocks
[];
}
SSubmitRsp
;
}
SSubmitRsp
;
#define SCHEMA_SMA_ON 0x1
#define SCHEMA_IDX_ON 0x2
typedef
struct
SSchema
{
typedef
struct
SSchema
{
int8_t
type
;
int8_t
type
;
int8_t
index
;
// default is 0, not index created
int8_t
flags
;
col_id_t
colId
;
col_id_t
colId
;
int32_t
bytes
;
int32_t
bytes
;
char
name
[
TSDB_COL_NAME_LEN
];
char
name
[
TSDB_COL_NAME_LEN
];
}
SSchema
;
}
SSchema
;
typedef
struct
{
int8_t
type
;
int8_t
sma
;
// ETsdbBSmaType and default is TSDB_BSMA_TYPE_I
col_id_t
colId
;
int32_t
bytes
;
char
name
[
TSDB_COL_NAME_LEN
];
}
SSchemaEx
;
#define SSCHMEA_TYPE(s) ((s)->type)
#define SSCHMEA_TYPE(s) ((s)->type)
#define SSCHMEA_SMA(s) ((s)->sma)
#define SSCHMEA_SMA(s) ((s)->sma)
#define SSCHMEA_COLID(s) ((s)->colId)
#define SSCHMEA_COLID(s) ((s)->colId)
...
@@ -342,13 +332,13 @@ int32_t tSerializeSConnectReq(void* buf, int32_t bufLen, SConnectReq* pReq);
...
@@ -342,13 +332,13 @@ int32_t tSerializeSConnectReq(void* buf, int32_t bufLen, SConnectReq* pReq);
int32_t
tDeserializeSConnectReq
(
void
*
buf
,
int32_t
bufLen
,
SConnectReq
*
pReq
);
int32_t
tDeserializeSConnectReq
(
void
*
buf
,
int32_t
bufLen
,
SConnectReq
*
pReq
);
typedef
struct
{
typedef
struct
{
int32_t
acctId
;
int32_t
acctId
;
int64_t
clusterId
;
int64_t
clusterId
;
uint32_t
connId
;
uint32_t
connId
;
int8_t
superUser
;
int8_t
superUser
;
int8_t
connType
;
int8_t
connType
;
SEpSet
epSet
;
SEpSet
epSet
;
char
sVersion
[
128
];
char
sVersion
[
128
];
}
SConnectRsp
;
}
SConnectRsp
;
int32_t
tSerializeSConnectRsp
(
void
*
buf
,
int32_t
bufLen
,
SConnectRsp
*
pRsp
);
int32_t
tSerializeSConnectRsp
(
void
*
buf
,
int32_t
bufLen
,
SConnectRsp
*
pRsp
);
...
@@ -663,14 +653,13 @@ typedef struct {
...
@@ -663,14 +653,13 @@ typedef struct {
int32_t
outputLen
;
int32_t
outputLen
;
int32_t
bufSize
;
int32_t
bufSize
;
int64_t
signature
;
int64_t
signature
;
int32_t
commentSize
;
char
*
pComment
;
int32_t
codeSize
;
char
*
pCode
;
char
pComment
[
TSDB_FUNC_COMMENT_LEN
];
char
pCode
[
TSDB_FUNC_CODE_LEN
];
}
SCreateFuncReq
;
}
SCreateFuncReq
;
int32_t
tSerializeSCreateFuncReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateFuncReq
*
pReq
);
int32_t
tSerializeSCreateFuncReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateFuncReq
*
pReq
);
int32_t
tDeserializeSCreateFuncReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateFuncReq
*
pReq
);
int32_t
tDeserializeSCreateFuncReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateFuncReq
*
pReq
);
void
tFreeSCreateFuncReq
(
SCreateFuncReq
*
pReq
);
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_FUNC_NAME_LEN
];
char
name
[
TSDB_FUNC_NAME_LEN
];
...
@@ -687,6 +676,7 @@ typedef struct {
...
@@ -687,6 +676,7 @@ typedef struct {
int32_t
tSerializeSRetrieveFuncReq
(
void
*
buf
,
int32_t
bufLen
,
SRetrieveFuncReq
*
pReq
);
int32_t
tSerializeSRetrieveFuncReq
(
void
*
buf
,
int32_t
bufLen
,
SRetrieveFuncReq
*
pReq
);
int32_t
tDeserializeSRetrieveFuncReq
(
void
*
buf
,
int32_t
bufLen
,
SRetrieveFuncReq
*
pReq
);
int32_t
tDeserializeSRetrieveFuncReq
(
void
*
buf
,
int32_t
bufLen
,
SRetrieveFuncReq
*
pReq
);
void
tFreeSRetrieveFuncReq
(
SRetrieveFuncReq
*
pReq
);
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_FUNC_NAME_LEN
];
char
name
[
TSDB_FUNC_NAME_LEN
];
...
@@ -698,8 +688,8 @@ typedef struct {
...
@@ -698,8 +688,8 @@ typedef struct {
int64_t
signature
;
int64_t
signature
;
int32_t
commentSize
;
int32_t
commentSize
;
int32_t
codeSize
;
int32_t
codeSize
;
char
pComment
[
TSDB_FUNC_COMMENT_LEN
]
;
char
*
pComment
;
char
pCode
[
TSDB_FUNC_CODE_LEN
]
;
char
*
pCode
;
}
SFuncInfo
;
}
SFuncInfo
;
typedef
struct
{
typedef
struct
{
...
@@ -709,6 +699,7 @@ typedef struct {
...
@@ -709,6 +699,7 @@ typedef struct {
int32_t
tSerializeSRetrieveFuncRsp
(
void
*
buf
,
int32_t
bufLen
,
SRetrieveFuncRsp
*
pRsp
);
int32_t
tSerializeSRetrieveFuncRsp
(
void
*
buf
,
int32_t
bufLen
,
SRetrieveFuncRsp
*
pRsp
);
int32_t
tDeserializeSRetrieveFuncRsp
(
void
*
buf
,
int32_t
bufLen
,
SRetrieveFuncRsp
*
pRsp
);
int32_t
tDeserializeSRetrieveFuncRsp
(
void
*
buf
,
int32_t
bufLen
,
SRetrieveFuncRsp
*
pRsp
);
void
tFreeSRetrieveFuncRsp
(
SRetrieveFuncRsp
*
pRsp
);
typedef
struct
{
typedef
struct
{
int32_t
statusInterval
;
int32_t
statusInterval
;
...
@@ -1213,12 +1204,12 @@ typedef struct {
...
@@ -1213,12 +1204,12 @@ typedef struct {
#define STREAM_TRIGGER_WINDOW_CLOSE 2
#define STREAM_TRIGGER_WINDOW_CLOSE 2
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
outputSTbName
[
TSDB_TABLE_FNAME_LEN
];
char
outputSTbName
[
TSDB_TABLE_FNAME_LEN
];
int8_t
igExists
;
int8_t
igExists
;
char
*
sql
;
char
*
sql
;
char
*
ast
;
char
*
ast
;
int8_t
triggerType
;
int8_t
triggerType
;
int64_t
watermark
;
int64_t
watermark
;
}
SCMCreateStreamReq
;
}
SCMCreateStreamReq
;
...
@@ -1457,7 +1448,7 @@ typedef struct SVCreateTbReq {
...
@@ -1457,7 +1448,7 @@ typedef struct SVCreateTbReq {
tb_uid_t
suid
;
tb_uid_t
suid
;
col_id_t
nCols
;
col_id_t
nCols
;
col_id_t
nBSmaCols
;
col_id_t
nBSmaCols
;
SSchema
Ex
*
pSchema
;
SSchema
*
pSchema
;
col_id_t
nTagCols
;
col_id_t
nTagCols
;
SSchema
*
pTagSchema
;
SSchema
*
pTagSchema
;
SRSmaParam
*
pRSmaParam
;
SRSmaParam
*
pRSmaParam
;
...
@@ -1469,7 +1460,7 @@ typedef struct SVCreateTbReq {
...
@@ -1469,7 +1460,7 @@ typedef struct SVCreateTbReq {
struct
{
struct
{
col_id_t
nCols
;
col_id_t
nCols
;
col_id_t
nBSmaCols
;
col_id_t
nBSmaCols
;
SSchema
Ex
*
pSchema
;
SSchema
*
pSchema
;
SRSmaParam
*
pRSmaParam
;
SRSmaParam
*
pRSmaParam
;
}
ntbCfg
;
}
ntbCfg
;
};
};
...
@@ -1671,14 +1662,14 @@ typedef struct {
...
@@ -1671,14 +1662,14 @@ typedef struct {
int32_t
pid
;
int32_t
pid
;
char
fqdn
[
TSDB_FQDN_LEN
];
char
fqdn
[
TSDB_FQDN_LEN
];
int32_t
subPlanNum
;
int32_t
subPlanNum
;
SArray
*
subDesc
;
// SArray<SQuerySubDesc>
SArray
*
subDesc
;
// SArray<SQuerySubDesc>
}
SQueryDesc
;
}
SQueryDesc
;
typedef
struct
{
typedef
struct
{
uint32_t
connId
;
uint32_t
connId
;
int32_t
pid
;
int32_t
pid
;
char
app
[
TSDB_APP_NAME_LEN
];
char
app
[
TSDB_APP_NAME_LEN
];
SArray
*
queryDesc
;
// SArray<SQueryDesc>
SArray
*
queryDesc
;
// SArray<SQueryDesc>
}
SQueryHbReqBasic
;
}
SQueryHbReqBasic
;
typedef
struct
{
typedef
struct
{
...
@@ -1742,7 +1733,7 @@ static FORCE_INLINE void tFreeClientHbReq(void* pReq) {
...
@@ -1742,7 +1733,7 @@ static FORCE_INLINE void tFreeClientHbReq(void* pReq) {
}
}
taosMemoryFreeClear
(
req
->
query
);
taosMemoryFreeClear
(
req
->
query
);
}
}
if
(
req
->
info
)
{
if
(
req
->
info
)
{
tFreeReqKvHash
(
req
->
info
);
tFreeReqKvHash
(
req
->
info
);
taosHashCleanup
(
req
->
info
);
taosHashCleanup
(
req
->
info
);
...
@@ -2034,16 +2025,13 @@ int32_t tDecodeSMqCMCommitOffsetReq(SCoder* decoder, SMqCMCommitOffsetReq* pReq)
...
@@ -2034,16 +2025,13 @@ int32_t tDecodeSMqCMCommitOffsetReq(SCoder* decoder, SMqCMCommitOffsetReq* pReq)
typedef
struct
{
typedef
struct
{
uint32_t
nCols
;
uint32_t
nCols
;
union
{
SSchema
*
pSchema
;
SSchema
*
pSchema
;
SSchemaEx
*
pSchemaEx
;
};
}
SSchemaWrapper
;
}
SSchemaWrapper
;
static
FORCE_INLINE
int32_t
taosEncodeSSchema
(
void
**
buf
,
const
SSchema
*
pSchema
)
{
static
FORCE_INLINE
int32_t
taosEncodeSSchema
(
void
**
buf
,
const
SSchema
*
pSchema
)
{
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
index
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
flags
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSchema
->
bytes
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSchema
->
bytes
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pSchema
->
colId
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pSchema
->
colId
);
tlen
+=
taosEncodeString
(
buf
,
pSchema
->
name
);
tlen
+=
taosEncodeString
(
buf
,
pSchema
->
name
);
...
@@ -2052,7 +2040,7 @@ static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema
...
@@ -2052,7 +2040,7 @@ static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema
static
FORCE_INLINE
void
*
taosDecodeSSchema
(
void
*
buf
,
SSchema
*
pSchema
)
{
static
FORCE_INLINE
void
*
taosDecodeSSchema
(
void
*
buf
,
SSchema
*
pSchema
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
index
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
flags
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSchema
->
bytes
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSchema
->
bytes
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pSchema
->
colId
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pSchema
->
colId
);
buf
=
taosDecodeStringTo
(
buf
,
pSchema
->
name
);
buf
=
taosDecodeStringTo
(
buf
,
pSchema
->
name
);
...
@@ -2061,7 +2049,7 @@ static FORCE_INLINE void* taosDecodeSSchema(void* buf, SSchema* pSchema) {
...
@@ -2061,7 +2049,7 @@ static FORCE_INLINE void* taosDecodeSSchema(void* buf, SSchema* pSchema) {
static
FORCE_INLINE
int32_t
tEncodeSSchema
(
SCoder
*
pEncoder
,
const
SSchema
*
pSchema
)
{
static
FORCE_INLINE
int32_t
tEncodeSSchema
(
SCoder
*
pEncoder
,
const
SSchema
*
pSchema
)
{
if
(
tEncodeI8
(
pEncoder
,
pSchema
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pSchema
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pSchema
->
index
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pSchema
->
flags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pSchema
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pSchema
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
pEncoder
,
pSchema
->
colId
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
pEncoder
,
pSchema
->
colId
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pSchema
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pSchema
->
name
)
<
0
)
return
-
1
;
...
@@ -2070,7 +2058,7 @@ static FORCE_INLINE int32_t tEncodeSSchema(SCoder* pEncoder, const SSchema* pSch
...
@@ -2070,7 +2058,7 @@ static FORCE_INLINE int32_t tEncodeSSchema(SCoder* pEncoder, const SSchema* pSch
static
FORCE_INLINE
int32_t
tDecodeSSchema
(
SCoder
*
pDecoder
,
SSchema
*
pSchema
)
{
static
FORCE_INLINE
int32_t
tDecodeSSchema
(
SCoder
*
pDecoder
,
SSchema
*
pSchema
)
{
if
(
tDecodeI8
(
pDecoder
,
&
pSchema
->
type
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pSchema
->
type
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pSchema
->
index
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pSchema
->
flags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pSchema
->
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pSchema
->
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
pDecoder
,
&
pSchema
->
colId
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
pDecoder
,
&
pSchema
->
colId
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
pDecoder
,
pSchema
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
pDecoder
,
pSchema
->
name
)
<
0
)
return
-
1
;
...
...
include/common/trow.h
浏览文件 @
5b835514
...
@@ -48,9 +48,12 @@ extern "C" {
...
@@ -48,9 +48,12 @@ extern "C" {
#define TD_VTYPE_NONE 0x02U // none or unknown/undefined
#define TD_VTYPE_NONE 0x02U // none or unknown/undefined
#define TD_VTYPE_MAX 0x03U //
#define TD_VTYPE_MAX 0x03U //
#define TD_VTYPE_NORM_BYTE 0x0U
#define TD_VTYPE_NORM_BYTE_I 0x0U
#define TD_VTYPE_NULL_BYTE 0x55U
#define TD_VTYPE_NULL_BYTE_I 0xFFU
#define TD_VTYPE_NONE_BYTE 0xAAU
#define TD_VTYPE_NORM_BYTE_II 0x0U
#define TD_VTYPE_NULL_BYTE_II 0x55U
#define TD_VTYPE_NONE_BYTE_II 0xAAU
#define TD_ROWS_ALL_NORM 0x00U
#define TD_ROWS_ALL_NORM 0x00U
#define TD_ROWS_NULL_NORM 0x01U
#define TD_ROWS_NULL_NORM 0x01U
...
@@ -224,8 +227,10 @@ static FORCE_INLINE int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TD
...
@@ -224,8 +227,10 @@ static FORCE_INLINE int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TD
int32_t
tdSetBitmapValTypeN
(
void
*
pBitmap
,
int16_t
nEle
,
TDRowValT
valType
,
int8_t
bitmapMode
);
int32_t
tdSetBitmapValTypeN
(
void
*
pBitmap
,
int16_t
nEle
,
TDRowValT
valType
,
int8_t
bitmapMode
);
static
FORCE_INLINE
int32_t
tdGetBitmapValTypeI
(
const
void
*
pBitmap
,
int16_t
colIdx
,
TDRowValT
*
pValType
);
static
FORCE_INLINE
int32_t
tdGetBitmapValTypeI
(
const
void
*
pBitmap
,
int16_t
colIdx
,
TDRowValT
*
pValType
);
static
FORCE_INLINE
int32_t
tdGetBitmapValTypeII
(
const
void
*
pBitmap
,
int16_t
colIdx
,
TDRowValT
*
pValType
);
static
FORCE_INLINE
int32_t
tdGetBitmapValTypeII
(
const
void
*
pBitmap
,
int16_t
colIdx
,
TDRowValT
*
pValType
);
static
FORCE_INLINE
int32_t
tdGetBitmapValType
(
const
void
*
pBitmap
,
int16_t
colIdx
,
TDRowValT
*
pValType
,
int8_t
bitmapMode
);
static
FORCE_INLINE
int32_t
tdGetBitmapValType
(
const
void
*
pBitmap
,
int16_t
colIdx
,
TDRowValT
*
pValType
,
static
FORCE_INLINE
bool
tdIsBitmapValTypeNormII
(
const
void
*
pBitmap
,
int16_t
idx
);
int8_t
bitmapMode
);
static
FORCE_INLINE
bool
tdIsBitmapValTypeNorm
(
const
void
*
pBitmap
,
int16_t
idx
,
int8_t
bitmapMode
);
bool
tdIsBitmapBlkNorm
(
const
void
*
pBitmap
,
int32_t
numOfBits
,
int8_t
bitmapMode
);
int32_t
tdAppendValToDataCol
(
SDataCol
*
pCol
,
TDRowValT
valType
,
const
void
*
val
,
int32_t
numOfRows
,
int32_t
maxPoints
,
int32_t
tdAppendValToDataCol
(
SDataCol
*
pCol
,
TDRowValT
valType
,
const
void
*
val
,
int32_t
numOfRows
,
int32_t
maxPoints
,
int8_t
bitmapMode
);
int8_t
bitmapMode
);
static
FORCE_INLINE
int32_t
tdAppendColValToTpRow
(
SRowBuilder
*
pBuilder
,
TDRowValT
valType
,
const
void
*
val
,
static
FORCE_INLINE
int32_t
tdAppendColValToTpRow
(
SRowBuilder
*
pBuilder
,
TDRowValT
valType
,
const
void
*
val
,
...
@@ -233,7 +238,7 @@ static FORCE_INLINE int32_t tdAppendColValToTpRow(SRowBuilder *pBuilder, TDRowVa
...
@@ -233,7 +238,7 @@ static FORCE_INLINE int32_t tdAppendColValToTpRow(SRowBuilder *pBuilder, TDRowVa
static
FORCE_INLINE
int32_t
tdAppendColValToKvRow
(
SRowBuilder
*
pBuilder
,
TDRowValT
valType
,
const
void
*
val
,
static
FORCE_INLINE
int32_t
tdAppendColValToKvRow
(
SRowBuilder
*
pBuilder
,
TDRowValT
valType
,
const
void
*
val
,
bool
isCopyVarData
,
int8_t
colType
,
int16_t
colIdx
,
int32_t
offset
,
bool
isCopyVarData
,
int8_t
colType
,
int16_t
colIdx
,
int32_t
offset
,
col_id_t
colId
);
col_id_t
colId
);
int32_t
tdAppendSTSRowToDataCol
(
STSRow
*
pRow
,
STSchema
*
pSchema
,
SDataCols
*
pCols
);
int32_t
tdAppendSTSRowToDataCol
(
STSRow
*
pRow
,
STSchema
*
pSchema
,
SDataCols
*
pCols
);
/**
/**
* @brief
* @brief
...
@@ -327,9 +332,9 @@ static FORCE_INLINE int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx,
...
@@ -327,9 +332,9 @@ static FORCE_INLINE int32_t tdSetBitmapValTypeII(void *pBitmap, int16_t colIdx,
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
FORCE_INLINE
bool
tdIsBitmapValTypeNorm
II
(
const
void
*
pBitmap
,
int16_t
idx
)
{
static
FORCE_INLINE
bool
tdIsBitmapValTypeNorm
(
const
void
*
pBitmap
,
int16_t
idx
,
int8_t
bitmapMode
)
{
TDRowValT
valType
=
0
;
TDRowValT
valType
=
0
;
tdGetBitmapValType
II
(
pBitmap
,
idx
,
&
valTyp
e
);
tdGetBitmapValType
(
pBitmap
,
idx
,
&
valType
,
bitmapMod
e
);
if
(
tdValTypeIsNorm
(
valType
))
{
if
(
tdValTypeIsNorm
(
valType
))
{
return
true
;
return
true
;
}
}
...
...
include/common/ttypes.h
浏览文件 @
5b835514
...
@@ -248,8 +248,8 @@ typedef struct tDataTypeDescriptor {
...
@@ -248,8 +248,8 @@ typedef struct tDataTypeDescriptor {
int32_t
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int32_t
bufferSize
);
int32_t
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int32_t
bufferSize
);
int32_t
(
*
decompFunc
)(
const
char
*
const
input
,
int32_t
compressedSize
,
const
int32_t
nelements
,
char
*
const
output
,
int32_t
(
*
decompFunc
)(
const
char
*
const
input
,
int32_t
compressedSize
,
const
int32_t
nelements
,
char
*
const
output
,
int32_t
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int32_t
bufferSize
);
int32_t
outputSize
,
char
algorithm
,
char
*
const
buffer
,
int32_t
bufferSize
);
void
(
*
statisFunc
)(
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numofrow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minindex
,
void
(
*
statisFunc
)(
int8_t
bitmapMode
,
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numofrow
,
int64_t
*
min
,
int16_t
*
maxindex
,
int16_t
*
numofnull
);
int
64_t
*
max
,
int64_t
*
sum
,
int16_t
*
minindex
,
int
16_t
*
maxindex
,
int16_t
*
numofnull
);
}
tDataTypeDescriptor
;
}
tDataTypeDescriptor
;
extern
tDataTypeDescriptor
tDataTypes
[
15
];
extern
tDataTypeDescriptor
tDataTypes
[
15
];
...
...
include/libs/nodes/plannodes.h
浏览文件 @
5b835514
...
@@ -355,8 +355,11 @@ typedef struct SQueryPlan {
...
@@ -355,8 +355,11 @@ typedef struct SQueryPlan {
int32_t
numOfSubplans
;
int32_t
numOfSubplans
;
SNodeList
*
pSubplans
;
// Element is SNodeListNode. The execution level of subplan, starting from 0.
SNodeList
*
pSubplans
;
// Element is SNodeListNode. The execution level of subplan, starting from 0.
SExplainInfo
explainInfo
;
SExplainInfo
explainInfo
;
SNodeList
*
pPlaceholderValues
;
}
SQueryPlan
;
}
SQueryPlan
;
void
nodesWalkPhysiPlan
(
SNode
*
pNode
,
FNodeWalker
walker
,
void
*
pContext
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/libs/nodes/querynodes.h
浏览文件 @
5b835514
...
@@ -82,6 +82,7 @@ typedef struct SValueNode {
...
@@ -82,6 +82,7 @@ typedef struct SValueNode {
bool
isDuration
;
bool
isDuration
;
bool
translate
;
bool
translate
;
bool
genByCalc
;
bool
genByCalc
;
int16_t
placeholderNo
;
union
{
union
{
bool
b
;
bool
b
;
int64_t
i
;
int64_t
i
;
...
...
include/libs/planner/planner.h
浏览文件 @
5b835514
...
@@ -21,6 +21,7 @@ extern "C" {
...
@@ -21,6 +21,7 @@ extern "C" {
#endif
#endif
#include "plannodes.h"
#include "plannodes.h"
#include "taos.h"
typedef
struct
SPlanContext
{
typedef
struct
SPlanContext
{
uint64_t
queryId
;
uint64_t
queryId
;
...
@@ -32,6 +33,7 @@ typedef struct SPlanContext {
...
@@ -32,6 +33,7 @@ typedef struct SPlanContext {
bool
showRewrite
;
bool
showRewrite
;
int8_t
triggerType
;
int8_t
triggerType
;
int64_t
watermark
;
int64_t
watermark
;
bool
isStmtQuery
;
}
SPlanContext
;
}
SPlanContext
;
// Create the physical plan for the query, according to the AST.
// Create the physical plan for the query, according to the AST.
...
@@ -43,6 +45,9 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
...
@@ -43,6 +45,9 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
// @pSource one execution location of this group of datasource subplans
// @pSource one execution location of this group of datasource subplans
int32_t
qSetSubplanExecutionNode
(
SSubplan
*
pSubplan
,
int32_t
groupId
,
SDownstreamSourceNode
*
pSource
);
int32_t
qSetSubplanExecutionNode
(
SSubplan
*
pSubplan
,
int32_t
groupId
,
SDownstreamSourceNode
*
pSource
);
typedef
TAOS_MULTI_BIND
TAOS_BIND_v2
;
// todo remove
int32_t
qStmtBindParam
(
SQueryPlan
*
pPlan
,
TAOS_BIND_v2
*
pParams
);
// Convert to subplan to string for the scheduler to send to the executor
// Convert to subplan to string for the scheduler to send to the executor
int32_t
qSubPlanToString
(
const
SSubplan
*
pSubplan
,
char
**
pStr
,
int32_t
*
pLen
);
int32_t
qSubPlanToString
(
const
SSubplan
*
pSubplan
,
char
**
pStr
,
int32_t
*
pLen
);
int32_t
qStringToSubplan
(
const
char
*
pStr
,
SSubplan
**
pSubplan
);
int32_t
qStringToSubplan
(
const
char
*
pStr
,
SSubplan
**
pSubplan
);
...
...
include/os/osThread.h
浏览文件 @
5b835514
...
@@ -22,6 +22,10 @@
...
@@ -22,6 +22,10 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#ifndef __USE_XOPEN2K
typedef
pthread_mutex_t
pthread_spinlock_t
;
#endif
typedef
pthread_t
TdThread
;
typedef
pthread_t
TdThread
;
typedef
pthread_spinlock_t
TdThreadSpinlock
;
typedef
pthread_spinlock_t
TdThreadSpinlock
;
typedef
pthread_mutex_t
TdThreadMutex
;
typedef
pthread_mutex_t
TdThreadMutex
;
...
@@ -33,8 +37,6 @@ typedef pthread_rwlockattr_t TdThreadRwlockAttr;
...
@@ -33,8 +37,6 @@ typedef pthread_rwlockattr_t TdThreadRwlockAttr;
typedef
pthread_cond_t
TdThreadCond
;
typedef
pthread_cond_t
TdThreadCond
;
typedef
pthread_condattr_t
TdThreadCondAttr
;
typedef
pthread_condattr_t
TdThreadCondAttr
;
typedef
pthread_key_t
TdThreadKey
;
typedef
pthread_key_t
TdThreadKey
;
typedef
pthread_barrier_t
TdThreadBarrier
;
typedef
pthread_barrierattr_t
TdThreadBarrierAttr
;
#define taosThreadCleanupPush pthread_cleanup_push
#define taosThreadCleanupPush pthread_cleanup_push
#define taosThreadCleanupPop pthread_cleanup_pop
#define taosThreadCleanupPop pthread_cleanup_pop
...
@@ -156,13 +158,6 @@ int32_t taosThreadAttrSetSchedParam(TdThreadAttr * attr, const struct sched_para
...
@@ -156,13 +158,6 @@ int32_t taosThreadAttrSetSchedParam(TdThreadAttr * attr, const struct sched_para
int32_t
taosThreadAttrSetSchedPolicy
(
TdThreadAttr
*
attr
,
int32_t
policy
);
int32_t
taosThreadAttrSetSchedPolicy
(
TdThreadAttr
*
attr
,
int32_t
policy
);
int32_t
taosThreadAttrSetScope
(
TdThreadAttr
*
attr
,
int32_t
contentionscope
);
int32_t
taosThreadAttrSetScope
(
TdThreadAttr
*
attr
,
int32_t
contentionscope
);
int32_t
taosThreadAttrSetStackSize
(
TdThreadAttr
*
attr
,
size_t
stacksize
);
int32_t
taosThreadAttrSetStackSize
(
TdThreadAttr
*
attr
,
size_t
stacksize
);
int32_t
taosThreadBarrierDestroy
(
TdThreadBarrier
*
barrier
);
int32_t
taosThreadBarrierInit
(
TdThreadBarrier
*
barrier
,
const
TdThreadBarrierAttr
*
attr
,
uint32_t
count
);
int32_t
taosThreadBarrierWait
(
TdThreadBarrier
*
barrier
);
int32_t
taosThreadBarrierAttrDestroy
(
TdThreadBarrierAttr
*
attr
);
int32_t
taosThreadBarrierAttrGetPshared
(
const
TdThreadBarrierAttr
*
attr
,
int32_t
*
pshared
);
int32_t
taosThreadBarrierAttrInit
(
TdThreadBarrierAttr
*
attr
);
int32_t
taosThreadBarrierAttrSetPshared
(
TdThreadBarrierAttr
*
attr
,
int32_t
pshared
);
int32_t
taosThreadCancel
(
TdThread
thread
);
int32_t
taosThreadCancel
(
TdThread
thread
);
int32_t
taosThreadCondDestroy
(
TdThreadCond
*
cond
);
int32_t
taosThreadCondDestroy
(
TdThreadCond
*
cond
);
int32_t
taosThreadCondInit
(
TdThreadCond
*
cond
,
const
TdThreadCondAttr
*
attr
);
int32_t
taosThreadCondInit
(
TdThreadCond
*
cond
,
const
TdThreadCondAttr
*
attr
);
...
...
include/util/tdef.h
浏览文件 @
5b835514
...
@@ -128,17 +128,17 @@ extern const int32_t TYPE_BYTES[15];
...
@@ -128,17 +128,17 @@ extern const int32_t TYPE_BYTES[15];
#define TSDB_INS_TABLE_QUERIES "queries"
#define TSDB_INS_TABLE_QUERIES "queries"
#define TSDB_INS_TABLE_VNODES "vnodes"
#define TSDB_INS_TABLE_VNODES "vnodes"
#define TSDB_PERFORMANCE_SCHEMA_DB
"performance_schema"
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
#define TSDB_PERFS_TABLE_CONNECTIONS
"connections"
#define TSDB_PERFS_TABLE_CONNECTIONS "connections"
#define TSDB_PERFS_TABLE_QUERIES
"queries"
#define TSDB_PERFS_TABLE_QUERIES "queries"
#define TSDB_PERFS_TABLE_TOPICS
"topics"
#define TSDB_PERFS_TABLE_TOPICS "topics"
#define TSDB_PERFS_TABLE_CONSUMERS
"consumers"
#define TSDB_PERFS_TABLE_CONSUMERS "consumers"
#define TSDB_PERFS_TABLE_SUBSCRIBES
"subscribes"
#define TSDB_PERFS_TABLE_SUBSCRIBES "subscribes"
#define TSDB_INDEX_TYPE_SMA "SMA"
#define TSDB_INDEX_TYPE_SMA "SMA"
#define TSDB_INDEX_TYPE_FULLTEXT "FULLTEXT"
#define TSDB_INDEX_TYPE_FULLTEXT "FULLTEXT"
#define TSDB_INS_USER_STABLES_DBNAME_COLID
2
#define TSDB_INS_USER_STABLES_DBNAME_COLID 2
#define TSDB_TICK_PER_SECOND(precision) \
#define TSDB_TICK_PER_SECOND(precision) \
((int64_t)((precision) == TSDB_TIME_PRECISION_MILLI ? 1e3L \
((int64_t)((precision) == TSDB_TIME_PRECISION_MILLI ? 1e3L \
...
@@ -234,8 +234,8 @@ typedef enum ELogicConditionType {
...
@@ -234,8 +234,8 @@ typedef enum ELogicConditionType {
#define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_FUNC_NAME_LEN 65
#define TSDB_FUNC_NAME_LEN 65
#define TSDB_FUNC_COMMENT_LEN
4096
#define TSDB_FUNC_COMMENT_LEN
1024 * 1024
#define TSDB_FUNC_CODE_LEN
(65535 - 512)
#define TSDB_FUNC_CODE_LEN
10 * 1024 * 1024
#define TSDB_FUNC_BUF_SIZE 512
#define TSDB_FUNC_BUF_SIZE 512
#define TSDB_FUNC_TYPE_SCALAR 1
#define TSDB_FUNC_TYPE_SCALAR 1
#define TSDB_FUNC_TYPE_AGGREGATE 2
#define TSDB_FUNC_TYPE_AGGREGATE 2
...
@@ -339,12 +339,12 @@ typedef enum ELogicConditionType {
...
@@ -339,12 +339,12 @@ typedef enum ELogicConditionType {
#define TSDB_MAX_TOTAL_BLOCKS 10000
#define TSDB_MAX_TOTAL_BLOCKS 10000
#define TSDB_DEFAULT_TOTAL_BLOCKS 6
#define TSDB_DEFAULT_TOTAL_BLOCKS 6
#define TSDB_MIN_DAYS_PER_FILE 60
// unit minute
#define TSDB_MIN_DAYS_PER_FILE 60 // unit minute
#define TSDB_MAX_DAYS_PER_FILE (3650 * 1440)
#define TSDB_MAX_DAYS_PER_FILE (3650 * 1440)
#define TSDB_DEFAULT_DAYS_PER_FILE (10 * 1440)
#define TSDB_DEFAULT_DAYS_PER_FILE (10 * 1440)
#define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute
#define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute
#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved.
#define TSDB_MAX_KEEP (365000 * 1440)
// data in db to be reserved.
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years
#define TSDB_MIN_MIN_ROW_FBLOCK 10
#define TSDB_MIN_MIN_ROW_FBLOCK 10
...
@@ -419,11 +419,11 @@ typedef enum ELogicConditionType {
...
@@ -419,11 +419,11 @@ typedef enum ELogicConditionType {
#define TSDB_DEFAULT_EXPLAIN_VERBOSE false
#define TSDB_DEFAULT_EXPLAIN_VERBOSE false
#define TSDB_MIN_EXPLAIN_RATIO
0
#define TSDB_MIN_EXPLAIN_RATIO 0
#define TSDB_MAX_EXPLAIN_RATIO
1
#define TSDB_MAX_EXPLAIN_RATIO 1
#define TSDB_DEFAULT_EXPLAIN_RATIO
0.001
#define TSDB_DEFAULT_EXPLAIN_RATIO 0.001
#define TSDB_EXPLAIN_RESULT_ROW_SIZE 1024
#define TSDB_EXPLAIN_RESULT_ROW_SIZE
1024
#define TSDB_EXPLAIN_RESULT_COLUMN_NAME "QUERY PLAN"
#define TSDB_EXPLAIN_RESULT_COLUMN_NAME "QUERY PLAN"
#define TSDB_MAX_JOIN_TABLE_NUM 10
#define TSDB_MAX_JOIN_TABLE_NUM 10
...
@@ -509,13 +509,13 @@ enum {
...
@@ -509,13 +509,13 @@ enum {
SND_WORKER_TYPE__UNIQUE
,
SND_WORKER_TYPE__UNIQUE
,
};
};
#define MNODE_HANDLE -1
#define MNODE_HANDLE
-1
#define QNODE_HANDLE 1
#define QNODE_HANDLE
1
#define DEFAULT_HANDLE 0
#define DEFAULT_HANDLE 0
#define TSDB_CONFIG_OPTION_LEN
16
#define TSDB_CONFIG_OPTION_LEN 16
#define TSDB_CONIIG_VALUE_LEN
48
#define TSDB_CONIIG_VALUE_LEN 48
#define TSDB_CONFIG_NUMBER
8
#define TSDB_CONFIG_NUMBER 8
#define QUERY_ID_SIZE 20
#define QUERY_ID_SIZE 20
#define QUERY_OBJ_ID_SIZE 18
#define QUERY_OBJ_ID_SIZE 18
...
@@ -524,7 +524,6 @@ enum {
...
@@ -524,7 +524,6 @@ enum {
#define MAX_NUM_STR_SIZE 40
#define MAX_NUM_STR_SIZE 40
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/client/src/clientMain.c
浏览文件 @
5b835514
...
@@ -71,6 +71,7 @@ void taos_cleanup(void) {
...
@@ -71,6 +71,7 @@ void taos_cleanup(void) {
schedulerDestroy
();
schedulerDestroy
();
tscInfo
(
"all local resources released"
);
tscInfo
(
"all local resources released"
);
taosCleanupCfg
();
taosCloseLog
();
taosCloseLog
();
}
}
...
...
source/common/src/tdatablock.c
浏览文件 @
5b835514
...
@@ -1101,6 +1101,11 @@ int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows)
...
@@ -1101,6 +1101,11 @@ int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows)
pColumn
->
nullbitmap
=
tmp
;
pColumn
->
nullbitmap
=
tmp
;
memset
(
pColumn
->
nullbitmap
,
0
,
BitmapLen
(
numOfRows
));
memset
(
pColumn
->
nullbitmap
,
0
,
BitmapLen
(
numOfRows
));
if
(
pColumn
->
info
.
type
==
TSDB_DATA_TYPE_NULL
)
{
return
TSDB_CODE_SUCCESS
;
}
assert
(
pColumn
->
info
.
bytes
);
assert
(
pColumn
->
info
.
bytes
);
tmp
=
taosMemoryRealloc
(
pColumn
->
pData
,
numOfRows
*
pColumn
->
info
.
bytes
);
tmp
=
taosMemoryRealloc
(
pColumn
->
pData
,
numOfRows
*
pColumn
->
info
.
bytes
);
if
(
tmp
==
NULL
)
{
if
(
tmp
==
NULL
)
{
...
...
source/common/src/tmsg.c
浏览文件 @
5b835514
...
@@ -142,10 +142,10 @@ static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq
...
@@ -142,10 +142,10 @@ static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq
if
(
tEncodeU32
(
pEncoder
,
pReq
->
query
->
connId
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
pEncoder
,
pReq
->
query
->
connId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pReq
->
query
->
pid
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pReq
->
query
->
pid
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pReq
->
query
->
app
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pReq
->
query
->
app
)
<
0
)
return
-
1
;
int32_t
num
=
taosArrayGetSize
(
pReq
->
query
->
queryDesc
);
int32_t
num
=
taosArrayGetSize
(
pReq
->
query
->
queryDesc
);
if
(
tEncodeI32
(
pEncoder
,
num
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
num
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SQueryDesc
*
desc
=
taosArrayGet
(
pReq
->
query
->
queryDesc
,
i
);
SQueryDesc
*
desc
=
taosArrayGet
(
pReq
->
query
->
queryDesc
,
i
);
if
(
tEncodeCStr
(
pEncoder
,
desc
->
sql
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
desc
->
sql
)
<
0
)
return
-
1
;
...
@@ -169,7 +169,7 @@ static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq
...
@@ -169,7 +169,7 @@ static int32_t tSerializeSClientHbReq(SCoder *pEncoder, const SClientHbReq *pReq
if
(
tEncodeI32
(
pEncoder
,
queryNum
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
queryNum
)
<
0
)
return
-
1
;
}
}
}
}
int32_t
kvNum
=
taosHashGetSize
(
pReq
->
info
);
int32_t
kvNum
=
taosHashGetSize
(
pReq
->
info
);
if
(
tEncodeI32
(
pEncoder
,
kvNum
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
kvNum
)
<
0
)
return
-
1
;
void
*
pIter
=
taosHashIterate
(
pReq
->
info
,
NULL
);
void
*
pIter
=
taosHashIterate
(
pReq
->
info
,
NULL
);
...
@@ -200,7 +200,7 @@ static int32_t tDeserializeSClientHbReq(SCoder *pDecoder, SClientHbReq *pReq) {
...
@@ -200,7 +200,7 @@ static int32_t tDeserializeSClientHbReq(SCoder *pDecoder, SClientHbReq *pReq) {
if
(
num
>
0
)
{
if
(
num
>
0
)
{
pReq
->
query
->
queryDesc
=
taosArrayInit
(
num
,
sizeof
(
SQueryDesc
));
pReq
->
query
->
queryDesc
=
taosArrayInit
(
num
,
sizeof
(
SQueryDesc
));
if
(
NULL
==
pReq
->
query
->
queryDesc
)
return
-
1
;
if
(
NULL
==
pReq
->
query
->
queryDesc
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SQueryDesc
desc
=
{
0
};
SQueryDesc
desc
=
{
0
};
if
(
tDecodeCStrTo
(
pDecoder
,
desc
.
sql
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
pDecoder
,
desc
.
sql
)
<
0
)
return
-
1
;
...
@@ -217,7 +217,7 @@ static int32_t tDeserializeSClientHbReq(SCoder *pDecoder, SClientHbReq *pReq) {
...
@@ -217,7 +217,7 @@ static int32_t tDeserializeSClientHbReq(SCoder *pDecoder, SClientHbReq *pReq) {
if
(
snum
>
0
)
{
if
(
snum
>
0
)
{
desc
.
subDesc
=
taosArrayInit
(
snum
,
sizeof
(
SQuerySubDesc
));
desc
.
subDesc
=
taosArrayInit
(
snum
,
sizeof
(
SQuerySubDesc
));
if
(
NULL
==
desc
.
subDesc
)
return
-
1
;
if
(
NULL
==
desc
.
subDesc
)
return
-
1
;
for
(
int32_t
m
=
0
;
m
<
snum
;
++
m
)
{
for
(
int32_t
m
=
0
;
m
<
snum
;
++
m
)
{
SQuerySubDesc
sDesc
=
{
0
};
SQuerySubDesc
sDesc
=
{
0
};
if
(
tDecodeI64
(
pDecoder
,
&
sDesc
.
tid
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
pDecoder
,
&
sDesc
.
tid
)
<
0
)
return
-
1
;
...
@@ -254,7 +254,7 @@ static int32_t tSerializeSClientHbRsp(SCoder *pEncoder, const SClientHbRsp *pRsp
...
@@ -254,7 +254,7 @@ static int32_t tSerializeSClientHbRsp(SCoder *pEncoder, const SClientHbRsp *pRsp
int32_t
queryNum
=
0
;
int32_t
queryNum
=
0
;
if
(
pRsp
->
query
)
{
if
(
pRsp
->
query
)
{
queryNum
=
1
;
queryNum
=
1
;
if
(
tEncodeI32
(
pEncoder
,
queryNum
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
queryNum
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
pEncoder
,
pRsp
->
query
->
connId
)
<
0
)
return
-
1
;
if
(
tEncodeU32
(
pEncoder
,
pRsp
->
query
->
connId
)
<
0
)
return
-
1
;
if
(
tEncodeU64
(
pEncoder
,
pRsp
->
query
->
killRid
)
<
0
)
return
-
1
;
if
(
tEncodeU64
(
pEncoder
,
pRsp
->
query
->
killRid
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pRsp
->
query
->
totalDnodes
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pRsp
->
query
->
totalDnodes
)
<
0
)
return
-
1
;
...
@@ -262,9 +262,9 @@ static int32_t tSerializeSClientHbRsp(SCoder *pEncoder, const SClientHbRsp *pRsp
...
@@ -262,9 +262,9 @@ static int32_t tSerializeSClientHbRsp(SCoder *pEncoder, const SClientHbRsp *pRsp
if
(
tEncodeI8
(
pEncoder
,
pRsp
->
query
->
killConnection
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pRsp
->
query
->
killConnection
)
<
0
)
return
-
1
;
if
(
tEncodeSEpSet
(
pEncoder
,
&
pRsp
->
query
->
epSet
)
<
0
)
return
-
1
;
if
(
tEncodeSEpSet
(
pEncoder
,
&
pRsp
->
query
->
epSet
)
<
0
)
return
-
1
;
}
else
{
}
else
{
if
(
tEncodeI32
(
pEncoder
,
queryNum
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
queryNum
)
<
0
)
return
-
1
;
}
}
int32_t
kvNum
=
taosArrayGetSize
(
pRsp
->
info
);
int32_t
kvNum
=
taosArrayGetSize
(
pRsp
->
info
);
if
(
tEncodeI32
(
pEncoder
,
kvNum
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
kvNum
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
kvNum
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
kvNum
;
i
++
)
{
...
@@ -411,7 +411,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -411,7 +411,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
stbCfg
.
nBSmaCols
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
stbCfg
.
nBSmaCols
);
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nCols
;
++
i
)
{
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nCols
;
++
i
)
{
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
sma
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
flags
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
colId
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
colId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
bytes
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
bytes
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
name
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
name
);
...
@@ -419,7 +419,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -419,7 +419,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
stbCfg
.
nTagCols
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
stbCfg
.
nTagCols
);
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nTagCols
;
++
i
)
{
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nTagCols
;
++
i
)
{
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
index
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
flags
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
colId
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
colId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
bytes
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
bytes
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
name
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
name
);
...
@@ -443,7 +443,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -443,7 +443,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
ntbCfg
.
nBSmaCols
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
ntbCfg
.
nBSmaCols
);
for
(
col_id_t
i
=
0
;
i
<
pReq
->
ntbCfg
.
nCols
;
++
i
)
{
for
(
col_id_t
i
=
0
;
i
<
pReq
->
ntbCfg
.
nCols
;
++
i
)
{
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
sma
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
flags
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
colId
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
colId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
bytes
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
bytes
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
name
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
name
);
...
@@ -478,10 +478,10 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -478,10 +478,10 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
buf
=
taosDecodeFixedI64
(
buf
,
&
(
pReq
->
stbCfg
.
suid
));
buf
=
taosDecodeFixedI64
(
buf
,
&
(
pReq
->
stbCfg
.
suid
));
buf
=
taosDecodeFixedI16
(
buf
,
&
(
pReq
->
stbCfg
.
nCols
));
buf
=
taosDecodeFixedI16
(
buf
,
&
(
pReq
->
stbCfg
.
nCols
));
buf
=
taosDecodeFixedI16
(
buf
,
&
(
pReq
->
stbCfg
.
nBSmaCols
));
buf
=
taosDecodeFixedI16
(
buf
,
&
(
pReq
->
stbCfg
.
nBSmaCols
));
pReq
->
stbCfg
.
pSchema
=
(
SSchema
Ex
*
)
taosMemoryMalloc
(
pReq
->
stbCfg
.
nCols
*
sizeof
(
SSchemaEx
));
pReq
->
stbCfg
.
pSchema
=
(
SSchema
*
)
taosMemoryMalloc
(
pReq
->
stbCfg
.
nCols
*
sizeof
(
SSchema
));
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nCols
;
++
i
)
{
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nCols
;
++
i
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
type
));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
type
));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
sma
));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
flags
));
buf
=
taosDecodeFixedI16
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
colId
));
buf
=
taosDecodeFixedI16
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
colId
));
buf
=
taosDecodeFixedI32
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
bytes
));
buf
=
taosDecodeFixedI32
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
bytes
));
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
name
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
name
);
...
@@ -490,7 +490,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -490,7 +490,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
pReq
->
stbCfg
.
pTagSchema
=
(
SSchema
*
)
taosMemoryMalloc
(
pReq
->
stbCfg
.
nTagCols
*
sizeof
(
SSchema
));
pReq
->
stbCfg
.
pTagSchema
=
(
SSchema
*
)
taosMemoryMalloc
(
pReq
->
stbCfg
.
nTagCols
*
sizeof
(
SSchema
));
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nTagCols
;
++
i
)
{
for
(
col_id_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nTagCols
;
++
i
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pTagSchema
[
i
].
type
));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pTagSchema
[
i
].
type
));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pTagSchema
[
i
].
index
));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pTagSchema
[
i
].
flags
));
buf
=
taosDecodeFixedI16
(
buf
,
&
pReq
->
stbCfg
.
pTagSchema
[
i
].
colId
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pReq
->
stbCfg
.
pTagSchema
[
i
].
colId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
stbCfg
.
pTagSchema
[
i
].
bytes
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
stbCfg
.
pTagSchema
[
i
].
bytes
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
name
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
name
);
...
@@ -520,10 +520,10 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -520,10 +520,10 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
case
TD_NORMAL_TABLE
:
case
TD_NORMAL_TABLE
:
buf
=
taosDecodeFixedI16
(
buf
,
&
pReq
->
ntbCfg
.
nCols
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pReq
->
ntbCfg
.
nCols
);
buf
=
taosDecodeFixedI16
(
buf
,
&
(
pReq
->
ntbCfg
.
nBSmaCols
));
buf
=
taosDecodeFixedI16
(
buf
,
&
(
pReq
->
ntbCfg
.
nBSmaCols
));
pReq
->
ntbCfg
.
pSchema
=
(
SSchema
Ex
*
)
taosMemoryMalloc
(
pReq
->
ntbCfg
.
nCols
*
sizeof
(
SSchemaEx
));
pReq
->
ntbCfg
.
pSchema
=
(
SSchema
*
)
taosMemoryMalloc
(
pReq
->
ntbCfg
.
nCols
*
sizeof
(
SSchema
));
for
(
col_id_t
i
=
0
;
i
<
pReq
->
ntbCfg
.
nCols
;
++
i
)
{
for
(
col_id_t
i
=
0
;
i
<
pReq
->
ntbCfg
.
nCols
;
++
i
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
ntbCfg
.
pSchema
[
i
].
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
ntbCfg
.
pSchema
[
i
].
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
ntbCfg
.
pSchema
[
i
].
sma
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
ntbCfg
.
pSchema
[
i
].
flags
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pReq
->
ntbCfg
.
pSchema
[
i
].
colId
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pReq
->
ntbCfg
.
pSchema
[
i
].
colId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
ntbCfg
.
pSchema
[
i
].
bytes
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
ntbCfg
.
pSchema
[
i
].
bytes
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
name
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
name
);
...
@@ -1492,10 +1492,25 @@ int32_t tSerializeSCreateFuncReq(void *buf, int32_t bufLen, SCreateFuncReq *pReq
...
@@ -1492,10 +1492,25 @@ int32_t tSerializeSCreateFuncReq(void *buf, int32_t bufLen, SCreateFuncReq *pReq
if
(
tEncodeI32
(
&
encoder
,
pReq
->
outputLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
outputLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
bufSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
bufSize
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
signature
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
signature
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
commentSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
codeSize
)
<
0
)
return
-
1
;
int32_t
codeSize
=
0
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
pComment
)
<
0
)
return
-
1
;
if
(
pReq
->
pCode
!=
NULL
)
{
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
pCode
)
<
0
)
return
-
1
;
codeSize
=
strlen
(
pReq
->
pCode
)
+
1
;
}
if
(
tEncodeI32
(
&
encoder
,
codeSize
)
<
0
)
return
-
1
;
if
(
pReq
->
pCode
!=
NULL
)
{
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
pCode
)
<
0
)
return
-
1
;
}
int32_t
commentSize
=
0
;
if
(
pReq
->
pComment
!=
NULL
)
{
commentSize
=
strlen
(
pReq
->
pComment
)
+
1
;
}
if
(
tEncodeI32
(
&
encoder
,
commentSize
)
<
0
)
return
-
1
;
if
(
pReq
->
pComment
!=
NULL
)
{
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
pComment
)
<
0
)
return
-
1
;
}
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -1516,16 +1531,40 @@ int32_t tDeserializeSCreateFuncReq(void *buf, int32_t bufLen, SCreateFuncReq *pR
...
@@ -1516,16 +1531,40 @@ int32_t tDeserializeSCreateFuncReq(void *buf, int32_t bufLen, SCreateFuncReq *pR
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
outputLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
outputLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
bufSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
bufSize
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
signature
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
signature
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
commentSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
codeSize
)
<
0
)
return
-
1
;
int32_t
codeSize
=
0
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pComment
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
codeSize
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pCode
)
<
0
)
return
-
1
;
if
(
codeSize
>
0
)
{
pReq
->
pCode
=
taosMemoryCalloc
(
1
,
codeSize
);
if
(
pReq
->
pCode
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pCode
)
<
0
)
return
-
1
;
}
int32_t
commentSize
=
0
;
if
(
tDecodeI32
(
&
decoder
,
&
commentSize
)
<
0
)
return
-
1
;
if
(
commentSize
>
0
)
{
pReq
->
pComment
=
taosMemoryCalloc
(
1
,
commentSize
);
if
(
pReq
->
pComment
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
pComment
)
<
0
)
return
-
1
;
}
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
return
0
;
}
}
void
tFreeSCreateFuncReq
(
SCreateFuncReq
*
pReq
)
{
taosMemoryFree
(
pReq
->
pCode
);
taosMemoryFree
(
pReq
->
pComment
);
}
int32_t
tSerializeSDropFuncReq
(
void
*
buf
,
int32_t
bufLen
,
SDropFuncReq
*
pReq
)
{
int32_t
tSerializeSDropFuncReq
(
void
*
buf
,
int32_t
bufLen
,
SDropFuncReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
...
@@ -1594,6 +1633,8 @@ int32_t tDeserializeSRetrieveFuncReq(void *buf, int32_t bufLen, SRetrieveFuncReq
...
@@ -1594,6 +1633,8 @@ int32_t tDeserializeSRetrieveFuncReq(void *buf, int32_t bufLen, SRetrieveFuncReq
return
0
;
return
0
;
}
}
void
tFreeSRetrieveFuncReq
(
SRetrieveFuncReq
*
pReq
)
{
taosArrayDestroy
(
pReq
->
pFuncNames
);
}
int32_t
tSerializeSRetrieveFuncRsp
(
void
*
buf
,
int32_t
bufLen
,
SRetrieveFuncRsp
*
pRsp
)
{
int32_t
tSerializeSRetrieveFuncRsp
(
void
*
buf
,
int32_t
bufLen
,
SRetrieveFuncRsp
*
pRsp
)
{
SCoder
encoder
=
{
0
};
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
...
@@ -1612,10 +1653,10 @@ int32_t tSerializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp *
...
@@ -1612,10 +1653,10 @@ int32_t tSerializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp *
if
(
tEncodeI32
(
&
encoder
,
pInfo
->
outputLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pInfo
->
outputLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pInfo
->
bufSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pInfo
->
bufSize
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pInfo
->
signature
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pInfo
->
signature
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pInfo
->
commentSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pInfo
->
codeSize
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pInfo
->
codeSize
)
<
0
)
return
-
1
;
if
(
tEncode
CStr
(
&
encoder
,
pInfo
->
pComment
)
<
0
)
return
-
1
;
if
(
tEncode
I32
(
&
encoder
,
pInfo
->
commentSize
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pInfo
->
pCode
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pInfo
->
pCode
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pInfo
->
pComment
)
<
0
)
return
-
1
;
}
}
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
...
@@ -1644,10 +1685,17 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp
...
@@ -1644,10 +1685,17 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp
if
(
tDecodeI32
(
&
decoder
,
&
fInfo
.
outputLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
fInfo
.
outputLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
fInfo
.
bufSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
fInfo
.
bufSize
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
fInfo
.
signature
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
fInfo
.
signature
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
fInfo
.
commentSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
fInfo
.
codeSize
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
fInfo
.
codeSize
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
fInfo
.
pComment
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
fInfo
.
commentSize
)
<
0
)
return
-
1
;
fInfo
.
pCode
=
taosMemoryCalloc
(
1
,
fInfo
.
codeSize
);
fInfo
.
pComment
=
taosMemoryCalloc
(
1
,
fInfo
.
commentSize
);
if
(
fInfo
.
pCode
==
NULL
||
fInfo
.
pComment
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
tDecodeCStrTo
(
&
decoder
,
fInfo
.
pCode
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
fInfo
.
pCode
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
fInfo
.
pComment
)
<
0
)
return
-
1
;
taosArrayPush
(
pRsp
->
pFuncInfos
,
&
fInfo
);
taosArrayPush
(
pRsp
->
pFuncInfos
,
&
fInfo
);
}
}
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
...
@@ -1656,6 +1704,16 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp
...
@@ -1656,6 +1704,16 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp
return
0
;
return
0
;
}
}
void
tFreeSRetrieveFuncRsp
(
SRetrieveFuncRsp
*
pRsp
)
{
int32_t
size
=
taosArrayGetSize
(
pRsp
->
pFuncInfos
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SFuncInfo
*
pInfo
=
taosArrayGet
(
pRsp
->
pFuncInfos
,
i
);
taosMemoryFree
(
pInfo
->
pCode
);
taosMemoryFree
(
pInfo
->
pComment
);
}
taosArrayDestroy
(
pRsp
->
pFuncInfos
);
}
int32_t
tSerializeSCreateDbReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDbReq
*
pReq
)
{
int32_t
tSerializeSCreateDbReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDbReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
...
...
source/common/src/trow.c
浏览文件 @
5b835514
...
@@ -16,10 +16,19 @@
...
@@ -16,10 +16,19 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "trow.h"
#include "trow.h"
const
uint8_t
tdVTypeByte
[
3
]
=
{
const
uint8_t
tdVTypeByte
[
2
][
3
]
=
{{
TD_VTYPE_NORM_BYTE
,
// TD_VTYPE_NORM
// 2 bits
TD_VTYPE_NONE_BYTE
,
// TD_VTYPE_NONE
TD_VTYPE_NORM_BYTE_II
,
TD_VTYPE_NULL_BYTE
,
// TD_VTYPE_NULL
TD_VTYPE_NONE_BYTE_II
,
TD_VTYPE_NULL_BYTE_II
,
},
{
// 1 bit
TD_VTYPE_NORM_BYTE_I
,
TD_VTYPE_NULL_BYTE_I
,
TD_VTYPE_NULL_BYTE_I
,
// padding
}
};
};
// declaration
// declaration
...
@@ -266,21 +275,53 @@ static FORCE_INLINE void dataColSetNullAt(SDataCol *pCol, int index, bool setBit
...
@@ -266,21 +275,53 @@ static FORCE_INLINE void dataColSetNullAt(SDataCol *pCol, int index, bool setBit
// }
// }
// }
// }
/**
* @brief Set bitmap area by byte preferentially and then by bit.
*
* @param pBitmap
* @param nEle
* @param valType
* @param bitmapMode 0 for 2 bits, 1 for 1 bit
* @return int32_t
*/
int32_t
tdSetBitmapValTypeN
(
void
*
pBitmap
,
int16_t
nEle
,
TDRowValT
valType
,
int8_t
bitmapMode
)
{
int32_t
tdSetBitmapValTypeN
(
void
*
pBitmap
,
int16_t
nEle
,
TDRowValT
valType
,
int8_t
bitmapMode
)
{
TASSERT
(
valType
<
TD_VTYPE_MAX
);
TASSERT
(
valType
<
TD_VTYPE_MAX
);
int16_t
nBytes
=
nEle
/
TD_VTYPE_PARTS
;
int32_t
nBytes
=
(
bitmapMode
==
0
?
nEle
/
TD_VTYPE_PARTS
:
nEle
/
TD_VTYPE_PARTS_I
);
uint8_t
vTypeByte
=
tdVTypeByte
[
bitmapMode
][
valType
];
for
(
int
i
=
0
;
i
<
nBytes
;
++
i
)
{
for
(
int
i
=
0
;
i
<
nBytes
;
++
i
)
{
*
(
uint8_t
*
)
pBitmap
=
tdVTypeByte
[
valType
]
;
*
(
uint8_t
*
)
pBitmap
=
vTypeByte
;
pBitmap
=
POINTER_SHIFT
(
pBitmap
,
1
);
pBitmap
=
POINTER_SHIFT
(
pBitmap
,
1
);
}
}
int16_t
nLeft
=
nEle
-
nBytes
*
TD_VTYPE_BITS
;
int32_t
nLeft
=
nEle
-
nBytes
*
(
bitmapMode
==
0
?
TD_VTYPE_BITS
:
TD_VTYPE_BITS_I
);
for
(
int
j
=
0
;
j
<
nLeft
;
++
j
)
{
for
(
int
j
=
0
;
j
<
nLeft
;
++
j
)
{
tdSetBitmapValType
(
pBitmap
,
j
,
valType
,
bitmapMode
);
tdSetBitmapValType
(
pBitmap
,
j
,
valType
,
bitmapMode
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
bool
tdIsBitmapBlkNorm
(
const
void
*
pBitmap
,
int32_t
numOfBits
,
int8_t
bitmapMode
)
{
int32_t
nBytes
=
(
bitmapMode
==
0
?
numOfBits
/
TD_VTYPE_PARTS
:
numOfBits
/
TD_VTYPE_PARTS_I
);
uint8_t
vTypeByte
=
tdVTypeByte
[
bitmapMode
][
TD_VTYPE_NORM
];
for
(
int
i
=
0
;
i
<
nBytes
;
++
i
)
{
if
(
*
((
uint8_t
*
)
pBitmap
)
!=
vTypeByte
)
{
return
false
;
}
pBitmap
=
POINTER_SHIFT
(
pBitmap
,
1
);
}
int32_t
nLeft
=
numOfBits
-
nBytes
*
(
bitmapMode
==
0
?
TD_VTYPE_BITS
:
TD_VTYPE_BITS_I
);
for
(
int
j
=
0
;
j
<
nLeft
;
++
j
)
{
uint8_t
vType
;
tdGetBitmapValType
(
pBitmap
,
j
,
&
vType
,
bitmapMode
);
if
(
vType
!=
TD_VTYPE_NORM
)
{
return
false
;
}
}
return
true
;
}
static
FORCE_INLINE
void
dataColSetNoneAt
(
SDataCol
*
pCol
,
int
index
,
bool
setBitmap
,
int8_t
bitmapMode
)
{
static
FORCE_INLINE
void
dataColSetNoneAt
(
SDataCol
*
pCol
,
int
index
,
bool
setBitmap
,
int8_t
bitmapMode
)
{
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
pCol
->
dataOff
[
index
]
=
pCol
->
len
;
pCol
->
dataOff
[
index
]
=
pCol
->
len
;
...
...
source/common/src/ttime.c
浏览文件 @
5b835514
...
@@ -415,7 +415,11 @@ int32_t convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec
...
@@ -415,7 +415,11 @@ int32_t convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec
if
(
type
==
TSDB_DATA_TYPE_BINARY
)
{
if
(
type
==
TSDB_DATA_TYPE_BINARY
)
{
newColData
=
taosMemoryCalloc
(
1
,
charLen
+
1
);
newColData
=
taosMemoryCalloc
(
1
,
charLen
+
1
);
memcpy
(
newColData
,
varDataVal
(
inputData
),
charLen
);
memcpy
(
newColData
,
varDataVal
(
inputData
),
charLen
);
taosParseTime
(
newColData
,
timeVal
,
charLen
,
(
int32_t
)
timePrec
,
0
);
bool
ret
=
taosParseTime
(
newColData
,
timeVal
,
charLen
,
(
int32_t
)
timePrec
,
0
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
taosMemoryFree
(
newColData
);
return
ret
;
}
taosMemoryFree
(
newColData
);
taosMemoryFree
(
newColData
);
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
}
else
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
newColData
=
taosMemoryCalloc
(
1
,
charLen
/
TSDB_NCHAR_SIZE
+
1
);
newColData
=
taosMemoryCalloc
(
1
,
charLen
/
TSDB_NCHAR_SIZE
+
1
);
...
@@ -425,7 +429,11 @@ int32_t convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec
...
@@ -425,7 +429,11 @@ int32_t convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
newColData
[
len
]
=
0
;
newColData
[
len
]
=
0
;
taosParseTime
(
newColData
,
timeVal
,
len
+
1
,
(
int32_t
)
timePrec
,
0
);
bool
ret
=
taosParseTime
(
newColData
,
timeVal
,
len
+
1
,
(
int32_t
)
timePrec
,
0
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
taosMemoryFree
(
newColData
);
return
ret
;
}
taosMemoryFree
(
newColData
);
taosMemoryFree
(
newColData
);
}
else
{
}
else
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
...
...
source/common/src/ttypes.c
浏览文件 @
5b835514
...
@@ -50,8 +50,8 @@ const int32_t TYPE_BYTES[15] = {
...
@@ -50,8 +50,8 @@ const int32_t TYPE_BYTES[15] = {
} \
} \
} while (0)
} while (0)
static
void
getStatics_bool
(
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
static
void
getStatics_bool
(
int8_t
bitmapMode
,
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int
64_t
*
max
,
int64_t
*
sum
,
int
16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int8_t
*
data
=
(
int8_t
*
)
pData
;
int8_t
*
data
=
(
int8_t
*
)
pData
;
*
min
=
INT64_MAX
;
*
min
=
INT64_MAX
;
*
max
=
INT64_MIN
;
*
max
=
INT64_MIN
;
...
@@ -62,7 +62,7 @@ static void getStatics_bool(const void *pBitmap, const void *pData, int32_t numO
...
@@ -62,7 +62,7 @@ static void getStatics_bool(const void *pBitmap, const void *pData, int32_t numO
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
// if (data[i] == TSDB_DATA_BOOL_NULL) {
// if (data[i] == TSDB_DATA_BOOL_NULL) {
if
(
!
tdIsBitmapValTypeNorm
II
(
pBitmap
,
i
))
{
if
(
!
tdIsBitmapValTypeNorm
(
pBitmap
,
i
,
bitmapMode
))
{
(
*
numOfNull
)
+=
1
;
(
*
numOfNull
)
+=
1
;
continue
;
continue
;
}
}
...
@@ -71,8 +71,8 @@ static void getStatics_bool(const void *pBitmap, const void *pData, int32_t numO
...
@@ -71,8 +71,8 @@ static void getStatics_bool(const void *pBitmap, const void *pData, int32_t numO
}
}
}
}
static
void
getStatics_i8
(
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
static
void
getStatics_i8
(
int8_t
bitmapMode
,
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int
64_t
*
max
,
int64_t
*
sum
,
int
16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int8_t
*
data
=
(
int8_t
*
)
pData
;
int8_t
*
data
=
(
int8_t
*
)
pData
;
*
min
=
INT64_MAX
;
*
min
=
INT64_MAX
;
*
max
=
INT64_MIN
;
*
max
=
INT64_MIN
;
...
@@ -83,7 +83,7 @@ static void getStatics_i8(const void *pBitmap, const void *pData, int32_t numOfR
...
@@ -83,7 +83,7 @@ static void getStatics_i8(const void *pBitmap, const void *pData, int32_t numOfR
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
// if (((uint8_t)data[i]) == TSDB_DATA_TINYINT_NULL) {
// if (((uint8_t)data[i]) == TSDB_DATA_TINYINT_NULL) {
if
(
!
tdIsBitmapValTypeNorm
II
(
pBitmap
,
i
))
{
if
(
!
tdIsBitmapValTypeNorm
(
pBitmap
,
i
,
bitmapMode
))
{
(
*
numOfNull
)
+=
1
;
(
*
numOfNull
)
+=
1
;
continue
;
continue
;
}
}
...
@@ -92,8 +92,8 @@ static void getStatics_i8(const void *pBitmap, const void *pData, int32_t numOfR
...
@@ -92,8 +92,8 @@ static void getStatics_i8(const void *pBitmap, const void *pData, int32_t numOfR
}
}
}
}
static
void
getStatics_u8
(
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
static
void
getStatics_u8
(
int8_t
bitmapMode
,
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int
64_t
*
max
,
int64_t
*
sum
,
int
16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
uint8_t
*
data
=
(
uint8_t
*
)
pData
;
uint8_t
*
data
=
(
uint8_t
*
)
pData
;
uint64_t
_min
=
UINT64_MAX
;
uint64_t
_min
=
UINT64_MAX
;
uint64_t
_max
=
0
;
uint64_t
_max
=
0
;
...
@@ -106,7 +106,7 @@ static void getStatics_u8(const void *pBitmap, const void *pData, int32_t numOfR
...
@@ -106,7 +106,7 @@ static void getStatics_u8(const void *pBitmap, const void *pData, int32_t numOfR
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
// if (((uint8_t)data[i]) == TSDB_DATA_UTINYINT_NULL) {
// if (((uint8_t)data[i]) == TSDB_DATA_UTINYINT_NULL) {
if
(
!
tdIsBitmapValTypeNorm
II
(
pBitmap
,
i
))
{
if
(
!
tdIsBitmapValTypeNorm
(
pBitmap
,
i
,
bitmapMode
))
{
(
*
numOfNull
)
+=
1
;
(
*
numOfNull
)
+=
1
;
continue
;
continue
;
}
}
...
@@ -119,8 +119,8 @@ static void getStatics_u8(const void *pBitmap, const void *pData, int32_t numOfR
...
@@ -119,8 +119,8 @@ static void getStatics_u8(const void *pBitmap, const void *pData, int32_t numOfR
*
sum
=
_sum
;
*
sum
=
_sum
;
}
}
static
void
getStatics_i16
(
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
static
void
getStatics_i16
(
int8_t
bitmapMode
,
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int
64_t
*
max
,
int64_t
*
sum
,
int
16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int16_t
*
data
=
(
int16_t
*
)
pData
;
int16_t
*
data
=
(
int16_t
*
)
pData
;
*
min
=
INT64_MAX
;
*
min
=
INT64_MAX
;
*
max
=
INT64_MIN
;
*
max
=
INT64_MIN
;
...
@@ -131,7 +131,7 @@ static void getStatics_i16(const void *pBitmap, const void *pData, int32_t numOf
...
@@ -131,7 +131,7 @@ static void getStatics_i16(const void *pBitmap, const void *pData, int32_t numOf
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
// if (((uint16_t)data[i]) == TSDB_DATA_SMALLINT_NULL) {
// if (((uint16_t)data[i]) == TSDB_DATA_SMALLINT_NULL) {
if
(
!
tdIsBitmapValTypeNorm
II
(
pBitmap
,
i
))
{
if
(
!
tdIsBitmapValTypeNorm
(
pBitmap
,
i
,
bitmapMode
))
{
(
*
numOfNull
)
+=
1
;
(
*
numOfNull
)
+=
1
;
continue
;
continue
;
}
}
...
@@ -140,8 +140,8 @@ static void getStatics_i16(const void *pBitmap, const void *pData, int32_t numOf
...
@@ -140,8 +140,8 @@ static void getStatics_i16(const void *pBitmap, const void *pData, int32_t numOf
}
}
}
}
static
void
getStatics_u16
(
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
static
void
getStatics_u16
(
int8_t
bitmapMode
,
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int
64_t
*
max
,
int64_t
*
sum
,
int
16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
uint16_t
*
data
=
(
uint16_t
*
)
pData
;
uint16_t
*
data
=
(
uint16_t
*
)
pData
;
uint64_t
_min
=
UINT64_MAX
;
uint64_t
_min
=
UINT64_MAX
;
uint64_t
_max
=
0
;
uint64_t
_max
=
0
;
...
@@ -154,7 +154,7 @@ static void getStatics_u16(const void *pBitmap, const void *pData, int32_t numOf
...
@@ -154,7 +154,7 @@ static void getStatics_u16(const void *pBitmap, const void *pData, int32_t numOf
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
// if (((uint16_t)data[i]) == TSDB_DATA_USMALLINT_NULL) {
// if (((uint16_t)data[i]) == TSDB_DATA_USMALLINT_NULL) {
if
(
!
tdIsBitmapValTypeNorm
II
(
pBitmap
,
i
))
{
if
(
!
tdIsBitmapValTypeNorm
(
pBitmap
,
i
,
bitmapMode
))
{
(
*
numOfNull
)
+=
1
;
(
*
numOfNull
)
+=
1
;
continue
;
continue
;
}
}
...
@@ -167,8 +167,8 @@ static void getStatics_u16(const void *pBitmap, const void *pData, int32_t numOf
...
@@ -167,8 +167,8 @@ static void getStatics_u16(const void *pBitmap, const void *pData, int32_t numOf
*
sum
=
_sum
;
*
sum
=
_sum
;
}
}
static
void
getStatics_i32
(
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
static
void
getStatics_i32
(
int8_t
bitmapMode
,
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int
64_t
*
max
,
int64_t
*
sum
,
int
16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int32_t
*
data
=
(
int32_t
*
)
pData
;
int32_t
*
data
=
(
int32_t
*
)
pData
;
*
min
=
INT64_MAX
;
*
min
=
INT64_MAX
;
*
max
=
INT64_MIN
;
*
max
=
INT64_MIN
;
...
@@ -179,7 +179,7 @@ static void getStatics_i32(const void *pBitmap, const void *pData, int32_t numOf
...
@@ -179,7 +179,7 @@ static void getStatics_i32(const void *pBitmap, const void *pData, int32_t numOf
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
// if (((uint32_t)data[i]) == TSDB_DATA_INT_NULL) {
// if (((uint32_t)data[i]) == TSDB_DATA_INT_NULL) {
if
(
!
tdIsBitmapValTypeNorm
II
(
pBitmap
,
i
))
{
if
(
!
tdIsBitmapValTypeNorm
(
pBitmap
,
i
,
bitmapMode
))
{
(
*
numOfNull
)
+=
1
;
(
*
numOfNull
)
+=
1
;
continue
;
continue
;
}
}
...
@@ -188,8 +188,8 @@ static void getStatics_i32(const void *pBitmap, const void *pData, int32_t numOf
...
@@ -188,8 +188,8 @@ static void getStatics_i32(const void *pBitmap, const void *pData, int32_t numOf
}
}
}
}
static
void
getStatics_u32
(
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
static
void
getStatics_u32
(
int8_t
bitmapMode
,
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int
64_t
*
max
,
int64_t
*
sum
,
int
16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
uint32_t
*
data
=
(
uint32_t
*
)
pData
;
uint32_t
*
data
=
(
uint32_t
*
)
pData
;
uint64_t
_min
=
UINT64_MAX
;
uint64_t
_min
=
UINT64_MAX
;
uint64_t
_max
=
0
;
uint64_t
_max
=
0
;
...
@@ -202,7 +202,7 @@ static void getStatics_u32(const void *pBitmap, const void *pData, int32_t numOf
...
@@ -202,7 +202,7 @@ static void getStatics_u32(const void *pBitmap, const void *pData, int32_t numOf
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
// if (((uint32_t)data[i]) == TSDB_DATA_UINT_NULL) {
// if (((uint32_t)data[i]) == TSDB_DATA_UINT_NULL) {
if
(
!
tdIsBitmapValTypeNorm
II
(
pBitmap
,
i
))
{
if
(
!
tdIsBitmapValTypeNorm
(
pBitmap
,
i
,
bitmapMode
))
{
(
*
numOfNull
)
+=
1
;
(
*
numOfNull
)
+=
1
;
continue
;
continue
;
}
}
...
@@ -215,8 +215,8 @@ static void getStatics_u32(const void *pBitmap, const void *pData, int32_t numOf
...
@@ -215,8 +215,8 @@ static void getStatics_u32(const void *pBitmap, const void *pData, int32_t numOf
*
sum
=
_sum
;
*
sum
=
_sum
;
}
}
static
void
getStatics_i64
(
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
static
void
getStatics_i64
(
int8_t
bitmapMode
,
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int
64_t
*
max
,
int64_t
*
sum
,
int
16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int64_t
*
data
=
(
int64_t
*
)
pData
;
int64_t
*
data
=
(
int64_t
*
)
pData
;
*
min
=
INT64_MAX
;
*
min
=
INT64_MAX
;
*
max
=
INT64_MIN
;
*
max
=
INT64_MIN
;
...
@@ -227,7 +227,7 @@ static void getStatics_i64(const void *pBitmap, const void *pData, int32_t numOf
...
@@ -227,7 +227,7 @@ static void getStatics_i64(const void *pBitmap, const void *pData, int32_t numOf
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
// if (((uint64_t)data[i]) == TSDB_DATA_BIGINT_NULL) {
// if (((uint64_t)data[i]) == TSDB_DATA_BIGINT_NULL) {
if
(
!
tdIsBitmapValTypeNorm
II
(
pBitmap
,
i
))
{
if
(
!
tdIsBitmapValTypeNorm
(
pBitmap
,
i
,
bitmapMode
))
{
(
*
numOfNull
)
+=
1
;
(
*
numOfNull
)
+=
1
;
continue
;
continue
;
}
}
...
@@ -236,8 +236,8 @@ static void getStatics_i64(const void *pBitmap, const void *pData, int32_t numOf
...
@@ -236,8 +236,8 @@ static void getStatics_i64(const void *pBitmap, const void *pData, int32_t numOf
}
}
}
}
static
void
getStatics_u64
(
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
static
void
getStatics_u64
(
int8_t
bitmapMode
,
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int
64_t
*
max
,
int64_t
*
sum
,
int
16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
uint64_t
*
data
=
(
uint64_t
*
)
pData
;
uint64_t
*
data
=
(
uint64_t
*
)
pData
;
uint64_t
_min
=
UINT64_MAX
;
uint64_t
_min
=
UINT64_MAX
;
uint64_t
_max
=
0
;
uint64_t
_max
=
0
;
...
@@ -250,7 +250,7 @@ static void getStatics_u64(const void *pBitmap, const void *pData, int32_t numOf
...
@@ -250,7 +250,7 @@ static void getStatics_u64(const void *pBitmap, const void *pData, int32_t numOf
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
// if (((uint64_t)data[i]) == TSDB_DATA_UBIGINT_NULL) {
// if (((uint64_t)data[i]) == TSDB_DATA_UBIGINT_NULL) {
if
(
!
tdIsBitmapValTypeNorm
II
(
pBitmap
,
i
))
{
if
(
!
tdIsBitmapValTypeNorm
(
pBitmap
,
i
,
bitmapMode
))
{
(
*
numOfNull
)
+=
1
;
(
*
numOfNull
)
+=
1
;
continue
;
continue
;
}
}
...
@@ -263,8 +263,8 @@ static void getStatics_u64(const void *pBitmap, const void *pData, int32_t numOf
...
@@ -263,8 +263,8 @@ static void getStatics_u64(const void *pBitmap, const void *pData, int32_t numOf
*
sum
=
_sum
;
*
sum
=
_sum
;
}
}
static
void
getStatics_f
(
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
static
void
getStatics_f
(
int8_t
bitmapMode
,
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int
64_t
*
max
,
int64_t
*
sum
,
int
16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
float
*
data
=
(
float
*
)
pData
;
float
*
data
=
(
float
*
)
pData
;
float
fmin
=
FLT_MAX
;
float
fmin
=
FLT_MAX
;
float
fmax
=
-
FLT_MAX
;
float
fmax
=
-
FLT_MAX
;
...
@@ -276,7 +276,7 @@ static void getStatics_f(const void *pBitmap, const void *pData, int32_t numOfRo
...
@@ -276,7 +276,7 @@ static void getStatics_f(const void *pBitmap, const void *pData, int32_t numOfRo
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
// if ((*(uint32_t *)&(data[i])) == TSDB_DATA_FLOAT_NULL) {
// if ((*(uint32_t *)&(data[i])) == TSDB_DATA_FLOAT_NULL) {
if
(
!
tdIsBitmapValTypeNorm
II
(
pBitmap
,
i
))
{
if
(
!
tdIsBitmapValTypeNorm
(
pBitmap
,
i
,
bitmapMode
))
{
(
*
numOfNull
)
+=
1
;
(
*
numOfNull
)
+=
1
;
continue
;
continue
;
}
}
...
@@ -300,8 +300,8 @@ static void getStatics_f(const void *pBitmap, const void *pData, int32_t numOfRo
...
@@ -300,8 +300,8 @@ static void getStatics_f(const void *pBitmap, const void *pData, int32_t numOfRo
SET_DOUBLE_VAL
(
min
,
fmin
);
SET_DOUBLE_VAL
(
min
,
fmin
);
}
}
static
void
getStatics_d
(
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
static
void
getStatics_d
(
int8_t
bitmapMode
,
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int
64_t
*
max
,
int64_t
*
sum
,
int
16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
double
*
data
=
(
double
*
)
pData
;
double
*
data
=
(
double
*
)
pData
;
double
dmin
=
DBL_MAX
;
double
dmin
=
DBL_MAX
;
double
dmax
=
-
DBL_MAX
;
double
dmax
=
-
DBL_MAX
;
...
@@ -313,7 +313,7 @@ static void getStatics_d(const void *pBitmap, const void *pData, int32_t numOfRo
...
@@ -313,7 +313,7 @@ static void getStatics_d(const void *pBitmap, const void *pData, int32_t numOfRo
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
// if ((*(uint64_t *)&(data[i])) == TSDB_DATA_DOUBLE_NULL) {
// if ((*(uint64_t *)&(data[i])) == TSDB_DATA_DOUBLE_NULL) {
if
(
!
tdIsBitmapValTypeNorm
II
(
pBitmap
,
i
))
{
if
(
!
tdIsBitmapValTypeNorm
(
pBitmap
,
i
,
bitmapMode
))
{
(
*
numOfNull
)
+=
1
;
(
*
numOfNull
)
+=
1
;
continue
;
continue
;
}
}
...
@@ -337,14 +337,14 @@ static void getStatics_d(const void *pBitmap, const void *pData, int32_t numOfRo
...
@@ -337,14 +337,14 @@ static void getStatics_d(const void *pBitmap, const void *pData, int32_t numOfRo
SET_DOUBLE_PTR
(
min
,
&
dmin
);
SET_DOUBLE_PTR
(
min
,
&
dmin
);
}
}
static
void
getStatics_bin
(
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
static
void
getStatics_bin
(
int8_t
bitmapMode
,
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int
64_t
*
max
,
int64_t
*
sum
,
int
16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
const
char
*
data
=
pData
;
const
char
*
data
=
pData
;
assert
(
numOfRow
<=
INT16_MAX
);
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
// if (isNull(data, TSDB_DATA_TYPE_BINARY)) {
// if (isNull(data, TSDB_DATA_TYPE_BINARY)) {
if
(
!
tdIsBitmapValTypeNorm
II
(
pBitmap
,
i
))
{
if
(
!
tdIsBitmapValTypeNorm
(
pBitmap
,
i
,
bitmapMode
))
{
(
*
numOfNull
)
+=
1
;
(
*
numOfNull
)
+=
1
;
}
}
...
@@ -358,14 +358,14 @@ static void getStatics_bin(const void *pBitmap, const void *pData, int32_t numOf
...
@@ -358,14 +358,14 @@ static void getStatics_bin(const void *pBitmap, const void *pData, int32_t numOf
*
maxIndex
=
0
;
*
maxIndex
=
0
;
}
}
static
void
getStatics_nchr
(
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int64_t
*
max
,
int64_t
*
sum
,
static
void
getStatics_nchr
(
int8_t
bitmapMode
,
const
void
*
pBitmap
,
const
void
*
pData
,
int32_t
numOfRow
,
int64_t
*
min
,
int16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
int
64_t
*
max
,
int64_t
*
sum
,
int
16_t
*
minIndex
,
int16_t
*
maxIndex
,
int16_t
*
numOfNull
)
{
const
char
*
data
=
pData
;
const
char
*
data
=
pData
;
assert
(
numOfRow
<=
INT16_MAX
);
assert
(
numOfRow
<=
INT16_MAX
);
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfRow
;
++
i
)
{
// if (isNull(data, TSDB_DATA_TYPE_NCHAR)) {
// if (isNull(data, TSDB_DATA_TYPE_NCHAR)) {
if
(
!
tdIsBitmapValTypeNorm
II
(
pBitmap
,
i
))
{
if
(
!
tdIsBitmapValTypeNorm
(
pBitmap
,
i
,
bitmapMode
))
{
(
*
numOfNull
)
+=
1
;
(
*
numOfNull
)
+=
1
;
}
}
...
@@ -405,19 +405,19 @@ tDataTypeDescriptor tDataTypes[15] = {
...
@@ -405,19 +405,19 @@ tDataTypeDescriptor tDataTypes[15] = {
};
};
char
tTokenTypeSwitcher
[
13
]
=
{
char
tTokenTypeSwitcher
[
13
]
=
{
TSDB_DATA_TYPE_NULL
,
// no type
TSDB_DATA_TYPE_NULL
,
// no type
TSDB_DATA_TYPE_BINARY
,
// TK_ID
TSDB_DATA_TYPE_BINARY
,
// TK_ID
TSDB_DATA_TYPE_BOOL
,
// TK_BOOL
TSDB_DATA_TYPE_BOOL
,
// TK_BOOL
TSDB_DATA_TYPE_BIGINT
,
// TK_TINYINT
TSDB_DATA_TYPE_BIGINT
,
// TK_TINYINT
TSDB_DATA_TYPE_BIGINT
,
// TK_SMALLINT
TSDB_DATA_TYPE_BIGINT
,
// TK_SMALLINT
TSDB_DATA_TYPE_BIGINT
,
// TK_INTEGER
TSDB_DATA_TYPE_BIGINT
,
// TK_INTEGER
TSDB_DATA_TYPE_BIGINT
,
// TK_BIGINT
TSDB_DATA_TYPE_BIGINT
,
// TK_BIGINT
TSDB_DATA_TYPE_DOUBLE
,
// TK_FLOAT
TSDB_DATA_TYPE_DOUBLE
,
// TK_FLOAT
TSDB_DATA_TYPE_DOUBLE
,
// TK_DOUBLE
TSDB_DATA_TYPE_DOUBLE
,
// TK_DOUBLE
TSDB_DATA_TYPE_BINARY
,
// TK_STRING
TSDB_DATA_TYPE_BINARY
,
// TK_STRING
TSDB_DATA_TYPE_BIGINT
,
// TK_TIMESTAMP
TSDB_DATA_TYPE_BIGINT
,
// TK_TIMESTAMP
TSDB_DATA_TYPE_VARCHAR
,
// TK_BINARY
TSDB_DATA_TYPE_VARCHAR
,
// TK_BINARY
TSDB_DATA_TYPE_NCHAR
,
// TK_NCHAR
TSDB_DATA_TYPE_NCHAR
,
// TK_NCHAR
};
};
float
floatMin
=
-
FLT_MAX
,
floatMax
=
FLT_MAX
;
float
floatMin
=
-
FLT_MAX
,
floatMax
=
FLT_MAX
;
...
...
source/dnode/mgmt/mgmt_mnode/src/mmFile.c
浏览文件 @
5b835514
...
@@ -121,7 +121,7 @@ int32_t mmWriteFile(SMgmtWrapper *pWrapper, SDCreateMnodeReq *pReq, bool deploye
...
@@ -121,7 +121,7 @@ int32_t mmWriteFile(SMgmtWrapper *pWrapper, SDCreateMnodeReq *pReq, bool deploye
int32_t
len
=
0
;
int32_t
len
=
0
;
int32_t
maxLen
=
4096
;
int32_t
maxLen
=
4096
;
char
*
content
=
taosMemoryCalloc
(
1
,
maxLen
+
1
);
char
*
content
=
taosMemoryCalloc
(
1
,
maxLen
+
1
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
mnodes
\"
: [{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
mnodes
\"
: [{
\n
"
);
...
...
source/dnode/mgmt/test/vnode/CMakeLists.txt
浏览文件 @
5b835514
aux_source_directory
(
. DND_VNODE_TEST_SRC
)
#
aux_source_directory(. DND_VNODE_TEST_SRC)
add_executable
(
dvnodeTest
${
DND_VNODE_TEST_SRC
}
)
#
add_executable(dvnodeTest ${DND_VNODE_TEST_SRC})
target_link_libraries
(
#
target_link_libraries(
dvnodeTest
#
dvnodeTest
PUBLIC sut
#
PUBLIC sut
)
#
)
add_test
(
#
add_test(
NAME dvnodeTest
#
NAME dvnodeTest
COMMAND dvnodeTest
#
COMMAND dvnodeTest
)
#
)
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
5b835514
...
@@ -275,16 +275,17 @@ typedef struct {
...
@@ -275,16 +275,17 @@ typedef struct {
}
SDbCfg
;
}
SDbCfg
;
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_DB_FNAME_LEN
];
char
name
[
TSDB_DB_FNAME_LEN
];
char
acct
[
TSDB_USER_LEN
];
char
acct
[
TSDB_USER_LEN
];
char
createUser
[
TSDB_USER_LEN
];
char
createUser
[
TSDB_USER_LEN
];
int64_t
createdTime
;
int64_t
createdTime
;
int64_t
updateTime
;
int64_t
updateTime
;
int64_t
uid
;
int64_t
uid
;
int32_t
cfgVersion
;
int32_t
cfgVersion
;
int32_t
vgVersion
;
int32_t
vgVersion
;
int8_t
hashMethod
;
// default is 1
int8_t
hashMethod
;
// default is 1
SDbCfg
cfg
;
SDbCfg
cfg
;
SRWLatch
lock
;
}
SDbObj
;
}
SDbObj
;
typedef
struct
{
typedef
struct
{
...
...
source/dnode/mnode/impl/src/mndBnode.c
浏览文件 @
5b835514
...
@@ -33,7 +33,7 @@ static int32_t mndProcessCreateBnodeReq(SNodeMsg *pReq);
...
@@ -33,7 +33,7 @@ static int32_t mndProcessCreateBnodeReq(SNodeMsg *pReq);
static
int32_t
mndProcessCreateBnodeRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndProcessCreateBnodeRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndProcessDropBnodeReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessDropBnodeReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessDropBnodeRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndProcessDropBnodeRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndRetrieveBnodes
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
int32_t
mndRetrieveBnodes
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextBnode
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextBnode
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitBnode
(
SMnode
*
pMnode
)
{
int32_t
mndInitBnode
(
SMnode
*
pMnode
)
{
...
@@ -437,7 +437,7 @@ static int32_t mndProcessDropBnodeRsp(SNodeMsg *pRsp) {
...
@@ -437,7 +437,7 @@ static int32_t mndProcessDropBnodeRsp(SNodeMsg *pRsp) {
return
0
;
return
0
;
}
}
static
int32_t
mndRetrieveBnodes
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
static
int32_t
mndRetrieveBnodes
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
...
@@ -449,8 +449,8 @@ static int32_t mndRetrieveBnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p
...
@@ -449,8 +449,8 @@ static int32_t mndRetrieveBnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
pShow
->
pIter
==
NULL
)
break
;
cols
=
0
;
cols
=
0
;
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pObj
->
id
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pObj
->
id
,
false
);
char
buf
[
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
buf
[
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
buf
,
pObj
->
pDnode
->
ep
,
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
buf
,
pObj
->
pDnode
->
ep
,
pShow
->
bytes
[
cols
]);
...
@@ -459,7 +459,7 @@ static int32_t mndRetrieveBnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p
...
@@ -459,7 +459,7 @@ static int32_t mndRetrieveBnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p
colDataAppend
(
pColInfo
,
numOfRows
,
buf
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
buf
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pObj
->
createdTime
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pObj
->
createdTime
,
false
);
numOfRows
++
;
numOfRows
++
;
sdbRelease
(
pSdb
,
pObj
);
sdbRelease
(
pSdb
,
pObj
);
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
5b835514
...
@@ -219,10 +219,14 @@ static int32_t mndDbActionDelete(SSdb *pSdb, SDbObj *pDb) {
...
@@ -219,10 +219,14 @@ static int32_t mndDbActionDelete(SSdb *pSdb, SDbObj *pDb) {
static
int32_t
mndDbActionUpdate
(
SSdb
*
pSdb
,
SDbObj
*
pOld
,
SDbObj
*
pNew
)
{
static
int32_t
mndDbActionUpdate
(
SSdb
*
pSdb
,
SDbObj
*
pOld
,
SDbObj
*
pNew
)
{
mTrace
(
"db:%s, perform update action, old row:%p new row:%p"
,
pOld
->
name
,
pOld
,
pNew
);
mTrace
(
"db:%s, perform update action, old row:%p new row:%p"
,
pOld
->
name
,
pOld
,
pNew
);
taosWLockLatch
(
&
pOld
->
lock
);
SArray
*
pOldRetensions
=
pOld
->
cfg
.
pRetensions
;
pOld
->
updateTime
=
pNew
->
updateTime
;
pOld
->
updateTime
=
pNew
->
updateTime
;
pOld
->
cfgVersion
=
pNew
->
cfgVersion
;
pOld
->
cfgVersion
=
pNew
->
cfgVersion
;
pOld
->
vgVersion
=
pNew
->
vgVersion
;
pOld
->
vgVersion
=
pNew
->
vgVersion
;
memcpy
(
&
pOld
->
cfg
,
&
pNew
->
cfg
,
sizeof
(
SDbCfg
));
memcpy
(
&
pOld
->
cfg
,
&
pNew
->
cfg
,
sizeof
(
SDbCfg
));
pNew
->
cfg
.
pRetensions
=
pOldRetensions
;
taosWUnLockLatch
(
&
pOld
->
lock
);
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndFunc.c
浏览文件 @
5b835514
...
@@ -34,7 +34,7 @@ static int32_t mndDropFunc(SMnode *pMnode, SNodeMsg *pReq, SFuncObj *pFunc);
...
@@ -34,7 +34,7 @@ static int32_t mndDropFunc(SMnode *pMnode, SNodeMsg *pReq, SFuncObj *pFunc);
static
int32_t
mndProcessCreateFuncReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessCreateFuncReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessDropFuncReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessDropFuncReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessRetrieveFuncReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessRetrieveFuncReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndRetrieveFuncs
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
int32_t
mndRetrieveFuncs
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextFunc
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextFunc
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitFunc
(
SMnode
*
pMnode
)
{
int32_t
mndInitFunc
(
SMnode
*
pMnode
)
{
...
@@ -63,28 +63,28 @@ static SSdbRaw *mndFuncActionEncode(SFuncObj *pFunc) {
...
@@ -63,28 +63,28 @@ static SSdbRaw *mndFuncActionEncode(SFuncObj *pFunc) {
int32_t
size
=
pFunc
->
commentSize
+
pFunc
->
codeSize
+
sizeof
(
SFuncObj
)
+
SDB_FUNC_RESERVE_SIZE
;
int32_t
size
=
pFunc
->
commentSize
+
pFunc
->
codeSize
+
sizeof
(
SFuncObj
)
+
SDB_FUNC_RESERVE_SIZE
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_FUNC
,
SDB_FUNC_VER
,
size
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_FUNC
,
SDB_FUNC_VER
,
size
);
if
(
pRaw
==
NULL
)
goto
FUNC_ENCODE
_OVER
;
if
(
pRaw
==
NULL
)
goto
_OVER
;
int32_t
dataPos
=
0
;
int32_t
dataPos
=
0
;
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pFunc
->
name
,
TSDB_FUNC_NAME_LEN
,
FUNC_ENCODE
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pFunc
->
name
,
TSDB_FUNC_NAME_LEN
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pFunc
->
createdTime
,
FUNC_ENCODE
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pFunc
->
createdTime
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pFunc
->
funcType
,
FUNC_ENCODE
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pFunc
->
funcType
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pFunc
->
scriptType
,
FUNC_ENCODE
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pFunc
->
scriptType
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pFunc
->
align
,
FUNC_ENCODE
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pFunc
->
align
,
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pFunc
->
outputType
,
FUNC_ENCODE
_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pFunc
->
outputType
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pFunc
->
outputLen
,
FUNC_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pFunc
->
outputLen
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pFunc
->
bufSize
,
FUNC_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pFunc
->
bufSize
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pFunc
->
signature
,
FUNC_ENCODE
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pFunc
->
signature
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pFunc
->
commentSize
,
FUNC_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pFunc
->
commentSize
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pFunc
->
codeSize
,
FUNC_ENCODE
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pFunc
->
codeSize
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pFunc
->
pComment
,
pFunc
->
commentSize
,
FUNC_ENCODE
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pFunc
->
pComment
,
pFunc
->
commentSize
,
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pFunc
->
pCode
,
pFunc
->
codeSize
,
FUNC_ENCODE
_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pFunc
->
pCode
,
pFunc
->
codeSize
,
_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
SDB_FUNC_RESERVE_SIZE
,
FUNC_ENCODE
_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
SDB_FUNC_RESERVE_SIZE
,
_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
FUNC_ENCODE
_OVER
);
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
_OVER
);
terrno
=
0
;
terrno
=
0
;
FUNC_ENCODE
_OVER:
_OVER:
if
(
terrno
!=
0
)
{
if
(
terrno
!=
0
)
{
mError
(
"func:%s, failed to encode to raw:%p since %s"
,
pFunc
->
name
,
pRaw
,
terrstr
());
mError
(
"func:%s, failed to encode to raw:%p since %s"
,
pFunc
->
name
,
pRaw
,
terrstr
());
sdbFreeRaw
(
pRaw
);
sdbFreeRaw
(
pRaw
);
...
@@ -99,45 +99,45 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) {
...
@@ -99,45 +99,45 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) {
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
int8_t
sver
=
0
;
int8_t
sver
=
0
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
goto
FUNC_DECODE
_OVER
;
if
(
sdbGetRawSoftVer
(
pRaw
,
&
sver
)
!=
0
)
goto
_OVER
;
if
(
sver
!=
SDB_FUNC_VER
)
{
if
(
sver
!=
SDB_FUNC_VER
)
{
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
terrno
=
TSDB_CODE_SDB_INVALID_DATA_VER
;
goto
FUNC_DECODE
_OVER
;
goto
_OVER
;
}
}
SSdbRow
*
pRow
=
sdbAllocRow
(
sizeof
(
SFuncObj
));
SSdbRow
*
pRow
=
sdbAllocRow
(
sizeof
(
SFuncObj
));
if
(
pRow
==
NULL
)
goto
FUNC_DECODE
_OVER
;
if
(
pRow
==
NULL
)
goto
_OVER
;
SFuncObj
*
pFunc
=
sdbGetRowObj
(
pRow
);
SFuncObj
*
pFunc
=
sdbGetRowObj
(
pRow
);
if
(
pFunc
==
NULL
)
goto
FUNC_DECODE
_OVER
;
if
(
pFunc
==
NULL
)
goto
_OVER
;
int32_t
dataPos
=
0
;
int32_t
dataPos
=
0
;
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pFunc
->
name
,
TSDB_FUNC_NAME_LEN
,
FUNC_DECODE
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pFunc
->
name
,
TSDB_FUNC_NAME_LEN
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pFunc
->
createdTime
,
FUNC_DECODE
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pFunc
->
createdTime
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pFunc
->
funcType
,
FUNC_DECODE
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pFunc
->
funcType
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pFunc
->
scriptType
,
FUNC_DECODE
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pFunc
->
scriptType
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pFunc
->
align
,
FUNC_DECODE
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pFunc
->
align
,
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pFunc
->
outputType
,
FUNC_DECODE
_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pFunc
->
outputType
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pFunc
->
outputLen
,
FUNC_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pFunc
->
outputLen
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pFunc
->
bufSize
,
FUNC_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pFunc
->
bufSize
,
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pFunc
->
signature
,
FUNC_DECODE
_OVER
)
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pFunc
->
signature
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pFunc
->
commentSize
,
FUNC_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pFunc
->
commentSize
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pFunc
->
codeSize
,
FUNC_DECODE
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pFunc
->
codeSize
,
_OVER
)
pFunc
->
pComment
=
taosMemoryCalloc
(
1
,
pFunc
->
commentSize
);
pFunc
->
pComment
=
taosMemoryCalloc
(
1
,
pFunc
->
commentSize
);
pFunc
->
pCode
=
taosMemoryCalloc
(
1
,
pFunc
->
codeSize
);
pFunc
->
pCode
=
taosMemoryCalloc
(
1
,
pFunc
->
codeSize
);
if
(
pFunc
->
pComment
==
NULL
||
pFunc
->
pCode
==
NULL
)
{
if
(
pFunc
->
pComment
==
NULL
||
pFunc
->
pCode
==
NULL
)
{
goto
FUNC_DECODE
_OVER
;
goto
_OVER
;
}
}
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pFunc
->
pComment
,
pFunc
->
commentSize
,
FUNC_DECODE
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pFunc
->
pComment
,
pFunc
->
commentSize
,
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pFunc
->
pCode
,
pFunc
->
codeSize
,
FUNC_DECODE
_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pFunc
->
pCode
,
pFunc
->
codeSize
,
_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
SDB_FUNC_RESERVE_SIZE
,
FUNC_DECODE
_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
SDB_FUNC_RESERVE_SIZE
,
_OVER
)
terrno
=
0
;
terrno
=
0
;
FUNC_DECODE
_OVER:
_OVER:
if
(
terrno
!=
0
)
{
if
(
terrno
!=
0
)
{
mError
(
"func:%s, failed to decode from raw:%p since %s"
,
pFunc
->
name
,
pRaw
,
terrstr
());
mError
(
"func:%s, failed to decode from raw:%p since %s"
,
pFunc
->
name
,
pRaw
,
terrstr
());
taosMemoryFreeClear
(
pRow
);
taosMemoryFreeClear
(
pRow
);
...
@@ -192,40 +192,40 @@ static int32_t mndCreateFunc(SMnode *pMnode, SNodeMsg *pReq, SCreateFuncReq *pCr
...
@@ -192,40 +192,40 @@ static int32_t mndCreateFunc(SMnode *pMnode, SNodeMsg *pReq, SCreateFuncReq *pCr
func
.
outputLen
=
pCreate
->
outputLen
;
func
.
outputLen
=
pCreate
->
outputLen
;
func
.
bufSize
=
pCreate
->
bufSize
;
func
.
bufSize
=
pCreate
->
bufSize
;
func
.
signature
=
pCreate
->
signature
;
func
.
signature
=
pCreate
->
signature
;
func
.
commentSize
=
pCreate
->
commentSize
;
func
.
commentSize
=
strlen
(
pCreate
->
pComment
)
+
1
;
func
.
codeSize
=
pCreate
->
codeSize
;
func
.
codeSize
=
strlen
(
pCreate
->
pCode
)
+
1
;
func
.
pComment
=
taosMemoryMalloc
(
func
.
commentSize
);
func
.
pComment
=
taosMemoryMalloc
(
func
.
commentSize
);
func
.
pCode
=
taosMemoryMalloc
(
func
.
codeSize
);
func
.
pCode
=
taosMemoryMalloc
(
func
.
codeSize
);
if
(
func
.
pCode
==
NULL
||
func
.
pCode
==
NULL
)
{
if
(
func
.
pCode
==
NULL
||
func
.
pCode
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
CREATE_FUNC
_OVER
;
goto
_OVER
;
}
}
memcpy
(
func
.
pComment
,
pCreate
->
pComment
,
pCreate
->
commentSize
);
memcpy
(
func
.
pComment
,
pCreate
->
pComment
,
func
.
commentSize
);
memcpy
(
func
.
pCode
,
pCreate
->
pCode
,
func
.
codeSize
);
memcpy
(
func
.
pCode
,
pCreate
->
pCode
,
func
.
codeSize
);
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_FUNC
,
&
pReq
->
rpcMsg
);
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_FUNC
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
CREATE_FUNC
_OVER
;
if
(
pTrans
==
NULL
)
goto
_OVER
;
mDebug
(
"trans:%d, used to create func:%s"
,
pTrans
->
id
,
pCreate
->
name
);
mDebug
(
"trans:%d, used to create func:%s"
,
pTrans
->
id
,
pCreate
->
name
);
SSdbRaw
*
pRedoRaw
=
mndFuncActionEncode
(
&
func
);
SSdbRaw
*
pRedoRaw
=
mndFuncActionEncode
(
&
func
);
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
goto
CREATE_FUNC
_OVER
;
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
goto
_OVER
;
if
(
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_CREATING
)
!=
0
)
goto
CREATE_FUNC
_OVER
;
if
(
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_CREATING
)
!=
0
)
goto
_OVER
;
SSdbRaw
*
pUndoRaw
=
mndFuncActionEncode
(
&
func
);
SSdbRaw
*
pUndoRaw
=
mndFuncActionEncode
(
&
func
);
if
(
pUndoRaw
==
NULL
||
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
goto
CREATE_FUNC
_OVER
;
if
(
pUndoRaw
==
NULL
||
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
goto
_OVER
;
if
(
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_DROPPED
)
!=
0
)
goto
CREATE_FUNC
_OVER
;
if
(
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_DROPPED
)
!=
0
)
goto
_OVER
;
SSdbRaw
*
pCommitRaw
=
mndFuncActionEncode
(
&
func
);
SSdbRaw
*
pCommitRaw
=
mndFuncActionEncode
(
&
func
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
goto
CREATE_FUNC
_OVER
;
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
goto
_OVER
;
if
(
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
)
!=
0
)
goto
CREATE_FUNC
_OVER
;
if
(
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
)
!=
0
)
goto
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
CREATE_FUNC
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
code
=
0
;
CREATE_FUNC
_OVER:
_OVER:
taosMemoryFree
(
func
.
pCode
);
taosMemoryFree
(
func
.
pCode
);
taosMemoryFree
(
func
.
pComment
);
taosMemoryFree
(
func
.
pComment
);
mndTransDrop
(
pTrans
);
mndTransDrop
(
pTrans
);
...
@@ -235,27 +235,27 @@ CREATE_FUNC_OVER:
...
@@ -235,27 +235,27 @@ CREATE_FUNC_OVER:
static
int32_t
mndDropFunc
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SFuncObj
*
pFunc
)
{
static
int32_t
mndDropFunc
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SFuncObj
*
pFunc
)
{
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_DROP_FUNC
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_DROP_FUNC
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
DROP_FUNC
_OVER
;
if
(
pTrans
==
NULL
)
goto
_OVER
;
mDebug
(
"trans:%d, used to drop user:%s"
,
pTrans
->
id
,
pFunc
->
name
);
mDebug
(
"trans:%d, used to drop user:%s"
,
pTrans
->
id
,
pFunc
->
name
);
SSdbRaw
*
pRedoRaw
=
mndFuncActionEncode
(
pFunc
);
SSdbRaw
*
pRedoRaw
=
mndFuncActionEncode
(
pFunc
);
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
goto
DROP_FUNC
_OVER
;
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
goto
_OVER
;
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_DROPPING
);
sdbSetRawStatus
(
pRedoRaw
,
SDB_STATUS_DROPPING
);
SSdbRaw
*
pUndoRaw
=
mndFuncActionEncode
(
pFunc
);
SSdbRaw
*
pUndoRaw
=
mndFuncActionEncode
(
pFunc
);
if
(
pUndoRaw
==
NULL
||
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
goto
DROP_FUNC
_OVER
;
if
(
pUndoRaw
==
NULL
||
mndTransAppendUndolog
(
pTrans
,
pUndoRaw
)
!=
0
)
goto
_OVER
;
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_READY
);
sdbSetRawStatus
(
pUndoRaw
,
SDB_STATUS_READY
);
SSdbRaw
*
pCommitRaw
=
mndFuncActionEncode
(
pFunc
);
SSdbRaw
*
pCommitRaw
=
mndFuncActionEncode
(
pFunc
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
goto
DROP_FUNC
_OVER
;
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
goto
_OVER
;
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_DROPPED
);
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_DROPPED
);
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
DROP_FUNC
_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
code
=
0
;
DROP_FUNC
_OVER:
_OVER:
mndTransDrop
(
pTrans
);
mndTransDrop
(
pTrans
);
return
code
;
return
code
;
}
}
...
@@ -269,7 +269,7 @@ static int32_t mndProcessCreateFuncReq(SNodeMsg *pReq) {
...
@@ -269,7 +269,7 @@ static int32_t mndProcessCreateFuncReq(SNodeMsg *pReq) {
if
(
tDeserializeSCreateFuncReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
createReq
)
!=
0
)
{
if
(
tDeserializeSCreateFuncReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
createReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
CREATE_FUNC
_OVER
;
goto
_OVER
;
}
}
mDebug
(
"func:%s, start to create"
,
createReq
.
name
);
mDebug
(
"func:%s, start to create"
,
createReq
.
name
);
...
@@ -279,60 +279,66 @@ static int32_t mndProcessCreateFuncReq(SNodeMsg *pReq) {
...
@@ -279,60 +279,66 @@ static int32_t mndProcessCreateFuncReq(SNodeMsg *pReq) {
if
(
createReq
.
igExists
)
{
if
(
createReq
.
igExists
)
{
mDebug
(
"func:%s, already exist, ignore exist is set"
,
createReq
.
name
);
mDebug
(
"func:%s, already exist, ignore exist is set"
,
createReq
.
name
);
code
=
0
;
code
=
0
;
goto
CREATE_FUNC
_OVER
;
goto
_OVER
;
}
else
{
}
else
{
terrno
=
TSDB_CODE_MND_FUNC_ALREADY_EXIST
;
terrno
=
TSDB_CODE_MND_FUNC_ALREADY_EXIST
;
goto
CREATE_FUNC
_OVER
;
goto
_OVER
;
}
}
}
else
if
(
terrno
==
TSDB_CODE_MND_FUNC_ALREADY_EXIST
)
{
}
else
if
(
terrno
==
TSDB_CODE_MND_FUNC_ALREADY_EXIST
)
{
goto
CREATE_FUNC
_OVER
;
goto
_OVER
;
}
}
if
(
createReq
.
name
[
0
]
==
0
)
{
if
(
createReq
.
name
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_NAME
;
terrno
=
TSDB_CODE_MND_INVALID_FUNC_NAME
;
goto
CREATE_FUNC
_OVER
;
goto
_OVER
;
}
}
if
(
createReq
.
commentSize
<=
0
||
createReq
.
commentSize
>
TSDB_FUNC_COMMENT_LEN
)
{
if
(
createReq
.
pComment
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_COMMENT
;
terrno
=
TSDB_CODE_MND_INVALID_FUNC_COMMENT
;
goto
CREATE_FUNC
_OVER
;
goto
_OVER
;
}
}
if
(
createReq
.
codeSize
<=
0
||
createReq
.
codeSize
>
TSDB_FUNC_CODE_LEN
)
{
if
(
createReq
.
pComment
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_COMMENT
;
goto
_OVER
;
}
if
(
createReq
.
pCode
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_CODE
;
terrno
=
TSDB_CODE_MND_INVALID_FUNC_CODE
;
goto
CREATE_FUNC
_OVER
;
goto
_OVER
;
}
}
if
(
createReq
.
pCode
[
0
]
==
0
)
{
if
(
createReq
.
pCode
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_CODE
;
terrno
=
TSDB_CODE_MND_INVALID_FUNC_CODE
;
goto
CREATE_FUNC
_OVER
;
goto
_OVER
;
}
}
if
(
createReq
.
bufSize
<=
0
||
createReq
.
bufSize
>
TSDB_FUNC_BUF_SIZE
)
{
if
(
createReq
.
bufSize
<=
0
||
createReq
.
bufSize
>
TSDB_FUNC_BUF_SIZE
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_BUFSIZE
;
terrno
=
TSDB_CODE_MND_INVALID_FUNC_BUFSIZE
;
goto
CREATE_FUNC
_OVER
;
goto
_OVER
;
}
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
pUser
==
NULL
)
{
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
CREATE_FUNC
_OVER
;
goto
_OVER
;
}
}
if
(
mndCheckFuncAuth
(
pUser
))
{
if
(
mndCheckFuncAuth
(
pUser
))
{
goto
CREATE_FUNC
_OVER
;
goto
_OVER
;
}
}
code
=
mndCreateFunc
(
pMnode
,
pReq
,
&
createReq
);
code
=
mndCreateFunc
(
pMnode
,
pReq
,
&
createReq
);
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
CREATE_FUNC
_OVER:
_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
if
(
code
!=
0
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"func:%s, failed to create since %s"
,
createReq
.
name
,
terrstr
());
mError
(
"func:%s, failed to create since %s"
,
createReq
.
name
,
terrstr
());
}
}
mndReleaseFunc
(
pMnode
,
pFunc
);
mndReleaseFunc
(
pMnode
,
pFunc
);
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
tFreeSCreateFuncReq
(
&
createReq
);
return
code
;
return
code
;
}
}
...
@@ -346,14 +352,14 @@ static int32_t mndProcessDropFuncReq(SNodeMsg *pReq) {
...
@@ -346,14 +352,14 @@ static int32_t mndProcessDropFuncReq(SNodeMsg *pReq) {
if
(
tDeserializeSDropFuncReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
dropReq
)
!=
0
)
{
if
(
tDeserializeSDropFuncReq
(
pReq
->
rpcMsg
.
pCont
,
pReq
->
rpcMsg
.
contLen
,
&
dropReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
DROP_FUNC
_OVER
;
goto
_OVER
;
}
}
mDebug
(
"func:%s, start to drop"
,
dropReq
.
name
);
mDebug
(
"func:%s, start to drop"
,
dropReq
.
name
);
if
(
dropReq
.
name
[
0
]
==
0
)
{
if
(
dropReq
.
name
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_FUNC_NAME
;
terrno
=
TSDB_CODE_MND_INVALID_FUNC_NAME
;
goto
DROP_FUNC
_OVER
;
goto
_OVER
;
}
}
pFunc
=
mndAcquireFunc
(
pMnode
,
dropReq
.
name
);
pFunc
=
mndAcquireFunc
(
pMnode
,
dropReq
.
name
);
...
@@ -361,27 +367,27 @@ static int32_t mndProcessDropFuncReq(SNodeMsg *pReq) {
...
@@ -361,27 +367,27 @@ static int32_t mndProcessDropFuncReq(SNodeMsg *pReq) {
if
(
dropReq
.
igNotExists
)
{
if
(
dropReq
.
igNotExists
)
{
mDebug
(
"func:%s, not exist, ignore not exist is set"
,
dropReq
.
name
);
mDebug
(
"func:%s, not exist, ignore not exist is set"
,
dropReq
.
name
);
code
=
0
;
code
=
0
;
goto
DROP_FUNC
_OVER
;
goto
_OVER
;
}
else
{
}
else
{
terrno
=
TSDB_CODE_MND_FUNC_NOT_EXIST
;
terrno
=
TSDB_CODE_MND_FUNC_NOT_EXIST
;
goto
DROP_FUNC
_OVER
;
goto
_OVER
;
}
}
}
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
user
);
if
(
pUser
==
NULL
)
{
if
(
pUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
goto
DROP_FUNC
_OVER
;
goto
_OVER
;
}
}
if
(
mndCheckFuncAuth
(
pUser
))
{
if
(
mndCheckFuncAuth
(
pUser
))
{
goto
DROP_FUNC
_OVER
;
goto
_OVER
;
}
}
code
=
mndDropFunc
(
pMnode
,
pReq
,
pFunc
);
code
=
mndDropFunc
(
pMnode
,
pReq
,
pFunc
);
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
if
(
code
==
0
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
DROP_FUNC
_OVER:
_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
if
(
code
!=
0
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"func:%s, failed to drop since %s"
,
dropReq
.
name
,
terrstr
());
mError
(
"func:%s, failed to drop since %s"
,
dropReq
.
name
,
terrstr
());
}
}
...
@@ -434,6 +440,12 @@ static int32_t mndProcessRetrieveFuncReq(SNodeMsg *pReq) {
...
@@ -434,6 +440,12 @@ static int32_t mndProcessRetrieveFuncReq(SNodeMsg *pReq) {
funcInfo
.
signature
=
pFunc
->
signature
;
funcInfo
.
signature
=
pFunc
->
signature
;
funcInfo
.
commentSize
=
pFunc
->
commentSize
;
funcInfo
.
commentSize
=
pFunc
->
commentSize
;
funcInfo
.
codeSize
=
pFunc
->
codeSize
;
funcInfo
.
codeSize
=
pFunc
->
codeSize
;
funcInfo
.
pCode
=
taosMemoryCalloc
(
1
,
sizeof
(
funcInfo
.
codeSize
));
funcInfo
.
pComment
=
taosMemoryCalloc
(
1
,
sizeof
(
funcInfo
.
commentSize
));
if
(
funcInfo
.
pCode
==
NULL
||
funcInfo
.
pComment
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
RETRIEVE_FUNC_OVER
;
}
memcpy
(
funcInfo
.
pComment
,
pFunc
->
pComment
,
pFunc
->
commentSize
);
memcpy
(
funcInfo
.
pComment
,
pFunc
->
pComment
,
pFunc
->
commentSize
);
memcpy
(
funcInfo
.
pCode
,
pFunc
->
pCode
,
pFunc
->
codeSize
);
memcpy
(
funcInfo
.
pCode
,
pFunc
->
pCode
,
pFunc
->
codeSize
);
taosArrayPush
(
retrieveRsp
.
pFuncInfos
,
&
funcInfo
);
taosArrayPush
(
retrieveRsp
.
pFuncInfos
,
&
funcInfo
);
...
@@ -455,8 +467,8 @@ static int32_t mndProcessRetrieveFuncReq(SNodeMsg *pReq) {
...
@@ -455,8 +467,8 @@ static int32_t mndProcessRetrieveFuncReq(SNodeMsg *pReq) {
code
=
0
;
code
=
0
;
RETRIEVE_FUNC_OVER:
RETRIEVE_FUNC_OVER:
t
aosArrayDestroy
(
retrieveReq
.
pFuncNames
);
t
FreeSRetrieveFuncReq
(
&
retrieveReq
);
t
aosArrayDestroy
(
retrieveRsp
.
pFuncInfos
);
t
FreeSRetrieveFuncRsp
(
&
retrieveRsp
);
return
code
;
return
code
;
}
}
...
@@ -479,7 +491,7 @@ static void *mnodeGenTypeStr(char *buf, int32_t buflen, uint8_t type, int16_t le
...
@@ -479,7 +491,7 @@ static void *mnodeGenTypeStr(char *buf, int32_t buflen, uint8_t type, int16_t le
return
tDataTypes
[
type
].
name
;
return
tDataTypes
[
type
].
name
;
}
}
static
int32_t
mndRetrieveFuncs
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
static
int32_t
mndRetrieveFuncs
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
...
@@ -496,34 +508,35 @@ static int32_t mndRetrieveFuncs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pB
...
@@ -496,34 +508,35 @@ static int32_t mndRetrieveFuncs(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pB
char
b1
[
tListLen
(
pFunc
->
name
)
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
b1
[
tListLen
(
pFunc
->
name
)
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
b1
,
pFunc
->
name
,
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
b1
,
pFunc
->
name
,
pShow
->
bytes
[
cols
]);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b1
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b1
,
false
);
char
*
b2
=
taosMemoryCalloc
(
1
,
pShow
->
bytes
[
cols
]);
char
*
b2
=
taosMemoryCalloc
(
1
,
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
b2
,
pFunc
->
pComment
,
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
b2
,
pFunc
->
pComment
,
pShow
->
bytes
[
cols
]);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b2
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b2
,
false
);
int32_t
isAgg
=
(
pFunc
->
funcType
==
TSDB_FUNC_TYPE_AGGREGATE
)
?
1
:
0
;
int32_t
isAgg
=
(
pFunc
->
funcType
==
TSDB_FUNC_TYPE_AGGREGATE
)
?
1
:
0
;
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
isAgg
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
isAgg
,
false
);
char
b3
[
TSDB_TYPE_STR_MAX_LEN
]
=
{
0
};
char
b3
[
TSDB_TYPE_STR_MAX_LEN
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
b3
,
mnodeGenTypeStr
(
buf
,
TSDB_TYPE_STR_MAX_LEN
,
pFunc
->
outputType
,
pFunc
->
outputLen
),
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
b3
,
mnodeGenTypeStr
(
buf
,
TSDB_TYPE_STR_MAX_LEN
,
pFunc
->
outputType
,
pFunc
->
outputLen
),
pShow
->
bytes
[
cols
]);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b3
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b3
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pFunc
->
createdTime
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pFunc
->
createdTime
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pFunc
->
codeSize
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pFunc
->
codeSize
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pFunc
->
bufSize
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pFunc
->
bufSize
,
false
);
numOfRows
++
;
numOfRows
++
;
sdbRelease
(
pSdb
,
pFunc
);
sdbRelease
(
pSdb
,
pFunc
);
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
5b835514
...
@@ -78,13 +78,13 @@ void mndReleaseMnode(SMnode *pMnode, SMnodeObj *pObj) {
...
@@ -78,13 +78,13 @@ void mndReleaseMnode(SMnode *pMnode, SMnodeObj *pObj) {
const
char
*
mndGetRoleStr
(
int32_t
showType
)
{
const
char
*
mndGetRoleStr
(
int32_t
showType
)
{
switch
(
showType
)
{
switch
(
showType
)
{
case
TAOS_SYNC_STATE_FOLLOWER
:
case
TAOS_SYNC_STATE_FOLLOWER
:
return
"
unsynced
"
;
return
"
FOLLOWER
"
;
case
TAOS_SYNC_STATE_CANDIDATE
:
case
TAOS_SYNC_STATE_CANDIDATE
:
return
"
slave
"
;
return
"
CANDIDATE
"
;
case
TAOS_SYNC_STATE_LEADER
:
case
TAOS_SYNC_STATE_LEADER
:
return
"
master
"
;
return
"
LEADER
"
;
default:
default:
return
"
undefined
"
;
return
"
ERROR
"
;
}
}
}
}
...
@@ -615,7 +615,7 @@ static int32_t mndProcessDropMnodeRsp(SNodeMsg *pRsp) {
...
@@ -615,7 +615,7 @@ static int32_t mndProcessDropMnodeRsp(SNodeMsg *pRsp) {
return
0
;
return
0
;
}
}
static
int32_t
mndRetrieveMnodes
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
static
int32_t
mndRetrieveMnodes
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
...
@@ -628,8 +628,8 @@ static int32_t mndRetrieveMnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p
...
@@ -628,8 +628,8 @@ static int32_t mndRetrieveMnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
pShow
->
pIter
==
NULL
)
break
;
cols
=
0
;
cols
=
0
;
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pObj
->
id
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pObj
->
id
,
false
);
char
b1
[
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
b1
[
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
b1
,
pObj
->
pDnode
->
ep
,
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
b1
,
pObj
->
pDnode
->
ep
,
pShow
->
bytes
[
cols
]);
...
@@ -638,11 +638,11 @@ static int32_t mndRetrieveMnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p
...
@@ -638,11 +638,11 @@ static int32_t mndRetrieveMnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p
colDataAppend
(
pColInfo
,
numOfRows
,
b1
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
b1
,
false
);
const
char
*
roles
=
mndGetRoleStr
(
pObj
->
role
);
const
char
*
roles
=
mndGetRoleStr
(
pObj
->
role
);
char
*
b2
=
taosMemoryCalloc
(
1
,
strlen
(
roles
)
+
VARSTR_HEADER_SIZE
);
char
*
b2
=
taosMemoryCalloc
(
1
,
strlen
(
roles
)
+
VARSTR_HEADER_SIZE
);
STR_WITH_MAXSIZE_TO_VARSTR
(
b2
,
roles
,
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
b2
,
roles
,
pShow
->
bytes
[
cols
]);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b2
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
b2
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pObj
->
roleTime
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pObj
->
roleTime
,
false
);
...
...
source/dnode/mnode/impl/src/mndQnode.c
浏览文件 @
5b835514
...
@@ -34,7 +34,7 @@ static int32_t mndProcessCreateQnodeRsp(SNodeMsg *pRsp);
...
@@ -34,7 +34,7 @@ static int32_t mndProcessCreateQnodeRsp(SNodeMsg *pRsp);
static
int32_t
mndProcessDropQnodeReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessDropQnodeReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessDropQnodeRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndProcessDropQnodeRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndProcessQnodeListReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessQnodeListReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndRetrieveQnodes
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
int32_t
mndRetrieveQnodes
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextQnode
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextQnode
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitQnode
(
SMnode
*
pMnode
)
{
int32_t
mndInitQnode
(
SMnode
*
pMnode
)
{
...
@@ -497,7 +497,7 @@ static int32_t mndProcessDropQnodeRsp(SNodeMsg *pRsp) {
...
@@ -497,7 +497,7 @@ static int32_t mndProcessDropQnodeRsp(SNodeMsg *pRsp) {
return
0
;
return
0
;
}
}
static
int32_t
mndRetrieveQnodes
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
static
int32_t
mndRetrieveQnodes
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
...
@@ -510,8 +510,8 @@ static int32_t mndRetrieveQnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p
...
@@ -510,8 +510,8 @@ static int32_t mndRetrieveQnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
pShow
->
pIter
==
NULL
)
break
;
cols
=
0
;
cols
=
0
;
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pObj
->
id
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pObj
->
id
,
false
);
char
ep
[
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
ep
[
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
ep
,
pObj
->
pDnode
->
ep
,
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
ep
,
pObj
->
pDnode
->
ep
,
pShow
->
bytes
[
cols
]);
...
...
source/dnode/mnode/impl/src/mndSnode.c
浏览文件 @
5b835514
...
@@ -33,7 +33,7 @@ static int32_t mndProcessCreateSnodeReq(SNodeMsg *pReq);
...
@@ -33,7 +33,7 @@ static int32_t mndProcessCreateSnodeReq(SNodeMsg *pReq);
static
int32_t
mndProcessCreateSnodeRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndProcessCreateSnodeRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndProcessDropSnodeReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessDropSnodeReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessDropSnodeRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndProcessDropSnodeRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndRetrieveSnodes
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
int32_t
mndRetrieveSnodes
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextSnode
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextSnode
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitSnode
(
SMnode
*
pMnode
)
{
int32_t
mndInitSnode
(
SMnode
*
pMnode
)
{
...
@@ -447,7 +447,7 @@ static int32_t mndProcessDropSnodeRsp(SNodeMsg *pRsp) {
...
@@ -447,7 +447,7 @@ static int32_t mndProcessDropSnodeRsp(SNodeMsg *pRsp) {
return
0
;
return
0
;
}
}
static
int32_t
mndRetrieveSnodes
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
static
int32_t
mndRetrieveSnodes
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
pNode
;
SMnode
*
pMnode
=
pReq
->
pNode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
...
@@ -459,8 +459,8 @@ static int32_t mndRetrieveSnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p
...
@@ -459,8 +459,8 @@ static int32_t mndRetrieveSnodes(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* p
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
pShow
->
pIter
==
NULL
)
break
;
cols
=
0
;
cols
=
0
;
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pObj
->
id
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pObj
->
id
,
false
);
char
ep
[
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
ep
[
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_WITH_MAXSIZE_TO_VARSTR
(
ep
,
pObj
->
pDnode
->
ep
,
pShow
->
bytes
[
cols
]);
STR_WITH_MAXSIZE_TO_VARSTR
(
ep
,
pObj
->
pDnode
->
ep
,
pShow
->
bytes
[
cols
]);
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
source/dnode/mnode/impl/test/func/func.cpp
浏览文件 @
5b835514
...
@@ -21,10 +21,25 @@ class MndTestFunc : public ::testing::Test {
...
@@ -21,10 +21,25 @@ class MndTestFunc : public ::testing::Test {
public:
public:
void
SetUp
()
override
{}
void
SetUp
()
override
{}
void
TearDown
()
override
{}
void
TearDown
()
override
{}
void
SetCode
(
SCreateFuncReq
*
pReq
,
const
char
*
pCode
);
void
SetComment
(
SCreateFuncReq
*
pReq
,
const
char
*
pComment
);
};
};
Testbase
MndTestFunc
::
test
;
Testbase
MndTestFunc
::
test
;
void
MndTestFunc
::
SetCode
(
SCreateFuncReq
*
pReq
,
const
char
*
pCode
)
{
int32_t
len
=
strlen
(
pCode
);
pReq
->
pCode
=
(
char
*
)
taosMemoryCalloc
(
1
,
len
+
1
);
strcpy
(
pReq
->
pCode
,
pCode
);
}
void
MndTestFunc
::
SetComment
(
SCreateFuncReq
*
pReq
,
const
char
*
pComment
)
{
int32_t
len
=
strlen
(
pComment
);
pReq
->
pComment
=
(
char
*
)
taosMemoryCalloc
(
1
,
len
+
1
);
strcpy
(
pReq
->
pComment
,
pComment
);
}
TEST_F
(
MndTestFunc
,
01
_Show_Func
)
{
TEST_F
(
MndTestFunc
,
01
_Show_Func
)
{
test
.
SendShowReq
(
TSDB_MGMT_TABLE_FUNC
,
"user_functions"
,
""
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_FUNC
,
"user_functions"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
...
@@ -38,6 +53,7 @@ TEST_F(MndTestFunc, 02_Create_Func) {
...
@@ -38,6 +53,7 @@ TEST_F(MndTestFunc, 02_Create_Func) {
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tFreeSCreateFuncReq
(
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -47,10 +63,12 @@ TEST_F(MndTestFunc, 02_Create_Func) {
...
@@ -47,10 +63,12 @@ TEST_F(MndTestFunc, 02_Create_Func) {
{
{
SCreateFuncReq
createReq
=
{
0
};
SCreateFuncReq
createReq
=
{
0
};
strcpy
(
createReq
.
name
,
"f1"
);
strcpy
(
createReq
.
name
,
"f1"
);
SetCode
(
&
createReq
,
"code1"
);
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tFreeSCreateFuncReq
(
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -60,25 +78,12 @@ TEST_F(MndTestFunc, 02_Create_Func) {
...
@@ -60,25 +78,12 @@ TEST_F(MndTestFunc, 02_Create_Func) {
{
{
SCreateFuncReq
createReq
=
{
0
};
SCreateFuncReq
createReq
=
{
0
};
strcpy
(
createReq
.
name
,
"f1"
);
strcpy
(
createReq
.
name
,
"f1"
);
createReq
.
commentSize
=
TSDB_FUNC_COMMENT_LEN
+
1
;
SetComment
(
&
createReq
,
"comment1"
);
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_FUNC_COMMENT
);
}
{
SCreateFuncReq
createReq
=
{
0
};
strcpy
(
createReq
.
name
,
"f1"
);
createReq
.
commentSize
=
TSDB_FUNC_COMMENT_LEN
;
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tFreeSCreateFuncReq
(
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -88,27 +93,29 @@ TEST_F(MndTestFunc, 02_Create_Func) {
...
@@ -88,27 +93,29 @@ TEST_F(MndTestFunc, 02_Create_Func) {
{
{
SCreateFuncReq
createReq
=
{
0
};
SCreateFuncReq
createReq
=
{
0
};
strcpy
(
createReq
.
name
,
"f1"
);
strcpy
(
createReq
.
name
,
"f1"
);
createReq
.
commentSize
=
TSDB_FUNC_COMMENT_LEN
;
SetCode
(
&
createReq
,
"code1"
)
;
createReq
.
codeSize
=
TSDB_FUNC_CODE_LEN
+
1
;
SetComment
(
&
createReq
,
""
)
;
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tFreeSCreateFuncReq
(
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_FUNC_CO
DE
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_FUNC_CO
MMENT
);
}
}
{
{
SCreateFuncReq
createReq
=
{
0
};
SCreateFuncReq
createReq
=
{
0
};
strcpy
(
createReq
.
name
,
"f1"
);
strcpy
(
createReq
.
name
,
"f1"
);
createReq
.
commentSize
=
TSDB_FUNC_COMMENT_LEN
;
SetCode
(
&
createReq
,
""
)
;
createReq
.
codeSize
=
TSDB_FUNC_CODE_LEN
;
SetComment
(
&
createReq
,
"comment1"
)
;
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tFreeSCreateFuncReq
(
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -118,13 +125,13 @@ TEST_F(MndTestFunc, 02_Create_Func) {
...
@@ -118,13 +125,13 @@ TEST_F(MndTestFunc, 02_Create_Func) {
{
{
SCreateFuncReq
createReq
=
{
0
};
SCreateFuncReq
createReq
=
{
0
};
strcpy
(
createReq
.
name
,
"f1"
);
strcpy
(
createReq
.
name
,
"f1"
);
createReq
.
commentSize
=
TSDB_FUNC_COMMENT_LEN
;
SetCode
(
&
createReq
,
"code1"
);
createReq
.
codeSize
=
TSDB_FUNC_CODE_LEN
;
SetComment
(
&
createReq
,
"comment1"
);
createReq
.
pCode
[
0
]
=
'a'
;
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tFreeSCreateFuncReq
(
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -134,14 +141,14 @@ TEST_F(MndTestFunc, 02_Create_Func) {
...
@@ -134,14 +141,14 @@ TEST_F(MndTestFunc, 02_Create_Func) {
{
{
SCreateFuncReq
createReq
=
{
0
};
SCreateFuncReq
createReq
=
{
0
};
strcpy
(
createReq
.
name
,
"f1"
);
strcpy
(
createReq
.
name
,
"f1"
);
createReq
.
commentSize
=
TSDB_FUNC_COMMENT_LEN
;
SetCode
(
&
createReq
,
"code1"
);
createReq
.
codeSize
=
TSDB_FUNC_CODE_LEN
;
SetComment
(
&
createReq
,
"comment1"
);
createReq
.
pCode
[
0
]
=
'a'
;
createReq
.
bufSize
=
TSDB_FUNC_BUF_SIZE
+
1
;
createReq
.
bufSize
=
TSDB_FUNC_BUF_SIZE
+
1
;
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tFreeSCreateFuncReq
(
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -151,9 +158,8 @@ TEST_F(MndTestFunc, 02_Create_Func) {
...
@@ -151,9 +158,8 @@ TEST_F(MndTestFunc, 02_Create_Func) {
for
(
int32_t
i
=
0
;
i
<
3
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
3
;
++
i
)
{
SCreateFuncReq
createReq
=
{
0
};
SCreateFuncReq
createReq
=
{
0
};
strcpy
(
createReq
.
name
,
"f1"
);
strcpy
(
createReq
.
name
,
"f1"
);
createReq
.
commentSize
=
TSDB_FUNC_COMMENT_LEN
;
SetCode
(
&
createReq
,
"code1"
);
createReq
.
codeSize
=
TSDB_FUNC_CODE_LEN
;
SetComment
(
&
createReq
,
"comment1"
);
createReq
.
pCode
[
0
]
=
'a'
;
createReq
.
bufSize
=
TSDB_FUNC_BUF_SIZE
+
1
;
createReq
.
bufSize
=
TSDB_FUNC_BUF_SIZE
+
1
;
createReq
.
igExists
=
0
;
createReq
.
igExists
=
0
;
if
(
i
==
2
)
createReq
.
igExists
=
1
;
if
(
i
==
2
)
createReq
.
igExists
=
1
;
...
@@ -163,16 +169,11 @@ TEST_F(MndTestFunc, 02_Create_Func) {
...
@@ -163,16 +169,11 @@ TEST_F(MndTestFunc, 02_Create_Func) {
createReq
.
outputLen
=
12
;
createReq
.
outputLen
=
12
;
createReq
.
bufSize
=
4
;
createReq
.
bufSize
=
4
;
createReq
.
signature
=
5
;
createReq
.
signature
=
5
;
for
(
int32_t
i
=
0
;
i
<
createReq
.
commentSize
-
1
;
++
i
)
{
createReq
.
pComment
[
i
]
=
'm'
;
}
for
(
int32_t
i
=
0
;
i
<
createReq
.
codeSize
-
1
;
++
i
)
{
createReq
.
pCode
[
i
]
=
'd'
;
}
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tFreeSCreateFuncReq
(
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -197,7 +198,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -197,7 +198,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
int32_t
contLen
=
tSerializeSRetrieveFuncReq
(
NULL
,
0
,
&
retrieveReq
);
int32_t
contLen
=
tSerializeSRetrieveFuncReq
(
NULL
,
0
,
&
retrieveReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSRetrieveFuncReq
(
pReq
,
contLen
,
&
retrieveReq
);
tSerializeSRetrieveFuncReq
(
pReq
,
contLen
,
&
retrieveReq
);
t
aosArrayDestroy
(
retrieveReq
.
pFuncNames
);
t
FreeSRetrieveFuncReq
(
&
retrieveReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -217,20 +218,10 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -217,20 +218,10 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
EXPECT_EQ
(
pFuncInfo
->
outputLen
,
12
);
EXPECT_EQ
(
pFuncInfo
->
outputLen
,
12
);
EXPECT_EQ
(
pFuncInfo
->
bufSize
,
4
);
EXPECT_EQ
(
pFuncInfo
->
bufSize
,
4
);
EXPECT_EQ
(
pFuncInfo
->
signature
,
5
);
EXPECT_EQ
(
pFuncInfo
->
signature
,
5
);
EXPECT_
EQ
(
pFuncInfo
->
commentSize
,
TSDB_FUNC_COMMENT_LEN
);
EXPECT_
STREQ
(
"comment1"
,
pFuncInfo
->
pComment
);
EXPECT_
EQ
(
pFuncInfo
->
codeSize
,
TSDB_FUNC_CODE_LEN
);
EXPECT_
STREQ
(
"code1"
,
pFuncInfo
->
pCode
);
char
comments
[
TSDB_FUNC_COMMENT_LEN
]
=
{
0
};
tFreeSRetrieveFuncRsp
(
&
retrieveRsp
);
for
(
int32_t
i
=
0
;
i
<
TSDB_FUNC_COMMENT_LEN
-
1
;
++
i
)
{
comments
[
i
]
=
'm'
;
}
char
codes
[
TSDB_FUNC_CODE_LEN
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
TSDB_FUNC_CODE_LEN
-
1
;
++
i
)
{
codes
[
i
]
=
'd'
;
}
EXPECT_STREQ
(
comments
,
pFuncInfo
->
pComment
);
EXPECT_STREQ
(
codes
,
pFuncInfo
->
pCode
);
taosArrayDestroy
(
retrieveRsp
.
pFuncInfos
);
}
}
{
{
...
@@ -241,7 +232,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -241,7 +232,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
int32_t
contLen
=
tSerializeSRetrieveFuncReq
(
NULL
,
0
,
&
retrieveReq
);
int32_t
contLen
=
tSerializeSRetrieveFuncReq
(
NULL
,
0
,
&
retrieveReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSRetrieveFuncReq
(
pReq
,
contLen
,
&
retrieveReq
);
tSerializeSRetrieveFuncReq
(
pReq
,
contLen
,
&
retrieveReq
);
t
aosArrayDestroy
(
retrieveReq
.
pFuncNames
);
t
FreeSRetrieveFuncReq
(
&
retrieveReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -259,7 +250,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -259,7 +250,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
int32_t
contLen
=
tSerializeSRetrieveFuncReq
(
NULL
,
0
,
&
retrieveReq
);
int32_t
contLen
=
tSerializeSRetrieveFuncReq
(
NULL
,
0
,
&
retrieveReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSRetrieveFuncReq
(
pReq
,
contLen
,
&
retrieveReq
);
tSerializeSRetrieveFuncReq
(
pReq
,
contLen
,
&
retrieveReq
);
t
aosArrayDestroy
(
retrieveReq
.
pFuncNames
);
t
FreeSRetrieveFuncReq
(
&
retrieveReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -275,7 +266,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -275,7 +266,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
int32_t
contLen
=
tSerializeSRetrieveFuncReq
(
NULL
,
0
,
&
retrieveReq
);
int32_t
contLen
=
tSerializeSRetrieveFuncReq
(
NULL
,
0
,
&
retrieveReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSRetrieveFuncReq
(
pReq
,
contLen
,
&
retrieveReq
);
tSerializeSRetrieveFuncReq
(
pReq
,
contLen
,
&
retrieveReq
);
t
aosArrayDestroy
(
retrieveReq
.
pFuncNames
);
t
FreeSRetrieveFuncReq
(
&
retrieveReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -285,8 +276,6 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -285,8 +276,6 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
{
{
SCreateFuncReq
createReq
=
{
0
};
SCreateFuncReq
createReq
=
{
0
};
strcpy
(
createReq
.
name
,
"f2"
);
strcpy
(
createReq
.
name
,
"f2"
);
createReq
.
commentSize
=
1024
;
createReq
.
codeSize
=
9527
;
createReq
.
igExists
=
1
;
createReq
.
igExists
=
1
;
createReq
.
funcType
=
2
;
createReq
.
funcType
=
2
;
createReq
.
scriptType
=
3
;
createReq
.
scriptType
=
3
;
...
@@ -294,16 +283,13 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -294,16 +283,13 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
createReq
.
outputLen
=
24
;
createReq
.
outputLen
=
24
;
createReq
.
bufSize
=
6
;
createReq
.
bufSize
=
6
;
createReq
.
signature
=
18
;
createReq
.
signature
=
18
;
for
(
int32_t
i
=
0
;
i
<
createReq
.
commentSize
-
1
;
++
i
)
{
SetCode
(
&
createReq
,
"code2"
);
createReq
.
pComment
[
i
]
=
'p'
;
SetComment
(
&
createReq
,
"comment2"
);
}
for
(
int32_t
i
=
0
;
i
<
createReq
.
codeSize
-
1
;
++
i
)
{
createReq
.
pCode
[
i
]
=
'q'
;
}
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
int32_t
contLen
=
tSerializeSCreateFuncReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tSerializeSCreateFuncReq
(
pReq
,
contLen
,
&
createReq
);
tFreeSCreateFuncReq
(
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -322,7 +308,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -322,7 +308,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
int32_t
contLen
=
tSerializeSRetrieveFuncReq
(
NULL
,
0
,
&
retrieveReq
);
int32_t
contLen
=
tSerializeSRetrieveFuncReq
(
NULL
,
0
,
&
retrieveReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSRetrieveFuncReq
(
pReq
,
contLen
,
&
retrieveReq
);
tSerializeSRetrieveFuncReq
(
pReq
,
contLen
,
&
retrieveReq
);
t
aosArrayDestroy
(
retrieveReq
.
pFuncNames
);
t
FreeSRetrieveFuncReq
(
&
retrieveReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -342,21 +328,13 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -342,21 +328,13 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
EXPECT_EQ
(
pFuncInfo
->
outputLen
,
24
);
EXPECT_EQ
(
pFuncInfo
->
outputLen
,
24
);
EXPECT_EQ
(
pFuncInfo
->
bufSize
,
6
);
EXPECT_EQ
(
pFuncInfo
->
bufSize
,
6
);
EXPECT_EQ
(
pFuncInfo
->
signature
,
18
);
EXPECT_EQ
(
pFuncInfo
->
signature
,
18
);
EXPECT_EQ
(
pFuncInfo
->
commentSize
,
1024
);
EXPECT_EQ
(
pFuncInfo
->
commentSize
,
strlen
(
"comment2"
)
+
1
);
EXPECT_EQ
(
pFuncInfo
->
codeSize
,
9527
);
EXPECT_EQ
(
pFuncInfo
->
codeSize
,
strlen
(
"code2"
)
+
1
);
char
comments
[
TSDB_FUNC_COMMENT_LEN
]
=
{
0
};
EXPECT_STREQ
(
"comment2"
,
pFuncInfo
->
pComment
);
for
(
int32_t
i
=
0
;
i
<
1024
-
1
;
++
i
)
{
EXPECT_STREQ
(
"code2"
,
pFuncInfo
->
pCode
);
comments
[
i
]
=
'p'
;
}
char
codes
[
TSDB_FUNC_CODE_LEN
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
9527
-
1
;
++
i
)
{
codes
[
i
]
=
'q'
;
}
EXPECT_STREQ
(
comments
,
pFuncInfo
->
pComment
);
tFreeSRetrieveFuncRsp
(
&
retrieveRsp
);
EXPECT_STREQ
(
codes
,
pFuncInfo
->
pCode
);
taosArrayDestroy
(
retrieveRsp
.
pFuncInfos
);
}
}
{
{
...
@@ -369,7 +347,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -369,7 +347,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
int32_t
contLen
=
tSerializeSRetrieveFuncReq
(
NULL
,
0
,
&
retrieveReq
);
int32_t
contLen
=
tSerializeSRetrieveFuncReq
(
NULL
,
0
,
&
retrieveReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSRetrieveFuncReq
(
pReq
,
contLen
,
&
retrieveReq
);
tSerializeSRetrieveFuncReq
(
pReq
,
contLen
,
&
retrieveReq
);
t
aosArrayDestroy
(
retrieveReq
.
pFuncNames
);
t
FreeSRetrieveFuncReq
(
&
retrieveReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
@@ -389,20 +367,10 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -389,20 +367,10 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
EXPECT_EQ
(
pFuncInfo
->
outputLen
,
24
);
EXPECT_EQ
(
pFuncInfo
->
outputLen
,
24
);
EXPECT_EQ
(
pFuncInfo
->
bufSize
,
6
);
EXPECT_EQ
(
pFuncInfo
->
bufSize
,
6
);
EXPECT_EQ
(
pFuncInfo
->
signature
,
18
);
EXPECT_EQ
(
pFuncInfo
->
signature
,
18
);
EXPECT_EQ
(
pFuncInfo
->
commentSize
,
1024
);
EXPECT_EQ
(
pFuncInfo
->
commentSize
,
strlen
(
"comment2"
)
+
1
);
EXPECT_EQ
(
pFuncInfo
->
codeSize
,
9527
);
EXPECT_EQ
(
pFuncInfo
->
codeSize
,
strlen
(
"code2"
)
+
1
);
EXPECT_STREQ
(
"comment2"
,
pFuncInfo
->
pComment
);
char
comments
[
TSDB_FUNC_COMMENT_LEN
]
=
{
0
};
EXPECT_STREQ
(
"code2"
,
pFuncInfo
->
pCode
);
for
(
int32_t
i
=
0
;
i
<
1024
-
1
;
++
i
)
{
comments
[
i
]
=
'p'
;
}
char
codes
[
TSDB_FUNC_CODE_LEN
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
9527
-
1
;
++
i
)
{
codes
[
i
]
=
'q'
;
}
EXPECT_STREQ
(
comments
,
pFuncInfo
->
pComment
);
EXPECT_STREQ
(
codes
,
pFuncInfo
->
pCode
);
}
}
{
{
...
@@ -414,21 +382,11 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -414,21 +382,11 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
EXPECT_EQ
(
pFuncInfo
->
outputLen
,
12
);
EXPECT_EQ
(
pFuncInfo
->
outputLen
,
12
);
EXPECT_EQ
(
pFuncInfo
->
bufSize
,
4
);
EXPECT_EQ
(
pFuncInfo
->
bufSize
,
4
);
EXPECT_EQ
(
pFuncInfo
->
signature
,
5
);
EXPECT_EQ
(
pFuncInfo
->
signature
,
5
);
EXPECT_EQ
(
pFuncInfo
->
commentSize
,
TSDB_FUNC_COMMENT_LEN
);
EXPECT_STREQ
(
"comment1"
,
pFuncInfo
->
pComment
);
EXPECT_EQ
(
pFuncInfo
->
codeSize
,
TSDB_FUNC_CODE_LEN
);
EXPECT_STREQ
(
"code1"
,
pFuncInfo
->
pCode
);
char
comments
[
TSDB_FUNC_COMMENT_LEN
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
TSDB_FUNC_COMMENT_LEN
-
1
;
++
i
)
{
comments
[
i
]
=
'm'
;
}
char
codes
[
TSDB_FUNC_CODE_LEN
]
=
{
0
};
for
(
int32_t
i
=
0
;
i
<
TSDB_FUNC_CODE_LEN
-
1
;
++
i
)
{
codes
[
i
]
=
'd'
;
}
EXPECT_STREQ
(
comments
,
pFuncInfo
->
pComment
);
EXPECT_STREQ
(
codes
,
pFuncInfo
->
pCode
);
}
}
taosArrayDestroy
(
retrieveRsp
.
pFuncInfos
);
tFreeSRetrieveFuncRsp
(
&
retrieveRsp
);
}
}
{
{
...
@@ -441,7 +399,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
...
@@ -441,7 +399,7 @@ TEST_F(MndTestFunc, 03_Retrieve_Func) {
int32_t
contLen
=
tSerializeSRetrieveFuncReq
(
NULL
,
0
,
&
retrieveReq
);
int32_t
contLen
=
tSerializeSRetrieveFuncReq
(
NULL
,
0
,
&
retrieveReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSRetrieveFuncReq
(
pReq
,
contLen
,
&
retrieveReq
);
tSerializeSRetrieveFuncReq
(
pReq
,
contLen
,
&
retrieveReq
);
t
aosArrayDestroy
(
retrieveReq
.
pFuncNames
);
t
FreeSRetrieveFuncReq
(
&
retrieveReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_RETRIEVE_FUNC
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
5b835514
...
@@ -43,10 +43,8 @@ typedef struct STable {
...
@@ -43,10 +43,8 @@ typedef struct STable {
#define TABLE_TID(t) (t)->tid
#define TABLE_TID(t) (t)->tid
#define TABLE_UID(t) (t)->uid
#define TABLE_UID(t) (t)->uid
STsdb
*
tsdbOpen
(
const
char
*
path
,
int32_t
vgId
,
const
STsdbCfg
*
pTsdbCfg
,
SMemAllocatorFactory
*
pMAF
,
SMeta
*
pMeta
,
STsdb
*
tsdbOpen
(
const
char
*
path
,
SVnode
*
pVnode
,
const
STsdbCfg
*
pTsdbCfg
,
SMemAllocatorFactory
*
pMAF
);
STfs
*
pTfs
);
void
tsdbClose
(
STsdb
*
);
void
tsdbClose
(
STsdb
*
);
void
tsdbRemove
(
const
char
*
path
);
int
tsdbInsertData
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
,
SSubmitRsp
*
pRsp
);
int
tsdbInsertData
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
,
SSubmitRsp
*
pRsp
);
int
tsdbPrepareCommit
(
STsdb
*
pTsdb
);
int
tsdbPrepareCommit
(
STsdb
*
pTsdb
);
int
tsdbCommit
(
STsdb
*
pTsdb
);
int
tsdbCommit
(
STsdb
*
pTsdb
);
...
@@ -167,16 +165,14 @@ struct STsdb {
...
@@ -167,16 +165,14 @@ struct STsdb {
SRtn
rtn
;
SRtn
rtn
;
SMemAllocatorFactory
*
pmaf
;
SMemAllocatorFactory
*
pmaf
;
STsdbFS
*
fs
;
STsdbFS
*
fs
;
SMeta
*
pMeta
;
STfs
*
pTfs
;
SSmaEnvs
smaEnvs
;
SSmaEnvs
smaEnvs
;
};
};
#define REPO_ID(r) ((r)->vgId)
#define REPO_ID(r) ((r)->vgId)
#define REPO_CFG(r) (&(r)->config)
#define REPO_CFG(r) (&(r)->config)
#define REPO_FS(r) ((r)->fs)
#define REPO_FS(r) ((r)->fs)
#define REPO_META(r) ((r)->pMeta)
#define REPO_META(r) ((r)->p
Vnode->p
Meta)
#define REPO_TFS(r) ((r)->pTfs)
#define REPO_TFS(r) ((r)->p
Vnode->p
Tfs)
#define IS_REPO_LOCKED(r) ((r)->repoLocked)
#define IS_REPO_LOCKED(r) ((r)->repoLocked)
#define REPO_TSMA_NUM(r) ((r)->smaEnvs.nTSma)
#define REPO_TSMA_NUM(r) ((r)->smaEnvs.nTSma)
#define REPO_RSMA_NUM(r) ((r)->smaEnvs.nRSma)
#define REPO_RSMA_NUM(r) ((r)->smaEnvs.nRSma)
...
...
source/dnode/vnode/src/meta/metaTDBImpl.c
浏览文件 @
5b835514
...
@@ -299,10 +299,10 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) {
...
@@ -299,10 +299,10 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) {
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
if
(
pTbCfg
->
type
==
META_SUPER_TABLE
)
{
schemaWrapper
.
nCols
=
pTbCfg
->
stbCfg
.
nCols
;
schemaWrapper
.
nCols
=
pTbCfg
->
stbCfg
.
nCols
;
schemaWrapper
.
pSchema
Ex
=
pTbCfg
->
stbCfg
.
pSchema
;
schemaWrapper
.
pSchema
=
pTbCfg
->
stbCfg
.
pSchema
;
}
else
{
}
else
{
schemaWrapper
.
nCols
=
pTbCfg
->
ntbCfg
.
nCols
;
schemaWrapper
.
nCols
=
pTbCfg
->
ntbCfg
.
nCols
;
schemaWrapper
.
pSchema
Ex
=
pTbCfg
->
ntbCfg
.
pSchema
;
schemaWrapper
.
pSchema
=
pTbCfg
->
ntbCfg
.
pSchema
;
}
}
pVal
=
pBuf
=
buf
;
pVal
=
pBuf
=
buf
;
metaEncodeSchemaEx
(
&
pBuf
,
&
schemaWrapper
);
metaEncodeSchemaEx
(
&
pBuf
,
&
schemaWrapper
);
...
@@ -464,7 +464,7 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) {
...
@@ -464,7 +464,7 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) {
tb_uid_t
quid
;
tb_uid_t
quid
;
SSchemaWrapper
*
pSW
;
SSchemaWrapper
*
pSW
;
STSchemaBuilder
sb
;
STSchemaBuilder
sb
;
SSchema
Ex
*
pSchema
;
SSchema
*
pSchema
;
STSchema
*
pTSchema
;
STSchema
*
pTSchema
;
STbCfg
*
pTbCfg
;
STbCfg
*
pTbCfg
;
...
@@ -482,8 +482,8 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) {
...
@@ -482,8 +482,8 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) {
tdInitTSchemaBuilder
(
&
sb
,
0
);
tdInitTSchemaBuilder
(
&
sb
,
0
);
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
pSchema
=
pSW
->
pSchema
Ex
+
i
;
pSchema
=
pSW
->
pSchema
+
i
;
tdAddColToSchema
(
&
sb
,
pSchema
->
type
,
pSchema
->
sma
,
pSchema
->
colId
,
pSchema
->
bytes
);
tdAddColToSchema
(
&
sb
,
pSchema
->
type
,
pSchema
->
flags
,
pSchema
->
colId
,
pSchema
->
bytes
);
}
}
pTSchema
=
tdGetSchemaFromBuilder
(
&
sb
);
pTSchema
=
tdGetSchemaFromBuilder
(
&
sb
);
tdDestroyTSchemaBuilder
(
&
sb
);
tdDestroyTSchemaBuilder
(
&
sb
);
...
@@ -939,7 +939,7 @@ static int metaEncodeSchema(void **buf, SSchemaWrapper *pSW) {
...
@@ -939,7 +939,7 @@ static int metaEncodeSchema(void **buf, SSchemaWrapper *pSW) {
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
pSchema
=
pSW
->
pSchema
+
i
;
pSchema
=
pSW
->
pSchema
+
i
;
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
index
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
flags
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pSchema
->
colId
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pSchema
->
colId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSchema
->
bytes
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSchema
->
bytes
);
tlen
+=
taosEncodeString
(
buf
,
pSchema
->
name
);
tlen
+=
taosEncodeString
(
buf
,
pSchema
->
name
);
...
@@ -966,14 +966,14 @@ static void *metaDecodeSchema(void *buf, SSchemaWrapper *pSW) {
...
@@ -966,14 +966,14 @@ static void *metaDecodeSchema(void *buf, SSchemaWrapper *pSW) {
}
}
static
int
metaEncodeSchemaEx
(
void
**
buf
,
SSchemaWrapper
*
pSW
)
{
static
int
metaEncodeSchemaEx
(
void
**
buf
,
SSchemaWrapper
*
pSW
)
{
int
tlen
=
0
;
int
tlen
=
0
;
SSchema
Ex
*
pSchema
;
SSchema
*
pSchema
;
tlen
+=
taosEncodeFixedU32
(
buf
,
pSW
->
nCols
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pSW
->
nCols
);
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
++
i
)
{
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
++
i
)
{
pSchema
=
pSW
->
pSchema
Ex
+
i
;
pSchema
=
pSW
->
pSchema
+
i
;
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
sma
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
flags
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pSchema
->
colId
);
tlen
+=
taosEncodeFixedI16
(
buf
,
pSchema
->
colId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSchema
->
bytes
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSchema
->
bytes
);
tlen
+=
taosEncodeString
(
buf
,
pSchema
->
name
);
tlen
+=
taosEncodeString
(
buf
,
pSchema
->
name
);
...
@@ -985,11 +985,11 @@ static int metaEncodeSchemaEx(void **buf, SSchemaWrapper *pSW) {
...
@@ -985,11 +985,11 @@ static int metaEncodeSchemaEx(void **buf, SSchemaWrapper *pSW) {
static
void
*
metaDecodeSchemaEx
(
void
*
buf
,
SSchemaWrapper
*
pSW
,
bool
isGetEx
)
{
static
void
*
metaDecodeSchemaEx
(
void
*
buf
,
SSchemaWrapper
*
pSW
,
bool
isGetEx
)
{
buf
=
taosDecodeFixedU32
(
buf
,
&
pSW
->
nCols
);
buf
=
taosDecodeFixedU32
(
buf
,
&
pSW
->
nCols
);
if
(
isGetEx
)
{
if
(
isGetEx
)
{
pSW
->
pSchema
Ex
=
(
SSchemaEx
*
)
taosMemoryMalloc
(
sizeof
(
SSchemaEx
)
*
pSW
->
nCols
);
pSW
->
pSchema
=
(
SSchema
*
)
taosMemoryMalloc
(
sizeof
(
SSchema
)
*
pSW
->
nCols
);
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
SSchema
Ex
*
pSchema
=
pSW
->
pSchemaEx
+
i
;
SSchema
*
pSchema
=
pSW
->
pSchema
+
i
;
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
sma
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
flags
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pSchema
->
colId
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pSchema
->
colId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSchema
->
bytes
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSchema
->
bytes
);
buf
=
taosDecodeStringTo
(
buf
,
pSchema
->
name
);
buf
=
taosDecodeStringTo
(
buf
,
pSchema
->
name
);
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
5b835514
...
@@ -100,7 +100,7 @@ int tsdbApplyRtnOnFSet(STsdb *pRepo, SDFileSet *pSet, SRtn *pRtn) {
...
@@ -100,7 +100,7 @@ int tsdbApplyRtnOnFSet(STsdb *pRepo, SDFileSet *pSet, SRtn *pRtn) {
level
=
tsdbGetFidLevel
(
pSet
->
fid
,
pRtn
);
level
=
tsdbGetFidLevel
(
pSet
->
fid
,
pRtn
);
if
(
tfsAllocDisk
(
pRepo
->
pTfs
,
level
,
&
did
)
<
0
)
{
if
(
tfsAllocDisk
(
pRepo
->
p
Vnode
->
p
Tfs
,
level
,
&
did
)
<
0
)
{
terrno
=
TSDB_CODE_TDB_NO_AVAIL_DISK
;
terrno
=
TSDB_CODE_TDB_NO_AVAIL_DISK
;
return
-
1
;
return
-
1
;
}
}
...
@@ -427,7 +427,7 @@ static int tsdbCreateCommitIters(SCommitH *pCommith) {
...
@@ -427,7 +427,7 @@ static int tsdbCreateCommitIters(SCommitH *pCommith) {
pCommitIter
->
pTable
=
(
STable
*
)
taosMemoryMalloc
(
sizeof
(
STable
));
pCommitIter
->
pTable
=
(
STable
*
)
taosMemoryMalloc
(
sizeof
(
STable
));
pCommitIter
->
pTable
->
uid
=
pTbData
->
uid
;
pCommitIter
->
pTable
->
uid
=
pTbData
->
uid
;
pCommitIter
->
pTable
->
tid
=
pTbData
->
uid
;
pCommitIter
->
pTable
->
tid
=
pTbData
->
uid
;
pCommitIter
->
pTable
->
pSchema
=
metaGetTbTSchema
(
pRepo
->
pMeta
,
pTbData
->
uid
,
0
);
pCommitIter
->
pTable
->
pSchema
=
metaGetTbTSchema
(
REPO_META
(
pRepo
)
,
pTbData
->
uid
,
0
);
}
}
return
0
;
return
0
;
...
@@ -459,7 +459,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
...
@@ -459,7 +459,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
STsdb
*
pRepo
=
TSDB_COMMIT_REPO
(
pCommith
);
SDFileSet
*
pWSet
=
TSDB_COMMIT_WRITE_FSET
(
pCommith
);
SDFileSet
*
pWSet
=
TSDB_COMMIT_WRITE_FSET
(
pCommith
);
if
(
tfsAllocDisk
(
pRepo
->
pTfs
,
tsdbGetFidLevel
(
fid
,
&
(
pCommith
->
rtn
)),
&
did
)
<
0
)
{
if
(
tfsAllocDisk
(
REPO_TFS
(
pRepo
)
,
tsdbGetFidLevel
(
fid
,
&
(
pCommith
->
rtn
)),
&
did
)
<
0
)
{
terrno
=
TSDB_CODE_TDB_NO_AVAIL_DISK
;
terrno
=
TSDB_CODE_TDB_NO_AVAIL_DISK
;
return
-
1
;
return
-
1
;
}
}
...
@@ -1201,6 +1201,23 @@ static int tsdbComparKeyBlock(const void *arg1, const void *arg2) {
...
@@ -1201,6 +1201,23 @@ static int tsdbComparKeyBlock(const void *arg1, const void *arg2) {
}
}
}
}
/**
* @brief Write SDataCols to data file.
*
* @param pRepo
* @param pTable
* @param pDFile
* @param pDFileAggr
* @param pDataCols The pDataCols would be generated from mem/imem directly with 2 bits bitmap or from tsdbRead
* interface with 1 bit bitmap.
* @param pBlock
* @param isLast
* @param isSuper
* @param ppBuf
* @param ppCBuf
* @param ppExBuf
* @return int
*/
int
tsdbWriteBlockImpl
(
STsdb
*
pRepo
,
STable
*
pTable
,
SDFile
*
pDFile
,
SDFile
*
pDFileAggr
,
SDataCols
*
pDataCols
,
int
tsdbWriteBlockImpl
(
STsdb
*
pRepo
,
STable
*
pTable
,
SDFile
*
pDFile
,
SDFile
*
pDFileAggr
,
SDataCols
*
pDataCols
,
SBlock
*
pBlock
,
bool
isLast
,
bool
isSuper
,
void
**
ppBuf
,
void
**
ppCBuf
,
void
**
ppExBuf
)
{
SBlock
*
pBlock
,
bool
isLast
,
bool
isSuper
,
void
**
ppBuf
,
void
**
ppCBuf
,
void
**
ppExBuf
)
{
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pRepo
);
...
@@ -1244,14 +1261,15 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
...
@@ -1244,14 +1261,15 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
pBlockCol
->
type
=
pDataCol
->
type
;
pBlockCol
->
type
=
pDataCol
->
type
;
pAggrBlkCol
->
colId
=
pDataCol
->
colId
;
pAggrBlkCol
->
colId
=
pDataCol
->
colId
;
if
(
tDataTypes
[
pDataCol
->
type
].
statisFunc
)
{
if
(
isSuper
&&
pColumn
->
sma
&&
tDataTypes
[
pDataCol
->
type
].
statisFunc
)
{
#if 0
#if 0
(*tDataTypes[pDataCol->type].statisFunc)(pDataCol->pData, rowsToWrite, &(pBlockCol->min), &(pBlockCol->max),
(*tDataTypes[pDataCol->type].statisFunc)(pDataCol->pData, rowsToWrite, &(pBlockCol->min), &(pBlockCol->max),
&(pBlockCol->sum), &(pBlockCol->minIndex), &(pBlockCol->maxIndex),
&(pBlockCol->sum), &(pBlockCol->minIndex), &(pBlockCol->maxIndex),
&(pBlockCol->numOfNull));
&(pBlockCol->numOfNull));
#endif
#endif
(
*
tDataTypes
[
pDataCol
->
type
].
statisFunc
)(
pDataCol
->
pBitmap
,
pDataCol
->
pData
,
rowsToWrite
,
&
(
pAggrBlkCol
->
min
),
&
(
pAggrBlkCol
->
max
),
(
*
tDataTypes
[
pDataCol
->
type
].
statisFunc
)(
pDataCols
->
bitmapMode
,
pDataCol
->
pBitmap
,
pDataCol
->
pData
,
rowsToWrite
,
&
(
pAggrBlkCol
->
sum
),
&
(
pAggrBlkCol
->
minIndex
),
&
(
pAggrBlkCol
->
maxIndex
),
&
(
pAggrBlkCol
->
min
),
&
(
pAggrBlkCol
->
max
),
&
(
pAggrBlkCol
->
sum
),
&
(
pAggrBlkCol
->
minIndex
),
&
(
pAggrBlkCol
->
maxIndex
),
&
(
pAggrBlkCol
->
numOfNull
));
&
(
pAggrBlkCol
->
numOfNull
));
if
(
pAggrBlkCol
->
numOfNull
==
0
)
{
if
(
pAggrBlkCol
->
numOfNull
==
0
)
{
...
@@ -1259,13 +1277,16 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
...
@@ -1259,13 +1277,16 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
}
else
{
}
else
{
TD_SET_COL_ROWS_MISC
(
pBlockCol
);
TD_SET_COL_ROWS_MISC
(
pBlockCol
);
}
}
}
else
if
(
tdIsBitmapBlkNorm
(
pDataCol
->
pBitmap
,
rowsToWrite
,
pDataCols
->
bitmapMode
))
{
// check if all rows normal
TD_SET_COL_ROWS_NORM
(
pBlockCol
);
}
else
{
}
else
{
TD_SET_COL_ROWS_MISC
(
pBlockCol
);
TD_SET_COL_ROWS_MISC
(
pBlockCol
);
}
}
++
nColsNotAllNull
;
++
nColsNotAllNull
;
if
(
pColumn
->
sma
)
{
if
(
isSuper
&&
pColumn
->
sma
)
{
++
nColsOfBlockSma
;
++
nColsOfBlockSma
;
}
}
}
}
...
@@ -1277,7 +1298,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
...
@@ -1277,7 +1298,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
uint32_t
toffset
=
0
;
uint32_t
toffset
=
0
;
int32_t
tsize
=
(
int32_t
)
tsdbBlockStatisSize
(
nColsNotAllNull
,
SBlockVerLatest
);
int32_t
tsize
=
(
int32_t
)
tsdbBlockStatisSize
(
nColsNotAllNull
,
SBlockVerLatest
);
int32_t
lsize
=
tsize
;
int32_t
lsize
=
tsize
;
uint32_t
tsizeAggr
=
(
uint32_t
)
tsdbBlockAggrSize
(
nCols
NotAllNull
,
SBlockVerLatest
);
uint32_t
tsizeAggr
=
(
uint32_t
)
tsdbBlockAggrSize
(
nCols
OfBlockSma
,
SBlockVerLatest
);
int32_t
keyLen
=
0
;
int32_t
keyLen
=
0
;
int32_t
nBitmaps
=
(
int32_t
)
TD_BITMAP_BYTES
(
rowsToWrite
);
int32_t
nBitmaps
=
(
int32_t
)
TD_BITMAP_BYTES
(
rowsToWrite
);
int32_t
sBitmaps
=
isSuper
?
(
int32_t
)
TD_BITMAP_BYTES_I
(
rowsToWrite
)
:
nBitmaps
;
int32_t
sBitmaps
=
isSuper
?
(
int32_t
)
TD_BITMAP_BYTES_I
(
rowsToWrite
)
:
nBitmaps
;
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
5b835514
...
@@ -644,7 +644,7 @@ static int tsdbComparFidFSet(const void *arg1, const void *arg2) {
...
@@ -644,7 +644,7 @@ static int tsdbComparFidFSet(const void *arg1, const void *arg2) {
}
}
static
void
tsdbGetTxnFname
(
STsdb
*
pRepo
,
TSDB_TXN_FILE_T
ftype
,
char
fname
[])
{
static
void
tsdbGetTxnFname
(
STsdb
*
pRepo
,
TSDB_TXN_FILE_T
ftype
,
char
fname
[])
{
snprintf
(
fname
,
TSDB_FILENAME_LEN
,
"%s/vnode/vnode%d/tsdb/%s"
,
tfsGetPrimaryPath
(
pRepo
->
pTfs
),
pRepo
->
vgId
,
snprintf
(
fname
,
TSDB_FILENAME_LEN
,
"%s/vnode/vnode%d/tsdb/%s"
,
tfsGetPrimaryPath
(
REPO_TFS
(
pRepo
)
),
pRepo
->
vgId
,
tsdbTxnFname
[
ftype
]);
tsdbTxnFname
[
ftype
]);
}
}
...
@@ -912,7 +912,7 @@ static int tsdbScanRootDir(STsdb *pRepo) {
...
@@ -912,7 +912,7 @@ static int tsdbScanRootDir(STsdb *pRepo) {
const
STfsFile
*
pf
;
const
STfsFile
*
pf
;
tsdbGetRootDir
(
REPO_ID
(
pRepo
),
rootDir
);
tsdbGetRootDir
(
REPO_ID
(
pRepo
),
rootDir
);
STfsDir
*
tdir
=
tfsOpendir
(
pRepo
->
pTfs
,
rootDir
);
STfsDir
*
tdir
=
tfsOpendir
(
REPO_TFS
(
pRepo
)
,
rootDir
);
if
(
tdir
==
NULL
)
{
if
(
tdir
==
NULL
)
{
tsdbError
(
"vgId:%d failed to open directory %s since %s"
,
REPO_ID
(
pRepo
),
rootDir
,
tstrerror
(
terrno
));
tsdbError
(
"vgId:%d failed to open directory %s since %s"
,
REPO_ID
(
pRepo
),
rootDir
,
tstrerror
(
terrno
));
return
-
1
;
return
-
1
;
...
@@ -946,7 +946,7 @@ static int tsdbScanDataDir(STsdb *pRepo) {
...
@@ -946,7 +946,7 @@ static int tsdbScanDataDir(STsdb *pRepo) {
const
STfsFile
*
pf
;
const
STfsFile
*
pf
;
tsdbGetDataDir
(
REPO_ID
(
pRepo
),
dataDir
);
tsdbGetDataDir
(
REPO_ID
(
pRepo
),
dataDir
);
STfsDir
*
tdir
=
tfsOpendir
(
pRepo
->
pTfs
,
dataDir
);
STfsDir
*
tdir
=
tfsOpendir
(
REPO_TFS
(
pRepo
)
,
dataDir
);
if
(
tdir
==
NULL
)
{
if
(
tdir
==
NULL
)
{
tsdbError
(
"vgId:%d failed to open directory %s since %s"
,
REPO_ID
(
pRepo
),
dataDir
,
tstrerror
(
terrno
));
tsdbError
(
"vgId:%d failed to open directory %s since %s"
,
REPO_ID
(
pRepo
),
dataDir
,
tstrerror
(
terrno
));
return
-
1
;
return
-
1
;
...
@@ -1128,7 +1128,7 @@ static int tsdbRestoreDFileSet(STsdb *pRepo) {
...
@@ -1128,7 +1128,7 @@ static int tsdbRestoreDFileSet(STsdb *pRepo) {
return
-
1
;
return
-
1
;
}
}
tdir
=
tfsOpendir
(
pRepo
->
pTfs
,
dataDir
);
tdir
=
tfsOpendir
(
REPO_TFS
(
pRepo
)
,
dataDir
);
if
(
tdir
==
NULL
)
{
if
(
tdir
==
NULL
)
{
tsdbError
(
"vgId:%d failed to restore DFileSet while open directory %s since %s"
,
REPO_ID
(
pRepo
),
dataDir
,
tsdbError
(
"vgId:%d failed to restore DFileSet while open directory %s since %s"
,
REPO_ID
(
pRepo
),
dataDir
,
tstrerror
(
terrno
));
tstrerror
(
terrno
));
...
...
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
5b835514
...
@@ -311,7 +311,7 @@ void tsdbInitDFile(STsdb *pRepo, SDFile *pDFile, SDiskID did, int fid, uint32_t
...
@@ -311,7 +311,7 @@ void tsdbInitDFile(STsdb *pRepo, SDFile *pDFile, SDiskID did, int fid, uint32_t
pDFile
->
info
.
fver
=
tsdbGetDFSVersion
(
ftype
);
pDFile
->
info
.
fver
=
tsdbGetDFSVersion
(
ftype
);
tsdbGetFilename
(
pRepo
->
vgId
,
fid
,
ver
,
ftype
,
fname
);
tsdbGetFilename
(
pRepo
->
vgId
,
fid
,
ver
,
ftype
,
fname
);
tfsInitFile
(
pRepo
->
pTfs
,
&
(
pDFile
->
f
),
did
,
fname
);
tfsInitFile
(
REPO_TFS
(
pRepo
)
,
&
(
pDFile
->
f
),
did
,
fname
);
}
}
void
tsdbInitDFileEx
(
SDFile
*
pDFile
,
SDFile
*
pODFile
)
{
void
tsdbInitDFileEx
(
SDFile
*
pDFile
,
SDFile
*
pODFile
)
{
...
@@ -330,7 +330,7 @@ int tsdbEncodeSDFile(void **buf, SDFile *pDFile) {
...
@@ -330,7 +330,7 @@ int tsdbEncodeSDFile(void **buf, SDFile *pDFile) {
void
*
tsdbDecodeSDFile
(
STsdb
*
pRepo
,
void
*
buf
,
SDFile
*
pDFile
)
{
void
*
tsdbDecodeSDFile
(
STsdb
*
pRepo
,
void
*
buf
,
SDFile
*
pDFile
)
{
buf
=
tsdbDecodeDFInfo
(
buf
,
&
(
pDFile
->
info
));
buf
=
tsdbDecodeDFInfo
(
buf
,
&
(
pDFile
->
info
));
buf
=
tfsDecodeFile
(
pRepo
->
pTfs
,
buf
,
&
(
pDFile
->
f
));
buf
=
tfsDecodeFile
(
REPO_TFS
(
pRepo
)
,
buf
,
&
(
pDFile
->
f
));
TSDB_FILE_SET_CLOSED
(
pDFile
);
TSDB_FILE_SET_CLOSED
(
pDFile
);
return
buf
;
return
buf
;
...
@@ -365,7 +365,7 @@ int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader, TSDB_FILE_T
...
@@ -365,7 +365,7 @@ int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader, TSDB_FILE_T
if
(
errno
==
ENOENT
)
{
if
(
errno
==
ENOENT
)
{
// Try to create directory recursively
// Try to create directory recursively
char
*
s
=
strdup
(
TSDB_FILE_REL_NAME
(
pDFile
));
char
*
s
=
strdup
(
TSDB_FILE_REL_NAME
(
pDFile
));
if
(
tfsMkdirRecurAt
(
pRepo
->
pTfs
,
taosDirName
(
s
),
TSDB_FILE_DID
(
pDFile
))
<
0
)
{
if
(
tfsMkdirRecurAt
(
REPO_TFS
(
pRepo
)
,
taosDirName
(
s
),
TSDB_FILE_DID
(
pDFile
))
<
0
)
{
taosMemoryFreeClear
(
s
);
taosMemoryFreeClear
(
s
);
return
-
1
;
return
-
1
;
}
}
...
@@ -443,7 +443,7 @@ int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) {
...
@@ -443,7 +443,7 @@ int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) {
}
}
static
int
tsdbScanAndTryFixDFile
(
STsdb
*
pRepo
,
SDFile
*
pDFile
)
{
static
int
tsdbScanAndTryFixDFile
(
STsdb
*
pRepo
,
SDFile
*
pDFile
)
{
SDFile
df
;
SDFile
df
;
tsdbInitDFileEx
(
&
df
,
pDFile
);
tsdbInitDFileEx
(
&
df
,
pDFile
);
...
...
source/dnode/vnode/src/tsdb/tsdbMain.c
浏览文件 @
5b835514
...
@@ -15,14 +15,12 @@
...
@@ -15,14 +15,12 @@
#include "vnodeInt.h"
#include "vnodeInt.h"
static
STsdb
*
tsdbNew
(
const
char
*
path
,
int32_t
vgId
,
const
STsdbCfg
*
pTsdbCfg
,
SMemAllocatorFactory
*
pMAF
,
static
STsdb
*
tsdbNew
(
const
char
*
path
,
SVnode
*
pVnode
,
const
STsdbCfg
*
pTsdbCfg
,
SMemAllocatorFactory
*
pMAF
);
SMeta
*
pMeta
,
STfs
*
pTfs
);
static
void
tsdbFree
(
STsdb
*
pTsdb
);
static
void
tsdbFree
(
STsdb
*
pTsdb
);
static
int
tsdbOpenImpl
(
STsdb
*
pTsdb
);
static
int
tsdbOpenImpl
(
STsdb
*
pTsdb
);
static
void
tsdbCloseImpl
(
STsdb
*
pTsdb
);
static
void
tsdbCloseImpl
(
STsdb
*
pTsdb
);
STsdb
*
tsdbOpen
(
const
char
*
path
,
int32_t
vgId
,
const
STsdbCfg
*
pTsdbCfg
,
SMemAllocatorFactory
*
pMAF
,
SMeta
*
pMeta
,
STsdb
*
tsdbOpen
(
const
char
*
path
,
SVnode
*
pVnode
,
const
STsdbCfg
*
pTsdbCfg
,
SMemAllocatorFactory
*
pMAF
)
{
STfs
*
pTfs
)
{
STsdb
*
pTsdb
=
NULL
;
STsdb
*
pTsdb
=
NULL
;
// Set default TSDB Options
// Set default TSDB Options
...
@@ -37,7 +35,7 @@ STsdb *tsdbOpen(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg, SMemAl
...
@@ -37,7 +35,7 @@ STsdb *tsdbOpen(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg, SMemAl
}
}
// Create the handle
// Create the handle
pTsdb
=
tsdbNew
(
path
,
vgId
,
pTsdbCfg
,
pMAF
,
pMeta
,
pTfs
);
pTsdb
=
tsdbNew
(
path
,
pVnode
,
pTsdbCfg
,
pMAF
);
if
(
pTsdb
==
NULL
)
{
if
(
pTsdb
==
NULL
)
{
// TODO: handle error
// TODO: handle error
return
NULL
;
return
NULL
;
...
@@ -61,11 +59,8 @@ void tsdbClose(STsdb *pTsdb) {
...
@@ -61,11 +59,8 @@ void tsdbClose(STsdb *pTsdb) {
}
}
}
}
void
tsdbRemove
(
const
char
*
path
)
{
taosRemoveDir
(
path
);
}
/* ------------------------ STATIC METHODS ------------------------ */
/* ------------------------ STATIC METHODS ------------------------ */
static
STsdb
*
tsdbNew
(
const
char
*
path
,
int32_t
vgId
,
const
STsdbCfg
*
pTsdbCfg
,
SMemAllocatorFactory
*
pMAF
,
static
STsdb
*
tsdbNew
(
const
char
*
path
,
SVnode
*
pVnode
,
const
STsdbCfg
*
pTsdbCfg
,
SMemAllocatorFactory
*
pMAF
)
{
SMeta
*
pMeta
,
STfs
*
pTfs
)
{
STsdb
*
pTsdb
=
NULL
;
STsdb
*
pTsdb
=
NULL
;
pTsdb
=
(
STsdb
*
)
taosMemoryCalloc
(
1
,
sizeof
(
STsdb
));
pTsdb
=
(
STsdb
*
)
taosMemoryCalloc
(
1
,
sizeof
(
STsdb
));
...
@@ -75,11 +70,10 @@ static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg,
...
@@ -75,11 +70,10 @@ static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg,
}
}
pTsdb
->
path
=
strdup
(
path
);
pTsdb
->
path
=
strdup
(
path
);
pTsdb
->
vgId
=
vgId
;
pTsdb
->
vgId
=
TD_VID
(
pVnode
);
pTsdb
->
pVnode
=
pVnode
;
tsdbOptionsCopy
(
&
(
pTsdb
->
config
),
pTsdbCfg
);
tsdbOptionsCopy
(
&
(
pTsdb
->
config
),
pTsdbCfg
);
pTsdb
->
pmaf
=
pMAF
;
pTsdb
->
pmaf
=
pMAF
;
pTsdb
->
pMeta
=
pMeta
;
pTsdb
->
pTfs
=
pTfs
;
pTsdb
->
fs
=
tsdbNewFS
(
pTsdbCfg
);
pTsdb
->
fs
=
tsdbNewFS
(
pTsdbCfg
);
return
pTsdb
;
return
pTsdb
;
...
@@ -156,7 +150,7 @@ int tsdbUnlockRepo(STsdb *pTsdb) {
...
@@ -156,7 +150,7 @@ int tsdbUnlockRepo(STsdb *pTsdb) {
#define IS_VALID_PRECISION(precision) \
#define IS_VALID_PRECISION(precision) \
(((precision) >= TSDB_TIME_PRECISION_MILLI) && ((precision) <= TSDB_TIME_PRECISION_NANO))
(((precision) >= TSDB_TIME_PRECISION_MILLI) && ((precision) <= TSDB_TIME_PRECISION_NANO))
#define TSDB_DEFAULT_COMPRESSION TWO_STAGE_COMP
#define TSDB_DEFAULT_COMPRESSION
TWO_STAGE_COMP
#define IS_VALID_COMPRESSION(compression) (((compression) >= NO_COMPRESSION) && ((compression) <= TWO_STAGE_COMP))
#define IS_VALID_COMPRESSION(compression) (((compression) >= NO_COMPRESSION) && ((compression) <= TWO_STAGE_COMP))
static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg);
static int32_t tsdbCheckAndSetDefaultCfg(STsdbCfg *pCfg);
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
5b835514
...
@@ -986,7 +986,7 @@ static int32_t loadBlockInfo(STsdbReadHandle* pTsdbReadHandle, int32_t index, in
...
@@ -986,7 +986,7 @@ static int32_t loadBlockInfo(STsdbReadHandle* pTsdbReadHandle, int32_t index, in
pCheckInfo
->
numOfBlocks
=
0
;
pCheckInfo
->
numOfBlocks
=
0
;
STable
table
=
{.
uid
=
pCheckInfo
->
tableId
,
.
tid
=
pCheckInfo
->
tableId
};
STable
table
=
{.
uid
=
pCheckInfo
->
tableId
,
.
tid
=
pCheckInfo
->
tableId
};
table
.
pSchema
=
metaGetTbTSchema
(
pTsdbReadHandle
->
pTsdb
->
pMeta
,
pCheckInfo
->
tableId
,
0
);
table
.
pSchema
=
metaGetTbTSchema
(
REPO_META
(
pTsdbReadHandle
->
pTsdb
)
,
pCheckInfo
->
tableId
,
0
);
if
(
tsdbSetReadTable
(
&
pTsdbReadHandle
->
rhelper
,
&
table
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tsdbSetReadTable
(
&
pTsdbReadHandle
->
rhelper
,
&
table
)
!=
TSDB_CODE_SUCCESS
)
{
code
=
terrno
;
code
=
terrno
;
...
@@ -1091,7 +1091,7 @@ static int32_t doLoadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBl
...
@@ -1091,7 +1091,7 @@ static int32_t doLoadFileDataBlock(STsdbReadHandle* pTsdbReadHandle, SBlock* pBl
int32_t
slotIndex
)
{
int32_t
slotIndex
)
{
int64_t
st
=
taosGetTimestampUs
();
int64_t
st
=
taosGetTimestampUs
();
STSchema
*
pSchema
=
metaGetTbTSchema
(
pTsdbReadHandle
->
pTsdb
->
pMeta
,
pCheckInfo
->
tableId
,
0
);
STSchema
*
pSchema
=
metaGetTbTSchema
(
REPO_META
(
pTsdbReadHandle
->
pTsdb
)
,
pCheckInfo
->
tableId
,
0
);
int32_t
code
=
tdInitDataCols
(
pTsdbReadHandle
->
pDataCols
,
pSchema
);
int32_t
code
=
tdInitDataCols
(
pTsdbReadHandle
->
pDataCols
,
pSchema
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tsdbError
(
"%p failed to malloc buf for pDataCols, %s"
,
pTsdbReadHandle
,
pTsdbReadHandle
->
idStr
);
tsdbError
(
"%p failed to malloc buf for pDataCols, %s"
,
pTsdbReadHandle
,
pTsdbReadHandle
->
idStr
);
...
@@ -1483,7 +1483,7 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit
...
@@ -1483,7 +1483,7 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit
int32_t
numOfColsOfRow1
=
0
;
int32_t
numOfColsOfRow1
=
0
;
if
(
pSchema1
==
NULL
)
{
if
(
pSchema1
==
NULL
)
{
pSchema1
=
metaGetTbTSchema
(
pTsdbReadHandle
->
pTsdb
->
pMeta
,
uid
,
TD_ROW_SVER
(
row1
));
pSchema1
=
metaGetTbTSchema
(
REPO_META
(
pTsdbReadHandle
->
pTsdb
)
,
uid
,
TD_ROW_SVER
(
row1
));
}
}
if
(
isRow1DataRow
)
{
if
(
isRow1DataRow
)
{
...
@@ -1496,7 +1496,7 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit
...
@@ -1496,7 +1496,7 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit
if
(
row2
)
{
if
(
row2
)
{
isRow2DataRow
=
TD_IS_TP_ROW
(
row2
);
isRow2DataRow
=
TD_IS_TP_ROW
(
row2
);
if
(
pSchema2
==
NULL
)
{
if
(
pSchema2
==
NULL
)
{
pSchema2
=
metaGetTbTSchema
(
pTsdbReadHandle
->
pTsdb
->
pMeta
,
uid
,
TD_ROW_SVER
(
row2
));
pSchema2
=
metaGetTbTSchema
(
REPO_META
(
pTsdbReadHandle
->
pTsdb
)
,
uid
,
TD_ROW_SVER
(
row2
));
}
}
if
(
isRow2DataRow
)
{
if
(
isRow2DataRow
)
{
numOfColsOfRow2
=
schemaNCols
(
pSchema2
);
numOfColsOfRow2
=
schemaNCols
(
pSchema2
);
...
@@ -2514,7 +2514,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
...
@@ -2514,7 +2514,7 @@ static int tsdbReadRowsFromCache(STableCheckInfo* pCheckInfo, TSKEY maxKey, int
win
->
ekey
=
key
;
win
->
ekey
=
key
;
if
(
rv
!=
TD_ROW_SVER
(
row
))
{
if
(
rv
!=
TD_ROW_SVER
(
row
))
{
pSchema
=
metaGetTbTSchema
(
pTsdbReadHandle
->
pTsdb
->
pMeta
,
pCheckInfo
->
tableId
,
0
);
pSchema
=
metaGetTbTSchema
(
REPO_META
(
pTsdbReadHandle
->
pTsdb
)
,
pCheckInfo
->
tableId
,
0
);
rv
=
TD_ROW_SVER
(
row
);
rv
=
TD_ROW_SVER
(
row
);
}
}
mergeTwoRowFromMem
(
pTsdbReadHandle
,
maxRowsToRead
,
numOfRows
,
row
,
NULL
,
numOfCols
,
pCheckInfo
->
tableId
,
pSchema
,
mergeTwoRowFromMem
(
pTsdbReadHandle
,
maxRowsToRead
,
numOfRows
,
row
,
NULL
,
numOfCols
,
pCheckInfo
->
tableId
,
pSchema
,
...
...
source/dnode/vnode/src/tsdb/tsdbSma.c
浏览文件 @
5b835514
...
@@ -260,7 +260,7 @@ static void poolFree(void *arg, void *ptr) {
...
@@ -260,7 +260,7 @@ static void poolFree(void *arg, void *ptr) {
int32_t
tsdbInitSma
(
STsdb
*
pTsdb
)
{
int32_t
tsdbInitSma
(
STsdb
*
pTsdb
)
{
// tSma
// tSma
int32_t
numOfTSma
=
taosArrayGetSize
(
metaGetSmaTbUids
(
pTsdb
->
pMeta
,
false
));
int32_t
numOfTSma
=
taosArrayGetSize
(
metaGetSmaTbUids
(
REPO_META
(
pTsdb
)
,
false
));
if
(
numOfTSma
>
0
)
{
if
(
numOfTSma
>
0
)
{
atomic_store_16
(
&
REPO_TSMA_NUM
(
pTsdb
),
(
int16_t
)
numOfTSma
);
atomic_store_16
(
&
REPO_TSMA_NUM
(
pTsdb
),
(
int16_t
)
numOfTSma
);
}
}
...
@@ -348,7 +348,7 @@ static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path, SDiskID did)
...
@@ -348,7 +348,7 @@ static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path, SDiskID did)
}
}
char
aname
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
aname
[
TSDB_FILENAME_LEN
]
=
{
0
};
tfsAbsoluteName
(
pTsdb
->
pTfs
,
did
,
path
,
aname
);
tfsAbsoluteName
(
REPO_TFS
(
pTsdb
)
,
did
,
path
,
aname
);
if
(
tsdbOpenDBEnv
(
&
pEnv
->
dbEnv
,
aname
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tsdbOpenDBEnv
(
&
pEnv
->
dbEnv
,
aname
)
!=
TSDB_CODE_SUCCESS
)
{
tsdbFreeSmaEnv
(
pEnv
);
tsdbFreeSmaEnv
(
pEnv
);
return
NULL
;
return
NULL
;
...
@@ -519,14 +519,14 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) {
...
@@ -519,14 +519,14 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) {
char
rname
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
rname
[
TSDB_FILENAME_LEN
]
=
{
0
};
SDiskID
did
=
{
0
};
SDiskID
did
=
{
0
};
tfsAllocDisk
(
pTsdb
->
pTfs
,
TFS_PRIMARY_LEVEL
,
&
did
);
tfsAllocDisk
(
REPO_TFS
(
pTsdb
)
,
TFS_PRIMARY_LEVEL
,
&
did
);
if
(
did
.
level
<
0
||
did
.
id
<
0
)
{
if
(
did
.
level
<
0
||
did
.
id
<
0
)
{
tsdbUnlockRepo
(
pTsdb
);
tsdbUnlockRepo
(
pTsdb
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
tsdbGetSmaDir
(
REPO_ID
(
pTsdb
),
smaType
,
rname
);
tsdbGetSmaDir
(
REPO_ID
(
pTsdb
),
smaType
,
rname
);
if
(
tfsMkdirRecurAt
(
pTsdb
->
pTfs
,
rname
,
did
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tfsMkdirRecurAt
(
REPO_TFS
(
pTsdb
)
,
rname
,
did
)
!=
TSDB_CODE_SUCCESS
)
{
tsdbUnlockRepo
(
pTsdb
);
tsdbUnlockRepo
(
pTsdb
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
@@ -557,7 +557,7 @@ static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t
...
@@ -557,7 +557,7 @@ static int32_t tsdbSetExpiredWindow(STsdb *pTsdb, SHashObj *pItemsHash, int64_t
}
}
// cache smaMeta
// cache smaMeta
STSma
*
pSma
=
metaGetSmaInfoByIndex
(
pTsdb
->
pMeta
,
indexUid
,
true
);
STSma
*
pSma
=
metaGetSmaInfoByIndex
(
REPO_META
(
pTsdb
)
,
indexUid
,
true
);
if
(
pSma
==
NULL
)
{
if
(
pSma
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_NO_SMA_INDEX_IN_META
;
terrno
=
TSDB_CODE_TDB_NO_SMA_INDEX_IN_META
;
taosHashCleanup
(
pItem
->
expiredWindows
);
taosHashCleanup
(
pItem
->
expiredWindows
);
...
@@ -613,7 +613,7 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
...
@@ -613,7 +613,7 @@ int32_t tsdbUpdateExpiredWindowImpl(STsdb *pTsdb, SSubmitReq *pMsg, int64_t vers
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
!
pTsdb
->
pMeta
)
{
if
(
!
REPO_META
(
pTsdb
)
)
{
terrno
=
TSDB_CODE_INVALID_PTR
;
terrno
=
TSDB_CODE_INVALID_PTR
;
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
@@ -1583,7 +1583,7 @@ int32_t tsdbCreateTSma(STsdb *pTsdb, char *pMsg) {
...
@@ -1583,7 +1583,7 @@ int32_t tsdbCreateTSma(STsdb *pTsdb, char *pMsg) {
// record current timezone of server side
// record current timezone of server side
vCreateSmaReq
.
tSma
.
timezoneInt
=
tsTimezone
;
vCreateSmaReq
.
tSma
.
timezoneInt
=
tsTimezone
;
if
(
metaCreateTSma
(
pTsdb
->
pMeta
,
&
vCreateSmaReq
)
<
0
)
{
if
(
metaCreateTSma
(
REPO_META
(
pTsdb
)
,
&
vCreateSmaReq
)
<
0
)
{
// TODO: handle error
// TODO: handle error
tdDestroyTSma
(
&
vCreateSmaReq
.
tSma
);
tdDestroyTSma
(
&
vCreateSmaReq
.
tSma
);
return
-
1
;
return
-
1
;
...
@@ -1610,7 +1610,7 @@ int32_t tsdbDropTSma(STsdb *pTsdb, char *pMsg) {
...
@@ -1610,7 +1610,7 @@ int32_t tsdbDropTSma(STsdb *pTsdb, char *pMsg) {
// }
// }
//
//
if
(
metaDropTSma
(
pTsdb
->
pMeta
,
vDropSmaReq
.
indexUid
)
<
0
)
{
if
(
metaDropTSma
(
REPO_META
(
pTsdb
)
,
vDropSmaReq
.
indexUid
)
<
0
)
{
// TODO: handle error
// TODO: handle error
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/vnode/src/vnd/vnodeOpen.c
浏览文件 @
5b835514
...
@@ -96,8 +96,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
...
@@ -96,8 +96,7 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
// open tsdb
// open tsdb
sprintf
(
tdir
,
"%s%s%s"
,
dir
,
TD_DIRSEP
,
VNODE_TSDB_DIR
);
sprintf
(
tdir
,
"%s%s%s"
,
dir
,
TD_DIRSEP
,
VNODE_TSDB_DIR
);
pVnode
->
pTsdb
=
pVnode
->
pTsdb
=
tsdbOpen
(
tdir
,
pVnode
,
&
(
pVnode
->
config
.
tsdbCfg
),
vBufPoolGetMAF
(
pVnode
));
tsdbOpen
(
tdir
,
TD_VID
(
pVnode
),
&
(
pVnode
->
config
.
tsdbCfg
),
vBufPoolGetMAF
(
pVnode
),
pVnode
->
pMeta
,
pVnode
->
pTfs
);
if
(
pVnode
->
pTsdb
==
NULL
)
{
if
(
pVnode
->
pTsdb
==
NULL
)
{
vError
(
"vgId: %d failed to open vnode tsdb since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
vError
(
"vgId: %d failed to open vnode tsdb since %s"
,
TD_VID
(
pVnode
),
tstrerror
(
terrno
));
goto
_err
;
goto
_err
;
...
...
source/libs/function/src/builtins.c
浏览文件 @
5b835514
...
@@ -237,33 +237,45 @@ static int32_t translateLength(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
...
@@ -237,33 +237,45 @@ static int32_t translateLength(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
translateConcatImpl
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
,
int32_t
minParaNum
,
int32_t
maxParaNum
,
int32_t
primaryParaNo
)
{
static
int32_t
translateConcatImpl
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
,
int32_t
minParaNum
,
int32_t
maxParaNum
,
bool
hasSep
)
{
int32_t
paraNum
=
LIST_LENGTH
(
pFunc
->
pParameterList
);
int32_t
paraNum
=
LIST_LENGTH
(
pFunc
->
pParameterList
);
if
(
paraNum
<
minParaNum
||
paraNum
>
maxParaNum
)
{
if
(
paraNum
<
minParaNum
||
paraNum
>
maxParaNum
)
{
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
uint8_t
resultType
=
TSDB_DATA_TYPE_
NCHAR
;
uint8_t
resultType
=
TSDB_DATA_TYPE_
BINARY
;
int32_t
resultBytes
=
0
;
int32_t
resultBytes
=
0
;
int32_t
sepBytes
=
0
;
int32_t
sepBytes
=
0
;
for
(
int32_t
i
=
0
;
i
<
LIST_LENGTH
(
pFunc
->
pParameterList
);
++
i
)
{
/* For concat/concat_ws function, if params have NCHAR type, promote the final result to NCHAR */
for
(
int32_t
i
=
0
;
i
<
paraNum
;
++
i
)
{
SNode
*
pPara
=
nodesListGetNode
(
pFunc
->
pParameterList
,
i
);
SNode
*
pPara
=
nodesListGetNode
(
pFunc
->
pParameterList
,
i
);
uint8_t
paraType
=
((
SExprNode
*
)
pPara
)
->
resType
.
type
;
uint8_t
paraType
=
((
SExprNode
*
)
pPara
)
->
resType
.
type
;
int32_t
paraBytes
=
((
SExprNode
*
)
pPara
)
->
resType
.
bytes
;
if
(
!
IS_VAR_DATA_TYPE
(
paraType
))
{
if
(
!
IS_VAR_DATA_TYPE
(
paraType
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
if
(
i
<
primaryParaNo
)
{
if
(
TSDB_DATA_TYPE_NCHAR
==
paraType
)
{
sepBytes
=
paraBytes
;
resultType
=
paraType
;
continue
;
}
}
for
(
int32_t
i
=
0
;
i
<
paraNum
;
++
i
)
{
SNode
*
pPara
=
nodesListGetNode
(
pFunc
->
pParameterList
,
i
);
uint8_t
paraType
=
((
SExprNode
*
)
pPara
)
->
resType
.
type
;
int32_t
paraBytes
=
((
SExprNode
*
)
pPara
)
->
resType
.
bytes
;
int32_t
factor
=
1
;
if
(
TSDB_DATA_TYPE_NCHAR
==
resultType
&&
TSDB_DATA_TYPE_VARCHAR
==
paraType
)
{
factor
*=
TSDB_NCHAR_SIZE
;
}
}
if
(
TSDB_DATA_TYPE_BINARY
==
paraType
)
{
resultBytes
+=
paraBytes
*
factor
;
resultType
=
TSDB_DATA_TYPE_BINARY
;
if
(
i
==
0
)
{
sepBytes
=
paraBytes
*
factor
;
}
}
resultBytes
+=
paraBytes
;
}
}
if
(
sepBytes
>
0
)
{
resultBytes
+=
sepBytes
*
(
paraNum
-
2
);
if
(
hasSep
)
{
resultBytes
+=
sepBytes
*
(
paraNum
-
3
);
}
}
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
resultBytes
,
.
type
=
resultType
};
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
resultBytes
,
.
type
=
resultType
};
...
@@ -271,11 +283,11 @@ static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t
...
@@ -271,11 +283,11 @@ static int32_t translateConcatImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t
}
}
static
int32_t
translateConcat
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
static
int32_t
translateConcat
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
return
translateConcatImpl
(
pFunc
,
pErrBuf
,
len
,
2
,
8
,
0
);
return
translateConcatImpl
(
pFunc
,
pErrBuf
,
len
,
2
,
8
,
false
);
}
}
static
int32_t
translateConcatWs
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
static
int32_t
translateConcatWs
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
return
translateConcatImpl
(
pFunc
,
pErrBuf
,
len
,
3
,
9
,
1
);
return
translateConcatImpl
(
pFunc
,
pErrBuf
,
len
,
3
,
9
,
true
);
}
}
static
int32_t
translateSubstr
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
static
int32_t
translateSubstr
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
...
@@ -318,7 +330,7 @@ static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t l
...
@@ -318,7 +330,7 @@ static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t l
}
}
uint8_t
paraType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
paraType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
if
(
!
IS_
VAR_DATA
_TYPE
(
paraType
)
&&
TSDB_DATA_TYPE_TIMESTAMP
!=
paraType
)
{
if
(
!
IS_
INTEGER
_TYPE
(
paraType
)
&&
TSDB_DATA_TYPE_TIMESTAMP
!=
paraType
)
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
...
@@ -346,7 +358,7 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
...
@@ -346,7 +358,7 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
uint8_t
para1Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
para1Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
para2Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
))
->
resType
.
type
;
uint8_t
para2Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
))
->
resType
.
type
;
if
((
!
IS_VAR_DATA_TYPE
(
para1Type
)
&&
TSDB_DATA_TYPE_TIMESTAMP
!=
para1Type
)
||
!
IS_INTEGER_TYPE
(
para2Type
))
{
if
((
!
IS_VAR_DATA_TYPE
(
para1Type
)
&&
!
IS_INTEGER_TYPE
(
para1Type
)
&&
TSDB_DATA_TYPE_TIMESTAMP
!=
para1Type
)
||
!
IS_INTEGER_TYPE
(
para2Type
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
...
@@ -360,12 +372,13 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
...
@@ -360,12 +372,13 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
uint8_t
para1Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
for
(
int32_t
i
=
0
;
i
<
2
;
++
i
)
{
uint8_t
para2Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
))
->
resType
.
type
;
uint8_t
paraType
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
i
))
->
resType
.
type
;
if
((
!
IS_VAR_DATA_TYPE
(
para1Type
)
&&
TSDB_DATA_TYPE_TIMESTAMP
!=
para1Type
)
||
if
(
!
IS_VAR_DATA_TYPE
(
paraType
)
&&
!
IS_INTEGER_TYPE
(
paraType
)
&&
TSDB_DATA_TYPE_TIMESTAMP
!=
paraType
)
{
(
!
IS_VAR_DATA_TYPE
(
para2Type
)
&&
TSDB_DATA_TYPE_TIMESTAMP
!=
para2Type
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
}
}
if
(
3
==
paraNum
)
{
if
(
3
==
paraNum
)
{
if
(
!
IS_INTEGER_TYPE
(((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
2
))
->
resType
.
type
))
{
if
(
!
IS_INTEGER_TYPE
(((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
2
))
->
resType
.
type
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
...
...
source/libs/nodes/src/nodesTraverseFuncs.c
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
5b835514
...
@@ -1226,7 +1226,7 @@ void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
...
@@ -1226,7 +1226,7 @@ void valueNodeToVariant(const SValueNode* pNode, SVariant* pVal) {
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
case
TSDB_DATA_TYPE_VARBINARY
:
pVal
->
pz
=
pNode
->
datum
.
p
+
VARSTR_HEADER_SIZE
;
pVal
->
pz
=
pNode
->
datum
.
p
;
break
;
break
;
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_DECIMAL
:
case
TSDB_DATA_TYPE_DECIMAL
:
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
5b835514
...
@@ -32,6 +32,7 @@ typedef struct SAstCreateContext {
...
@@ -32,6 +32,7 @@ typedef struct SAstCreateContext {
bool
notSupport
;
bool
notSupport
;
bool
valid
;
bool
valid
;
SNode
*
pRootNode
;
SNode
*
pRootNode
;
int16_t
placeholderNo
;
}
SAstCreateContext
;
}
SAstCreateContext
;
typedef
enum
EDatabaseOptionType
{
typedef
enum
EDatabaseOptionType
{
...
@@ -86,7 +87,7 @@ SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pC
...
@@ -86,7 +87,7 @@ SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pC
SNode
*
createValueNode
(
SAstCreateContext
*
pCxt
,
int32_t
dataType
,
const
SToken
*
pLiteral
);
SNode
*
createValueNode
(
SAstCreateContext
*
pCxt
,
int32_t
dataType
,
const
SToken
*
pLiteral
);
SNode
*
createDurationValueNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLiteral
);
SNode
*
createDurationValueNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLiteral
);
SNode
*
createDefaultDatabaseCondValue
(
SAstCreateContext
*
pCxt
);
SNode
*
createDefaultDatabaseCondValue
(
SAstCreateContext
*
pCxt
);
SNode
*
createPlaceholderValueNode
(
SAstCreateContext
*
pCxt
);
SNode
*
createPlaceholderValueNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLiteral
);
SNode
*
setProjectionAlias
(
SAstCreateContext
*
pCxt
,
SNode
*
pNode
,
const
SToken
*
pAlias
);
SNode
*
setProjectionAlias
(
SAstCreateContext
*
pCxt
,
SNode
*
pNode
,
const
SToken
*
pAlias
);
SNode
*
createLogicConditionNode
(
SAstCreateContext
*
pCxt
,
ELogicConditionType
type
,
SNode
*
pParam1
,
SNode
*
pParam2
);
SNode
*
createLogicConditionNode
(
SAstCreateContext
*
pCxt
,
ELogicConditionType
type
,
SNode
*
pParam1
,
SNode
*
pParam2
);
SNode
*
createOperatorNode
(
SAstCreateContext
*
pCxt
,
EOperatorType
type
,
SNode
*
pLeft
,
SNode
*
pRight
);
SNode
*
createOperatorNode
(
SAstCreateContext
*
pCxt
,
EOperatorType
type
,
SNode
*
pLeft
,
SNode
*
pRight
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
5b835514
...
@@ -465,8 +465,8 @@ literal(A) ::= NK_STRING(B).
...
@@ -465,8 +465,8 @@ literal(A) ::= NK_STRING(B).
literal(A) ::= NK_BOOL(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &B)); }
literal(A) ::= NK_BOOL(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &B)); }
literal(A) ::= TIMESTAMP(B) NK_STRING(C). { A = createRawExprNodeExt(pCxt, &B, &C, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &C)); }
literal(A) ::= TIMESTAMP(B) NK_STRING(C). { A = createRawExprNodeExt(pCxt, &B, &C, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &C)); }
literal(A) ::= duration_literal(B). { A = B; }
literal(A) ::= duration_literal(B). { A = B; }
literal(A) ::= NULL(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_NULL,
NULL
)); }
literal(A) ::= NULL(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_NULL,
&B
)); }
literal(A) ::= NK_QUESTION(B). { A = createRawExprNode(pCxt, &B, createPlaceholderValueNode(pCxt)); }
literal(A) ::= NK_QUESTION(B). { A = createRawExprNode(pCxt, &B, createPlaceholderValueNode(pCxt
, &B
)); }
duration_literal(A) ::= NK_VARIABLE(B). { A = createRawExprNode(pCxt, &B, createDurationValueNode(pCxt, &B)); }
duration_literal(A) ::= NK_VARIABLE(B). { A = createRawExprNode(pCxt, &B, createDurationValueNode(pCxt, &B)); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
5b835514
...
@@ -44,6 +44,7 @@ void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) {
...
@@ -44,6 +44,7 @@ void initAstCreateContext(SParseContext* pParseCxt, SAstCreateContext* pCxt) {
pCxt
->
notSupport
=
false
;
pCxt
->
notSupport
=
false
;
pCxt
->
valid
=
true
;
pCxt
->
valid
=
true
;
pCxt
->
pRootNode
=
NULL
;
pCxt
->
pRootNode
=
NULL
;
pCxt
->
placeholderNo
=
1
;
}
}
static
void
trimEscape
(
SToken
*
pName
)
{
static
void
trimEscape
(
SToken
*
pName
)
{
...
@@ -258,14 +259,12 @@ SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pC
...
@@ -258,14 +259,12 @@ SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pC
SNode
*
createValueNode
(
SAstCreateContext
*
pCxt
,
int32_t
dataType
,
const
SToken
*
pLiteral
)
{
SNode
*
createValueNode
(
SAstCreateContext
*
pCxt
,
int32_t
dataType
,
const
SToken
*
pLiteral
)
{
SValueNode
*
val
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
SValueNode
*
val
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
CHECK_OUT_OF_MEM
(
val
);
CHECK_OUT_OF_MEM
(
val
);
if
(
NULL
!=
pLiteral
)
{
val
->
literal
=
strndup
(
pLiteral
->
z
,
pLiteral
->
n
);
val
->
literal
=
strndup
(
pLiteral
->
z
,
pLiteral
->
n
);
if
(
TK_NK_ID
!=
pLiteral
->
type
&&
TK_TIMEZONE
!=
pLiteral
->
type
&&
if
(
TK_NK_ID
!=
pLiteral
->
type
&&
TK_TIMEZONE
!=
pLiteral
->
type
&&
(
IS_VAR_DATA_TYPE
(
dataType
)
||
TSDB_DATA_TYPE_TIMESTAMP
==
dataType
))
{
(
IS_VAR_DATA_TYPE
(
dataType
)
||
TSDB_DATA_TYPE_TIMESTAMP
==
dataType
))
{
trimString
(
pLiteral
->
z
,
pLiteral
->
n
,
val
->
literal
,
pLiteral
->
n
);
trimString
(
pLiteral
->
z
,
pLiteral
->
n
,
val
->
literal
,
pLiteral
->
n
);
}
CHECK_OUT_OF_MEM
(
val
->
literal
);
}
}
CHECK_OUT_OF_MEM
(
val
->
literal
);
val
->
node
.
resType
.
type
=
dataType
;
val
->
node
.
resType
.
type
=
dataType
;
val
->
node
.
resType
.
bytes
=
IS_VAR_DATA_TYPE
(
dataType
)
?
strlen
(
val
->
literal
)
:
tDataTypes
[
dataType
].
bytes
;
val
->
node
.
resType
.
bytes
=
IS_VAR_DATA_TYPE
(
dataType
)
?
strlen
(
val
->
literal
)
:
tDataTypes
[
dataType
].
bytes
;
if
(
TSDB_DATA_TYPE_TIMESTAMP
==
dataType
)
{
if
(
TSDB_DATA_TYPE_TIMESTAMP
==
dataType
)
{
...
@@ -306,10 +305,12 @@ SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt) {
...
@@ -306,10 +305,12 @@ SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt) {
return
(
SNode
*
)
val
;
return
(
SNode
*
)
val
;
}
}
SNode
*
createPlaceholderValueNode
(
SAstCreateContext
*
pCxt
)
{
SNode
*
createPlaceholderValueNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLiteral
)
{
SValueNode
*
val
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
SValueNode
*
val
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
CHECK_OUT_OF_MEM
(
val
);
CHECK_OUT_OF_MEM
(
val
);
// todo
val
->
literal
=
strndup
(
pLiteral
->
z
,
pLiteral
->
n
);
CHECK_OUT_OF_MEM
(
val
->
literal
);
val
->
placeholderNo
=
pCxt
->
placeholderNo
++
;
return
(
SNode
*
)
val
;
return
(
SNode
*
)
val
;
}
}
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
5b835514
...
@@ -50,7 +50,6 @@ int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) {
...
@@ -50,7 +50,6 @@ int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) {
Parse
(
pParser
,
0
,
t0
,
&
cxt
);
Parse
(
pParser
,
0
,
t0
,
&
cxt
);
goto
abort_parse
;
goto
abort_parse
;
}
}
case
TK_NK_QUESTION
:
case
TK_NK_ILLEGAL
:
{
case
TK_NK_ILLEGAL
:
{
snprintf
(
cxt
.
pQueryCxt
->
pMsg
,
cxt
.
pQueryCxt
->
msgLen
,
"unrecognized token:
\"
%s
\"
"
,
t0
.
z
);
snprintf
(
cxt
.
pQueryCxt
->
pMsg
,
cxt
.
pQueryCxt
->
msgLen
,
"unrecognized token:
\"
%s
\"
"
,
t0
.
z
);
cxt
.
valid
=
false
;
cxt
.
valid
=
false
;
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
5b835514
...
@@ -403,6 +403,9 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) {
...
@@ -403,6 +403,9 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) {
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
uint8_t
precision
=
(
NULL
!=
pCxt
->
pCurrStmt
?
pCxt
->
pCurrStmt
->
precision
:
pVal
->
node
.
resType
.
precision
);
uint8_t
precision
=
(
NULL
!=
pCxt
->
pCurrStmt
?
pCxt
->
pCurrStmt
->
precision
:
pVal
->
node
.
resType
.
precision
);
pVal
->
node
.
resType
.
precision
=
precision
;
pVal
->
node
.
resType
.
precision
=
precision
;
if
(
pVal
->
placeholderNo
>
0
)
{
return
DEAL_RES_CONTINUE
;
}
if
(
pVal
->
isDuration
)
{
if
(
pVal
->
isDuration
)
{
if
(
parseNatualDuration
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
&
pVal
->
datum
.
i
,
&
pVal
->
unit
,
precision
)
!=
if
(
parseNatualDuration
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
&
pVal
->
datum
.
i
,
&
pVal
->
unit
,
precision
)
!=
TSDB_CODE_SUCCESS
)
{
TSDB_CODE_SUCCESS
)
{
...
@@ -492,8 +495,10 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
...
@@ -492,8 +495,10 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
((
SExprNode
*
)(
pOp
->
pRight
))
->
aliasName
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
((
SExprNode
*
)(
pOp
->
pRight
))
->
aliasName
);
}
}
if
((
TSDB_DATA_TYPE_TIMESTAMP
==
ldt
.
type
&&
TSDB_DATA_TYPE_BIGINT
==
rdt
.
type
)
||
if
((
TSDB_DATA_TYPE_TIMESTAMP
==
ldt
.
type
&&
IS_INTEGER_TYPE
(
rdt
.
type
))
||
(
TSDB_DATA_TYPE_TIMESTAMP
==
rdt
.
type
&&
TSDB_DATA_TYPE_BIGINT
==
ldt
.
type
))
{
(
TSDB_DATA_TYPE_TIMESTAMP
==
rdt
.
type
&&
IS_INTEGER_TYPE
(
ldt
.
type
))
||
(
TSDB_DATA_TYPE_TIMESTAMP
==
ldt
.
type
&&
TSDB_DATA_TYPE_BOOL
==
rdt
.
type
)
||
(
TSDB_DATA_TYPE_TIMESTAMP
==
rdt
.
type
&&
TSDB_DATA_TYPE_BOOL
==
ldt
.
type
))
{
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
pOp
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_TIMESTAMP
].
bytes
;
pOp
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_TIMESTAMP
].
bytes
;
}
else
{
}
else
{
...
@@ -807,7 +812,7 @@ static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) {
...
@@ -807,7 +812,7 @@ static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) {
size_t
nums
=
taosArrayGetSize
(
pTables
);
size_t
nums
=
taosArrayGetSize
(
pTables
);
for
(
size_t
i
=
0
;
i
<
nums
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
nums
;
++
i
)
{
STableNode
*
pTable
=
taosArrayGetP
(
pTables
,
i
);
STableNode
*
pTable
=
taosArrayGetP
(
pTables
,
i
);
int32_t
code
=
createColumnNodeByTable
(
pCxt
,
pTable
,
*
pCols
);
int32_t
code
=
createColumnNodeByTable
(
pCxt
,
pTable
,
*
pCols
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
return
code
;
}
}
...
@@ -833,7 +838,8 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
...
@@ -833,7 +838,8 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
return
NULL
;
return
NULL
;
}
}
pFunc
->
pParameterList
=
nodesMakeList
();
pFunc
->
pParameterList
=
nodesMakeList
();
if
(
NULL
==
pFunc
->
pParameterList
||
TSDB_CODE_SUCCESS
!=
nodesListStrictAppend
(
pFunc
->
pParameterList
,
nodesCloneNode
(
pExpr
)))
{
if
(
NULL
==
pFunc
->
pParameterList
||
TSDB_CODE_SUCCESS
!=
nodesListStrictAppend
(
pFunc
->
pParameterList
,
nodesCloneNode
(
pExpr
)))
{
nodesDestroyNode
(
pFunc
);
nodesDestroyNode
(
pFunc
);
return
NULL
;
return
NULL
;
}
}
...
@@ -842,7 +848,7 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
...
@@ -842,7 +848,7 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
pFunc
->
funcId
=
pSrcFunc
->
funcId
;
pFunc
->
funcId
=
pSrcFunc
->
funcId
;
pFunc
->
funcType
=
pSrcFunc
->
funcType
;
pFunc
->
funcType
=
pSrcFunc
->
funcType
;
strcpy
(
pFunc
->
functionName
,
pSrcFunc
->
functionName
);
strcpy
(
pFunc
->
functionName
,
pSrcFunc
->
functionName
);
char
buf
[
TSDB_FUNC_NAME_LEN
+
TSDB_TABLE_NAME_LEN
+
TSDB_COL_NAME_LEN
];
char
buf
[
TSDB_FUNC_NAME_LEN
+
TSDB_TABLE_NAME_LEN
+
TSDB_COL_NAME_LEN
];
int32_t
len
=
0
;
int32_t
len
=
0
;
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pExpr
))
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pExpr
))
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pExpr
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pExpr
;
...
@@ -870,7 +876,7 @@ static int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STabl
...
@@ -870,7 +876,7 @@ static int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STabl
static
int32_t
createTableAllCols
(
STranslateContext
*
pCxt
,
SColumnNode
*
pCol
,
SNodeList
**
pOutput
)
{
static
int32_t
createTableAllCols
(
STranslateContext
*
pCxt
,
SColumnNode
*
pCol
,
SNodeList
**
pOutput
)
{
STableNode
*
pTable
=
NULL
;
STableNode
*
pTable
=
NULL
;
int32_t
code
=
findTable
(
pCxt
,
pCol
->
tableAlias
,
&
pTable
);
int32_t
code
=
findTable
(
pCxt
,
pCol
->
tableAlias
,
&
pTable
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
==
*
pOutput
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
==
*
pOutput
)
{
*
pOutput
=
nodesMakeList
();
*
pOutput
=
nodesMakeList
();
if
(
NULL
==
*
pOutput
)
{
if
(
NULL
==
*
pOutput
)
{
...
@@ -884,18 +890,20 @@ static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, SN
...
@@ -884,18 +890,20 @@ static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, SN
}
}
static
bool
isStar
(
SNode
*
pNode
)
{
static
bool
isStar
(
SNode
*
pNode
)
{
return
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
&&
(
'\0'
==
((
SColumnNode
*
)
pNode
)
->
tableAlias
[
0
])
&&
(
0
==
strcmp
(((
SColumnNode
*
)
pNode
)
->
colName
,
"*"
));
return
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
&&
(
'\0'
==
((
SColumnNode
*
)
pNode
)
->
tableAlias
[
0
])
&&
(
0
==
strcmp
(((
SColumnNode
*
)
pNode
)
->
colName
,
"*"
));
}
}
static
bool
isTableStar
(
SNode
*
pNode
)
{
static
bool
isTableStar
(
SNode
*
pNode
)
{
return
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
&&
(
'\0'
!=
((
SColumnNode
*
)
pNode
)
->
tableAlias
[
0
])
&&
(
0
==
strcmp
(((
SColumnNode
*
)
pNode
)
->
colName
,
"*"
));
return
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
&&
(
'\0'
!=
((
SColumnNode
*
)
pNode
)
->
tableAlias
[
0
])
&&
(
0
==
strcmp
(((
SColumnNode
*
)
pNode
)
->
colName
,
"*"
));
}
}
static
int32_t
createMultiResFuncsParas
(
STranslateContext
*
pCxt
,
SNodeList
*
pSrcParas
,
SNodeList
**
pOutput
)
{
static
int32_t
createMultiResFuncsParas
(
STranslateContext
*
pCxt
,
SNodeList
*
pSrcParas
,
SNodeList
**
pOutput
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNodeList
*
pExprs
=
NULL
;
SNodeList
*
pExprs
=
NULL
;
SNode
*
pPara
=
NULL
;
SNode
*
pPara
=
NULL
;
FOREACH
(
pPara
,
pSrcParas
)
{
FOREACH
(
pPara
,
pSrcParas
)
{
if
(
isStar
(
pPara
))
{
if
(
isStar
(
pPara
))
{
code
=
createAllColumns
(
pCxt
,
&
pExprs
);
code
=
createAllColumns
(
pCxt
,
&
pExprs
);
...
@@ -927,7 +935,7 @@ static int32_t createMultiResFuncs(SFunctionNode* pSrcFunc, SNodeList* pExprs, S
...
@@ -927,7 +935,7 @@ static int32_t createMultiResFuncs(SFunctionNode* pSrcFunc, SNodeList* pExprs, S
}
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNode
*
pExpr
=
NULL
;
SNode
*
pExpr
=
NULL
;
FOREACH
(
pExpr
,
pExprs
)
{
FOREACH
(
pExpr
,
pExprs
)
{
code
=
nodesListStrictAppend
(
pFuncs
,
createMultiResFunc
(
pSrcFunc
,
(
SExprNode
*
)
pExpr
));
code
=
nodesListStrictAppend
(
pFuncs
,
createMultiResFunc
(
pSrcFunc
,
(
SExprNode
*
)
pExpr
));
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
...
@@ -946,7 +954,7 @@ static int32_t createMultiResFuncs(SFunctionNode* pSrcFunc, SNodeList* pExprs, S
...
@@ -946,7 +954,7 @@ static int32_t createMultiResFuncs(SFunctionNode* pSrcFunc, SNodeList* pExprs, S
static
int32_t
createMultiResFuncsFromStar
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pSrcFunc
,
SNodeList
**
pOutput
)
{
static
int32_t
createMultiResFuncsFromStar
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pSrcFunc
,
SNodeList
**
pOutput
)
{
SNodeList
*
pExprs
=
NULL
;
SNodeList
*
pExprs
=
NULL
;
int32_t
code
=
createMultiResFuncsParas
(
pCxt
,
pSrcFunc
->
pParameterList
,
&
pExprs
);
int32_t
code
=
createMultiResFuncsParas
(
pCxt
,
pSrcFunc
->
pParameterList
,
&
pExprs
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createMultiResFuncs
(
pSrcFunc
,
pExprs
,
pOutput
);
code
=
createMultiResFuncs
(
pSrcFunc
,
pExprs
,
pOutput
);
}
}
...
@@ -968,8 +976,8 @@ static bool isCountStar(SNode* pNode) {
...
@@ -968,8 +976,8 @@ static bool isCountStar(SNode* pNode) {
static
int32_t
rewriteCountStar
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pCount
)
{
static
int32_t
rewriteCountStar
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pCount
)
{
SColumnNode
*
pCol
=
nodesListGetNode
(
pCount
->
pParameterList
,
0
);
SColumnNode
*
pCol
=
nodesListGetNode
(
pCount
->
pParameterList
,
0
);
STableNode
*
pTable
=
NULL
;
STableNode
*
pTable
=
NULL
;
int32_t
code
=
findTable
(
pCxt
,
(
'\0'
==
pCol
->
tableAlias
[
0
]
?
NULL
:
pCol
->
tableAlias
),
&
pTable
);
int32_t
code
=
findTable
(
pCxt
,
(
'\0'
==
pCol
->
tableAlias
[
0
]
?
NULL
:
pCol
->
tableAlias
),
&
pTable
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
QUERY_NODE_REAL_TABLE
==
nodeType
(
pTable
))
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
QUERY_NODE_REAL_TABLE
==
nodeType
(
pTable
))
{
setColumnInfoBySchema
((
SRealTableNode
*
)
pTable
,
((
SRealTableNode
*
)
pTable
)
->
pMeta
->
schema
,
false
,
pCol
);
setColumnInfoBySchema
((
SRealTableNode
*
)
pTable
,
((
SRealTableNode
*
)
pTable
)
->
pMeta
->
schema
,
false
,
pCol
);
}
}
...
@@ -1123,9 +1131,7 @@ static int32_t translateGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
...
@@ -1123,9 +1131,7 @@ static int32_t translateGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
return
translateExprList
(
pCxt
,
pSelect
->
pGroupByList
);
return
translateExprList
(
pCxt
,
pSelect
->
pGroupByList
);
}
}
static
bool
isValTimeUnit
(
char
unit
)
{
static
bool
isValTimeUnit
(
char
unit
)
{
return
(
'n'
==
unit
||
'y'
==
unit
);
}
return
(
'n'
==
unit
||
'y'
==
unit
);
}
static
int64_t
getMonthsFromTimeVal
(
int64_t
val
,
int32_t
fromPrecision
,
char
unit
)
{
static
int64_t
getMonthsFromTimeVal
(
int64_t
val
,
int32_t
fromPrecision
,
char
unit
)
{
int64_t
days
=
convertTimeFromPrecisionToUnit
(
val
,
fromPrecision
,
'd'
);
int64_t
days
=
convertTimeFromPrecisionToUnit
(
val
,
fromPrecision
,
'd'
);
...
@@ -1153,8 +1159,8 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode*
...
@@ -1153,8 +1159,8 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode*
uint8_t
precision
=
((
SColumnNode
*
)
pInterval
->
pCol
)
->
node
.
resType
.
precision
;
uint8_t
precision
=
((
SColumnNode
*
)
pInterval
->
pCol
)
->
node
.
resType
.
precision
;
SValueNode
*
pInter
=
(
SValueNode
*
)
pInterval
->
pInterval
;
SValueNode
*
pInter
=
(
SValueNode
*
)
pInterval
->
pInterval
;
bool
valInter
=
isValTimeUnit
(
pInter
->
unit
);
bool
valInter
=
isValTimeUnit
(
pInter
->
unit
);
if
(
pInter
->
datum
.
i
<=
0
||
if
(
pInter
->
datum
.
i
<=
0
||
(
!
valInter
&&
convertTimePrecision
(
pInter
->
datum
.
i
,
precision
,
TSDB_TIME_PRECISION_MICRO
)
<
tsMinIntervalTime
))
{
(
!
valInter
&&
convertTimePrecision
(
pInter
->
datum
.
i
,
precision
,
TSDB_TIME_PRECISION_MICRO
)
<
tsMinIntervalTime
))
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL
,
tsMinIntervalTime
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INTER_VALUE_TOO_SMALL
,
tsMinIntervalTime
);
}
}
...
@@ -1165,18 +1171,19 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode*
...
@@ -1165,18 +1171,19 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode*
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INTER_OFFSET_NEGATIVE
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INTER_OFFSET_NEGATIVE
);
}
}
if
(
pInter
->
unit
==
'n'
&&
pOffset
->
unit
==
'y'
)
{
if
(
pInter
->
unit
==
'n'
&&
pOffset
->
unit
==
'y'
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INTER_OFFSET_UNIT
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INTER_OFFSET_UNIT
);
}
}
bool
fixed
=
!
isValTimeUnit
(
pOffset
->
unit
)
&&
!
valInter
;
bool
fixed
=
!
isValTimeUnit
(
pOffset
->
unit
)
&&
!
valInter
;
if
((
fixed
&&
pOffset
->
datum
.
i
>=
pInter
->
datum
.
i
)
||
if
((
fixed
&&
pOffset
->
datum
.
i
>=
pInter
->
datum
.
i
)
||
(
!
fixed
&&
getMonthsFromTimeVal
(
pOffset
->
datum
.
i
,
precision
,
pOffset
->
unit
)
>=
getMonthsFromTimeVal
(
pInter
->
datum
.
i
,
precision
,
pInter
->
unit
)))
{
(
!
fixed
&&
getMonthsFromTimeVal
(
pOffset
->
datum
.
i
,
precision
,
pOffset
->
unit
)
>=
getMonthsFromTimeVal
(
pInter
->
datum
.
i
,
precision
,
pInter
->
unit
)))
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INTER_OFFSET_TOO_BIG
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INTER_OFFSET_TOO_BIG
);
}
}
}
}
if
(
NULL
!=
pInterval
->
pSliding
)
{
if
(
NULL
!=
pInterval
->
pSliding
)
{
const
static
int32_t
INTERVAL_SLIDING_FACTOR
=
100
;
const
static
int32_t
INTERVAL_SLIDING_FACTOR
=
100
;
SValueNode
*
pSliding
=
(
SValueNode
*
)
pInterval
->
pSliding
;
SValueNode
*
pSliding
=
(
SValueNode
*
)
pInterval
->
pSliding
;
if
(
pInter
->
unit
==
'n'
||
pInter
->
unit
==
'y'
)
{
if
(
pInter
->
unit
==
'n'
||
pInter
->
unit
==
'y'
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INTER_SLIDING_UNIT
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INTER_SLIDING_UNIT
);
...
@@ -1286,14 +1293,14 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
...
@@ -1286,14 +1293,14 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
static
int64_t
getUnitPerMinute
(
uint8_t
precision
)
{
static
int64_t
getUnitPerMinute
(
uint8_t
precision
)
{
switch
(
precision
)
{
switch
(
precision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
case
TSDB_TIME_PRECISION_MILLI
:
return
MILLISECOND_PER_MINUTE
;
return
MILLISECOND_PER_MINUTE
;
case
TSDB_TIME_PRECISION_MICRO
:
case
TSDB_TIME_PRECISION_MICRO
:
return
MILLISECOND_PER_MINUTE
*
1000L
;
return
MILLISECOND_PER_MINUTE
*
1000L
;
case
TSDB_TIME_PRECISION_NANO
:
case
TSDB_TIME_PRECISION_NANO
:
return
NANOSECOND_PER_MINUTE
;
return
NANOSECOND_PER_MINUTE
;
default:
default:
break
;
break
;
}
}
return
MILLISECOND_PER_MINUTE
;
return
MILLISECOND_PER_MINUTE
;
}
}
...
@@ -1362,7 +1369,8 @@ static int32_t checkRangeOption(STranslateContext* pCxt, const char* pName, SVal
...
@@ -1362,7 +1369,8 @@ static int32_t checkRangeOption(STranslateContext* pCxt, const char* pName, SVal
if
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
pVal
))
{
if
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
pVal
))
{
return
pCxt
->
errCode
;
return
pCxt
->
errCode
;
}
}
if
(
pVal
->
isDuration
&&
(
TIME_UNIT_MINUTE
!=
pVal
->
unit
&&
TIME_UNIT_HOUR
!=
pVal
->
unit
&&
TIME_UNIT_DAY
!=
pVal
->
unit
))
{
if
(
pVal
->
isDuration
&&
(
TIME_UNIT_MINUTE
!=
pVal
->
unit
&&
TIME_UNIT_HOUR
!=
pVal
->
unit
&&
TIME_UNIT_DAY
!=
pVal
->
unit
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_OPTION_UNIT
,
pName
,
pVal
->
unit
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_OPTION_UNIT
,
pName
,
pVal
->
unit
);
}
}
int64_t
val
=
getBigintFromValueNode
(
pVal
);
int64_t
val
=
getBigintFromValueNode
(
pVal
);
...
@@ -1457,9 +1465,12 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
...
@@ -1457,9 +1465,12 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
SValueNode
*
pKeep0
=
(
SValueNode
*
)
nodesListGetNode
(
pKeep
,
0
);
SValueNode
*
pKeep0
=
(
SValueNode
*
)
nodesListGetNode
(
pKeep
,
0
);
SValueNode
*
pKeep1
=
(
SValueNode
*
)
nodesListGetNode
(
pKeep
,
1
);
SValueNode
*
pKeep1
=
(
SValueNode
*
)
nodesListGetNode
(
pKeep
,
1
);
SValueNode
*
pKeep2
=
(
SValueNode
*
)
nodesListGetNode
(
pKeep
,
2
);
SValueNode
*
pKeep2
=
(
SValueNode
*
)
nodesListGetNode
(
pKeep
,
2
);
if
((
pKeep0
->
isDuration
&&
(
TIME_UNIT_MINUTE
!=
pKeep0
->
unit
&&
TIME_UNIT_HOUR
!=
pKeep0
->
unit
&&
TIME_UNIT_DAY
!=
pKeep0
->
unit
))
||
if
((
pKeep0
->
isDuration
&&
(
pKeep1
->
isDuration
&&
(
TIME_UNIT_MINUTE
!=
pKeep1
->
unit
&&
TIME_UNIT_HOUR
!=
pKeep1
->
unit
&&
TIME_UNIT_DAY
!=
pKeep1
->
unit
))
||
(
TIME_UNIT_MINUTE
!=
pKeep0
->
unit
&&
TIME_UNIT_HOUR
!=
pKeep0
->
unit
&&
TIME_UNIT_DAY
!=
pKeep0
->
unit
))
||
(
pKeep2
->
isDuration
&&
(
TIME_UNIT_MINUTE
!=
pKeep2
->
unit
&&
TIME_UNIT_HOUR
!=
pKeep2
->
unit
&&
TIME_UNIT_DAY
!=
pKeep2
->
unit
)))
{
(
pKeep1
->
isDuration
&&
(
TIME_UNIT_MINUTE
!=
pKeep1
->
unit
&&
TIME_UNIT_HOUR
!=
pKeep1
->
unit
&&
TIME_UNIT_DAY
!=
pKeep1
->
unit
))
||
(
pKeep2
->
isDuration
&&
(
TIME_UNIT_MINUTE
!=
pKeep2
->
unit
&&
TIME_UNIT_HOUR
!=
pKeep2
->
unit
&&
TIME_UNIT_DAY
!=
pKeep2
->
unit
)))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_KEEP_UNIT
,
pKeep0
->
unit
,
pKeep1
->
unit
,
pKeep2
->
unit
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_KEEP_UNIT
,
pKeep0
->
unit
,
pKeep1
->
unit
,
pKeep2
->
unit
);
}
}
...
@@ -1516,7 +1527,8 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p
...
@@ -1516,7 +1527,8 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p
code
=
checkRangeOption
(
pCxt
,
"compression"
,
pOptions
->
pCompressionLevel
,
TSDB_MIN_COMP_LEVEL
,
TSDB_MAX_COMP_LEVEL
);
code
=
checkRangeOption
(
pCxt
,
"compression"
,
pOptions
->
pCompressionLevel
,
TSDB_MIN_COMP_LEVEL
,
TSDB_MAX_COMP_LEVEL
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkRangeOption
(
pCxt
,
"daysPerFile"
,
pOptions
->
pDaysPerFile
,
TSDB_MIN_DAYS_PER_FILE
,
TSDB_MAX_DAYS_PER_FILE
);
code
=
checkRangeOption
(
pCxt
,
"daysPerFile"
,
pOptions
->
pDaysPerFile
,
TSDB_MIN_DAYS_PER_FILE
,
TSDB_MAX_DAYS_PER_FILE
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkRangeOption
(
pCxt
,
"fsyncPeriod"
,
pOptions
->
pFsyncPeriod
,
TSDB_MIN_FSYNC_PERIOD
,
TSDB_MAX_FSYNC_PERIOD
);
code
=
checkRangeOption
(
pCxt
,
"fsyncPeriod"
,
pOptions
->
pFsyncPeriod
,
TSDB_MIN_FSYNC_PERIOD
,
TSDB_MAX_FSYNC_PERIOD
);
...
@@ -1569,7 +1581,7 @@ static int32_t checkCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt*
...
@@ -1569,7 +1581,7 @@ static int32_t checkCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt*
return
checkDatabaseOptions
(
pCxt
,
pStmt
->
pOptions
);
return
checkDatabaseOptions
(
pCxt
,
pStmt
->
pOptions
);
}
}
typedef
int32_t
(
*
FSerializeFunc
)(
void
*
pBuf
,
int32_t
bufLen
,
void
*
pReq
);
typedef
int32_t
(
*
FSerializeFunc
)(
void
*
pBuf
,
int32_t
bufLen
,
void
*
pReq
);
static
int32_t
buildCmdMsg
(
STranslateContext
*
pCxt
,
int16_t
msgType
,
FSerializeFunc
func
,
void
*
pReq
)
{
static
int32_t
buildCmdMsg
(
STranslateContext
*
pCxt
,
int16_t
msgType
,
FSerializeFunc
func
,
void
*
pReq
)
{
pCxt
->
pCmdMsg
=
taosMemoryMalloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
taosMemoryMalloc
(
sizeof
(
SCmdMsgInfo
));
...
@@ -1605,7 +1617,7 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS
...
@@ -1605,7 +1617,7 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS
static
int32_t
translateDropDatabase
(
STranslateContext
*
pCxt
,
SDropDatabaseStmt
*
pStmt
)
{
static
int32_t
translateDropDatabase
(
STranslateContext
*
pCxt
,
SDropDatabaseStmt
*
pStmt
)
{
SDropDbReq
dropReq
=
{
0
};
SDropDbReq
dropReq
=
{
0
};
SName
name
=
{
0
};
SName
name
=
{
0
};
tNameSetDbName
(
&
name
,
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
strlen
(
pStmt
->
dbName
));
tNameSetDbName
(
&
name
,
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
strlen
(
pStmt
->
dbName
));
tNameGetFullDbName
(
&
name
,
dropReq
.
db
);
tNameGetFullDbName
(
&
name
,
dropReq
.
db
);
dropReq
.
ignoreNotExists
=
pStmt
->
ignoreNotExists
;
dropReq
.
ignoreNotExists
=
pStmt
->
ignoreNotExists
;
...
@@ -1819,7 +1831,7 @@ static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt
...
@@ -1819,7 +1831,7 @@ static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt
STableMeta
*
pTableMeta
=
NULL
;
STableMeta
*
pTableMeta
=
NULL
;
SName
tableName
;
SName
tableName
;
int32_t
code
=
getTableMetaImpl
(
int32_t
code
=
getTableMetaImpl
(
pCxt
,
toName
(
pCxt
->
pParseCxt
->
acctId
,
pClause
->
dbName
,
pClause
->
tableName
,
&
tableName
),
&
pTableMeta
);
pCxt
,
toName
(
pCxt
->
pParseCxt
->
acctId
,
pClause
->
dbName
,
pClause
->
tableName
,
&
tableName
),
&
pTableMeta
);
if
((
TSDB_CODE_TDB_INVALID_TABLE_ID
==
code
||
TSDB_CODE_VND_TB_NOT_EXIST
==
code
)
&&
pClause
->
ignoreNotExists
)
{
if
((
TSDB_CODE_TDB_INVALID_TABLE_ID
==
code
||
TSDB_CODE_VND_TB_NOT_EXIST
==
code
)
&&
pClause
->
ignoreNotExists
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2105,7 +2117,7 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt
...
@@ -2105,7 +2117,7 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt
}
}
SMCreateSmaReq
createSmaReq
=
{
0
};
SMCreateSmaReq
createSmaReq
=
{
0
};
int32_t
code
=
buildCreateSmaReq
(
pCxt
,
pStmt
,
&
createSmaReq
);
int32_t
code
=
buildCreateSmaReq
(
pCxt
,
pStmt
,
&
createSmaReq
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
buildCmdMsg
(
pCxt
,
TDMT_MND_CREATE_SMA
,
(
FSerializeFunc
)
tSerializeSMCreateSmaReq
,
&
createSmaReq
);
code
=
buildCmdMsg
(
pCxt
,
TDMT_MND_CREATE_SMA
,
(
FSerializeFunc
)
tSerializeSMCreateSmaReq
,
&
createSmaReq
);
}
}
...
@@ -2118,7 +2130,7 @@ static int32_t buildCreateFullTextReq(STranslateContext* pCxt, SCreateIndexStmt*
...
@@ -2118,7 +2130,7 @@ static int32_t buildCreateFullTextReq(STranslateContext* pCxt, SCreateIndexStmt*
}
}
static
int32_t
translateCreateFullTextIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
static
int32_t
translateCreateFullTextIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
SMCreateFullTextReq
createFTReq
=
{
0
};
SMCreateFullTextReq
createFTReq
=
{
0
};
int32_t
code
=
buildCreateFullTextReq
(
pCxt
,
pStmt
,
&
createFTReq
);
int32_t
code
=
buildCreateFullTextReq
(
pCxt
,
pStmt
,
&
createFTReq
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
buildCmdMsg
(
pCxt
,
TDMT_MND_CREATE_INDEX
,
(
FSerializeFunc
)
tSerializeSMCreateFullTextReq
,
&
createFTReq
);
code
=
buildCmdMsg
(
pCxt
,
TDMT_MND_CREATE_INDEX
,
(
FSerializeFunc
)
tSerializeSMCreateFullTextReq
,
&
createFTReq
);
}
}
...
@@ -2174,7 +2186,8 @@ static int16_t getCreateComponentNodeMsgType(ENodeType type) {
...
@@ -2174,7 +2186,8 @@ static int16_t getCreateComponentNodeMsgType(ENodeType type) {
static
int32_t
translateCreateComponentNode
(
STranslateContext
*
pCxt
,
SCreateComponentNodeStmt
*
pStmt
)
{
static
int32_t
translateCreateComponentNode
(
STranslateContext
*
pCxt
,
SCreateComponentNodeStmt
*
pStmt
)
{
SMCreateQnodeReq
createReq
=
{.
dnodeId
=
pStmt
->
dnodeId
};
SMCreateQnodeReq
createReq
=
{.
dnodeId
=
pStmt
->
dnodeId
};
return
buildCmdMsg
(
pCxt
,
getCreateComponentNodeMsgType
(
nodeType
(
pStmt
)),
(
FSerializeFunc
)
tSerializeSCreateDropMQSBNodeReq
,
&
createReq
);
return
buildCmdMsg
(
pCxt
,
getCreateComponentNodeMsgType
(
nodeType
(
pStmt
)),
(
FSerializeFunc
)
tSerializeSCreateDropMQSBNodeReq
,
&
createReq
);
}
}
static
int16_t
getDropComponentNodeMsgType
(
ENodeType
type
)
{
static
int16_t
getDropComponentNodeMsgType
(
ENodeType
type
)
{
...
@@ -2195,7 +2208,8 @@ static int16_t getDropComponentNodeMsgType(ENodeType type) {
...
@@ -2195,7 +2208,8 @@ static int16_t getDropComponentNodeMsgType(ENodeType type) {
static
int32_t
translateDropComponentNode
(
STranslateContext
*
pCxt
,
SDropComponentNodeStmt
*
pStmt
)
{
static
int32_t
translateDropComponentNode
(
STranslateContext
*
pCxt
,
SDropComponentNodeStmt
*
pStmt
)
{
SDDropQnodeReq
dropReq
=
{.
dnodeId
=
pStmt
->
dnodeId
};
SDDropQnodeReq
dropReq
=
{.
dnodeId
=
pStmt
->
dnodeId
};
return
buildCmdMsg
(
pCxt
,
getDropComponentNodeMsgType
(
nodeType
(
pStmt
)),
(
FSerializeFunc
)
tSerializeSCreateDropMQSBNodeReq
,
&
dropReq
);
return
buildCmdMsg
(
pCxt
,
getDropComponentNodeMsgType
(
nodeType
(
pStmt
)),
(
FSerializeFunc
)
tSerializeSCreateDropMQSBNodeReq
,
&
dropReq
);
}
}
static
int32_t
translateCreateTopic
(
STranslateContext
*
pCxt
,
SCreateTopicStmt
*
pStmt
)
{
static
int32_t
translateCreateTopic
(
STranslateContext
*
pCxt
,
SCreateTopicStmt
*
pStmt
)
{
...
@@ -2299,11 +2313,13 @@ static int32_t translateCreateStream(STranslateContext* pCxt, SCreateStreamStmt*
...
@@ -2299,11 +2313,13 @@ static int32_t translateCreateStream(STranslateContext* pCxt, SCreateStreamStmt*
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pStmt
->
pOptions
->
pWatermark
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pStmt
->
pOptions
->
pWatermark
)
{
code
=
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pWatermark
))
?
pCxt
->
errCode
:
TSDB_CODE_SUCCESS
;
code
=
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pWatermark
))
?
pCxt
->
errCode
:
TSDB_CODE_SUCCESS
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
createReq
.
triggerType
=
pStmt
->
pOptions
->
triggerType
;
createReq
.
triggerType
=
pStmt
->
pOptions
->
triggerType
;
createReq
.
watermark
=
(
NULL
!=
pStmt
->
pOptions
->
pWatermark
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pWatermark
)
->
datum
.
i
:
0
);
createReq
.
watermark
=
(
NULL
!=
pStmt
->
pOptions
->
pWatermark
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pWatermark
)
->
datum
.
i
:
0
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -2455,9 +2471,7 @@ static int32_t extractSelectResultSchema(const SSelectStmt* pSelect, int32_t* nu
...
@@ -2455,9 +2471,7 @@ static int32_t extractSelectResultSchema(const SSelectStmt* pSelect, int32_t* nu
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int8_t
extractResultTsPrecision
(
const
SSelectStmt
*
pSelect
)
{
static
int8_t
extractResultTsPrecision
(
const
SSelectStmt
*
pSelect
)
{
return
pSelect
->
precision
;
}
return
pSelect
->
precision
;
}
static
int32_t
extractExplainResultSchema
(
int32_t
*
numOfCols
,
SSchema
**
pSchema
)
{
static
int32_t
extractExplainResultSchema
(
int32_t
*
numOfCols
,
SSchema
**
pSchema
)
{
*
numOfCols
=
1
;
*
numOfCols
=
1
;
...
@@ -2720,11 +2734,15 @@ typedef struct SVgroupTablesBatch {
...
@@ -2720,11 +2734,15 @@ typedef struct SVgroupTablesBatch {
char
dbName
[
TSDB_DB_NAME_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
}
SVgroupTablesBatch
;
}
SVgroupTablesBatch
;
static
void
toSchemaEx
(
const
SColumnDefNode
*
pCol
,
col_id_t
colId
,
SSchemaEx
*
pSchema
)
{
static
void
toSchemaEx
(
const
SColumnDefNode
*
pCol
,
col_id_t
colId
,
SSchema
*
pSchema
)
{
int8_t
flags
=
0
;
if
(
pCol
->
sma
)
{
flags
|=
SCHEMA_SMA_ON
;
}
pSchema
->
colId
=
colId
;
pSchema
->
colId
=
colId
;
pSchema
->
type
=
pCol
->
dataType
.
type
;
pSchema
->
type
=
pCol
->
dataType
.
type
;
pSchema
->
bytes
=
calcTypeBytes
(
pCol
->
dataType
);
pSchema
->
bytes
=
calcTypeBytes
(
pCol
->
dataType
);
pSchema
->
sma
=
pCol
->
sma
?
TSDB_BSMA_TYPE_LATEST
:
TSDB_BSMA_TYPE_NONE
;
pSchema
->
flags
=
flags
;
strcpy
(
pSchema
->
name
,
pCol
->
colName
);
strcpy
(
pSchema
->
name
,
pCol
->
colName
);
}
}
...
@@ -2769,7 +2787,7 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
...
@@ -2769,7 +2787,7 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
req
.
dbFName
=
strdup
(
dbFName
);
req
.
dbFName
=
strdup
(
dbFName
);
req
.
name
=
strdup
(
pStmt
->
tableName
);
req
.
name
=
strdup
(
pStmt
->
tableName
);
req
.
ntbCfg
.
nCols
=
LIST_LENGTH
(
pStmt
->
pCols
);
req
.
ntbCfg
.
nCols
=
LIST_LENGTH
(
pStmt
->
pCols
);
req
.
ntbCfg
.
pSchema
=
taosMemoryCalloc
(
req
.
ntbCfg
.
nCols
,
sizeof
(
SSchema
Ex
));
req
.
ntbCfg
.
pSchema
=
taosMemoryCalloc
(
req
.
ntbCfg
.
nCols
,
sizeof
(
SSchema
));
if
(
NULL
==
req
.
name
||
NULL
==
req
.
ntbCfg
.
pSchema
)
{
if
(
NULL
==
req
.
name
||
NULL
==
req
.
ntbCfg
.
pSchema
)
{
destroyCreateTbReq
(
&
req
);
destroyCreateTbReq
(
&
req
);
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -3174,7 +3192,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
...
@@ -3174,7 +3192,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pQuery
->
precision
=
extractResultTsPrecision
((
SSelectStmt
*
)
pQuery
->
pRoot
);
pQuery
->
precision
=
extractResultTsPrecision
((
SSelectStmt
*
)
pQuery
->
pRoot
);
}
}
if
(
NULL
!=
pCxt
->
pDbs
)
{
if
(
NULL
!=
pCxt
->
pDbs
)
{
...
...
source/libs/parser/src/sql.c
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
source/libs/parser/test/parserTestUtil.h
浏览文件 @
5b835514
...
@@ -13,4 +13,9 @@
...
@@ -13,4 +13,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
extern
bool
g_isDump
;
#ifndef PARSER_TEST_UTIL_H
\ No newline at end of file
#define PARSER_TEST_UTIL_H
extern
bool
g_isDump
;
#endif // PARSER_TEST_UTIL_H
source/libs/planner/src/planner.c
浏览文件 @
5b835514
...
@@ -17,6 +17,31 @@
...
@@ -17,6 +17,31 @@
#include "planInt.h"
#include "planInt.h"
typedef
struct
SCollectPlaceholderValuesCxt
{
int32_t
errCode
;
SNodeList
*
pValues
;
}
SCollectPlaceholderValuesCxt
;
static
EDealRes
collectPlaceholderValuesImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
pNode
)
&&
((
SValueNode
*
)
pNode
)
->
placeholderNo
>
0
)
{
SCollectPlaceholderValuesCxt
*
pCxt
=
pContext
;
pCxt
->
errCode
=
nodesListMakeAppend
(
&
pCxt
->
pValues
,
pNode
);
return
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
;
}
return
DEAL_RES_CONTINUE
;
}
static
int32_t
collectPlaceholderValues
(
SPlanContext
*
pCxt
,
SQueryPlan
*
pPlan
)
{
SCollectPlaceholderValuesCxt
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
pValues
=
NULL
};
nodesWalkPhysiPlan
((
SNode
*
)
pPlan
,
collectPlaceholderValuesImpl
,
&
cxt
);
if
(
TSDB_CODE_SUCCESS
==
cxt
.
errCode
)
{
pPlan
->
pPlaceholderValues
=
cxt
.
pValues
;
}
else
{
nodesDestroyList
(
cxt
.
pValues
);
}
return
cxt
.
errCode
;
}
int32_t
qCreateQueryPlan
(
SPlanContext
*
pCxt
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
)
{
int32_t
qCreateQueryPlan
(
SPlanContext
*
pCxt
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
)
{
SLogicNode
*
pLogicNode
=
NULL
;
SLogicNode
*
pLogicNode
=
NULL
;
SLogicSubplan
*
pLogicSubplan
=
NULL
;
SLogicSubplan
*
pLogicSubplan
=
NULL
;
...
@@ -35,6 +60,9 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
...
@@ -35,6 +60,9 @@ int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNo
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createPhysiPlan
(
pCxt
,
pLogicPlan
,
pPlan
,
pExecNodeList
);
code
=
createPhysiPlan
(
pCxt
,
pLogicPlan
,
pPlan
,
pExecNodeList
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
pCxt
->
isStmtQuery
)
{
code
=
collectPlaceholderValues
(
pCxt
,
*
pPlan
);
}
nodesDestroyNode
(
pLogicNode
);
nodesDestroyNode
(
pLogicNode
);
nodesDestroyNode
(
pLogicSubplan
);
nodesDestroyNode
(
pLogicSubplan
);
...
@@ -73,6 +101,82 @@ int32_t qSetSubplanExecutionNode(SSubplan* subplan, int32_t groupId, SDownstream
...
@@ -73,6 +101,82 @@ int32_t qSetSubplanExecutionNode(SSubplan* subplan, int32_t groupId, SDownstream
return
setSubplanExecutionNode
(
subplan
->
pNode
,
groupId
,
pSource
);
return
setSubplanExecutionNode
(
subplan
->
pNode
,
groupId
,
pSource
);
}
}
static
int32_t
setValueByBindParam
(
SValueNode
*
pVal
,
TAOS_BIND_v2
*
pParam
)
{
if
(
1
==
*
(
pParam
->
is_null
))
{
pVal
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_NULL
;
pVal
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_NULL
].
bytes
;
return
TSDB_CODE_SUCCESS
;
}
pVal
->
node
.
resType
.
type
=
pParam
->
buffer_type
;
pVal
->
node
.
resType
.
bytes
=
*
(
pParam
->
length
);
switch
(
pParam
->
buffer_type
)
{
case
TSDB_DATA_TYPE_BOOL
:
pVal
->
datum
.
b
=
*
((
bool
*
)
pParam
->
buffer
);
break
;
case
TSDB_DATA_TYPE_TINYINT
:
pVal
->
datum
.
i
=
*
((
int8_t
*
)
pParam
->
buffer
);
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
pVal
->
datum
.
i
=
*
((
int16_t
*
)
pParam
->
buffer
);
break
;
case
TSDB_DATA_TYPE_INT
:
pVal
->
datum
.
i
=
*
((
int32_t
*
)
pParam
->
buffer
);
break
;
case
TSDB_DATA_TYPE_BIGINT
:
pVal
->
datum
.
i
=
*
((
int64_t
*
)
pParam
->
buffer
);
break
;
case
TSDB_DATA_TYPE_FLOAT
:
pVal
->
datum
.
d
=
*
((
float
*
)
pParam
->
buffer
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
pVal
->
datum
.
d
=
*
((
double
*
)
pParam
->
buffer
);
break
;
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
pVal
->
datum
.
p
=
taosMemoryCalloc
(
1
,
pVal
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
+
1
);
if
(
NULL
==
pVal
->
datum
.
p
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
varDataSetLen
(
pVal
->
datum
.
p
,
pVal
->
node
.
resType
.
bytes
);
strncpy
(
varDataVal
(
pVal
->
datum
.
p
),
(
const
char
*
)
pParam
->
buffer
,
pVal
->
node
.
resType
.
bytes
);
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
pVal
->
datum
.
i
=
*
((
int64_t
*
)
pParam
->
buffer
);
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
pVal
->
datum
.
u
=
*
((
uint8_t
*
)
pParam
->
buffer
);
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
pVal
->
datum
.
u
=
*
((
uint16_t
*
)
pParam
->
buffer
);
break
;
case
TSDB_DATA_TYPE_UINT
:
pVal
->
datum
.
u
=
*
((
uint32_t
*
)
pParam
->
buffer
);
break
;
case
TSDB_DATA_TYPE_UBIGINT
:
pVal
->
datum
.
u
=
*
((
uint64_t
*
)
pParam
->
buffer
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_DECIMAL
:
case
TSDB_DATA_TYPE_BLOB
:
case
TSDB_DATA_TYPE_MEDIUMBLOB
:
// todo
default:
break
;
}
pVal
->
translate
=
true
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
qStmtBindParam
(
SQueryPlan
*
pPlan
,
TAOS_BIND_v2
*
pParams
)
{
int32_t
index
=
0
;
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pPlan
->
pPlaceholderValues
)
{
setValueByBindParam
((
SValueNode
*
)
pNode
,
pParams
+
index
);
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
qSubPlanToString
(
const
SSubplan
*
pSubplan
,
char
**
pStr
,
int32_t
*
pLen
)
{
int32_t
qSubPlanToString
(
const
SSubplan
*
pSubplan
,
char
**
pStr
,
int32_t
*
pLen
)
{
if
(
SUBPLAN_TYPE_MODIFY
==
pSubplan
->
subplanType
)
{
if
(
SUBPLAN_TYPE_MODIFY
==
pSubplan
->
subplanType
)
{
SDataInserterNode
*
insert
=
(
SDataInserterNode
*
)
pSubplan
->
pDataSink
;
SDataInserterNode
*
insert
=
(
SDataInserterNode
*
)
pSubplan
->
pDataSink
;
...
...
source/libs/planner/test/planStmtTest.cpp
0 → 100644
浏览文件 @
5b835514
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "planTestUtil.h"
#include "planner.h"
using
namespace
std
;
class
PlanStmtTest
:
public
PlannerTestBase
{
public:
void
prepare
(
const
string
&
sql
)
{
run
(
sql
);
// todo calloc pBindParams_
}
void
bindParam
(
int32_t
val
)
{
TAOS_BIND_v2
*
pBind
=
pBindParams_
+
paramNo_
++
;
pBind
->
buffer_type
=
TSDB_DATA_TYPE_INT
;
pBind
->
num
=
1
;
pBind
->
buffer_length
=
sizeof
(
int32_t
);
pBind
->
buffer
=
taosMemoryCalloc
(
1
,
pBind
->
buffer_length
);
pBind
->
length
=
(
int32_t
*
)
taosMemoryCalloc
(
1
,
sizeof
(
int32_t
));
pBind
->
is_null
=
(
char
*
)
taosMemoryCalloc
(
1
,
sizeof
(
char
));
*
((
int32_t
*
)
pBind
->
buffer
)
=
val
;
*
(
pBind
->
length
)
=
sizeof
(
int32_t
);
*
(
pBind
->
is_null
)
=
0
;
}
void
exec
()
{
// todo
}
private:
TAOS_BIND_v2
*
pBindParams_
;
int32_t
paramNo_
;
};
TEST_F
(
PlanStmtTest
,
stmt
)
{
useDb
(
"root"
,
"test"
);
run
(
"SELECT * FROM t1 where c1 = ?"
);
}
source/libs/planner/test/planTestUtil.cpp
0 → 100644
浏览文件 @
5b835514
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "planTestUtil.h"
#include <algorithm>
#include "cmdnodes.h"
#include "parser.h"
#include "planInt.h"
using
namespace
std
;
using
namespace
testing
;
#define DO_WITH_THROW(func, ...) \
do { \
int32_t code__ = func(__VA_ARGS__); \
if (TSDB_CODE_SUCCESS != code__) { \
throw runtime_error("sql:[" + stmtEnv_.sql_ + "] " #func " code:" + to_string(code__) + ", strerror:" + string(tstrerror(code__)) + ", msg:" + string(stmtEnv_.msgBuf_.data())); \
} \
} while(0);
class
PlannerTestBaseImpl
{
public:
void
useDb
(
const
string
&
acctId
,
const
string
&
db
)
{
caseEnv_
.
acctId_
=
acctId
;
caseEnv_
.
db_
=
db
;
}
void
run
(
const
string
&
sql
)
{
reset
();
try
{
SQuery
*
pQuery
=
nullptr
;
doParseSql
(
sql
,
&
pQuery
);
SPlanContext
cxt
=
{
0
};
setPlanContext
(
pQuery
,
&
cxt
);
SLogicNode
*
pLogicNode
=
nullptr
;
doCreateLogicPlan
(
&
cxt
,
&
pLogicNode
);
doOptimizeLogicPlan
(
&
cxt
,
pLogicNode
);
SLogicSubplan
*
pLogicSubplan
=
nullptr
;
doSplitLogicPlan
(
&
cxt
,
pLogicNode
,
&
pLogicSubplan
);
SQueryLogicPlan
*
pLogicPlan
=
nullptr
;
doScaleOutLogicPlan
(
&
cxt
,
pLogicSubplan
,
&
pLogicPlan
);
SQueryPlan
*
pPlan
=
nullptr
;
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
&
pPlan
,
NULL
);
}
catch
(...)
{
dump
();
throw
;
}
}
private:
struct
caseEnv
{
string
acctId_
;
string
db_
;
};
struct
stmtEnv
{
string
sql_
;
array
<
char
,
1024
>
msgBuf_
;
};
struct
stmtRes
{
string
ast_
;
string
rawLogicPlan_
;
string
optimizedLogicPlan_
;
string
splitLogicPlan_
;
string
scaledLogicPlan_
;
string
physiPlan_
;
};
void
reset
()
{
stmtEnv_
.
sql_
.
clear
();
stmtEnv_
.
msgBuf_
.
fill
(
0
);
res_
.
ast_
.
clear
();
res_
.
rawLogicPlan_
.
clear
();
res_
.
optimizedLogicPlan_
.
clear
();
res_
.
splitLogicPlan_
.
clear
();
res_
.
scaledLogicPlan_
.
clear
();
res_
.
physiPlan_
.
clear
();
}
void
dump
()
{
cout
<<
"==========================================sql : ["
<<
stmtEnv_
.
sql_
<<
"]"
<<
endl
;
cout
<<
"syntax tree : "
<<
endl
;
cout
<<
res_
.
ast_
<<
endl
;
cout
<<
"raw logic plan : "
<<
endl
;
cout
<<
res_
.
rawLogicPlan_
<<
endl
;
cout
<<
"optimized logic plan : "
<<
endl
;
cout
<<
res_
.
optimizedLogicPlan_
<<
endl
;
cout
<<
"split logic plan : "
<<
endl
;
cout
<<
res_
.
splitLogicPlan_
<<
endl
;
cout
<<
"scaled logic plan : "
<<
endl
;
cout
<<
res_
.
scaledLogicPlan_
<<
endl
;
cout
<<
"physical plan : "
<<
endl
;
cout
<<
res_
.
physiPlan_
<<
endl
;
}
void
doParseSql
(
const
string
&
sql
,
SQuery
**
pQuery
)
{
stmtEnv_
.
sql_
=
sql
;
transform
(
stmtEnv_
.
sql_
.
begin
(),
stmtEnv_
.
sql_
.
end
(),
stmtEnv_
.
sql_
.
begin
(),
::
tolower
);
SParseContext
cxt
=
{
0
};
cxt
.
acctId
=
atoi
(
caseEnv_
.
acctId_
.
c_str
());
cxt
.
db
=
caseEnv_
.
db_
.
c_str
();
cxt
.
pSql
=
stmtEnv_
.
sql_
.
c_str
();
cxt
.
sqlLen
=
stmtEnv_
.
sql_
.
length
();
cxt
.
pMsg
=
stmtEnv_
.
msgBuf_
.
data
();
cxt
.
msgLen
=
stmtEnv_
.
msgBuf_
.
max_size
();
DO_WITH_THROW
(
qParseQuerySql
,
&
cxt
,
pQuery
);
res_
.
ast_
=
toString
((
*
pQuery
)
->
pRoot
);
}
void
doCreateLogicPlan
(
SPlanContext
*
pCxt
,
SLogicNode
**
pLogicNode
)
{
DO_WITH_THROW
(
createLogicPlan
,
pCxt
,
pLogicNode
);
res_
.
rawLogicPlan_
=
toString
((
SNode
*
)(
*
pLogicNode
));
}
void
doOptimizeLogicPlan
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
)
{
DO_WITH_THROW
(
optimizeLogicPlan
,
pCxt
,
pLogicNode
);
res_
.
optimizedLogicPlan_
=
toString
((
SNode
*
)
pLogicNode
);
}
void
doSplitLogicPlan
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
,
SLogicSubplan
**
pLogicSubplan
)
{
DO_WITH_THROW
(
splitLogicPlan
,
pCxt
,
pLogicNode
,
pLogicSubplan
);
res_
.
splitLogicPlan_
=
toString
((
SNode
*
)(
*
pLogicSubplan
));
}
void
doScaleOutLogicPlan
(
SPlanContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
,
SQueryLogicPlan
**
pLogicPlan
)
{
DO_WITH_THROW
(
scaleOutLogicPlan
,
pCxt
,
pLogicSubplan
,
pLogicPlan
);
res_
.
scaledLogicPlan_
=
toString
((
SNode
*
)(
*
pLogicPlan
));
}
void
doCreatePhysiPlan
(
SPlanContext
*
pCxt
,
SQueryLogicPlan
*
pLogicPlan
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
)
{
DO_WITH_THROW
(
createPhysiPlan
,
pCxt
,
pLogicPlan
,
pPlan
,
pExecNodeList
);
res_
.
physiPlan_
=
toString
((
SNode
*
)(
*
pPlan
));
}
void
setPlanContext
(
SQuery
*
pQuery
,
SPlanContext
*
pCxt
)
{
if
(
QUERY_NODE_CREATE_TOPIC_STMT
==
nodeType
(
pQuery
->
pRoot
))
{
pCxt
->
pAstRoot
=
((
SCreateTopicStmt
*
)
pQuery
->
pRoot
)
->
pQuery
;
pCxt
->
topicQuery
=
true
;
}
else
if
(
QUERY_NODE_CREATE_INDEX_STMT
==
nodeType
(
pQuery
->
pRoot
))
{
SMCreateSmaReq
req
=
{
0
};
tDeserializeSMCreateSmaReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
);
nodesStringToNode
(
req
.
ast
,
&
pCxt
->
pAstRoot
);
pCxt
->
streamQuery
=
true
;
}
else
if
(
QUERY_NODE_CREATE_STREAM_STMT
==
nodeType
(
pQuery
->
pRoot
))
{
SCreateStreamStmt
*
pStmt
=
(
SCreateStreamStmt
*
)
pQuery
->
pRoot
;
pCxt
->
pAstRoot
=
pStmt
->
pQuery
;
pCxt
->
streamQuery
=
true
;
pCxt
->
triggerType
=
pStmt
->
pOptions
->
triggerType
;
pCxt
->
watermark
=
(
NULL
!=
pStmt
->
pOptions
->
pWatermark
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pWatermark
)
->
datum
.
i
:
0
);
}
else
{
pCxt
->
pAstRoot
=
pQuery
->
pRoot
;
}
}
string
toString
(
const
SNode
*
pRoot
)
{
char
*
pStr
=
NULL
;
int32_t
len
=
0
;
DO_WITH_THROW
(
nodesNodeToString
,
pRoot
,
false
,
&
pStr
,
&
len
)
string
str
(
pStr
);
taosMemoryFreeClear
(
pStr
);
return
str
;
}
caseEnv
caseEnv_
;
stmtEnv
stmtEnv_
;
stmtRes
res_
;
};
PlannerTestBase
::
PlannerTestBase
()
:
impl_
(
new
PlannerTestBaseImpl
())
{
}
PlannerTestBase
::~
PlannerTestBase
()
{
}
void
PlannerTestBase
::
useDb
(
const
std
::
string
&
acctId
,
const
std
::
string
&
db
)
{
impl_
->
useDb
(
acctId
,
db
);
}
void
PlannerTestBase
::
run
(
const
std
::
string
&
sql
)
{
return
impl_
->
run
(
sql
);
}
source/libs/planner/test/planTestUtil.h
0 → 100644
浏览文件 @
5b835514
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLAN_TEST_UTIL_H
#define PLAN_TEST_UTIL_H
#include <gtest/gtest.h>
class
PlannerTestBaseImpl
;
class
PlannerTestBase
:
public
testing
::
Test
{
public:
PlannerTestBase
();
virtual
~
PlannerTestBase
();
void
useDb
(
const
std
::
string
&
acctId
,
const
std
::
string
&
db
);
void
run
(
const
std
::
string
&
sql
);
private:
std
::
unique_ptr
<
PlannerTestBaseImpl
>
impl_
;
};
#endif // PLAN_TEST_UTIL_H
source/libs/planner/test/plannerTest.cpp
浏览文件 @
5b835514
...
@@ -90,17 +90,16 @@ protected:
...
@@ -90,17 +90,16 @@ protected:
return
false
;
return
false
;
}
}
SQueryPlan
*
pPlan
=
nullptr
;
code
=
createPhysiPlan
(
&
cxt
,
pLogicPlan
,
&
plan_
,
NULL
);
code
=
createPhysiPlan
(
&
cxt
,
pLogicPlan
,
&
pPlan
,
NULL
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] createPhysiPlan code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] createPhysiPlan code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
return
false
;
return
false
;
}
}
cout
<<
"unformatted physical plan : "
<<
endl
;
cout
<<
"unformatted physical plan : "
<<
endl
;
cout
<<
toString
((
const
SNode
*
)
p
Plan
,
false
)
<<
endl
;
cout
<<
toString
((
const
SNode
*
)
p
lan_
,
false
)
<<
endl
;
SNode
*
pNode
;
SNode
*
pNode
;
FOREACH
(
pNode
,
p
Plan
->
pSubplans
)
{
FOREACH
(
pNode
,
p
lan_
->
pSubplans
)
{
SNode
*
pSubplan
;
SNode
*
pSubplan
;
FOREACH
(
pSubplan
,
((
SNodeListNode
*
)
pNode
)
->
pNodeList
)
{
FOREACH
(
pSubplan
,
((
SNodeListNode
*
)
pNode
)
->
pNodeList
)
{
cout
<<
"unformatted physical subplan : "
<<
endl
;
cout
<<
"unformatted physical subplan : "
<<
endl
;
...
@@ -160,6 +159,7 @@ private:
...
@@ -160,6 +159,7 @@ private:
string
sqlBuf_
;
string
sqlBuf_
;
SParseContext
cxt_
;
SParseContext
cxt_
;
SQuery
*
query_
;
SQuery
*
query_
;
SQueryPlan
*
plan_
;
};
};
TEST_F
(
PlannerTest
,
selectBasic
)
{
TEST_F
(
PlannerTest
,
selectBasic
)
{
...
...
source/libs/scalar/inc/sclvector.h
浏览文件 @
5b835514
...
@@ -52,6 +52,9 @@ static FORCE_INLINE double getVectorDoubleValue_FLOAT(void *src, int32_t index)
...
@@ -52,6 +52,9 @@ static FORCE_INLINE double getVectorDoubleValue_FLOAT(void *src, int32_t index)
static
FORCE_INLINE
double
getVectorDoubleValue_DOUBLE
(
void
*
src
,
int32_t
index
)
{
static
FORCE_INLINE
double
getVectorDoubleValue_DOUBLE
(
void
*
src
,
int32_t
index
)
{
return
(
double
)
*
((
double
*
)
src
+
index
);
return
(
double
)
*
((
double
*
)
src
+
index
);
}
}
static
FORCE_INLINE
double
getVectorDoubleValue_BOOL
(
void
*
src
,
int32_t
index
)
{
return
(
double
)
*
((
bool
*
)
src
+
index
);
}
static
FORCE_INLINE
_getDoubleValue_fn_t
getVectorDoubleValueFn
(
int32_t
srcType
)
{
static
FORCE_INLINE
_getDoubleValue_fn_t
getVectorDoubleValueFn
(
int32_t
srcType
)
{
_getDoubleValue_fn_t
p
=
NULL
;
_getDoubleValue_fn_t
p
=
NULL
;
...
@@ -77,6 +80,8 @@ static FORCE_INLINE _getDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType)
...
@@ -77,6 +80,8 @@ static FORCE_INLINE _getDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType)
p
=
getVectorDoubleValue_DOUBLE
;
p
=
getVectorDoubleValue_DOUBLE
;
}
else
if
(
srcType
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
}
else
if
(
srcType
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
p
=
getVectorDoubleValue_BIGINT
;
p
=
getVectorDoubleValue_BIGINT
;
}
else
if
(
srcType
==
TSDB_DATA_TYPE_BOOL
)
{
p
=
getVectorDoubleValue_BOOL
;
}
else
{
}
else
{
assert
(
0
);
assert
(
0
);
}
}
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
5b835514
...
@@ -398,7 +398,7 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
...
@@ -398,7 +398,7 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
SScalarParam
*
params
=
NULL
;
SScalarParam
*
params
=
NULL
;
int32_t
rowNum
=
0
;
int32_t
rowNum
=
0
;
int32_t
code
=
0
;
int32_t
code
=
0
;
SCL_ERR_RET
(
sclInitOperatorParams
(
&
params
,
node
,
ctx
,
&
rowNum
));
SCL_ERR_RET
(
sclInitOperatorParams
(
&
params
,
node
,
ctx
,
&
rowNum
));
output
->
columnData
=
createColumnInfoData
(
&
node
->
node
.
resType
,
rowNum
);
output
->
columnData
=
createColumnInfoData
(
&
node
->
node
.
resType
,
rowNum
);
if
(
output
->
columnData
==
NULL
)
{
if
(
output
->
columnData
==
NULL
)
{
...
@@ -411,7 +411,7 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
...
@@ -411,7 +411,7 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
int32_t
paramNum
=
scalarGetOperatorParamNum
(
node
->
opType
);
int32_t
paramNum
=
scalarGetOperatorParamNum
(
node
->
opType
);
SScalarParam
*
pLeft
=
&
params
[
0
];
SScalarParam
*
pLeft
=
&
params
[
0
];
SScalarParam
*
pRight
=
paramNum
>
1
?
&
params
[
1
]
:
NULL
;
SScalarParam
*
pRight
=
paramNum
>
1
?
&
params
[
1
]
:
NULL
;
OperatorFn
(
pLeft
,
pRight
,
output
,
TSDB_ORDER_ASC
);
OperatorFn
(
pLeft
,
pRight
,
output
,
TSDB_ORDER_ASC
);
_return:
_return:
...
@@ -426,7 +426,7 @@ _return:
...
@@ -426,7 +426,7 @@ _return:
EDealRes
sclRewriteFunction
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
EDealRes
sclRewriteFunction
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
SFunctionNode
*
node
=
(
SFunctionNode
*
)
*
pNode
;
SFunctionNode
*
node
=
(
SFunctionNode
*
)
*
pNode
;
SScalarParam
output
=
{
0
};
SScalarParam
output
=
{
0
};
ctx
->
code
=
sclExecFunction
(
node
,
ctx
,
&
output
);
ctx
->
code
=
sclExecFunction
(
node
,
ctx
,
&
output
);
if
(
ctx
->
code
)
{
if
(
ctx
->
code
)
{
return
DEAL_RES_ERROR
;
return
DEAL_RES_ERROR
;
...
@@ -440,16 +440,19 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
...
@@ -440,16 +440,19 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
return
DEAL_RES_ERROR
;
return
DEAL_RES_ERROR
;
}
}
res
->
node
.
resType
=
node
->
node
.
resType
;
if
(
colDataIsNull_s
(
output
.
columnData
,
0
))
{
res
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_NULL
;
int32_t
type
=
output
.
columnData
->
info
.
type
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
res
->
datum
.
p
=
output
.
columnData
->
pData
;
output
.
columnData
->
pData
=
NULL
;
}
else
{
}
else
{
memcpy
(
nodesGetValueFromNode
(
res
),
output
.
columnData
->
pData
,
tDataTypes
[
type
].
bytes
);
res
->
node
.
resType
=
node
->
node
.
resType
;
int32_t
type
=
output
.
columnData
->
info
.
type
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
res
->
datum
.
p
=
output
.
columnData
->
pData
;
output
.
columnData
->
pData
=
NULL
;
}
else
{
memcpy
(
nodesGetValueFromNode
(
res
),
output
.
columnData
->
pData
,
tDataTypes
[
type
].
bytes
);
}
}
}
nodesDestroyNode
(
*
pNode
);
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
res
;
*
pNode
=
(
SNode
*
)
res
;
...
@@ -469,7 +472,7 @@ EDealRes sclRewriteLogic(SNode** pNode, SScalarCtx *ctx) {
...
@@ -469,7 +472,7 @@ EDealRes sclRewriteLogic(SNode** pNode, SScalarCtx *ctx) {
SValueNode
*
res
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
SValueNode
*
res
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
if
(
NULL
==
res
)
{
if
(
NULL
==
res
)
{
sclError
(
"make value node failed"
);
sclError
(
"make value node failed"
);
sclFreeParam
(
&
output
);
sclFreeParam
(
&
output
);
ctx
->
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
ctx
->
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
DEAL_RES_ERROR
;
return
DEAL_RES_ERROR
;
}
}
...
...
source/libs/scalar/src/sclfunc.c
浏览文件 @
5b835514
...
@@ -313,8 +313,8 @@ static int32_t doLengthFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
...
@@ -313,8 +313,8 @@ static int32_t doLengthFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
concatCopyHelper
(
const
char
*
input
,
char
*
output
,
bool
hasNchar
Col
,
int32_t
type
,
int16_t
*
dataLen
)
{
static
int32_t
concatCopyHelper
(
const
char
*
input
,
char
*
output
,
bool
hasNchar
,
int32_t
type
,
int16_t
*
dataLen
)
{
if
(
hasNchar
Col
&&
type
==
TSDB_DATA_TYPE_VARCHAR
)
{
if
(
hasNchar
&&
type
==
TSDB_DATA_TYPE_VARCHAR
)
{
TdUcs4
*
newBuf
=
taosMemoryCalloc
((
varDataLen
(
input
)
+
1
)
*
TSDB_NCHAR_SIZE
,
1
);
TdUcs4
*
newBuf
=
taosMemoryCalloc
((
varDataLen
(
input
)
+
1
)
*
TSDB_NCHAR_SIZE
,
1
);
bool
ret
=
taosMbsToUcs4
(
varDataVal
(
input
),
varDataLen
(
input
),
newBuf
,
(
varDataLen
(
input
)
+
1
)
*
TSDB_NCHAR_SIZE
,
NULL
);
bool
ret
=
taosMbsToUcs4
(
varDataVal
(
input
),
varDataLen
(
input
),
newBuf
,
(
varDataLen
(
input
)
+
1
)
*
TSDB_NCHAR_SIZE
,
NULL
);
if
(
!
ret
)
{
if
(
!
ret
)
{
...
@@ -345,10 +345,6 @@ static int32_t getNumOfNullEntries(SColumnInfoData *pColumnInfoData, int32_t num
...
@@ -345,10 +345,6 @@ static int32_t getNumOfNullEntries(SColumnInfoData *pColumnInfoData, int32_t num
}
}
int32_t
concatFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
int32_t
concatFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
if
(
inputNum
<
2
||
inputNum
>
8
)
{
// concat accpet 2-8 input strings
return
TSDB_CODE_FAILED
;
}
SColumnInfoData
**
pInputData
=
taosMemoryCalloc
(
inputNum
,
sizeof
(
SColumnInfoData
*
));
SColumnInfoData
**
pInputData
=
taosMemoryCalloc
(
inputNum
,
sizeof
(
SColumnInfoData
*
));
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
char
**
input
=
taosMemoryCalloc
(
inputNum
,
POINTER_BYTES
);
char
**
input
=
taosMemoryCalloc
(
inputNum
,
POINTER_BYTES
);
...
@@ -356,15 +352,8 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
...
@@ -356,15 +352,8 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
int32_t
inputLen
=
0
;
int32_t
inputLen
=
0
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
bool
hasNchar
Col
=
false
;
bool
hasNchar
=
(
GET_PARAM_TYPE
(
pOutput
)
==
TSDB_DATA_TYPE_NCHAR
)
?
true
:
false
;
for
(
int32_t
i
=
0
;
i
<
inputNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
inputNum
;
++
i
)
{
int32_t
type
=
GET_PARAM_TYPE
(
&
pInput
[
i
]);
if
(
!
IS_VAR_DATA_TYPE
(
type
))
{
return
TSDB_CODE_FAILED
;
}
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
hasNcharCol
=
true
;
}
if
(
pInput
[
i
].
numOfRows
>
numOfRows
)
{
if
(
pInput
[
i
].
numOfRows
>
numOfRows
)
{
numOfRows
=
pInput
[
i
].
numOfRows
;
numOfRows
=
pInput
[
i
].
numOfRows
;
}
}
...
@@ -373,7 +362,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
...
@@ -373,7 +362,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
pInputData
[
i
]
=
pInput
[
i
].
columnData
;
pInputData
[
i
]
=
pInput
[
i
].
columnData
;
input
[
i
]
=
pInputData
[
i
]
->
pData
+
pInputData
[
i
]
->
varmeta
.
offset
[
0
];
input
[
i
]
=
pInputData
[
i
]
->
pData
+
pInputData
[
i
]
->
varmeta
.
offset
[
0
];
int32_t
factor
=
1
;
int32_t
factor
=
1
;
if
(
hasNchar
Col
&&
(
GET_PARAM_TYPE
(
&
pInput
[
i
])
==
TSDB_DATA_TYPE_VARCHAR
))
{
if
(
hasNchar
&&
(
GET_PARAM_TYPE
(
&
pInput
[
i
])
==
TSDB_DATA_TYPE_VARCHAR
))
{
factor
=
TSDB_NCHAR_SIZE
;
factor
=
TSDB_NCHAR_SIZE
;
}
}
...
@@ -405,7 +394,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
...
@@ -405,7 +394,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
int16_t
dataLen
=
0
;
int16_t
dataLen
=
0
;
for
(
int32_t
i
=
0
;
i
<
inputNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
inputNum
;
++
i
)
{
int32_t
ret
=
concatCopyHelper
(
input
[
i
],
output
,
hasNchar
Col
,
GET_PARAM_TYPE
(
&
pInput
[
i
]),
&
dataLen
);
int32_t
ret
=
concatCopyHelper
(
input
[
i
],
output
,
hasNchar
,
GET_PARAM_TYPE
(
&
pInput
[
i
]),
&
dataLen
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
return
ret
;
}
}
...
@@ -428,10 +417,6 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
...
@@ -428,10 +417,6 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
int32_t
concatWsFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
int32_t
concatWsFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
if
(
inputNum
<
3
||
inputNum
>
9
)
{
// concat accpet 3-9 input strings including the separator
return
TSDB_CODE_FAILED
;
}
SColumnInfoData
**
pInputData
=
taosMemoryCalloc
(
inputNum
,
sizeof
(
SColumnInfoData
*
));
SColumnInfoData
**
pInputData
=
taosMemoryCalloc
(
inputNum
,
sizeof
(
SColumnInfoData
*
));
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
char
**
input
=
taosMemoryCalloc
(
inputNum
,
POINTER_BYTES
);
char
**
input
=
taosMemoryCalloc
(
inputNum
,
POINTER_BYTES
);
...
@@ -439,15 +424,8 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
...
@@ -439,15 +424,8 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
int32_t
inputLen
=
0
;
int32_t
inputLen
=
0
;
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
bool
hasNchar
Col
=
false
;
bool
hasNchar
=
(
GET_PARAM_TYPE
(
pOutput
)
==
TSDB_DATA_TYPE_NCHAR
)
?
true
:
false
;
for
(
int32_t
i
=
1
;
i
<
inputNum
;
++
i
)
{
for
(
int32_t
i
=
1
;
i
<
inputNum
;
++
i
)
{
int32_t
type
=
GET_PARAM_TYPE
(
&
pInput
[
i
]);
if
(
!
IS_VAR_DATA_TYPE
(
GET_PARAM_TYPE
(
&
pInput
[
i
])))
{
return
TSDB_CODE_FAILED
;
}
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
hasNcharCol
=
true
;
}
if
(
pInput
[
i
].
numOfRows
>
numOfRows
)
{
if
(
pInput
[
i
].
numOfRows
>
numOfRows
)
{
numOfRows
=
pInput
[
i
].
numOfRows
;
numOfRows
=
pInput
[
i
].
numOfRows
;
}
}
...
@@ -456,7 +434,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
...
@@ -456,7 +434,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
pInputData
[
i
]
=
pInput
[
i
].
columnData
;
pInputData
[
i
]
=
pInput
[
i
].
columnData
;
input
[
i
]
=
pInputData
[
i
]
->
pData
+
pInputData
[
i
]
->
varmeta
.
offset
[
0
];
input
[
i
]
=
pInputData
[
i
]
->
pData
+
pInputData
[
i
]
->
varmeta
.
offset
[
0
];
int32_t
factor
=
1
;
int32_t
factor
=
1
;
if
(
hasNchar
Col
&&
(
GET_PARAM_TYPE
(
&
pInput
[
i
])
==
TSDB_DATA_TYPE_VARCHAR
))
{
if
(
hasNchar
&&
(
GET_PARAM_TYPE
(
&
pInput
[
i
])
==
TSDB_DATA_TYPE_VARCHAR
))
{
factor
=
TSDB_NCHAR_SIZE
;
factor
=
TSDB_NCHAR_SIZE
;
}
}
...
@@ -487,7 +465,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
...
@@ -487,7 +465,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
continue
;
continue
;
}
}
int32_t
ret
=
concatCopyHelper
(
input
[
i
],
output
,
hasNchar
Col
,
GET_PARAM_TYPE
(
&
pInput
[
i
]),
&
dataLen
);
int32_t
ret
=
concatCopyHelper
(
input
[
i
],
output
,
hasNchar
,
GET_PARAM_TYPE
(
&
pInput
[
i
]),
&
dataLen
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
return
ret
;
}
}
...
@@ -499,7 +477,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
...
@@ -499,7 +477,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
if
(
i
<
inputNum
-
1
)
{
if
(
i
<
inputNum
-
1
)
{
//insert the separator
//insert the separator
char
*
sep
=
pInputData
[
0
]
->
pData
;
char
*
sep
=
pInputData
[
0
]
->
pData
;
int32_t
ret
=
concatCopyHelper
(
sep
,
output
,
hasNchar
Col
,
GET_PARAM_TYPE
(
&
pInput
[
0
]),
&
dataLen
);
int32_t
ret
=
concatCopyHelper
(
sep
,
output
,
hasNchar
,
GET_PARAM_TYPE
(
&
pInput
[
0
]),
&
dataLen
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
return
ret
;
}
}
...
@@ -817,13 +795,6 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
...
@@ -817,13 +795,6 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
int32_t
toISO8601Function
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
int32_t
toISO8601Function
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
int32_t
type
=
GET_PARAM_TYPE
(
pInput
);
int32_t
type
=
GET_PARAM_TYPE
(
pInput
);
if
(
type
!=
TSDB_DATA_TYPE_BIGINT
&&
type
!=
TSDB_DATA_TYPE_TIMESTAMP
)
{
return
TSDB_CODE_FAILED
;
}
if
(
inputNum
!=
1
)
{
return
TSDB_CODE_FAILED
;
}
char
*
input
=
pInput
[
0
].
columnData
->
pData
;
char
*
input
=
pInput
[
0
].
columnData
->
pData
;
for
(
int32_t
i
=
0
;
i
<
pInput
[
0
].
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInput
[
0
].
numOfRows
;
++
i
)
{
...
@@ -889,13 +860,6 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
...
@@ -889,13 +860,6 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
int32_t
toUnixtimestampFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
int32_t
toUnixtimestampFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
int32_t
type
=
GET_PARAM_TYPE
(
pInput
);
int32_t
type
=
GET_PARAM_TYPE
(
pInput
);
int32_t
timePrec
=
GET_PARAM_PRECISON
(
pInput
);
int32_t
timePrec
=
GET_PARAM_PRECISON
(
pInput
);
if
(
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
return
TSDB_CODE_FAILED
;
}
if
(
inputNum
!=
1
)
{
return
TSDB_CODE_FAILED
;
}
char
*
input
=
pInput
[
0
].
columnData
->
pData
+
pInput
[
0
].
columnData
->
varmeta
.
offset
[
0
];
char
*
input
=
pInput
[
0
].
columnData
->
pData
+
pInput
[
0
].
columnData
->
varmeta
.
offset
[
0
];
for
(
int32_t
i
=
0
;
i
<
pInput
[
0
].
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pInput
[
0
].
numOfRows
;
++
i
)
{
...
@@ -905,7 +869,11 @@ int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
...
@@ -905,7 +869,11 @@ int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
}
}
int64_t
timeVal
=
0
;
int64_t
timeVal
=
0
;
convertStringToTimestamp
(
type
,
input
,
timePrec
,
&
timeVal
);
int32_t
ret
=
convertStringToTimestamp
(
type
,
input
,
timePrec
,
&
timeVal
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
colDataAppendNULL
(
pOutput
->
columnData
,
i
);
continue
;
}
colDataAppend
(
pOutput
->
columnData
,
i
,
(
char
*
)
&
timeVal
,
false
);
colDataAppend
(
pOutput
->
columnData
,
i
,
(
char
*
)
&
timeVal
,
false
);
input
+=
varDataTLen
(
input
);
input
+=
varDataTLen
(
input
);
...
@@ -919,18 +887,6 @@ int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
...
@@ -919,18 +887,6 @@ int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
int32_t
timeTruncateFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
int32_t
timeTruncateFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
int32_t
type
=
GET_PARAM_TYPE
(
&
pInput
[
0
]);
int32_t
type
=
GET_PARAM_TYPE
(
&
pInput
[
0
]);
int32_t
timePrec
=
GET_PARAM_PRECISON
(
&
pInput
[
0
]);
int32_t
timePrec
=
GET_PARAM_PRECISON
(
&
pInput
[
0
]);
if
(
inputNum
!=
2
)
{
return
TSDB_CODE_FAILED
;
}
if
(
type
!=
TSDB_DATA_TYPE_BIGINT
&&
type
!=
TSDB_DATA_TYPE_TIMESTAMP
&&
type
!=
TSDB_DATA_TYPE_BINARY
&&
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
return
TSDB_CODE_FAILED
;
}
if
(
GET_PARAM_TYPE
(
&
pInput
[
1
])
!=
TSDB_DATA_TYPE_BIGINT
)
{
//time_unit
return
TSDB_CODE_FAILED
;
}
int64_t
timeUnit
,
timeVal
=
0
;
int64_t
timeUnit
,
timeVal
=
0
;
GET_TYPED_DATA
(
timeUnit
,
int64_t
,
GET_PARAM_TYPE
(
&
pInput
[
1
]),
pInput
[
1
].
columnData
->
pData
);
GET_TYPED_DATA
(
timeUnit
,
int64_t
,
GET_PARAM_TYPE
(
&
pInput
[
1
]),
pInput
[
1
].
columnData
->
pData
);
...
@@ -952,7 +908,11 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
...
@@ -952,7 +908,11 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
}
}
if
(
IS_VAR_DATA_TYPE
(
type
))
{
/* datetime format strings */
if
(
IS_VAR_DATA_TYPE
(
type
))
{
/* datetime format strings */
convertStringToTimestamp
(
type
,
input
,
TSDB_TIME_PRECISION_NANO
,
&
timeVal
);
int32_t
ret
=
convertStringToTimestamp
(
type
,
input
,
TSDB_TIME_PRECISION_NANO
,
&
timeVal
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
colDataAppendNULL
(
pOutput
->
columnData
,
i
);
continue
;
}
//If converted value is less than 10digits in second, use value in second instead
//If converted value is less than 10digits in second, use value in second instead
int64_t
timeValSec
=
timeVal
/
1000000000
;
int64_t
timeValSec
=
timeVal
/
1000000000
;
if
(
timeValSec
<
1000000000
)
{
if
(
timeValSec
<
1000000000
)
{
...
@@ -1118,16 +1078,9 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
...
@@ -1118,16 +1078,9 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
}
}
int32_t
timeDiffFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
int32_t
timeDiffFunction
(
SScalarParam
*
pInput
,
int32_t
inputNum
,
SScalarParam
*
pOutput
)
{
if
(
inputNum
!=
2
&&
inputNum
!=
3
)
{
return
TSDB_CODE_FAILED
;
}
int32_t
timePrec
=
GET_PARAM_PRECISON
(
&
pInput
[
0
]);
int32_t
timePrec
=
GET_PARAM_PRECISON
(
&
pInput
[
0
]);
int64_t
timeUnit
=
-
1
,
timeVal
[
2
]
=
{
0
};
int64_t
timeUnit
=
-
1
,
timeVal
[
2
]
=
{
0
};
if
(
inputNum
==
3
)
{
if
(
inputNum
==
3
)
{
if
(
GET_PARAM_TYPE
(
&
pInput
[
2
])
!=
TSDB_DATA_TYPE_BIGINT
)
{
return
TSDB_CODE_FAILED
;
}
GET_TYPED_DATA
(
timeUnit
,
int64_t
,
GET_PARAM_TYPE
(
&
pInput
[
2
]),
pInput
[
2
].
columnData
->
pData
);
GET_TYPED_DATA
(
timeUnit
,
int64_t
,
GET_PARAM_TYPE
(
&
pInput
[
2
]),
pInput
[
2
].
columnData
->
pData
);
}
}
...
@@ -1155,7 +1108,11 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
...
@@ -1155,7 +1108,11 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
int32_t
type
=
GET_PARAM_TYPE
(
&
pInput
[
k
]);
int32_t
type
=
GET_PARAM_TYPE
(
&
pInput
[
k
]);
if
(
IS_VAR_DATA_TYPE
(
type
))
{
/* datetime format strings */
if
(
IS_VAR_DATA_TYPE
(
type
))
{
/* datetime format strings */
convertStringToTimestamp
(
type
,
input
[
k
],
TSDB_TIME_PRECISION_NANO
,
&
timeVal
[
k
]);
int32_t
ret
=
convertStringToTimestamp
(
type
,
input
[
k
],
TSDB_TIME_PRECISION_NANO
,
&
timeVal
[
k
]);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
colDataAppendNULL
(
pOutput
->
columnData
,
i
);
continue
;
}
}
else
if
(
type
==
TSDB_DATA_TYPE_BIGINT
||
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
/* unix timestamp or ts column*/
}
else
if
(
type
==
TSDB_DATA_TYPE_BIGINT
||
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
/* unix timestamp or ts column*/
GET_TYPED_DATA
(
timeVal
[
k
],
int64_t
,
type
,
input
[
k
]);
GET_TYPED_DATA
(
timeVal
[
k
],
int64_t
,
type
,
input
[
k
]);
if
(
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
if
(
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
5b835514
...
@@ -57,6 +57,10 @@ int64_t getVectorBigintValue_FLOAT(void *src, int32_t index) {
...
@@ -57,6 +57,10 @@ int64_t getVectorBigintValue_FLOAT(void *src, int32_t index) {
int64_t
getVectorBigintValue_DOUBLE
(
void
*
src
,
int32_t
index
)
{
int64_t
getVectorBigintValue_DOUBLE
(
void
*
src
,
int32_t
index
)
{
return
(
int64_t
)
*
((
double
*
)
src
+
index
);
return
(
int64_t
)
*
((
double
*
)
src
+
index
);
}
}
int64_t
getVectorBigintValue_BOOL
(
void
*
src
,
int32_t
index
)
{
return
(
int64_t
)
*
((
bool
*
)
src
+
index
);
}
_getBigintValue_fn_t
getVectorBigintValueFn
(
int32_t
srcType
)
{
_getBigintValue_fn_t
getVectorBigintValueFn
(
int32_t
srcType
)
{
_getBigintValue_fn_t
p
=
NULL
;
_getBigintValue_fn_t
p
=
NULL
;
if
(
srcType
==
TSDB_DATA_TYPE_TINYINT
)
{
if
(
srcType
==
TSDB_DATA_TYPE_TINYINT
)
{
...
@@ -81,6 +85,8 @@ _getBigintValue_fn_t getVectorBigintValueFn(int32_t srcType) {
...
@@ -81,6 +85,8 @@ _getBigintValue_fn_t getVectorBigintValueFn(int32_t srcType) {
p
=
getVectorBigintValue_DOUBLE
;
p
=
getVectorBigintValue_DOUBLE
;
}
else
if
(
srcType
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
}
else
if
(
srcType
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
p
=
getVectorBigintValue_BIGINT
;
p
=
getVectorBigintValue_BIGINT
;
}
else
if
(
srcType
==
TSDB_DATA_TYPE_BOOL
)
{
p
=
getVectorBigintValue_BOOL
;
}
else
{
}
else
{
assert
(
0
);
assert
(
0
);
}
}
...
@@ -620,8 +626,10 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
...
@@ -620,8 +626,10 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
SColumnInfoData
*
pLeftCol
=
doVectorConvert
(
pLeft
,
&
leftConvert
);
SColumnInfoData
*
pLeftCol
=
doVectorConvert
(
pLeft
,
&
leftConvert
);
SColumnInfoData
*
pRightCol
=
doVectorConvert
(
pRight
,
&
rightConvert
);
SColumnInfoData
*
pRightCol
=
doVectorConvert
(
pRight
,
&
rightConvert
);
if
((
GET_PARAM_TYPE
(
pLeft
)
==
TSDB_DATA_TYPE_TIMESTAMP
&&
GET_PARAM_TYPE
(
pRight
)
==
TSDB_DATA_TYPE_BIGINT
)
||
if
((
GET_PARAM_TYPE
(
pLeft
)
==
TSDB_DATA_TYPE_TIMESTAMP
&&
IS_INTEGER_TYPE
(
GET_PARAM_TYPE
(
pRight
)))
||
(
GET_PARAM_TYPE
(
pRight
)
==
TSDB_DATA_TYPE_TIMESTAMP
&&
GET_PARAM_TYPE
(
pLeft
)
==
TSDB_DATA_TYPE_BIGINT
))
{
//timestamp plus duration
(
GET_PARAM_TYPE
(
pRight
)
==
TSDB_DATA_TYPE_TIMESTAMP
&&
IS_INTEGER_TYPE
(
GET_PARAM_TYPE
(
pLeft
)))
||
(
GET_PARAM_TYPE
(
pLeft
)
==
TSDB_DATA_TYPE_TIMESTAMP
&&
GET_PARAM_TYPE
(
pRight
)
==
TSDB_DATA_TYPE_BOOL
)
||
(
GET_PARAM_TYPE
(
pRight
)
==
TSDB_DATA_TYPE_TIMESTAMP
&&
GET_PARAM_TYPE
(
pLeft
)
==
TSDB_DATA_TYPE_BOOL
))
{
//timestamp plus duration
int64_t
*
output
=
(
int64_t
*
)
pOutputCol
->
pData
;
int64_t
*
output
=
(
int64_t
*
)
pOutputCol
->
pData
;
_getBigintValue_fn_t
getVectorBigintValueFnLeft
=
getVectorBigintValueFn
(
pLeftCol
->
info
.
type
);
_getBigintValue_fn_t
getVectorBigintValueFnLeft
=
getVectorBigintValueFn
(
pLeftCol
->
info
.
type
);
_getBigintValue_fn_t
getVectorBigintValueFnRight
=
getVectorBigintValueFn
(
pRightCol
->
info
.
type
);
_getBigintValue_fn_t
getVectorBigintValueFnRight
=
getVectorBigintValueFn
(
pRightCol
->
info
.
type
);
...
...
source/os/src/osFile.c
浏览文件 @
5b835514
...
@@ -772,6 +772,9 @@ int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf) {
...
@@ -772,6 +772,9 @@ int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf) {
if
(
pFile
==
NULL
)
{
if
(
pFile
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
if
(
*
ptrBuf
!=
NULL
)
{
taosMemoryFreeClear
(
*
ptrBuf
);
}
assert
(
pFile
->
fp
!=
NULL
);
assert
(
pFile
->
fp
!=
NULL
);
size_t
len
=
0
;
size_t
len
=
0
;
...
...
source/os/src/osThread.c
浏览文件 @
5b835514
...
@@ -77,34 +77,6 @@ int32_t taosThreadAttrSetStackSize(TdThreadAttr * attr, size_t stacksize) {
...
@@ -77,34 +77,6 @@ int32_t taosThreadAttrSetStackSize(TdThreadAttr * attr, size_t stacksize) {
return
pthread_attr_setstacksize
(
attr
,
stacksize
);
return
pthread_attr_setstacksize
(
attr
,
stacksize
);
}
}
int32_t
taosThreadBarrierDestroy
(
TdThreadBarrier
*
barrier
)
{
return
pthread_barrier_destroy
(
barrier
);
}
int32_t
taosThreadBarrierInit
(
TdThreadBarrier
*
barrier
,
const
TdThreadBarrierAttr
*
attr
,
uint32_t
count
)
{
return
pthread_barrier_init
(
barrier
,
attr
,
count
);
}
int32_t
taosThreadBarrierWait
(
TdThreadBarrier
*
barrier
)
{
return
pthread_barrier_wait
(
barrier
);
}
int32_t
taosThreadBarrierAttrDestroy
(
TdThreadBarrierAttr
*
attr
)
{
return
pthread_barrierattr_destroy
(
attr
);
}
int32_t
taosThreadBarrierAttrGetPshared
(
const
TdThreadBarrierAttr
*
attr
,
int32_t
*
pshared
)
{
return
pthread_barrierattr_getpshared
(
attr
,
pshared
);
}
int32_t
taosThreadBarrierAttrInit
(
TdThreadBarrierAttr
*
attr
)
{
return
pthread_barrierattr_init
(
attr
);
}
int32_t
taosThreadBarrierAttrSetPshared
(
TdThreadBarrierAttr
*
attr
,
int32_t
pshared
)
{
return
pthread_barrierattr_setpshared
(
attr
,
pshared
);
}
int32_t
taosThreadCancel
(
TdThread
thread
)
{
int32_t
taosThreadCancel
(
TdThread
thread
)
{
return
pthread_cancel
(
thread
);
return
pthread_cancel
(
thread
);
}
}
...
@@ -322,23 +294,43 @@ int32_t taosThreadSetSpecific(TdThreadKey key, const void *value) {
...
@@ -322,23 +294,43 @@ int32_t taosThreadSetSpecific(TdThreadKey key, const void *value) {
}
}
int32_t
taosThreadSpinDestroy
(
TdThreadSpinlock
*
lock
)
{
int32_t
taosThreadSpinDestroy
(
TdThreadSpinlock
*
lock
)
{
return
pthread_spin_destroy
(
lock
);
#ifndef __USE_XOPEN2K
return
pthread_mutex_destroy
((
pthread_mutex_t
*
)
lock
);
#else
return
pthread_spin_destroy
((
pthread_spinlock_t
*
)
lock
);
#endif
}
}
int32_t
taosThreadSpinInit
(
TdThreadSpinlock
*
lock
,
int32_t
pshared
)
{
int32_t
taosThreadSpinInit
(
TdThreadSpinlock
*
lock
,
int32_t
pshared
)
{
return
pthread_spin_init
(
lock
,
pshared
);
#ifndef __USE_XOPEN2K
return
pthread_mutex_init
((
pthread_mutex_t
*
)
lock
,
pshared
);
#else
return
pthread_spin_init
((
pthread_spinlock_t
*
)
lock
,
pshared
);
#endif
}
}
int32_t
taosThreadSpinLock
(
TdThreadSpinlock
*
lock
)
{
int32_t
taosThreadSpinLock
(
TdThreadSpinlock
*
lock
)
{
return
pthread_spin_lock
(
lock
);
#ifndef __USE_XOPEN2K
return
pthread_mutex_lock
((
pthread_mutex_t
*
)
lock
);
#else
return
pthread_spin_lock
((
pthread_spinlock_t
*
)
lock
);
#endif
}
}
int32_t
taosThreadSpinTrylock
(
TdThreadSpinlock
*
lock
)
{
int32_t
taosThreadSpinTrylock
(
TdThreadSpinlock
*
lock
)
{
return
pthread_spin_trylock
(
lock
);
#ifndef __USE_XOPEN2K
return
pthread_mutex_trylock
((
pthread_mutex_t
*
)
lock
);
#else
return
pthread_spin_trylock
((
pthread_spinlock_t
*
)
lock
);
#endif
}
}
int32_t
taosThreadSpinUnlock
(
TdThreadSpinlock
*
lock
)
{
int32_t
taosThreadSpinUnlock
(
TdThreadSpinlock
*
lock
)
{
return
pthread_spin_unlock
(
lock
);
#ifndef __USE_XOPEN2K
return
pthread_mutex_unlock
((
pthread_mutex_t
*
)
lock
);
#else
return
pthread_spin_unlock
((
pthread_spinlock_t
*
)
lock
);
#endif
}
}
void
taosThreadTestCancel
(
void
)
{
void
taosThreadTestCancel
(
void
)
{
...
...
tests/script/tmp/data.sim
浏览文件 @
5b835514
...
@@ -3,6 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1
...
@@ -3,6 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode1 -s start
sql connect
sql connect
return
sql create database db
sql create database db
sql create table db.tb (ts timestamp, i int)
sql create table db.tb (ts timestamp, i int)
sql insert into db.tb values(now, 1)
sql insert into db.tb values(now, 1)
...
...
tests/script/tsim/bnode/basic1.sim
浏览文件 @
5b835514
...
@@ -24,7 +24,7 @@ if $data00 != 1 then
...
@@ -24,7 +24,7 @@ if $data00 != 1 then
return -1
return -1
endi
endi
if $data02 !=
master
then
if $data02 !=
LEADER
then
return -1
return -1
endi
endi
...
@@ -71,7 +71,7 @@ if $data00 != 1 then
...
@@ -71,7 +71,7 @@ if $data00 != 1 then
return -1
return -1
endi
endi
if $data02 !=
master
then
if $data02 !=
LEADER
then
return -1
return -1
endi
endi
...
...
tests/script/tsim/db/alter_option.sim
浏览文件 @
5b835514
...
@@ -72,7 +72,7 @@ print rows: $rows
...
@@ -72,7 +72,7 @@ print rows: $rows
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
print ====> dataX_db
print ====> dataX_db
print $data
0_db $data1_db
$data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
print $data
(db)[0] $data(db)[1]
$data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $rows != 3 then
if $rows != 3 then
return -1
return -1
...
...
tests/script/tsim/db/basic6.sim
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
tests/script/tsim/dnode/basic1.sim
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
tests/script/tsim/mnode/basic1.sim
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
tests/script/tsim/qnode/basic1.sim
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
tests/script/tsim/query/explain.sim
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
tests/script/tsim/query/session.sim
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
tests/script/tsim/query/time_process.sim
0 → 100644
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
tests/script/tsim/snode/basic1.sim
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
tests/script/tsim/user/basic1.sim
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
tests/system-test/2-query/between.py
0 → 100644
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
tests/system-test/fulltest.sh
0 → 100755
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
tests/system-test/test.py
0 → 100644
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
tests/tsim/inc/simInt.h
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
tests/tsim/src/simExe.c
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
tools/shell/src/shellEngine.c
浏览文件 @
5b835514
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录