Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b7281e4d
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
提交
b7281e4d
编写于
4月 19, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into fix/valgrind
上级
25a4645f
52647f10
变更
45
隐藏空白更改
内联
并排
Showing
45 changed file
with
1920 addition
and
1596 deletion
+1920
-1596
include/common/tmsg.h
include/common/tmsg.h
+10
-21
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
+1
-1
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+5
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+8
-12
source/common/src/ttime.c
source/common/src/ttime.c
+10
-2
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+3
-9
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+15
-5
source/dnode/mgmt/test/vnode/CMakeLists.txt
source/dnode/mgmt/test/vnode/CMakeLists.txt
+10
-10
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+19
-55
source/dnode/vnode/CMakeLists.txt
source/dnode/vnode/CMakeLists.txt
+0
-1
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+5
-2
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+2
-0
source/dnode/vnode/src/meta/metaTDBImpl.c
source/dnode/vnode/src/meta/metaTDBImpl.c
+13
-13
source/dnode/vnode/src/vnd/vnodeCfg.c
source/dnode/vnode/src/vnd/vnodeCfg.c
+101
-1
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+0
-74
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+22
-36
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+8
-7
source/libs/nodes/src/nodesTraverseFuncs.c
source/libs/nodes/src/nodesTraverseFuncs.c
+285
-64
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
+3
-3
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/parInsert.c
source/libs/parser/src/parInsert.c
+138
-133
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+91
-72
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+471
-925
source/libs/parser/test/parserTestUtil.h
source/libs/parser/test/parserTestUtil.h
+6
-1
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+4
-0
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
+207
-0
source/libs/planner/test/planTestUtil.h
source/libs/planner/test/planTestUtil.h
+21
-2
source/libs/planner/test/plannerTest.cpp
source/libs/planner/test/plannerTest.cpp
+4
-4
source/libs/planner/test/plannerTestMain.cpp
source/libs/planner/test/plannerTestMain.cpp
+20
-0
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
+15
-36
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+10
-2
source/os/src/osThread.c
source/os/src/osThread.c
+25
-33
tests/script/tsim/query/time_process.sim
tests/script/tsim/query/time_process.sim
+133
-0
tests/system-test/2-query/between.py
tests/system-test/2-query/between.py
+51
-39
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+1
-1
未找到文件。
include/common/tmsg.h
浏览文件 @
b7281e4d
...
@@ -253,22 +253,16 @@ typedef struct {
...
@@ -253,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)
...
@@ -1437,8 +1431,6 @@ typedef struct {
...
@@ -1437,8 +1431,6 @@ typedef struct {
}
SRSmaParam
;
}
SRSmaParam
;
typedef
struct
SVCreateTbReq
{
typedef
struct
SVCreateTbReq
{
int64_t
ver
;
// use a general definition
char
*
dbFName
;
char
*
name
;
char
*
name
;
uint32_t
ttl
;
uint32_t
ttl
;
uint32_t
keep
;
uint32_t
keep
;
...
@@ -1454,7 +1446,7 @@ typedef struct SVCreateTbReq {
...
@@ -1454,7 +1446,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
;
...
@@ -1466,7 +1458,7 @@ typedef struct SVCreateTbReq {
...
@@ -1466,7 +1458,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
;
};
};
...
@@ -2031,16 +2023,13 @@ int32_t tDecodeSMqCMCommitOffsetReq(SCoder* decoder, SMqCMCommitOffsetReq* pReq)
...
@@ -2031,16 +2023,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
);
...
@@ -2049,7 +2038,7 @@ static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema
...
@@ -2049,7 +2038,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
);
...
@@ -2058,7 +2047,7 @@ static FORCE_INLINE void* taosDecodeSSchema(void* buf, SSchema* pSchema) {
...
@@ -2058,7 +2047,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
;
...
@@ -2067,7 +2056,7 @@ static FORCE_INLINE int32_t tEncodeSSchema(SCoder* pEncoder, const SSchema* pSch
...
@@ -2067,7 +2056,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/libs/nodes/plannodes.h
浏览文件 @
b7281e4d
...
@@ -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
浏览文件 @
b7281e4d
...
@@ -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
浏览文件 @
b7281e4d
...
@@ -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
浏览文件 @
b7281e4d
...
@@ -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
浏览文件 @
b7281e4d
...
@@ -199,7 +199,7 @@ typedef enum EOperatorType {
...
@@ -199,7 +199,7 @@ typedef enum EOperatorType {
}
EOperatorType
;
}
EOperatorType
;
typedef
enum
ELogicConditionType
{
typedef
enum
ELogicConditionType
{
LOGIC_COND_TYPE_AND
,
LOGIC_COND_TYPE_AND
=
1
,
LOGIC_COND_TYPE_OR
,
LOGIC_COND_TYPE_OR
,
LOGIC_COND_TYPE_NOT
,
LOGIC_COND_TYPE_NOT
,
}
ELogicConditionType
;
}
ELogicConditionType
;
...
...
source/common/src/tdatablock.c
浏览文件 @
b7281e4d
...
@@ -1100,6 +1100,11 @@ int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows)
...
@@ -1100,6 +1100,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
浏览文件 @
b7281e4d
...
@@ -397,8 +397,6 @@ int32_t tDeserializeSClientHbBatchRsp(void *buf, int32_t bufLen, SClientHbBatchR
...
@@ -397,8 +397,6 @@ int32_t tDeserializeSClientHbBatchRsp(void *buf, int32_t bufLen, SClientHbBatchR
int32_t
tSerializeSVCreateTbReq
(
void
**
buf
,
SVCreateTbReq
*
pReq
)
{
int32_t
tSerializeSVCreateTbReq
(
void
**
buf
,
SVCreateTbReq
*
pReq
)
{
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
ver
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
dbFName
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
ttl
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
ttl
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
keep
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
keep
);
...
@@ -411,7 +409,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -411,7 +409,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 +417,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -419,7 +417,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 +441,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -443,7 +441,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
);
...
@@ -466,8 +464,6 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -466,8 +464,6 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
}
}
void
*
tDeserializeSVCreateTbReq
(
void
*
buf
,
SVCreateTbReq
*
pReq
)
{
void
*
tDeserializeSVCreateTbReq
(
void
*
buf
,
SVCreateTbReq
*
pReq
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
(
pReq
->
ver
));
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
dbFName
));
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
name
));
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
name
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pReq
->
ttl
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pReq
->
ttl
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pReq
->
keep
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pReq
->
keep
));
...
@@ -478,10 +474,10 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -478,10 +474,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 +486,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -490,7 +486,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 +516,10 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -520,10 +516,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
);
...
...
source/common/src/ttime.c
浏览文件 @
b7281e4d
...
@@ -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/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
b7281e4d
...
@@ -82,13 +82,13 @@ int32_t vmProcessGetVnodeLoadsReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) {
...
@@ -82,13 +82,13 @@ int32_t vmProcessGetVnodeLoadsReq(SMgmtWrapper *pWrapper, SNodeMsg *pReq) {
}
}
static
void
vmGenerateVnodeCfg
(
SCreateVnodeReq
*
pCreate
,
SVnodeCfg
*
pCfg
)
{
static
void
vmGenerateVnodeCfg
(
SCreateVnodeReq
*
pCreate
,
SVnodeCfg
*
pCfg
)
{
memcpy
(
pCfg
,
&
vnodeCfgDefault
,
sizeof
(
SVnodeCfg
));
pCfg
->
vgId
=
pCreate
->
vgId
;
pCfg
->
vgId
=
pCreate
->
vgId
;
strcpy
(
pCfg
->
dbname
,
pCreate
->
db
);
pCfg
->
wsize
=
pCreate
->
cacheBlockSize
*
1024
*
1024
;
pCfg
->
wsize
=
pCreate
->
cacheBlockSize
*
1024
*
1024
;
pCfg
->
ssize
=
1024
;
pCfg
->
ssize
=
1024
;
pCfg
->
lsize
=
1024
*
1024
;
pCfg
->
lsize
=
1024
*
1024
;
pCfg
->
isHeapAllocator
=
true
;
pCfg
->
ttl
=
4
;
pCfg
->
keep
=
pCreate
->
daysToKeep0
;
pCfg
->
streamMode
=
pCreate
->
streamMode
;
pCfg
->
streamMode
=
pCreate
->
streamMode
;
pCfg
->
isWeak
=
true
;
pCfg
->
isWeak
=
true
;
pCfg
->
tsdbCfg
.
keep2
=
pCreate
->
daysToKeep0
;
pCfg
->
tsdbCfg
.
keep2
=
pCreate
->
daysToKeep0
;
...
@@ -96,12 +96,6 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
...
@@ -96,12 +96,6 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
pCfg
->
tsdbCfg
.
keep1
=
pCreate
->
daysToKeep0
;
pCfg
->
tsdbCfg
.
keep1
=
pCreate
->
daysToKeep0
;
pCfg
->
tsdbCfg
.
lruCacheSize
=
pCreate
->
cacheBlockSize
;
pCfg
->
tsdbCfg
.
lruCacheSize
=
pCreate
->
cacheBlockSize
;
pCfg
->
tsdbCfg
.
retentions
=
pCreate
->
pRetensions
;
pCfg
->
tsdbCfg
.
retentions
=
pCreate
->
pRetensions
;
pCfg
->
walCfg
.
level
=
TAOS_WAL_WRITE
;
pCfg
->
walCfg
.
fsyncPeriod
=
0
;
pCfg
->
walCfg
.
retentionPeriod
=
0
;
pCfg
->
walCfg
.
retentionSize
=
0
;
pCfg
->
walCfg
.
rollPeriod
=
0
;
pCfg
->
walCfg
.
segSize
=
0
;
pCfg
->
walCfg
.
vgId
=
pCreate
->
vgId
;
pCfg
->
walCfg
.
vgId
=
pCreate
->
vgId
;
pCfg
->
hashBegin
=
pCreate
->
hashBegin
;
pCfg
->
hashBegin
=
pCreate
->
hashBegin
;
pCfg
->
hashEnd
=
pCreate
->
hashEnd
;
pCfg
->
hashEnd
=
pCreate
->
hashEnd
;
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
b7281e4d
...
@@ -97,6 +97,7 @@ static void vmProcessFetchQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
...
@@ -97,6 +97,7 @@ static void vmProcessFetchQueue(SQueueInfo *pInfo, SNodeMsg *pMsg) {
static
void
vmProcessWriteQueue
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
static
void
vmProcessWriteQueue
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
int64_t
version
;
SArray
*
pArray
=
taosArrayInit
(
numOfMsgs
,
sizeof
(
SNodeMsg
*
));
SArray
*
pArray
=
taosArrayInit
(
numOfMsgs
,
sizeof
(
SNodeMsg
*
));
if
(
pArray
==
NULL
)
{
if
(
pArray
==
NULL
)
{
...
@@ -115,23 +116,32 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
...
@@ -115,23 +116,32 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
}
}
}
}
vnodePreprocessWriteReqs
(
pVnode
->
pImpl
,
pArray
);
vnodePreprocessWriteReqs
(
pVnode
->
pImpl
,
pArray
,
&
version
);
numOfMsgs
=
taosArrayGetSize
(
pArray
);
numOfMsgs
=
taosArrayGetSize
(
pArray
);
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
i
++
)
{
SNodeMsg
*
pMsg
=
*
(
SNodeMsg
**
)
taosArrayGet
(
pArray
,
i
);
SNodeMsg
*
pMsg
=
*
(
SNodeMsg
**
)
taosArrayGet
(
pArray
,
i
);
SRpcMsg
*
pRpc
=
&
pMsg
->
rpcMsg
;
SRpcMsg
*
pRpc
=
&
pMsg
->
rpcMsg
;
SRpcMsg
*
pRsp
=
NULL
;
SRpcMsg
rsp
;
int32_t
code
=
vnodeProcessWriteReq
(
pVnode
->
pImpl
,
pRpc
,
&
pRsp
);
rsp
.
pCont
=
NULL
;
rsp
.
contLen
=
0
;
rsp
.
code
=
0
;
rsp
.
handle
=
pRpc
->
handle
;
rsp
.
ahandle
=
pRpc
->
ahandle
;
int32_t
code
=
vnodeProcessWriteReq
(
pVnode
->
pImpl
,
pRpc
,
version
++
,
&
rsp
);
tmsgSendRsp
(
&
rsp
);
#if 0
if (pRsp != NULL) {
if (pRsp != NULL) {
pRsp->ahandle = pRpc->ahandle;
pRsp->ahandle = pRpc->ahandle;
tmsgSendRsp
(
pRsp
);
taosMemoryFree(pRsp);
taosMemoryFree(pRsp);
} else {
} else {
if (code != 0 && terrno != 0) code = terrno;
if (code != 0 && terrno != 0) code = terrno;
vmSendRsp(pVnode->pWrapper, pMsg, code);
vmSendRsp(pVnode->pWrapper, pMsg, code);
}
}
#endif
}
}
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
i
++
)
{
...
@@ -153,7 +163,7 @@ static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
...
@@ -153,7 +163,7 @@ static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
// todo
// todo
SRpcMsg
*
pRsp
=
NULL
;
SRpcMsg
*
pRsp
=
NULL
;
(
void
)
vnodeProcessWriteReq
(
pVnode
->
pImpl
,
&
pMsg
->
rpcMsg
,
&
pRsp
);
//
(void)vnodeProcessWriteReq(pVnode->pImpl, &pMsg->rpcMsg, &pRsp);
}
}
}
}
...
...
source/dnode/mgmt/test/vnode/CMakeLists.txt
浏览文件 @
b7281e4d
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/src/mndStb.c
浏览文件 @
b7281e4d
...
@@ -18,8 +18,8 @@
...
@@ -18,8 +18,8 @@
#include "mndDb.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndDnode.h"
#include "mndInfoSchema.h"
#include "mndInfoSchema.h"
#include "mndPerfSchema.h"
#include "mndMnode.h"
#include "mndMnode.h"
#include "mndPerfSchema.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndTrans.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndUser.h"
...
@@ -40,7 +40,7 @@ static int32_t mndProcessVCreateStbRsp(SNodeMsg *pRsp);
...
@@ -40,7 +40,7 @@ static int32_t mndProcessVCreateStbRsp(SNodeMsg *pRsp);
static
int32_t
mndProcessVAlterStbRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndProcessVAlterStbRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndProcessVDropStbRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndProcessVDropStbRsp
(
SNodeMsg
*
pRsp
);
static
int32_t
mndProcessTableMetaReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndProcessTableMetaReq
(
SNodeMsg
*
pReq
);
static
int32_t
mndRetrieveStb
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
int32_t
mndRetrieveStb
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
);
static
void
mndCancelGetNextStb
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextStb
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitStb
(
SMnode
*
pMnode
)
{
int32_t
mndInitStb
(
SMnode
*
pMnode
)
{
...
@@ -333,9 +333,9 @@ static SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName) {
...
@@ -333,9 +333,9 @@ static SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName) {
}
}
static
FORCE_INLINE
int
schemaExColIdCompare
(
const
void
*
colId
,
const
void
*
pSchema
)
{
static
FORCE_INLINE
int
schemaExColIdCompare
(
const
void
*
colId
,
const
void
*
pSchema
)
{
if
(
*
(
col_id_t
*
)
colId
<
((
SSchema
Ex
*
)
pSchema
)
->
colId
)
{
if
(
*
(
col_id_t
*
)
colId
<
((
SSchema
*
)
pSchema
)
->
colId
)
{
return
-
1
;
return
-
1
;
}
else
if
(
*
(
col_id_t
*
)
colId
>
((
SSchema
Ex
*
)
pSchema
)
->
colId
)
{
}
else
if
(
*
(
col_id_t
*
)
colId
>
((
SSchema
*
)
pSchema
)
->
colId
)
{
return
1
;
return
1
;
}
}
return
0
;
return
0
;
...
@@ -348,8 +348,6 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
...
@@ -348,8 +348,6 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
tNameGetFullDbName
(
&
name
,
dbFName
);
tNameGetFullDbName
(
&
name
,
dbFName
);
SVCreateTbReq
req
=
{
0
};
SVCreateTbReq
req
=
{
0
};
req
.
ver
=
0
;
req
.
dbFName
=
dbFName
;
req
.
name
=
(
char
*
)
tNameGetTableName
(
&
name
);
req
.
name
=
(
char
*
)
tNameGetTableName
(
&
name
);
req
.
ttl
=
0
;
req
.
ttl
=
0
;
req
.
keep
=
0
;
req
.
keep
=
0
;
...
@@ -360,49 +358,15 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
...
@@ -360,49 +358,15 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
req
.
stbCfg
.
nTagCols
=
pStb
->
numOfTags
;
req
.
stbCfg
.
nTagCols
=
pStb
->
numOfTags
;
req
.
stbCfg
.
pTagSchema
=
pStb
->
pTags
;
req
.
stbCfg
.
pTagSchema
=
pStb
->
pTags
;
req
.
stbCfg
.
nBSmaCols
=
pStb
->
numOfSmas
;
req
.
stbCfg
.
nBSmaCols
=
pStb
->
numOfSmas
;
req
.
stbCfg
.
pSchema
=
(
SSchema
Ex
*
)
taosMemoryCalloc
(
pStb
->
numOfColumns
,
sizeof
(
SSchemaEx
));
req
.
stbCfg
.
pSchema
=
(
SSchema
*
)
taosMemoryCalloc
(
pStb
->
numOfColumns
,
sizeof
(
SSchema
));
if
(
req
.
stbCfg
.
pSchema
==
NULL
)
{
if
(
req
.
stbCfg
.
pSchema
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
return
NULL
;
}
}
int
bSmaStat
=
0
;
// no column has bsma
memcpy
(
req
.
stbCfg
.
pSchema
,
pStb
->
pColumns
,
sizeof
(
SSchema
)
*
pStb
->
numOfColumns
);
if
(
pStb
->
numOfSmas
==
pStb
->
numOfColumns
)
{
// assume pColumns > 0
for
(
int
i
=
0
;
i
<
pStb
->
numOfColumns
;
i
++
)
{
bSmaStat
=
1
;
// all columns have bsma
req
.
stbCfg
.
pSchema
[
i
].
flags
=
SCHEMA_SMA_ON
;
}
else
if
(
pStb
->
numOfSmas
!=
0
)
{
bSmaStat
=
2
;
// partial columns have bsma
TASSERT
(
pStb
->
pSmas
!=
NULL
);
// TODO: remove the assert
}
for
(
int32_t
i
=
0
;
i
<
req
.
stbCfg
.
nCols
;
++
i
)
{
SSchemaEx
*
pSchemaEx
=
req
.
stbCfg
.
pSchema
+
i
;
SSchema
*
pSchema
=
pStb
->
pColumns
+
i
;
pSchemaEx
->
type
=
pSchema
->
type
;
pSchemaEx
->
sma
=
(
bSmaStat
==
1
)
?
TSDB_BSMA_TYPE_LATEST
:
TSDB_BSMA_TYPE_NONE
;
pSchemaEx
->
colId
=
pSchema
->
colId
;
pSchemaEx
->
bytes
=
pSchema
->
bytes
;
memcpy
(
pSchemaEx
->
name
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
);
}
if
(
bSmaStat
==
2
)
{
if
(
pStb
->
pSmas
==
NULL
)
{
mError
(
"stb:%s, sma options is empty"
,
pStb
->
name
);
taosMemoryFreeClear
(
req
.
stbCfg
.
pSchema
);
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
NULL
;
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfSmas
;
++
i
)
{
SSchema
*
pSmaSchema
=
pStb
->
pSmas
+
i
;
SSchemaEx
*
pColSchema
=
taosbsearch
(
&
pSmaSchema
->
colId
,
req
.
stbCfg
.
pSchema
,
req
.
stbCfg
.
nCols
,
sizeof
(
SSchemaEx
),
schemaExColIdCompare
,
TD_EQ
);
if
(
pColSchema
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
taosMemoryFreeClear
(
req
.
stbCfg
.
pSchema
);
mError
(
"stb:%s, sma col:%s not found in columns"
,
pStb
->
name
,
pSmaSchema
->
name
);
return
NULL
;
}
pColSchema
->
sma
=
TSDB_BSMA_TYPE_LATEST
;
}
}
}
SRSmaParam
*
pRSmaParam
=
NULL
;
SRSmaParam
*
pRSmaParam
=
NULL
;
...
@@ -428,9 +392,9 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
...
@@ -428,9 +392,9 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
*
(
pRSmaParam
->
pFuncIds
+
f
)
=
pStb
->
aggregationMethod
;
*
(
pRSmaParam
->
pFuncIds
+
f
)
=
pStb
->
aggregationMethod
;
}
}
req
.
stbCfg
.
pRSmaParam
=
pRSmaParam
;
req
.
stbCfg
.
pRSmaParam
=
pRSmaParam
;
}
}
int32_t
contLen
=
tSerializeSVCreateTbReq
(
NULL
,
&
req
)
+
sizeof
(
SMsgHead
);
int32_t
contLen
=
tSerializeSVCreateTbReq
(
NULL
,
&
req
)
+
sizeof
(
SMsgHead
);
SMsgHead
*
pHead
=
taosMemoryMalloc
(
contLen
);
SMsgHead
*
pHead
=
taosMemoryMalloc
(
contLen
);
if
(
pHead
==
NULL
)
{
if
(
pHead
==
NULL
)
{
if
(
pRSmaParam
)
{
if
(
pRSmaParam
)
{
...
@@ -1644,14 +1608,14 @@ static void mndExtractTableName(char *tableId, char *name) {
...
@@ -1644,14 +1608,14 @@ static void mndExtractTableName(char *tableId, char *name) {
}
}
}
}
static
int32_t
mndRetrieveStb
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
static
int32_t
mndRetrieveStb
(
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
;
SStbObj
*
pStb
=
NULL
;
SStbObj
*
pStb
=
NULL
;
int32_t
cols
=
0
;
int32_t
cols
=
0
;
SDbObj
*
pDb
=
NULL
;
SDbObj
*
pDb
=
NULL
;
if
(
strlen
(
pShow
->
db
)
>
0
)
{
if
(
strlen
(
pShow
->
db
)
>
0
)
{
pDb
=
mndAcquireDb
(
pMnode
,
pShow
->
db
);
pDb
=
mndAcquireDb
(
pMnode
,
pShow
->
db
);
if
(
pDb
==
NULL
)
return
terrno
;
if
(
pDb
==
NULL
)
return
terrno
;
...
@@ -1669,20 +1633,20 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlo
...
@@ -1669,20 +1633,20 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlo
cols
=
0
;
cols
=
0
;
SName
name
=
{
0
};
SName
name
=
{
0
};
char
stbName
[
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
stbName
[
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
mndExtractTableName
(
pStb
->
name
,
&
stbName
[
VARSTR_HEADER_SIZE
]);
mndExtractTableName
(
pStb
->
name
,
&
stbName
[
VARSTR_HEADER_SIZE
]);
varDataSetLen
(
stbName
,
strlen
(
&
stbName
[
VARSTR_HEADER_SIZE
]));
varDataSetLen
(
stbName
,
strlen
(
&
stbName
[
VARSTR_HEADER_SIZE
]));
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
stbName
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
stbName
,
false
);
char
db
[
TSDB_DB_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
db
[
TSDB_DB_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
tNameFromString
(
&
name
,
pStb
->
db
,
T_NAME_ACCT
|
T_NAME_DB
);
tNameFromString
(
&
name
,
pStb
->
db
,
T_NAME_ACCT
|
T_NAME_DB
);
tNameGetDbName
(
&
name
,
varDataVal
(
db
));
tNameGetDbName
(
&
name
,
varDataVal
(
db
));
varDataSetLen
(
db
,
strlen
(
varDataVal
(
db
)));
varDataSetLen
(
db
,
strlen
(
varDataVal
(
db
)));
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
db
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
db
,
false
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStb
->
createdTime
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStb
->
createdTime
,
false
);
...
@@ -1696,7 +1660,7 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlo
...
@@ -1696,7 +1660,7 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, SSDataBlock* pBlo
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
cols
++
);
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStb
->
updateTime
,
false
);
// number of tables
colDataAppend
(
pColInfo
,
numOfRows
,
(
const
char
*
)
&
pStb
->
updateTime
,
false
);
// number of tables
char
*
p
=
taosMemoryMalloc
(
pStb
->
commentLen
+
VARSTR_HEADER_SIZE
);
// check malloc failures
char
*
p
=
taosMemoryMalloc
(
pStb
->
commentLen
+
VARSTR_HEADER_SIZE
);
// check malloc failures
if
(
p
!=
NULL
)
{
if
(
p
!=
NULL
)
{
if
(
pStb
->
commentLen
!=
0
)
{
if
(
pStb
->
commentLen
!=
0
)
{
STR_TO_VARSTR
(
p
,
pStb
->
comment
);
STR_TO_VARSTR
(
p
,
pStb
->
comment
);
...
...
source/dnode/vnode/CMakeLists.txt
浏览文件 @
b7281e4d
...
@@ -13,7 +13,6 @@ target_sources(
...
@@ -13,7 +13,6 @@ target_sources(
"src/vnd/vnodeInt.c"
"src/vnd/vnodeInt.c"
"src/vnd/vnodeQuery.c"
"src/vnd/vnodeQuery.c"
"src/vnd/vnodeStateMgr.c"
"src/vnd/vnodeStateMgr.c"
"src/vnd/vnodeWrite.c"
"src/vnd/vnodeModule.c"
"src/vnd/vnodeModule.c"
"src/vnd/vnodeSvr.c"
"src/vnd/vnodeSvr.c"
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
b7281e4d
...
@@ -40,14 +40,16 @@ typedef struct SVnode SVnode;
...
@@ -40,14 +40,16 @@ typedef struct SVnode SVnode;
typedef
struct
STsdbCfg
STsdbCfg
;
// todo: remove
typedef
struct
STsdbCfg
STsdbCfg
;
// todo: remove
typedef
struct
SVnodeCfg
SVnodeCfg
;
typedef
struct
SVnodeCfg
SVnodeCfg
;
extern
const
SVnodeCfg
vnodeCfgDefault
;
int
vnodeInit
(
int
nthreads
);
int
vnodeInit
(
int
nthreads
);
void
vnodeCleanup
();
void
vnodeCleanup
();
int
vnodeCreate
(
const
char
*
path
,
SVnodeCfg
*
pCfg
,
STfs
*
pTfs
);
int
vnodeCreate
(
const
char
*
path
,
SVnodeCfg
*
pCfg
,
STfs
*
pTfs
);
void
vnodeDestroy
(
const
char
*
path
,
STfs
*
pTfs
);
void
vnodeDestroy
(
const
char
*
path
,
STfs
*
pTfs
);
SVnode
*
vnodeOpen
(
const
char
*
path
,
STfs
*
pTfs
,
SMsgCb
msgCb
);
SVnode
*
vnodeOpen
(
const
char
*
path
,
STfs
*
pTfs
,
SMsgCb
msgCb
);
void
vnodeClose
(
SVnode
*
pVnode
);
void
vnodeClose
(
SVnode
*
pVnode
);
void
vnodePreprocessWriteReqs
(
SVnode
*
pVnode
,
SArray
*
pMsgs
);
int
vnodePreprocessWriteReqs
(
SVnode
*
pVnode
,
SArray
*
pMsgs
,
int64_t
*
version
);
int
vnodeProcessWriteReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
*
pRsp
);
int
vnodeProcessWriteReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
int64_t
version
,
SRpcMsg
*
pRsp
);
int
vnodeProcessCMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
int
vnodeProcessCMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
int
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
int
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
int
vnodeProcessQueryMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
int
vnodeProcessQueryMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
...
@@ -133,6 +135,7 @@ struct STsdbCfg {
...
@@ -133,6 +135,7 @@ struct STsdbCfg {
struct
SVnodeCfg
{
struct
SVnodeCfg
{
int32_t
vgId
;
int32_t
vgId
;
char
dbname
[
TSDB_DB_NAME_LEN
];
uint64_t
dbId
;
uint64_t
dbId
;
uint64_t
wsize
;
uint64_t
wsize
;
uint64_t
ssize
;
uint64_t
ssize
;
...
...
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
b7281e4d
...
@@ -31,6 +31,8 @@ extern "C" {
...
@@ -31,6 +31,8 @@ extern "C" {
// clang-format on
// clang-format on
// vnodeCfg ====================
// vnodeCfg ====================
int
vnodeEncodeConfig
(
const
void
*
pObj
,
SJson
*
pJson
);
int
vnodeDecodeConfig
(
const
SJson
*
pJson
,
void
*
pObj
);
// vnodeModule ====================
// vnodeModule ====================
int
vnodeScheduleTask
(
int
(
*
execute
)(
void
*
),
void
*
arg
);
int
vnodeScheduleTask
(
int
(
*
execute
)(
void
*
),
void
*
arg
);
...
...
source/dnode/vnode/src/meta/metaTDBImpl.c
浏览文件 @
b7281e4d
...
@@ -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/vnd/vnodeCfg.c
浏览文件 @
b7281e4d
...
@@ -16,13 +16,113 @@
...
@@ -16,13 +16,113 @@
#include "vnodeInt.h"
#include "vnodeInt.h"
const
SVnodeCfg
vnodeCfgDefault
=
{
const
SVnodeCfg
vnodeCfgDefault
=
{
.
wsize
=
96
*
1024
*
1024
,
.
ssize
=
1
*
1024
*
1024
,
.
lsize
=
1024
,
.
walCfg
=
{.
level
=
TAOS_WAL_WRITE
}};
.
vgId
=
-
1
,
.
dbname
=
""
,
.
dbId
=
0
,
.
wsize
=
96
*
1024
*
1024
,
.
ssize
=
1
*
1024
*
1024
,
.
lsize
=
1024
,
.
isHeapAllocator
=
false
,
.
ttl
=
0
,
.
keep
=
0
,
.
streamMode
=
0
,
.
isWeak
=
0
,
.
tsdbCfg
=
{.
precision
=
TWO_STAGE_COMP
,
.
update
=
0
,
.
compression
=
2
,
.
days
=
10
,
.
minRows
=
100
,
.
maxRows
=
4096
,
.
keep2
=
3650
,
.
keep0
=
3650
,
.
keep1
=
3650
},
.
walCfg
=
{.
vgId
=
-
1
,
.
fsyncPeriod
=
0
,
.
retentionPeriod
=
0
,
.
rollPeriod
=
0
,
.
segSize
=
0
,
.
level
=
TAOS_WAL_WRITE
},
.
hashBegin
=
0
,
.
hashEnd
=
0
,
.
hashMethod
=
0
};
int
vnodeCheckCfg
(
const
SVnodeCfg
*
pCfg
)
{
int
vnodeCheckCfg
(
const
SVnodeCfg
*
pCfg
)
{
// TODO
// TODO
return
0
;
return
0
;
}
}
int
vnodeEncodeConfig
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SVnodeCfg
*
pCfg
=
(
SVnodeCfg
*
)
pObj
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"vgId"
,
pCfg
->
vgId
)
<
0
)
return
-
1
;
if
(
tjsonAddStringToObject
(
pJson
,
"dbname"
,
pCfg
->
dbname
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"dbId"
,
pCfg
->
dbId
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wsize"
,
pCfg
->
wsize
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"ssize"
,
pCfg
->
ssize
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"lsize"
,
pCfg
->
lsize
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"isHeap"
,
pCfg
->
isHeapAllocator
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"ttl"
,
pCfg
->
ttl
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"keep"
,
pCfg
->
keep
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"streamMode"
,
pCfg
->
streamMode
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"isWeak"
,
pCfg
->
isWeak
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"precision"
,
pCfg
->
tsdbCfg
.
precision
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"update"
,
pCfg
->
tsdbCfg
.
update
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"compression"
,
pCfg
->
tsdbCfg
.
compression
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"daysPerFile"
,
pCfg
->
tsdbCfg
.
days
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"minRows"
,
pCfg
->
tsdbCfg
.
minRows
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"maxRows"
,
pCfg
->
tsdbCfg
.
maxRows
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"keep0"
,
pCfg
->
tsdbCfg
.
keep0
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"keep1"
,
pCfg
->
tsdbCfg
.
keep1
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"keep2"
,
pCfg
->
tsdbCfg
.
keep2
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"lruCacheSize"
,
pCfg
->
tsdbCfg
.
lruCacheSize
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wal.vgId"
,
pCfg
->
walCfg
.
vgId
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wal.fsyncPeriod"
,
pCfg
->
walCfg
.
fsyncPeriod
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wal.retentionPeriod"
,
pCfg
->
walCfg
.
retentionPeriod
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wal.rollPeriod"
,
pCfg
->
walCfg
.
rollPeriod
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wal.retentionSize"
,
pCfg
->
walCfg
.
retentionSize
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wal.segSize"
,
pCfg
->
walCfg
.
segSize
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wal.level"
,
pCfg
->
walCfg
.
level
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"hashBegin"
,
pCfg
->
hashBegin
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"hashEnd"
,
pCfg
->
hashEnd
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"hashMethod"
,
pCfg
->
hashMethod
)
<
0
)
return
-
1
;
return
0
;
}
int
vnodeDecodeConfig
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SVnodeCfg
*
pCfg
=
(
SVnodeCfg
*
)
pObj
;
if
(
tjsonGetNumberValue
(
pJson
,
"vgId"
,
pCfg
->
vgId
)
<
0
)
return
-
1
;
if
(
tjsonGetStringValue
(
pJson
,
"dbname"
,
pCfg
->
dbname
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"dbId"
,
pCfg
->
dbId
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wsize"
,
pCfg
->
wsize
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"ssize"
,
pCfg
->
ssize
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"lsize"
,
pCfg
->
lsize
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"isHeap"
,
pCfg
->
isHeapAllocator
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"ttl"
,
pCfg
->
ttl
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"keep"
,
pCfg
->
keep
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"streamMode"
,
pCfg
->
streamMode
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"isWeak"
,
pCfg
->
isWeak
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"precision"
,
pCfg
->
tsdbCfg
.
precision
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"update"
,
pCfg
->
tsdbCfg
.
update
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"compression"
,
pCfg
->
tsdbCfg
.
compression
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"daysPerFile"
,
pCfg
->
tsdbCfg
.
days
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"minRows"
,
pCfg
->
tsdbCfg
.
minRows
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"maxRows"
,
pCfg
->
tsdbCfg
.
maxRows
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"keep0"
,
pCfg
->
tsdbCfg
.
keep0
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"keep1"
,
pCfg
->
tsdbCfg
.
keep1
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"keep2"
,
pCfg
->
tsdbCfg
.
keep2
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"lruCacheSize"
,
pCfg
->
tsdbCfg
.
lruCacheSize
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wal.vgId"
,
pCfg
->
walCfg
.
vgId
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wal.fsyncPeriod"
,
pCfg
->
walCfg
.
fsyncPeriod
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wal.retentionPeriod"
,
pCfg
->
walCfg
.
retentionPeriod
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wal.rollPeriod"
,
pCfg
->
walCfg
.
rollPeriod
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wal.retentionSize"
,
pCfg
->
walCfg
.
retentionSize
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wal.segSize"
,
pCfg
->
walCfg
.
segSize
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wal.level"
,
pCfg
->
walCfg
.
level
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"hashBegin"
,
pCfg
->
hashBegin
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"hashEnd"
,
pCfg
->
hashEnd
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"hashMethod"
,
pCfg
->
hashMethod
)
<
0
)
return
-
1
;
return
0
;
}
int
vnodeValidateTableHash
(
SVnodeCfg
*
pVnodeOptions
,
char
*
tableFName
)
{
int
vnodeValidateTableHash
(
SVnodeCfg
*
pVnodeOptions
,
char
*
tableFName
)
{
uint32_t
hashValue
=
0
;
uint32_t
hashValue
=
0
;
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
b7281e4d
...
@@ -181,80 +181,6 @@ static int vnodeEndCommit(SVnode *pVnode) {
...
@@ -181,80 +181,6 @@ static int vnodeEndCommit(SVnode *pVnode) {
static
FORCE_INLINE
void
vnodeWaitCommit
(
SVnode
*
pVnode
)
{
tsem_wait
(
&
pVnode
->
canCommit
);
}
static
FORCE_INLINE
void
vnodeWaitCommit
(
SVnode
*
pVnode
)
{
tsem_wait
(
&
pVnode
->
canCommit
);
}
static
int
vnodeEncodeConfig
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SVnodeCfg
*
pCfg
=
(
SVnodeCfg
*
)
pObj
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"vgId"
,
pCfg
->
vgId
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"dbId"
,
pCfg
->
dbId
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wsize"
,
pCfg
->
wsize
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"ssize"
,
pCfg
->
ssize
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"lsize"
,
pCfg
->
lsize
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"isHeap"
,
pCfg
->
isHeapAllocator
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"ttl"
,
pCfg
->
ttl
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"keep"
,
pCfg
->
keep
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"streamMode"
,
pCfg
->
streamMode
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"isWeak"
,
pCfg
->
isWeak
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"precision"
,
pCfg
->
tsdbCfg
.
precision
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"update"
,
pCfg
->
tsdbCfg
.
update
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"compression"
,
pCfg
->
tsdbCfg
.
compression
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"daysPerFile"
,
pCfg
->
tsdbCfg
.
days
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"minRows"
,
pCfg
->
tsdbCfg
.
minRows
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"maxRows"
,
pCfg
->
tsdbCfg
.
maxRows
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"keep0"
,
pCfg
->
tsdbCfg
.
keep0
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"keep1"
,
pCfg
->
tsdbCfg
.
keep1
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"keep2"
,
pCfg
->
tsdbCfg
.
keep2
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"lruCacheSize"
,
pCfg
->
tsdbCfg
.
lruCacheSize
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wal.vgId"
,
pCfg
->
walCfg
.
vgId
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wal.fsyncPeriod"
,
pCfg
->
walCfg
.
fsyncPeriod
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wal.retentionPeriod"
,
pCfg
->
walCfg
.
retentionPeriod
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wal.rollPeriod"
,
pCfg
->
walCfg
.
rollPeriod
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wal.retentionSize"
,
pCfg
->
walCfg
.
retentionSize
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wal.segSize"
,
pCfg
->
walCfg
.
segSize
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"wal.level"
,
pCfg
->
walCfg
.
level
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"hashBegin"
,
pCfg
->
hashBegin
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"hashEnd"
,
pCfg
->
hashEnd
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"hashMethod"
,
pCfg
->
hashMethod
)
<
0
)
return
-
1
;
return
0
;
}
static
int
vnodeDecodeConfig
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SVnodeCfg
*
pCfg
=
(
SVnodeCfg
*
)
pObj
;
if
(
tjsonGetNumberValue
(
pJson
,
"vgId"
,
pCfg
->
vgId
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"dbId"
,
pCfg
->
dbId
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wsize"
,
pCfg
->
wsize
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"ssize"
,
pCfg
->
ssize
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"lsize"
,
pCfg
->
lsize
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"isHeap"
,
pCfg
->
isHeapAllocator
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"ttl"
,
pCfg
->
ttl
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"keep"
,
pCfg
->
keep
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"streamMode"
,
pCfg
->
streamMode
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"isWeak"
,
pCfg
->
isWeak
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"precision"
,
pCfg
->
tsdbCfg
.
precision
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"update"
,
pCfg
->
tsdbCfg
.
update
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"compression"
,
pCfg
->
tsdbCfg
.
compression
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"daysPerFile"
,
pCfg
->
tsdbCfg
.
days
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"minRows"
,
pCfg
->
tsdbCfg
.
minRows
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"maxRows"
,
pCfg
->
tsdbCfg
.
maxRows
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"keep0"
,
pCfg
->
tsdbCfg
.
keep0
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"keep1"
,
pCfg
->
tsdbCfg
.
keep1
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"keep2"
,
pCfg
->
tsdbCfg
.
keep2
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"lruCacheSize"
,
pCfg
->
tsdbCfg
.
lruCacheSize
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wal.vgId"
,
pCfg
->
walCfg
.
vgId
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wal.fsyncPeriod"
,
pCfg
->
walCfg
.
fsyncPeriod
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wal.retentionPeriod"
,
pCfg
->
walCfg
.
retentionPeriod
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wal.rollPeriod"
,
pCfg
->
walCfg
.
rollPeriod
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wal.retentionSize"
,
pCfg
->
walCfg
.
retentionSize
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wal.segSize"
,
pCfg
->
walCfg
.
segSize
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"wal.level"
,
pCfg
->
walCfg
.
level
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"hashBegin"
,
pCfg
->
hashBegin
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"hashEnd"
,
pCfg
->
hashEnd
)
<
0
)
return
-
1
;
if
(
tjsonGetNumberValue
(
pJson
,
"hashMethod"
,
pCfg
->
hashMethod
)
<
0
)
return
-
1
;
return
0
;
}
static
int
vnodeEncodeState
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int
vnodeEncodeState
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SVState
*
pState
=
(
SVState
*
)
pObj
;
const
SVState
*
pState
=
(
SVState
*
)
pObj
;
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
b7281e4d
...
@@ -16,34 +16,32 @@
...
@@ -16,34 +16,32 @@
#include "vnodeInt.h"
#include "vnodeInt.h"
static
int
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
void
*
pReq
);
static
int
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
void
*
pReq
);
static
int
vnodeProcessCreateTbReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
void
*
pReq
,
SRpcMsg
*
*
pRsp
);
static
int
vnodeProcessCreateTbReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
void
*
pReq
,
SRpcMsg
*
pRsp
);
static
int
vnodeProcessAlterStbReq
(
SVnode
*
pVnode
,
void
*
pReq
);
static
int
vnodeProcessAlterStbReq
(
SVnode
*
pVnode
,
void
*
pReq
);
static
int
vnodeProcessSubmitReq
(
SVnode
*
pVnode
,
SSubmitReq
*
pSubmitReq
,
SRpcMsg
*
pRsp
);
static
int
vnodeProcessSubmitReq
(
SVnode
*
pVnode
,
SSubmitReq
*
pSubmitReq
,
SRpcMsg
*
pRsp
);
void
vnodePreprocessWriteReqs
(
SVnode
*
pVnode
,
SArray
*
pMsgs
)
{
int
vnodePreprocessWriteReqs
(
SVnode
*
pVnode
,
SArray
*
pMsgs
,
int64_t
*
version
)
{
SNodeMsg
*
pMsg
;
SNodeMsg
*
pMsg
;
SRpcMsg
*
pRpc
;
SRpcMsg
*
pRpc
;
*
version
=
pVnode
->
state
.
processed
;
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pMsgs
);
i
++
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pMsgs
);
i
++
)
{
pMsg
=
*
(
SNodeMsg
**
)
taosArrayGet
(
pMsgs
,
i
);
pMsg
=
*
(
SNodeMsg
**
)
taosArrayGet
(
pMsgs
,
i
);
pRpc
=
&
pMsg
->
rpcMsg
;
pRpc
=
&
pMsg
->
rpcMsg
;
// set request version
// set request version
void
*
pBuf
=
POINTER_SHIFT
(
pRpc
->
pCont
,
sizeof
(
SMsgHead
));
if
(
walWrite
(
pVnode
->
pWal
,
pVnode
->
state
.
processed
++
,
pRpc
->
msgType
,
pRpc
->
pCont
,
pRpc
->
contLen
)
<
0
)
{
int64_t
ver
=
pVnode
->
state
.
processed
++
;
taosEncodeFixedI64
(
&
pBuf
,
ver
);
if
(
walWrite
(
pVnode
->
pWal
,
ver
,
pRpc
->
msgType
,
pRpc
->
pCont
,
pRpc
->
contLen
)
<
0
)
{
// TODO: handle error
/*ASSERT(false);*/
vError
(
"vnode:%d write wal error since %s"
,
TD_VID
(
pVnode
),
terrstr
());
vError
(
"vnode:%d write wal error since %s"
,
TD_VID
(
pVnode
),
terrstr
());
return
-
1
;
}
}
}
}
walFsync
(
pVnode
->
pWal
,
false
);
walFsync
(
pVnode
->
pWal
,
false
);
return
0
;
}
}
int
vnodeProcessWriteReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
*
pRsp
)
{
int
vnodeProcessWriteReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
int64_t
version
,
SRpcMsg
*
pRsp
)
{
void
*
ptr
=
NULL
;
void
*
ptr
=
NULL
;
int
ret
;
int
ret
;
...
@@ -58,33 +56,29 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -58,33 +56,29 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
}
}
// todo: change the interface here
// todo: change the interface here
int64_t
ver
;
if
(
tqPushMsg
(
pVnode
->
pTq
,
pMsg
->
pCont
,
pMsg
->
contLen
,
pMsg
->
msgType
,
version
)
<
0
)
{
taosDecodeFixedI64
(
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
&
ver
);
if
(
tqPushMsg
(
pVnode
->
pTq
,
pMsg
->
pCont
,
pMsg
->
contLen
,
pMsg
->
msgType
,
ver
)
<
0
)
{
// TODO: handle error
// TODO: handle error
}
}
switch
(
pMsg
->
msgType
)
{
switch
(
pMsg
->
msgType
)
{
case
TDMT_VND_CREATE_STB
:
case
TDMT_VND_CREATE_STB
:
ret
=
vnodeProcessCreateStbReq
(
pVnode
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)));
ret
=
vnodeProcessCreateStbReq
(
pVnode
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)));
return
0
;
break
;
case
TDMT_VND_CREATE_TABLE
:
case
TDMT_VND_CREATE_TABLE
:
return
vnodeProcessCreateTbReq
(
pVnode
,
pMsg
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
pRsp
);
pRsp
->
msgType
=
TDMT_VND_CREATE_TABLE_RSP
;
vnodeProcessCreateTbReq
(
pVnode
,
pMsg
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
pRsp
);
break
;
case
TDMT_VND_ALTER_STB
:
case
TDMT_VND_ALTER_STB
:
return
vnodeProcessAlterStbReq
(
pVnode
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)));
vnodeProcessAlterStbReq
(
pVnode
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)));
break
;
case
TDMT_VND_DROP_STB
:
case
TDMT_VND_DROP_STB
:
vTrace
(
"vgId:%d, process drop stb req"
,
TD_VID
(
pVnode
));
vTrace
(
"vgId:%d, process drop stb req"
,
TD_VID
(
pVnode
));
break
;
break
;
case
TDMT_VND_DROP_TABLE
:
case
TDMT_VND_DROP_TABLE
:
break
;
break
;
case
TDMT_VND_SUBMIT
:
case
TDMT_VND_SUBMIT
:
/*printf("vnode %d write data %ld\n", TD_VID(pVnode), ver);*/
pRsp
->
msgType
=
TDMT_VND_SUBMIT_RSP
;
if
(
pVnode
->
config
.
streamMode
==
0
)
{
vnodeProcessSubmitReq
(
pVnode
,
ptr
,
pRsp
);
*
pRsp
=
taosMemoryCalloc
(
1
,
sizeof
(
SRpcMsg
));
(
*
pRsp
)
->
handle
=
pMsg
->
handle
;
(
*
pRsp
)
->
ahandle
=
pMsg
->
ahandle
;
return
vnodeProcessSubmitReq
(
pVnode
,
ptr
,
*
pRsp
);
}
break
;
break
;
case
TDMT_VND_MQ_SET_CONN
:
{
case
TDMT_VND_MQ_SET_CONN
:
{
if
(
tqProcessSetConnReq
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
if
(
tqProcessSetConnReq
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
...
@@ -128,7 +122,7 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -128,7 +122,7 @@ int vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
break
;
break
;
}
}
pVnode
->
state
.
applied
=
ver
;
pVnode
->
state
.
applied
=
ver
sion
;
// Check if it needs to commit
// Check if it needs to commit
if
(
vnodeShouldCommit
(
pVnode
))
{
if
(
vnodeShouldCommit
(
pVnode
))
{
...
@@ -217,13 +211,12 @@ static int vnodeProcessCreateStbReq(SVnode *pVnode, void *pReq) {
...
@@ -217,13 +211,12 @@ static int vnodeProcessCreateStbReq(SVnode *pVnode, void *pReq) {
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
->
pFuncIds
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
->
pFuncIds
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
);
}
}
taosMemoryFree
(
vCreateTbReq
.
dbFName
);
taosMemoryFree
(
vCreateTbReq
.
name
);
taosMemoryFree
(
vCreateTbReq
.
name
);
return
0
;
return
0
;
}
}
static
int
vnodeProcessCreateTbReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
void
*
pReq
,
SRpcMsg
*
*
pRsp
)
{
static
int
vnodeProcessCreateTbReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
void
*
pReq
,
SRpcMsg
*
pRsp
)
{
SVCreateTbBatchReq
vCreateTbBatchReq
=
{
0
};
SVCreateTbBatchReq
vCreateTbBatchReq
=
{
0
};
SVCreateTbBatchRsp
vCreateTbBatchRsp
=
{
0
};
SVCreateTbBatchRsp
vCreateTbBatchRsp
=
{
0
};
tDeserializeSVCreateTbBatchReq
(
pReq
,
&
vCreateTbBatchReq
);
tDeserializeSVCreateTbBatchReq
(
pReq
,
&
vCreateTbBatchReq
);
...
@@ -233,7 +226,7 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR
...
@@ -233,7 +226,7 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR
char
tableFName
[
TSDB_TABLE_FNAME_LEN
];
char
tableFName
[
TSDB_TABLE_FNAME_LEN
];
SMsgHead
*
pHead
=
(
SMsgHead
*
)
pMsg
->
pCont
;
SMsgHead
*
pHead
=
(
SMsgHead
*
)
pMsg
->
pCont
;
sprintf
(
tableFName
,
"%s.%s"
,
p
CreateTbReq
->
dbFN
ame
,
pCreateTbReq
->
name
);
sprintf
(
tableFName
,
"%s.%s"
,
p
Vnode
->
config
.
dbn
ame
,
pCreateTbReq
->
name
);
int32_t
code
=
vnodeValidateTableHash
(
&
pVnode
->
config
,
tableFName
);
int32_t
code
=
vnodeValidateTableHash
(
&
pVnode
->
config
,
tableFName
);
if
(
code
)
{
if
(
code
)
{
...
@@ -249,7 +242,6 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR
...
@@ -249,7 +242,6 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR
}
}
// TODO: to encapsule a free API
// TODO: to encapsule a free API
taosMemoryFree
(
pCreateTbReq
->
name
);
taosMemoryFree
(
pCreateTbReq
->
name
);
taosMemoryFree
(
pCreateTbReq
->
dbFName
);
if
(
pCreateTbReq
->
type
==
TD_SUPER_TABLE
)
{
if
(
pCreateTbReq
->
type
==
TD_SUPER_TABLE
)
{
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pSchema
);
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pSchema
);
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pTagSchema
);
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pTagSchema
);
...
@@ -276,12 +268,8 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR
...
@@ -276,12 +268,8 @@ static int vnodeProcessCreateTbReq(SVnode *pVnode, SRpcMsg *pMsg, void *pReq, SR
tSerializeSVCreateTbBatchRsp
(
msg
,
contLen
,
&
vCreateTbBatchRsp
);
tSerializeSVCreateTbBatchRsp
(
msg
,
contLen
,
&
vCreateTbBatchRsp
);
taosArrayDestroy
(
vCreateTbBatchRsp
.
rspList
);
taosArrayDestroy
(
vCreateTbBatchRsp
.
rspList
);
*
pRsp
=
taosMemoryCalloc
(
1
,
sizeof
(
SRpcMsg
));
pRsp
->
pCont
=
msg
;
(
*
pRsp
)
->
msgType
=
TDMT_VND_CREATE_TABLE_RSP
;
pRsp
->
contLen
=
contLen
;
(
*
pRsp
)
->
pCont
=
msg
;
(
*
pRsp
)
->
contLen
=
contLen
;
(
*
pRsp
)
->
handle
=
pMsg
->
handle
;
(
*
pRsp
)
->
ahandle
=
pMsg
->
ahandle
;
}
}
return
0
;
return
0
;
...
@@ -298,7 +286,6 @@ static int vnodeProcessAlterStbReq(SVnode *pVnode, void *pReq) {
...
@@ -298,7 +286,6 @@ static int vnodeProcessAlterStbReq(SVnode *pVnode, void *pReq) {
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pRSmaParam
->
pFuncIds
);
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pRSmaParam
->
pFuncIds
);
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pRSmaParam
);
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pRSmaParam
);
}
}
taosMemoryFree
(
vAlterTbReq
.
dbFName
);
taosMemoryFree
(
vAlterTbReq
.
name
);
taosMemoryFree
(
vAlterTbReq
.
name
);
return
0
;
return
0
;
}
}
...
@@ -315,7 +302,6 @@ static int vnodeProcessSubmitReq(SVnode *pVnode, SSubmitReq *pSubmitReq, SRpcMsg
...
@@ -315,7 +302,6 @@ static int vnodeProcessSubmitReq(SVnode *pVnode, SSubmitReq *pSubmitReq, SRpcMsg
}
}
// encode the response (TODO)
// encode the response (TODO)
pRsp
->
msgType
=
TDMT_VND_SUBMIT_RSP
;
pRsp
->
pCont
=
rpcMallocCont
(
sizeof
(
SSubmitRsp
));
pRsp
->
pCont
=
rpcMallocCont
(
sizeof
(
SSubmitRsp
));
memcpy
(
pRsp
->
pCont
,
&
rsp
,
sizeof
(
rsp
));
memcpy
(
pRsp
->
pCont
,
&
rsp
,
sizeof
(
rsp
));
pRsp
->
contLen
=
sizeof
(
SSubmitRsp
);
pRsp
->
contLen
=
sizeof
(
SSubmitRsp
);
...
...
source/libs/function/src/builtins.c
浏览文件 @
b7281e4d
...
@@ -330,7 +330,7 @@ static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t l
...
@@ -330,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
);
}
}
...
@@ -358,7 +358,7 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
...
@@ -358,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
);
}
}
...
@@ -372,12 +372,13 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
...
@@ -372,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
浏览文件 @
b7281e4d
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
*/
*/
#include "querynodes.h"
#include "querynodes.h"
#include "plannodes.h"
typedef
enum
ETraversalOrder
{
typedef
enum
ETraversalOrder
{
TRAVERSAL_PREORDER
=
1
,
TRAVERSAL_PREORDER
=
1
,
...
@@ -21,9 +22,14 @@ typedef enum ETraversalOrder {
...
@@ -21,9 +22,14 @@ typedef enum ETraversalOrder {
TRAVERSAL_POSTORDER
,
TRAVERSAL_POSTORDER
,
}
ETraversalOrder
;
}
ETraversalOrder
;
static
EDealRes
walkList
(
SNodeList
*
pNodeList
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
);
typedef
EDealRes
(
*
FNodeDispatcher
)(
SNode
*
pNode
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
);
static
EDealRes
walkNode
(
SNode
*
pNode
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
)
{
static
EDealRes
walkExpr
(
SNode
*
pNode
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
);
static
EDealRes
walkExprs
(
SNodeList
*
pNodeList
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
);
static
EDealRes
walkPhysiPlan
(
SNode
*
pNode
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
);
static
EDealRes
walkPhysiPlans
(
SNodeList
*
pNodeList
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
);
static
EDealRes
walkNode
(
SNode
*
pNode
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
,
FNodeDispatcher
dispatcher
)
{
if
(
NULL
==
pNode
)
{
if
(
NULL
==
pNode
)
{
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
...
@@ -37,6 +43,18 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker
...
@@ -37,6 +43,18 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker
}
}
}
}
res
=
dispatcher
(
pNode
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
&&
TRAVERSAL_POSTORDER
==
order
)
{
res
=
walker
(
pNode
,
pContext
);
}
return
res
;
}
static
EDealRes
dispatchExpr
(
SNode
*
pNode
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
)
{
EDealRes
res
=
DEAL_RES_CONTINUE
;
switch
(
nodeType
(
pNode
))
{
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_COLUMN
:
case
QUERY_NODE_COLUMN
:
case
QUERY_NODE_VALUE
:
case
QUERY_NODE_VALUE
:
...
@@ -45,98 +63,98 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker
...
@@ -45,98 +63,98 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker
break
;
break
;
case
QUERY_NODE_OPERATOR
:
{
case
QUERY_NODE_OPERATOR
:
{
SOperatorNode
*
pOpNode
=
(
SOperatorNode
*
)
pNode
;
SOperatorNode
*
pOpNode
=
(
SOperatorNode
*
)
pNode
;
res
=
walk
Node
(
pOpNode
->
pLeft
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(
pOpNode
->
pLeft
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walk
Node
(
pOpNode
->
pRight
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(
pOpNode
->
pRight
,
order
,
walker
,
pContext
);
}
}
break
;
break
;
}
}
case
QUERY_NODE_LOGIC_CONDITION
:
case
QUERY_NODE_LOGIC_CONDITION
:
res
=
walk
List
(((
SLogicConditionNode
*
)
pNode
)
->
pParameterList
,
order
,
walker
,
pContext
);
res
=
walk
Exprs
(((
SLogicConditionNode
*
)
pNode
)
->
pParameterList
,
order
,
walker
,
pContext
);
break
;
break
;
case
QUERY_NODE_FUNCTION
:
case
QUERY_NODE_FUNCTION
:
res
=
walk
List
(((
SFunctionNode
*
)
pNode
)
->
pParameterList
,
order
,
walker
,
pContext
);
res
=
walk
Exprs
(((
SFunctionNode
*
)
pNode
)
->
pParameterList
,
order
,
walker
,
pContext
);
break
;
break
;
case
QUERY_NODE_REAL_TABLE
:
case
QUERY_NODE_REAL_TABLE
:
case
QUERY_NODE_TEMP_TABLE
:
case
QUERY_NODE_TEMP_TABLE
:
break
;
// todo
break
;
// todo
case
QUERY_NODE_JOIN_TABLE
:
{
case
QUERY_NODE_JOIN_TABLE
:
{
SJoinTableNode
*
pJoinTableNode
=
(
SJoinTableNode
*
)
pNode
;
SJoinTableNode
*
pJoinTableNode
=
(
SJoinTableNode
*
)
pNode
;
res
=
walk
Node
(
pJoinTableNode
->
pLeft
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(
pJoinTableNode
->
pLeft
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walk
Node
(
pJoinTableNode
->
pRight
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(
pJoinTableNode
->
pRight
,
order
,
walker
,
pContext
);
}
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walk
Node
(
pJoinTableNode
->
pOnCond
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(
pJoinTableNode
->
pOnCond
,
order
,
walker
,
pContext
);
}
}
break
;
break
;
}
}
case
QUERY_NODE_GROUPING_SET
:
case
QUERY_NODE_GROUPING_SET
:
res
=
walk
List
(((
SGroupingSetNode
*
)
pNode
)
->
pParameterList
,
order
,
walker
,
pContext
);
res
=
walk
Exprs
(((
SGroupingSetNode
*
)
pNode
)
->
pParameterList
,
order
,
walker
,
pContext
);
break
;
break
;
case
QUERY_NODE_ORDER_BY_EXPR
:
case
QUERY_NODE_ORDER_BY_EXPR
:
res
=
walk
Node
(((
SOrderByExprNode
*
)
pNode
)
->
pExpr
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(((
SOrderByExprNode
*
)
pNode
)
->
pExpr
,
order
,
walker
,
pContext
);
break
;
break
;
case
QUERY_NODE_STATE_WINDOW
:
{
case
QUERY_NODE_STATE_WINDOW
:
{
SStateWindowNode
*
pState
=
(
SStateWindowNode
*
)
pNode
;
SStateWindowNode
*
pState
=
(
SStateWindowNode
*
)
pNode
;
res
=
walk
Node
(
pState
->
pExpr
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(
pState
->
pExpr
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walk
Node
(
pState
->
pCol
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(
pState
->
pCol
,
order
,
walker
,
pContext
);
}
}
break
;
break
;
}
}
case
QUERY_NODE_SESSION_WINDOW
:
{
case
QUERY_NODE_SESSION_WINDOW
:
{
SSessionWindowNode
*
pSession
=
(
SSessionWindowNode
*
)
pNode
;
SSessionWindowNode
*
pSession
=
(
SSessionWindowNode
*
)
pNode
;
res
=
walk
Node
((
SNode
*
)
pSession
->
pCol
,
order
,
walker
,
pContext
);
res
=
walk
Expr
((
SNode
*
)
pSession
->
pCol
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walk
Node
((
SNode
*
)
pSession
->
pGap
,
order
,
walker
,
pContext
);
res
=
walk
Expr
((
SNode
*
)
pSession
->
pGap
,
order
,
walker
,
pContext
);
}
}
break
;
break
;
}
}
case
QUERY_NODE_INTERVAL_WINDOW
:
{
case
QUERY_NODE_INTERVAL_WINDOW
:
{
SIntervalWindowNode
*
pInterval
=
(
SIntervalWindowNode
*
)
pNode
;
SIntervalWindowNode
*
pInterval
=
(
SIntervalWindowNode
*
)
pNode
;
res
=
walk
Node
(
pInterval
->
pInterval
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(
pInterval
->
pInterval
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walk
Node
(
pInterval
->
pOffset
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(
pInterval
->
pOffset
,
order
,
walker
,
pContext
);
}
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walk
Node
(
pInterval
->
pSliding
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(
pInterval
->
pSliding
,
order
,
walker
,
pContext
);
}
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walk
Node
(
pInterval
->
pFill
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(
pInterval
->
pFill
,
order
,
walker
,
pContext
);
}
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walk
Node
(
pInterval
->
pCol
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(
pInterval
->
pCol
,
order
,
walker
,
pContext
);
}
}
break
;
break
;
}
}
case
QUERY_NODE_NODE_LIST
:
case
QUERY_NODE_NODE_LIST
:
res
=
walk
List
(((
SNodeListNode
*
)
pNode
)
->
pNodeList
,
order
,
walker
,
pContext
);
res
=
walk
Exprs
(((
SNodeListNode
*
)
pNode
)
->
pNodeList
,
order
,
walker
,
pContext
);
break
;
break
;
case
QUERY_NODE_FILL
:
case
QUERY_NODE_FILL
:
res
=
walk
Node
(((
SFillNode
*
)
pNode
)
->
pValues
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(((
SFillNode
*
)
pNode
)
->
pValues
,
order
,
walker
,
pContext
);
break
;
break
;
case
QUERY_NODE_RAW_EXPR
:
case
QUERY_NODE_RAW_EXPR
:
res
=
walk
Node
(((
SRawExprNode
*
)
pNode
)
->
pNode
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(((
SRawExprNode
*
)
pNode
)
->
pNode
,
order
,
walker
,
pContext
);
break
;
break
;
case
QUERY_NODE_TARGET
:
case
QUERY_NODE_TARGET
:
res
=
walk
Node
(((
STargetNode
*
)
pNode
)
->
pExpr
,
order
,
walker
,
pContext
);
res
=
walk
Expr
(((
STargetNode
*
)
pNode
)
->
pExpr
,
order
,
walker
,
pContext
);
break
;
break
;
default:
default:
break
;
break
;
}
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
&&
TRAVERSAL_POSTORDER
==
order
)
{
res
=
walker
(
pNode
,
pContext
);
}
return
res
;
return
res
;
}
}
static
EDealRes
walkList
(
SNodeList
*
pNodeList
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
)
{
static
EDealRes
walkExpr
(
SNode
*
pNode
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
)
{
return
walkNode
(
pNode
,
order
,
walker
,
pContext
,
dispatchExpr
);
}
static
EDealRes
walkExprs
(
SNodeList
*
pNodeList
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
)
{
SNode
*
node
;
SNode
*
node
;
FOREACH
(
node
,
pNodeList
)
{
FOREACH
(
node
,
pNodeList
)
{
EDealRes
res
=
walk
Node
(
node
,
order
,
walker
,
pContext
);
EDealRes
res
=
walk
Expr
(
node
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
==
res
||
DEAL_RES_END
==
res
)
{
if
(
DEAL_RES_ERROR
==
res
||
DEAL_RES_END
==
res
)
{
return
res
;
return
res
;
}
}
...
@@ -145,24 +163,24 @@ static EDealRes walkList(SNodeList* pNodeList, ETraversalOrder order, FNodeWalke
...
@@ -145,24 +163,24 @@ static EDealRes walkList(SNodeList* pNodeList, ETraversalOrder order, FNodeWalke
}
}
void
nodesWalkExpr
(
SNodeptr
pNode
,
FNodeWalker
walker
,
void
*
pContext
)
{
void
nodesWalkExpr
(
SNodeptr
pNode
,
FNodeWalker
walker
,
void
*
pContext
)
{
(
void
)
walk
Node
(
pNode
,
TRAVERSAL_PREORDER
,
walker
,
pContext
);
(
void
)
walk
Expr
(
pNode
,
TRAVERSAL_PREORDER
,
walker
,
pContext
);
}
}
void
nodesWalkExprs
(
SNodeList
*
pNodeList
,
FNodeWalker
walker
,
void
*
pContext
)
{
void
nodesWalkExprs
(
SNodeList
*
pNodeList
,
FNodeWalker
walker
,
void
*
pContext
)
{
(
void
)
walk
List
(
pNodeList
,
TRAVERSAL_PREORDER
,
walker
,
pContext
);
(
void
)
walk
Exprs
(
pNodeList
,
TRAVERSAL_PREORDER
,
walker
,
pContext
);
}
}
void
nodesWalkExprPostOrder
(
SNodeptr
pNode
,
FNodeWalker
walker
,
void
*
pContext
)
{
void
nodesWalkExprPostOrder
(
SNodeptr
pNode
,
FNodeWalker
walker
,
void
*
pContext
)
{
(
void
)
walk
Node
(
pNode
,
TRAVERSAL_POSTORDER
,
walker
,
pContext
);
(
void
)
walk
Expr
(
pNode
,
TRAVERSAL_POSTORDER
,
walker
,
pContext
);
}
}
void
nodesWalkExprsPostOrder
(
SNodeList
*
pList
,
FNodeWalker
walker
,
void
*
pContext
)
{
void
nodesWalkExprsPostOrder
(
SNodeList
*
pList
,
FNodeWalker
walker
,
void
*
pContext
)
{
(
void
)
walk
List
(
pList
,
TRAVERSAL_POSTORDER
,
walker
,
pContext
);
(
void
)
walk
Exprs
(
pList
,
TRAVERSAL_POSTORDER
,
walker
,
pContext
);
}
}
static
EDealRes
rewrite
List
(
SNodeList
*
pNodeList
,
ETraversalOrder
order
,
FNodeRewriter
rewriter
,
void
*
pContext
);
static
EDealRes
rewrite
Exprs
(
SNodeList
*
pNodeList
,
ETraversalOrder
order
,
FNodeRewriter
rewriter
,
void
*
pContext
);
static
EDealRes
rewrite
Node
(
SNode
**
pRawNode
,
ETraversalOrder
order
,
FNodeRewriter
rewriter
,
void
*
pContext
)
{
static
EDealRes
rewrite
Expr
(
SNode
**
pRawNode
,
ETraversalOrder
order
,
FNodeRewriter
rewriter
,
void
*
pContext
)
{
if
(
NULL
==
pRawNode
||
NULL
==
*
pRawNode
)
{
if
(
NULL
==
pRawNode
||
NULL
==
*
pRawNode
)
{
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
...
@@ -185,82 +203,82 @@ static EDealRes rewriteNode(SNode** pRawNode, ETraversalOrder order, FNodeRewrit
...
@@ -185,82 +203,82 @@ static EDealRes rewriteNode(SNode** pRawNode, ETraversalOrder order, FNodeRewrit
break
;
break
;
case
QUERY_NODE_OPERATOR
:
{
case
QUERY_NODE_OPERATOR
:
{
SOperatorNode
*
pOpNode
=
(
SOperatorNode
*
)
pNode
;
SOperatorNode
*
pOpNode
=
(
SOperatorNode
*
)
pNode
;
res
=
rewrite
Node
(
&
(
pOpNode
->
pLeft
),
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
(
pOpNode
->
pLeft
),
order
,
rewriter
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
rewrite
Node
(
&
(
pOpNode
->
pRight
),
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
(
pOpNode
->
pRight
),
order
,
rewriter
,
pContext
);
}
}
break
;
break
;
}
}
case
QUERY_NODE_LOGIC_CONDITION
:
case
QUERY_NODE_LOGIC_CONDITION
:
res
=
rewrite
List
(((
SLogicConditionNode
*
)
pNode
)
->
pParameterList
,
order
,
rewriter
,
pContext
);
res
=
rewrite
Exprs
(((
SLogicConditionNode
*
)
pNode
)
->
pParameterList
,
order
,
rewriter
,
pContext
);
break
;
break
;
case
QUERY_NODE_FUNCTION
:
case
QUERY_NODE_FUNCTION
:
res
=
rewrite
List
(((
SFunctionNode
*
)
pNode
)
->
pParameterList
,
order
,
rewriter
,
pContext
);
res
=
rewrite
Exprs
(((
SFunctionNode
*
)
pNode
)
->
pParameterList
,
order
,
rewriter
,
pContext
);
break
;
break
;
case
QUERY_NODE_REAL_TABLE
:
case
QUERY_NODE_REAL_TABLE
:
case
QUERY_NODE_TEMP_TABLE
:
case
QUERY_NODE_TEMP_TABLE
:
break
;
// todo
break
;
// todo
case
QUERY_NODE_JOIN_TABLE
:
{
case
QUERY_NODE_JOIN_TABLE
:
{
SJoinTableNode
*
pJoinTableNode
=
(
SJoinTableNode
*
)
pNode
;
SJoinTableNode
*
pJoinTableNode
=
(
SJoinTableNode
*
)
pNode
;
res
=
rewrite
Node
(
&
(
pJoinTableNode
->
pLeft
),
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
(
pJoinTableNode
->
pLeft
),
order
,
rewriter
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
rewrite
Node
(
&
(
pJoinTableNode
->
pRight
),
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
(
pJoinTableNode
->
pRight
),
order
,
rewriter
,
pContext
);
}
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
rewrite
Node
(
&
(
pJoinTableNode
->
pOnCond
),
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
(
pJoinTableNode
->
pOnCond
),
order
,
rewriter
,
pContext
);
}
}
break
;
break
;
}
}
case
QUERY_NODE_GROUPING_SET
:
case
QUERY_NODE_GROUPING_SET
:
res
=
rewrite
List
(((
SGroupingSetNode
*
)
pNode
)
->
pParameterList
,
order
,
rewriter
,
pContext
);
res
=
rewrite
Exprs
(((
SGroupingSetNode
*
)
pNode
)
->
pParameterList
,
order
,
rewriter
,
pContext
);
break
;
break
;
case
QUERY_NODE_ORDER_BY_EXPR
:
case
QUERY_NODE_ORDER_BY_EXPR
:
res
=
rewrite
Node
(
&
(((
SOrderByExprNode
*
)
pNode
)
->
pExpr
),
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
(((
SOrderByExprNode
*
)
pNode
)
->
pExpr
),
order
,
rewriter
,
pContext
);
break
;
break
;
case
QUERY_NODE_STATE_WINDOW
:
{
case
QUERY_NODE_STATE_WINDOW
:
{
SStateWindowNode
*
pState
=
(
SStateWindowNode
*
)
pNode
;
SStateWindowNode
*
pState
=
(
SStateWindowNode
*
)
pNode
;
res
=
rewrite
Node
(
&
pState
->
pExpr
,
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
pState
->
pExpr
,
order
,
rewriter
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
rewrite
Node
(
&
pState
->
pCol
,
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
pState
->
pCol
,
order
,
rewriter
,
pContext
);
}
}
break
;
break
;
}
}
case
QUERY_NODE_SESSION_WINDOW
:
{
case
QUERY_NODE_SESSION_WINDOW
:
{
SSessionWindowNode
*
pSession
=
(
SSessionWindowNode
*
)
pNode
;
SSessionWindowNode
*
pSession
=
(
SSessionWindowNode
*
)
pNode
;
res
=
rewrite
Node
((
SNode
**
)
&
pSession
->
pCol
,
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
((
SNode
**
)
&
pSession
->
pCol
,
order
,
rewriter
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
rewrite
Node
((
SNode
**
)
&
pSession
->
pGap
,
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
((
SNode
**
)
&
pSession
->
pGap
,
order
,
rewriter
,
pContext
);
}
}
break
;
break
;
}
}
case
QUERY_NODE_INTERVAL_WINDOW
:
{
case
QUERY_NODE_INTERVAL_WINDOW
:
{
SIntervalWindowNode
*
pInterval
=
(
SIntervalWindowNode
*
)
pNode
;
SIntervalWindowNode
*
pInterval
=
(
SIntervalWindowNode
*
)
pNode
;
res
=
rewrite
Node
(
&
(
pInterval
->
pInterval
),
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
(
pInterval
->
pInterval
),
order
,
rewriter
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
rewrite
Node
(
&
(
pInterval
->
pOffset
),
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
(
pInterval
->
pOffset
),
order
,
rewriter
,
pContext
);
}
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
rewrite
Node
(
&
(
pInterval
->
pSliding
),
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
(
pInterval
->
pSliding
),
order
,
rewriter
,
pContext
);
}
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
rewrite
Node
(
&
(
pInterval
->
pFill
),
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
(
pInterval
->
pFill
),
order
,
rewriter
,
pContext
);
}
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
rewrite
Node
(
&
(
pInterval
->
pCol
),
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
(
pInterval
->
pCol
),
order
,
rewriter
,
pContext
);
}
}
break
;
break
;
}
}
case
QUERY_NODE_NODE_LIST
:
case
QUERY_NODE_NODE_LIST
:
res
=
rewrite
List
(((
SNodeListNode
*
)
pNode
)
->
pNodeList
,
order
,
rewriter
,
pContext
);
res
=
rewrite
Exprs
(((
SNodeListNode
*
)
pNode
)
->
pNodeList
,
order
,
rewriter
,
pContext
);
break
;
break
;
case
QUERY_NODE_FILL
:
case
QUERY_NODE_FILL
:
res
=
rewrite
Node
(
&
(((
SFillNode
*
)
pNode
)
->
pValues
),
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
(((
SFillNode
*
)
pNode
)
->
pValues
),
order
,
rewriter
,
pContext
);
break
;
break
;
case
QUERY_NODE_RAW_EXPR
:
case
QUERY_NODE_RAW_EXPR
:
res
=
rewrite
Node
(
&
(((
SRawExprNode
*
)
pNode
)
->
pNode
),
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
(((
SRawExprNode
*
)
pNode
)
->
pNode
),
order
,
rewriter
,
pContext
);
break
;
break
;
case
QUERY_NODE_TARGET
:
case
QUERY_NODE_TARGET
:
res
=
rewrite
Node
(
&
(((
STargetNode
*
)
pNode
)
->
pExpr
),
order
,
rewriter
,
pContext
);
res
=
rewrite
Expr
(
&
(((
STargetNode
*
)
pNode
)
->
pExpr
),
order
,
rewriter
,
pContext
);
break
;
break
;
default:
default:
break
;
break
;
...
@@ -273,10 +291,10 @@ static EDealRes rewriteNode(SNode** pRawNode, ETraversalOrder order, FNodeRewrit
...
@@ -273,10 +291,10 @@ static EDealRes rewriteNode(SNode** pRawNode, ETraversalOrder order, FNodeRewrit
return
res
;
return
res
;
}
}
static
EDealRes
rewrite
List
(
SNodeList
*
pNodeList
,
ETraversalOrder
order
,
FNodeRewriter
rewriter
,
void
*
pContext
)
{
static
EDealRes
rewrite
Exprs
(
SNodeList
*
pNodeList
,
ETraversalOrder
order
,
FNodeRewriter
rewriter
,
void
*
pContext
)
{
SNode
**
pNode
;
SNode
**
pNode
;
FOREACH_FOR_REWRITE
(
pNode
,
pNodeList
)
{
FOREACH_FOR_REWRITE
(
pNode
,
pNodeList
)
{
EDealRes
res
=
rewrite
Node
(
pNode
,
order
,
rewriter
,
pContext
);
EDealRes
res
=
rewrite
Expr
(
pNode
,
order
,
rewriter
,
pContext
);
if
(
DEAL_RES_ERROR
==
res
||
DEAL_RES_END
==
res
)
{
if
(
DEAL_RES_ERROR
==
res
||
DEAL_RES_END
==
res
)
{
return
res
;
return
res
;
}
}
...
@@ -285,19 +303,19 @@ static EDealRes rewriteList(SNodeList* pNodeList, ETraversalOrder order, FNodeRe
...
@@ -285,19 +303,19 @@ static EDealRes rewriteList(SNodeList* pNodeList, ETraversalOrder order, FNodeRe
}
}
void
nodesRewriteExpr
(
SNode
**
pNode
,
FNodeRewriter
rewriter
,
void
*
pContext
)
{
void
nodesRewriteExpr
(
SNode
**
pNode
,
FNodeRewriter
rewriter
,
void
*
pContext
)
{
(
void
)
rewrite
Node
(
pNode
,
TRAVERSAL_PREORDER
,
rewriter
,
pContext
);
(
void
)
rewrite
Expr
(
pNode
,
TRAVERSAL_PREORDER
,
rewriter
,
pContext
);
}
}
void
nodesRewriteExprs
(
SNodeList
*
pList
,
FNodeRewriter
rewriter
,
void
*
pContext
)
{
void
nodesRewriteExprs
(
SNodeList
*
pList
,
FNodeRewriter
rewriter
,
void
*
pContext
)
{
(
void
)
rewrite
List
(
pList
,
TRAVERSAL_PREORDER
,
rewriter
,
pContext
);
(
void
)
rewrite
Exprs
(
pList
,
TRAVERSAL_PREORDER
,
rewriter
,
pContext
);
}
}
void
nodesRewriteExprPostOrder
(
SNode
**
pNode
,
FNodeRewriter
rewriter
,
void
*
pContext
)
{
void
nodesRewriteExprPostOrder
(
SNode
**
pNode
,
FNodeRewriter
rewriter
,
void
*
pContext
)
{
(
void
)
rewrite
Node
(
pNode
,
TRAVERSAL_POSTORDER
,
rewriter
,
pContext
);
(
void
)
rewrite
Expr
(
pNode
,
TRAVERSAL_POSTORDER
,
rewriter
,
pContext
);
}
}
void
nodesRewriteExprsPostOrder
(
SNodeList
*
pList
,
FNodeRewriter
rewriter
,
void
*
pContext
)
{
void
nodesRewriteExprsPostOrder
(
SNodeList
*
pList
,
FNodeRewriter
rewriter
,
void
*
pContext
)
{
(
void
)
rewrite
List
(
pList
,
TRAVERSAL_POSTORDER
,
rewriter
,
pContext
);
(
void
)
rewrite
Exprs
(
pList
,
TRAVERSAL_POSTORDER
,
rewriter
,
pContext
);
}
}
void
nodesWalkSelectStmt
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
FNodeWalker
walker
,
void
*
pContext
)
{
void
nodesWalkSelectStmt
(
SSelectStmt
*
pSelect
,
ESqlClause
clause
,
FNodeWalker
walker
,
void
*
pContext
)
{
...
@@ -357,3 +375,206 @@ void nodesRewriteSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeRewrit
...
@@ -357,3 +375,206 @@ void nodesRewriteSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeRewrit
return
;
return
;
}
}
static
EDealRes
walkPhysiNode
(
SPhysiNode
*
pNode
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
)
{
EDealRes
res
=
walkPhysiPlan
((
SNode
*
)
pNode
->
pOutputDataBlockDesc
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlan
(
pNode
->
pConditions
,
order
,
walker
,
pContext
);
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pNode
->
pChildren
,
order
,
walker
,
pContext
);
}
return
res
;
}
static
EDealRes
walkScanPhysi
(
SScanPhysiNode
*
pScan
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
)
{
EDealRes
res
=
walkPhysiNode
((
SPhysiNode
*
)
pScan
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pScan
->
pScanCols
,
order
,
walker
,
pContext
);
}
return
res
;
}
static
EDealRes
walkTableScanPhysi
(
STableScanPhysiNode
*
pScan
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
)
{
EDealRes
res
=
walkScanPhysi
((
SScanPhysiNode
*
)
pScan
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pScan
->
pDynamicScanFuncs
,
order
,
walker
,
pContext
);
}
return
res
;
}
static
EDealRes
walkWindowPhysi
(
SWinodwPhysiNode
*
pWindow
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
)
{
EDealRes
res
=
walkPhysiNode
((
SPhysiNode
*
)
pWindow
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pWindow
->
pExprs
,
order
,
walker
,
pContext
);
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pWindow
->
pFuncs
,
order
,
walker
,
pContext
);
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlan
(
pWindow
->
pTspk
,
order
,
walker
,
pContext
);
}
return
res
;
}
static
EDealRes
dispatchPhysiPlan
(
SNode
*
pNode
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
)
{
EDealRes
res
=
DEAL_RES_CONTINUE
;
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
:
res
=
walkScanPhysi
((
SScanPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
break
;
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
:
res
=
walkTableScanPhysi
((
STableScanPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
break
;
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN
:
res
=
walkTableScanPhysi
((
STableScanPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
break
;
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
:
res
=
walkScanPhysi
((
SScanPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
break
;
case
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
:
res
=
walkScanPhysi
((
SScanPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
break
;
case
QUERY_NODE_PHYSICAL_PLAN_PROJECT
:
{
SProjectPhysiNode
*
pProject
=
(
SProjectPhysiNode
*
)
pNode
;
res
=
walkPhysiNode
((
SPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pProject
->
pProjections
,
order
,
walker
,
pContext
);
}
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN_JOIN
:
{
SJoinPhysiNode
*
pJoin
=
(
SJoinPhysiNode
*
)
pNode
;
res
=
walkPhysiNode
((
SPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlan
(
pJoin
->
pOnConditions
,
order
,
walker
,
pContext
);
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pJoin
->
pTargets
,
order
,
walker
,
pContext
);
}
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN_AGG
:
{
SAggPhysiNode
*
pAgg
=
(
SAggPhysiNode
*
)
pNode
;
res
=
walkPhysiNode
((
SPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pAgg
->
pExprs
,
order
,
walker
,
pContext
);
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pAgg
->
pGroupKeys
,
order
,
walker
,
pContext
);
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pAgg
->
pAggFuncs
,
order
,
walker
,
pContext
);
}
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
:
{
SExchangePhysiNode
*
pExchange
=
(
SExchangePhysiNode
*
)
pNode
;
res
=
walkPhysiNode
((
SPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pExchange
->
pSrcEndPoints
,
order
,
walker
,
pContext
);
}
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN_SORT
:
{
SSortPhysiNode
*
pSort
=
(
SSortPhysiNode
*
)
pNode
;
res
=
walkPhysiNode
((
SPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pSort
->
pExprs
,
order
,
walker
,
pContext
);
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pSort
->
pSortKeys
,
order
,
walker
,
pContext
);
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pSort
->
pTargets
,
order
,
walker
,
pContext
);
}
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
{
SIntervalPhysiNode
*
pInterval
=
(
SIntervalPhysiNode
*
)
pNode
;
res
=
walkWindowPhysi
((
SWinodwPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlan
((
SNode
*
)
pInterval
->
pFill
,
order
,
walker
,
pContext
);
}
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
:
res
=
walkWindowPhysi
((
SWinodwPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
break
;
case
QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW
:
{
SStateWinodwPhysiNode
*
pState
=
(
SStateWinodwPhysiNode
*
)
pNode
;
res
=
walkWindowPhysi
((
SWinodwPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlan
(
pState
->
pStateKey
,
order
,
walker
,
pContext
);
}
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN_PARTITION
:
{
SPartitionPhysiNode
*
pPart
=
(
SPartitionPhysiNode
*
)
pNode
;
res
=
walkPhysiNode
((
SPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pPart
->
pExprs
,
order
,
walker
,
pContext
);
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pPart
->
pPartitionKeys
,
order
,
walker
,
pContext
);
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pPart
->
pTargets
,
order
,
walker
,
pContext
);
}
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
res
=
walkPhysiPlan
((
SNode
*
)(((
SDataSinkNode
*
)
pNode
)
->
pInputDataBlockDesc
),
order
,
walker
,
pContext
);
break
;
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
res
=
walkPhysiPlan
((
SNode
*
)(((
SDataSinkNode
*
)
pNode
)
->
pInputDataBlockDesc
),
order
,
walker
,
pContext
);
break
;
case
QUERY_NODE_PHYSICAL_SUBPLAN
:
{
SSubplan
*
pSubplan
=
(
SSubplan
*
)
pNode
;
res
=
walkPhysiNode
((
SPhysiNode
*
)
pNode
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlans
(
pSubplan
->
pChildren
,
order
,
walker
,
pContext
);
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlan
((
SNode
*
)
pSubplan
->
pNode
,
order
,
walker
,
pContext
);
}
if
(
DEAL_RES_ERROR
!=
res
&&
DEAL_RES_END
!=
res
)
{
res
=
walkPhysiPlan
((
SNode
*
)
pSubplan
->
pDataSink
,
order
,
walker
,
pContext
);
}
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN
:
{
SQueryPlan
*
pPlan
=
(
SQueryPlan
*
)
pNode
;
if
(
NULL
!=
pPlan
->
pSubplans
)
{
// only need to walk the top-level subplans, because they will recurse to all the subplans below
walkPhysiPlan
(
nodesListGetNode
(
pPlan
->
pSubplans
,
0
),
order
,
walker
,
pContext
);
}
break
;
}
default:
res
=
dispatchExpr
(
pNode
,
order
,
walker
,
pContext
);
break
;
}
return
res
;
}
static
EDealRes
walkPhysiPlan
(
SNode
*
pNode
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
)
{
return
walkNode
(
pNode
,
order
,
walker
,
pContext
,
dispatchPhysiPlan
);
}
static
EDealRes
walkPhysiPlans
(
SNodeList
*
pNodeList
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
)
{
SNode
*
node
;
FOREACH
(
node
,
pNodeList
)
{
EDealRes
res
=
walkPhysiPlan
(
node
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
==
res
||
DEAL_RES_END
==
res
)
{
return
res
;
}
}
return
DEAL_RES_CONTINUE
;
}
void
nodesWalkPhysiPlan
(
SNode
*
pNode
,
FNodeWalker
walker
,
void
*
pContext
)
{
(
void
)
walkPhysiPlan
(
pNode
,
TRAVERSAL_PREORDER
,
walker
,
pContext
);
}
source/libs/parser/inc/parAst.h
浏览文件 @
b7281e4d
...
@@ -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
浏览文件 @
b7281e4d
...
@@ -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)); }
...
@@ -646,7 +646,7 @@ predicate(A) ::= expression(B) BETWEEN expression(C) AND expression(D).
...
@@ -646,7 +646,7 @@ predicate(A) ::= expression(B) BETWEEN expression(C) AND expression(D).
predicate(A) ::= expression(B) NOT BETWEEN expression(C) AND expression(D). {
predicate(A) ::= expression(B) NOT BETWEEN expression(C) AND expression(D). {
SToken s = getTokenFromRawExprNode(pCxt, B);
SToken s = getTokenFromRawExprNode(pCxt, B);
SToken e = getTokenFromRawExprNode(pCxt, D);
SToken e = getTokenFromRawExprNode(pCxt, D);
A = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt,
C), releaseRawExprNode(pCxt, B
), releaseRawExprNode(pCxt, D)));
A = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt,
B), releaseRawExprNode(pCxt, C
), releaseRawExprNode(pCxt, D)));
}
}
predicate(A) ::= expression(B) IS NULL(C). {
predicate(A) ::= expression(B) IS NULL(C). {
SToken s = getTokenFromRawExprNode(pCxt, B);
SToken s = getTokenFromRawExprNode(pCxt, B);
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
b7281e4d
...
@@ -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
浏览文件 @
b7281e4d
...
@@ -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/parInsert.c
浏览文件 @
b7281e4d
...
@@ -15,57 +15,57 @@
...
@@ -15,57 +15,57 @@
#include "parInsertData.h"
#include "parInsertData.h"
#include "parInt.h"
#include "parInt.h"
#include "parUtil.h"
#include "parToken.h"
#include "parToken.h"
#include "parUtil.h"
#include "tglobal.h"
#include "tglobal.h"
#include "ttime.h"
#include "ttime.h"
#include "ttypes.h"
#include "ttypes.h"
#define NEXT_TOKEN(pSql, sToken) \
#define NEXT_TOKEN(pSql, sToken)
\
do { \
do {
\
int32_t index = 0; \
int32_t index = 0;
\
sToken = tStrGetToken(pSql, &index, false); \
sToken = tStrGetToken(pSql, &index, false); \
pSql += index; \
pSql += index;
\
} while (0)
} while (0)
#define NEXT_TOKEN_WITH_PREV(pSql, sToken) \
#define NEXT_TOKEN_WITH_PREV(pSql, sToken)
\
do { \
do {
\
int32_t index = 0; \
int32_t index = 0;
\
sToken = tStrGetToken(pSql, &index, true); \
sToken = tStrGetToken(pSql, &index, true); \
pSql += index; \
pSql += index;
\
} while (0)
} while (0)
#define NEXT_TOKEN_KEEP_SQL(pSql, sToken, index) \
#define NEXT_TOKEN_KEEP_SQL(pSql, sToken, index) \
do { \
do {
\
sToken = tStrGetToken(pSql, &index, false); \
sToken = tStrGetToken(pSql, &index, false);
\
} while (0)
} while (0)
#define CHECK_CODE(expr) \
#define CHECK_CODE(expr)
\
do { \
do {
\
int32_t code = expr; \
int32_t code = expr;
\
if (TSDB_CODE_SUCCESS != code) { \
if (TSDB_CODE_SUCCESS != code) { \
return code; \
return code;
\
} \
}
\
} while (0)
} while (0)
typedef
struct
SInsertParseContext
{
typedef
struct
SInsertParseContext
{
SParseContext
*
pComCxt
;
// input
SParseContext
*
pComCxt
;
// input
char
*
pSql
;
// input
char
*
pSql
;
// input
SMsgBuf
msg
;
// input
SMsgBuf
msg
;
// input
STableMeta
*
pTableMeta
;
// each table
STableMeta
*
pTableMeta
;
// each table
SParsedDataColInfo
tags
;
// each table
SParsedDataColInfo
tags
;
// each table
SKVRowBuilder
tagsBuilder
;
// each table
SKVRowBuilder
tagsBuilder
;
// each table
SVCreateTbReq
createTblReq
;
// each table
SVCreateTbReq
createTblReq
;
// each table
SHashObj
*
pVgroupsHashObj
;
// global
SHashObj
*
pVgroupsHashObj
;
// global
SHashObj
*
pTableBlockHashObj
;
// global
SHashObj
*
pTableBlockHashObj
;
// global
SHashObj
*
pSubTableHashObj
;
// global
SHashObj
*
pSubTableHashObj
;
// global
SArray
*
pTableDataBlocks
;
// global
SArray
*
pTableDataBlocks
;
// global
SArray
*
pVgDataBlocks
;
// global
SArray
*
pVgDataBlocks
;
// global
int32_t
totalNum
;
int32_t
totalNum
;
SVnodeModifOpStmt
*
pOutput
;
SVnodeModifOpStmt
*
pOutput
;
}
SInsertParseContext
;
}
SInsertParseContext
;
typedef
int32_t
(
*
_row_append_fn_t
)(
SMsgBuf
*
pMsgBuf
,
const
void
*
value
,
int32_t
len
,
void
*
param
);
typedef
int32_t
(
*
_row_append_fn_t
)(
SMsgBuf
*
pMsgBuf
,
const
void
*
value
,
int32_t
len
,
void
*
param
);
static
uint8_t
TRUE_VALUE
=
(
uint8_t
)
TSDB_TRUE
;
static
uint8_t
TRUE_VALUE
=
(
uint8_t
)
TSDB_TRUE
;
static
uint8_t
FALSE_VALUE
=
(
uint8_t
)
TSDB_FALSE
;
static
uint8_t
FALSE_VALUE
=
(
uint8_t
)
TSDB_FALSE
;
...
@@ -151,7 +151,7 @@ static int32_t buildName(SInsertParseContext* pCxt, SToken* pStname, char* fullD
...
@@ -151,7 +151,7 @@ static int32_t buildName(SInsertParseContext* pCxt, SToken* pStname, char* fullD
}
}
char
*
p
=
strnchr
(
pStname
->
z
,
TS_PATH_DELIMITER
[
0
],
pStname
->
n
,
false
);
char
*
p
=
strnchr
(
pStname
->
z
,
TS_PATH_DELIMITER
[
0
],
pStname
->
n
,
false
);
if
(
NULL
!=
p
)
{
// db.table
if
(
NULL
!=
p
)
{
// db.table
int32_t
n
=
sprintf
(
fullDbName
,
"%d."
,
pCxt
->
pComCxt
->
acctId
);
int32_t
n
=
sprintf
(
fullDbName
,
"%d."
,
pCxt
->
pComCxt
->
acctId
);
strncpy
(
fullDbName
+
n
,
pStname
->
z
,
p
-
pStname
->
z
);
strncpy
(
fullDbName
+
n
,
pStname
->
z
,
p
-
pStname
->
z
);
strncpy
(
tableName
,
p
+
1
,
pStname
->
n
-
(
p
-
pStname
->
z
)
-
1
);
strncpy
(
tableName
,
p
+
1
,
pStname
->
n
-
(
p
-
pStname
->
z
)
-
1
);
...
@@ -168,14 +168,14 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar
...
@@ -168,14 +168,14 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar
const
char
*
msg2
=
"invalid database name"
;
const
char
*
msg2
=
"invalid database name"
;
const
char
*
msg3
=
"db is not specified"
;
const
char
*
msg3
=
"db is not specified"
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
char
*
p
=
strnchr
(
pTableName
->
z
,
TS_PATH_DELIMITER
[
0
],
pTableName
->
n
,
true
);
char
*
p
=
strnchr
(
pTableName
->
z
,
TS_PATH_DELIMITER
[
0
],
pTableName
->
n
,
true
);
if
(
p
!=
NULL
)
{
// db has been specified in sql string so we ignore current db path
if
(
p
!=
NULL
)
{
// db has been specified in sql string so we ignore current db path
assert
(
*
p
==
TS_PATH_DELIMITER
[
0
]);
assert
(
*
p
==
TS_PATH_DELIMITER
[
0
]);
int32_t
dbLen
=
p
-
pTableName
->
z
;
int32_t
dbLen
=
p
-
pTableName
->
z
;
char
name
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
name
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
strncpy
(
name
,
pTableName
->
z
,
dbLen
);
strncpy
(
name
,
pTableName
->
z
,
dbLen
);
dbLen
=
strdequote
(
name
);
dbLen
=
strdequote
(
name
);
...
@@ -185,9 +185,9 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar
...
@@ -185,9 +185,9 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar
}
}
int32_t
tbLen
=
pTableName
->
n
-
dbLen
-
1
;
int32_t
tbLen
=
pTableName
->
n
-
dbLen
-
1
;
char
tbname
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
char
tbname
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
strncpy
(
tbname
,
p
+
1
,
tbLen
);
strncpy
(
tbname
,
p
+
1
,
tbLen
);
/*tbLen = */
strdequote
(
tbname
);
/*tbLen = */
strdequote
(
tbname
);
code
=
tNameFromString
(
pName
,
tbname
,
T_NAME_TABLE
);
code
=
tNameFromString
(
pName
,
tbname
,
T_NAME_TABLE
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -225,28 +225,26 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar
...
@@ -225,28 +225,26 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar
static
int32_t
getTableMetaImpl
(
SInsertParseContext
*
pCxt
,
SToken
*
pTname
,
bool
isStb
)
{
static
int32_t
getTableMetaImpl
(
SInsertParseContext
*
pCxt
,
SToken
*
pTname
,
bool
isStb
)
{
SParseContext
*
pBasicCtx
=
pCxt
->
pComCxt
;
SParseContext
*
pBasicCtx
=
pCxt
->
pComCxt
;
SName
name
=
{
0
};
SName
name
=
{
0
};
createSName
(
&
name
,
pTname
,
pBasicCtx
,
&
pCxt
->
msg
);
createSName
(
&
name
,
pTname
,
pBasicCtx
,
&
pCxt
->
msg
);
if
(
isStb
)
{
if
(
isStb
)
{
CHECK_CODE
(
catalogGetSTableMeta
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
pCxt
->
pTableMeta
));
CHECK_CODE
(
catalogGetSTableMeta
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
pCxt
->
pTableMeta
));
}
else
{
}
else
{
CHECK_CODE
(
catalogGetTableMeta
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
pCxt
->
pTableMeta
));
CHECK_CODE
(
catalogGetTableMeta
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
pCxt
->
pTableMeta
));
}
}
SVgroupInfo
vg
;
SVgroupInfo
vg
;
CHECK_CODE
(
catalogGetTableHashVgroup
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
vg
));
CHECK_CODE
(
catalogGetTableHashVgroup
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
vg
));
CHECK_CODE
(
taosHashPut
(
pCxt
->
pVgroupsHashObj
,
(
const
char
*
)
&
vg
.
vgId
,
sizeof
(
vg
.
vgId
),
(
char
*
)
&
vg
,
sizeof
(
vg
)));
CHECK_CODE
(
taosHashPut
(
pCxt
->
pVgroupsHashObj
,
(
const
char
*
)
&
vg
.
vgId
,
sizeof
(
vg
.
vgId
),
(
char
*
)
&
vg
,
sizeof
(
vg
)));
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
getTableMeta
(
SInsertParseContext
*
pCxt
,
SToken
*
pTname
)
{
return
TSDB_CODE_SUCCESS
;
return
getTableMetaImpl
(
pCxt
,
pTname
,
false
);
}
}
static
int32_t
getSTableMeta
(
SInsertParseContext
*
pCxt
,
SToken
*
pTname
)
{
static
int32_t
getTableMeta
(
SInsertParseContext
*
pCxt
,
SToken
*
pTname
)
{
return
getTableMetaImpl
(
pCxt
,
pTname
,
false
);
}
return
getTableMetaImpl
(
pCxt
,
pTname
,
true
);
}
static
int32_t
getSTableMeta
(
SInsertParseContext
*
pCxt
,
SToken
*
pTname
)
{
return
getTableMetaImpl
(
pCxt
,
pTname
,
true
);
}
static
int32_t
findCol
(
SToken
*
pColname
,
int32_t
start
,
int32_t
end
,
SSchema
*
pSchema
)
{
static
int32_t
findCol
(
SToken
*
pColname
,
int32_t
start
,
int32_t
end
,
SSchema
*
pSchema
)
{
while
(
start
<
end
)
{
while
(
start
<
end
)
{
...
@@ -259,24 +257,24 @@ static int32_t findCol(SToken* pColname, int32_t start, int32_t end, SSchema* pS
...
@@ -259,24 +257,24 @@ static int32_t findCol(SToken* pColname, int32_t start, int32_t end, SSchema* pS
}
}
static
void
buildMsgHeader
(
STableDataBlocks
*
src
,
SVgDataBlocks
*
blocks
)
{
static
void
buildMsgHeader
(
STableDataBlocks
*
src
,
SVgDataBlocks
*
blocks
)
{
SSubmitReq
*
submit
=
(
SSubmitReq
*
)
blocks
->
pData
;
SSubmitReq
*
submit
=
(
SSubmitReq
*
)
blocks
->
pData
;
submit
->
header
.
vgId
=
htonl
(
blocks
->
vg
.
vgId
);
submit
->
header
.
vgId
=
htonl
(
blocks
->
vg
.
vgId
);
submit
->
header
.
contLen
=
htonl
(
blocks
->
size
);
submit
->
header
.
contLen
=
htonl
(
blocks
->
size
);
submit
->
length
=
submit
->
header
.
contLen
;
submit
->
length
=
submit
->
header
.
contLen
;
submit
->
numOfBlocks
=
htonl
(
blocks
->
numOfTables
);
submit
->
numOfBlocks
=
htonl
(
blocks
->
numOfTables
);
SSubmitBlk
*
blk
=
(
SSubmitBlk
*
)(
submit
+
1
);
SSubmitBlk
*
blk
=
(
SSubmitBlk
*
)(
submit
+
1
);
int32_t
numOfBlocks
=
blocks
->
numOfTables
;
int32_t
numOfBlocks
=
blocks
->
numOfTables
;
while
(
numOfBlocks
--
)
{
while
(
numOfBlocks
--
)
{
int32_t
dataLen
=
blk
->
dataLen
;
int32_t
dataLen
=
blk
->
dataLen
;
blk
->
uid
=
htobe64
(
blk
->
uid
);
blk
->
uid
=
htobe64
(
blk
->
uid
);
blk
->
suid
=
htobe64
(
blk
->
suid
);
blk
->
suid
=
htobe64
(
blk
->
suid
);
blk
->
padding
=
htonl
(
blk
->
padding
);
blk
->
padding
=
htonl
(
blk
->
padding
);
blk
->
sversion
=
htonl
(
blk
->
sversion
);
blk
->
sversion
=
htonl
(
blk
->
sversion
);
blk
->
dataLen
=
htonl
(
blk
->
dataLen
);
blk
->
dataLen
=
htonl
(
blk
->
dataLen
);
blk
->
schemaLen
=
htonl
(
blk
->
schemaLen
);
blk
->
schemaLen
=
htonl
(
blk
->
schemaLen
);
blk
->
numOfRows
=
htons
(
blk
->
numOfRows
);
blk
->
numOfRows
=
htons
(
blk
->
numOfRows
);
blk
=
(
SSubmitBlk
*
)(
blk
->
data
+
dataLen
);
blk
=
(
SSubmitBlk
*
)(
blk
->
data
+
dataLen
);
}
}
}
}
static
int32_t
buildOutput
(
SInsertParseContext
*
pCxt
)
{
static
int32_t
buildOutput
(
SInsertParseContext
*
pCxt
)
{
...
@@ -287,7 +285,7 @@ static int32_t buildOutput(SInsertParseContext* pCxt) {
...
@@ -287,7 +285,7 @@ static int32_t buildOutput(SInsertParseContext* pCxt) {
}
}
for
(
size_t
i
=
0
;
i
<
numOfVg
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
numOfVg
;
++
i
)
{
STableDataBlocks
*
src
=
taosArrayGetP
(
pCxt
->
pVgDataBlocks
,
i
);
STableDataBlocks
*
src
=
taosArrayGetP
(
pCxt
->
pVgDataBlocks
,
i
);
SVgDataBlocks
*
dst
=
taosMemoryCalloc
(
1
,
sizeof
(
SVgDataBlocks
));
SVgDataBlocks
*
dst
=
taosMemoryCalloc
(
1
,
sizeof
(
SVgDataBlocks
));
if
(
NULL
==
dst
)
{
if
(
NULL
==
dst
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
...
@@ -301,13 +299,13 @@ static int32_t buildOutput(SInsertParseContext* pCxt) {
...
@@ -301,13 +299,13 @@ static int32_t buildOutput(SInsertParseContext* pCxt) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
checkTimestamp
(
STableDataBlocks
*
pDataBlocks
,
const
char
*
start
)
{
static
int32_t
checkTimestamp
(
STableDataBlocks
*
pDataBlocks
,
const
char
*
start
)
{
// once the data block is disordered, we do NOT keep previous timestamp any more
// once the data block is disordered, we do NOT keep previous timestamp any more
if
(
!
pDataBlocks
->
ordered
)
{
if
(
!
pDataBlocks
->
ordered
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
TSKEY
k
=
*
(
TSKEY
*
)
start
;
TSKEY
k
=
*
(
TSKEY
*
)
start
;
if
(
k
<=
pDataBlocks
->
prevTS
)
{
if
(
k
<=
pDataBlocks
->
prevTS
)
{
pDataBlocks
->
ordered
=
false
;
pDataBlocks
->
ordered
=
false
;
}
}
...
@@ -316,12 +314,12 @@ static int32_t checkTimestamp(STableDataBlocks *pDataBlocks, const char *start)
...
@@ -316,12 +314,12 @@ static int32_t checkTimestamp(STableDataBlocks *pDataBlocks, const char *start)
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int
parseTime
(
char
**
end
,
SToken
*
pToken
,
int16_t
timePrec
,
int64_t
*
time
,
SMsgBuf
*
pMsgBuf
)
{
static
int
parseTime
(
char
**
end
,
SToken
*
pToken
,
int16_t
timePrec
,
int64_t
*
time
,
SMsgBuf
*
pMsgBuf
)
{
int32_t
index
=
0
;
int32_t
index
=
0
;
SToken
sToken
;
SToken
sToken
;
int64_t
interval
;
int64_t
interval
;
int64_t
ts
=
0
;
int64_t
ts
=
0
;
char
*
pTokenEnd
=
*
end
;
char
*
pTokenEnd
=
*
end
;
if
(
pToken
->
type
==
TK_NOW
)
{
if
(
pToken
->
type
==
TK_NOW
)
{
ts
=
taosGetTimestamp
(
timePrec
);
ts
=
taosGetTimestamp
(
timePrec
);
...
@@ -330,7 +328,7 @@ static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time
...
@@ -330,7 +328,7 @@ static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time
}
else
if
(
pToken
->
type
==
TK_NK_INTEGER
)
{
}
else
if
(
pToken
->
type
==
TK_NK_INTEGER
)
{
bool
isSigned
=
false
;
bool
isSigned
=
false
;
toInteger
(
pToken
->
z
,
pToken
->
n
,
10
,
&
ts
,
&
isSigned
);
toInteger
(
pToken
->
z
,
pToken
->
n
,
10
,
&
ts
,
&
isSigned
);
}
else
{
// parse the RFC-3339/ISO-8601 timestamp format string
}
else
{
// parse the RFC-3339/ISO-8601 timestamp format string
if
(
taosParseTime
(
pToken
->
z
,
time
,
pToken
->
n
,
timePrec
,
tsDaylight
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
taosParseTime
(
pToken
->
z
,
time
,
pToken
->
n
,
timePrec
,
tsDaylight
)
!=
TSDB_CODE_SUCCESS
)
{
return
buildSyntaxErrMsg
(
pMsgBuf
,
"invalid timestamp format"
,
pToken
->
z
);
return
buildSyntaxErrMsg
(
pMsgBuf
,
"invalid timestamp format"
,
pToken
->
z
);
}
}
...
@@ -340,7 +338,7 @@ static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time
...
@@ -340,7 +338,7 @@ static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time
for
(
int
k
=
pToken
->
n
;
pToken
->
z
[
k
]
!=
'\0'
;
k
++
)
{
for
(
int
k
=
pToken
->
n
;
pToken
->
z
[
k
]
!=
'\0'
;
k
++
)
{
if
(
pToken
->
z
[
k
]
==
' '
||
pToken
->
z
[
k
]
==
'\t'
)
continue
;
if
(
pToken
->
z
[
k
]
==
' '
||
pToken
->
z
[
k
]
==
'\t'
)
continue
;
if
(
pToken
->
z
[
k
]
==
'('
&&
pToken
->
z
[
k
+
1
]
==
')'
)
{
//
for insert NOW()/TODAY()
if
(
pToken
->
z
[
k
]
==
'('
&&
pToken
->
z
[
k
+
1
]
==
')'
)
{
//
for insert NOW()/TODAY()
*
end
=
pTokenEnd
=
&
pToken
->
z
[
k
+
2
];
*
end
=
pTokenEnd
=
&
pToken
->
z
[
k
+
2
];
k
++
;
k
++
;
continue
;
continue
;
...
@@ -391,8 +389,10 @@ static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time
...
@@ -391,8 +389,10 @@ static int parseTime(char **end, SToken *pToken, int16_t timePrec, int64_t *time
}
}
static
FORCE_INLINE
int32_t
checkAndTrimValue
(
SToken
*
pToken
,
uint32_t
type
,
char
*
tmpTokenBuf
,
SMsgBuf
*
pMsgBuf
)
{
static
FORCE_INLINE
int32_t
checkAndTrimValue
(
SToken
*
pToken
,
uint32_t
type
,
char
*
tmpTokenBuf
,
SMsgBuf
*
pMsgBuf
)
{
if
((
pToken
->
type
!=
TK_NOW
&&
pToken
->
type
!=
TK_TODAY
&&
pToken
->
type
!=
TK_NK_INTEGER
&&
pToken
->
type
!=
TK_NK_STRING
&&
pToken
->
type
!=
TK_NK_FLOAT
&&
if
((
pToken
->
type
!=
TK_NOW
&&
pToken
->
type
!=
TK_TODAY
&&
pToken
->
type
!=
TK_NK_INTEGER
&&
pToken
->
type
!=
TK_NK_BOOL
&&
pToken
->
type
!=
TK_NULL
&&
pToken
->
type
!=
TK_NK_HEX
&&
pToken
->
type
!=
TK_NK_OCT
&&
pToken
->
type
!=
TK_NK_BIN
)
||
pToken
->
type
!=
TK_NK_STRING
&&
pToken
->
type
!=
TK_NK_FLOAT
&&
pToken
->
type
!=
TK_NK_BOOL
&&
pToken
->
type
!=
TK_NULL
&&
pToken
->
type
!=
TK_NK_HEX
&&
pToken
->
type
!=
TK_NK_OCT
&&
pToken
->
type
!=
TK_NK_BIN
)
||
(
pToken
->
n
==
0
)
||
(
pToken
->
type
==
TK_NK_RP
))
{
(
pToken
->
n
==
0
)
||
(
pToken
->
type
==
TK_NK_RP
))
{
return
buildSyntaxErrMsg
(
pMsgBuf
,
"invalid data or symbol"
,
pToken
->
z
);
return
buildSyntaxErrMsg
(
pMsgBuf
,
"invalid data or symbol"
,
pToken
->
z
);
}
}
...
@@ -408,7 +408,7 @@ static FORCE_INLINE int32_t checkAndTrimValue(SToken* pToken, uint32_t type, cha
...
@@ -408,7 +408,7 @@ static FORCE_INLINE int32_t checkAndTrimValue(SToken* pToken, uint32_t type, cha
}
}
// delete escape character: \\, \', \"
// delete escape character: \\, \', \"
char
delim
=
pToken
->
z
[
0
];
char
delim
=
pToken
->
z
[
0
];
int32_t
cnt
=
0
;
int32_t
cnt
=
0
;
int32_t
j
=
0
;
int32_t
j
=
0
;
for
(
uint32_t
k
=
1
;
k
<
pToken
->
n
-
1
;
++
k
)
{
for
(
uint32_t
k
=
1
;
k
<
pToken
->
n
-
1
;
++
k
)
{
...
@@ -431,12 +431,12 @@ static FORCE_INLINE int32_t checkAndTrimValue(SToken* pToken, uint32_t type, cha
...
@@ -431,12 +431,12 @@ static FORCE_INLINE int32_t checkAndTrimValue(SToken* pToken, uint32_t type, cha
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
bool
isNullStr
(
SToken
*
pToken
)
{
static
bool
isNullStr
(
SToken
*
pToken
)
{
return
(
pToken
->
type
==
TK_NULL
)
||
((
pToken
->
type
==
TK_NK_STRING
)
&&
(
pToken
->
n
!=
0
)
&&
return
(
pToken
->
type
==
TK_NULL
)
||
((
pToken
->
type
==
TK_NK_STRING
)
&&
(
pToken
->
n
!=
0
)
&&
(
strncasecmp
(
TSDB_DATA_NULL_STR_L
,
pToken
->
z
,
pToken
->
n
)
==
0
));
(
strncasecmp
(
TSDB_DATA_NULL_STR_L
,
pToken
->
z
,
pToken
->
n
)
==
0
));
}
}
static
FORCE_INLINE
int32_t
toDouble
(
SToken
*
pToken
,
double
*
value
,
char
**
endPtr
)
{
static
FORCE_INLINE
int32_t
toDouble
(
SToken
*
pToken
,
double
*
value
,
char
**
endPtr
)
{
errno
=
0
;
errno
=
0
;
*
value
=
strtold
(
pToken
->
z
,
endPtr
);
*
value
=
strtold
(
pToken
->
z
,
endPtr
);
...
@@ -448,9 +448,10 @@ static FORCE_INLINE int32_t toDouble(SToken *pToken, double *value, char **endPt
...
@@ -448,9 +448,10 @@ static FORCE_INLINE int32_t toDouble(SToken *pToken, double *value, char **endPt
return
pToken
->
type
;
return
pToken
->
type
;
}
}
static
int32_t
parseValueToken
(
char
**
end
,
SToken
*
pToken
,
SSchema
*
pSchema
,
int16_t
timePrec
,
char
*
tmpTokenBuf
,
_row_append_fn_t
func
,
void
*
param
,
SMsgBuf
*
pMsgBuf
)
{
static
int32_t
parseValueToken
(
char
**
end
,
SToken
*
pToken
,
SSchema
*
pSchema
,
int16_t
timePrec
,
char
*
tmpTokenBuf
,
_row_append_fn_t
func
,
void
*
param
,
SMsgBuf
*
pMsgBuf
)
{
int64_t
iv
;
int64_t
iv
;
char
*
endptr
=
NULL
;
char
*
endptr
=
NULL
;
bool
isSigned
=
false
;
bool
isSigned
=
false
;
int32_t
code
=
checkAndTrimValue
(
pToken
,
pSchema
->
type
,
tmpTokenBuf
,
pMsgBuf
);
int32_t
code
=
checkAndTrimValue
(
pToken
,
pSchema
->
type
,
tmpTokenBuf
,
pMsgBuf
);
...
@@ -497,7 +498,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
...
@@ -497,7 +498,7 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
return
func
(
pMsgBuf
,
&
tmpVal
,
pSchema
->
bytes
,
param
);
return
func
(
pMsgBuf
,
&
tmpVal
,
pSchema
->
bytes
,
param
);
}
}
case
TSDB_DATA_TYPE_UTINYINT
:{
case
TSDB_DATA_TYPE_UTINYINT
:
{
if
(
TSDB_CODE_SUCCESS
!=
toInteger
(
pToken
->
z
,
pToken
->
n
,
10
,
&
iv
,
&
isSigned
))
{
if
(
TSDB_CODE_SUCCESS
!=
toInteger
(
pToken
->
z
,
pToken
->
n
,
10
,
&
iv
,
&
isSigned
))
{
return
buildSyntaxErrMsg
(
pMsgBuf
,
"invalid unsigned tinyint data"
,
pToken
->
z
);
return
buildSyntaxErrMsg
(
pMsgBuf
,
"invalid unsigned tinyint data"
,
pToken
->
z
);
}
else
if
(
!
IS_VALID_UTINYINT
(
iv
))
{
}
else
if
(
!
IS_VALID_UTINYINT
(
iv
))
{
...
@@ -571,7 +572,8 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
...
@@ -571,7 +572,8 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
if
(
TK_NK_ILLEGAL
==
toDouble
(
pToken
,
&
dv
,
&
endptr
))
{
if
(
TK_NK_ILLEGAL
==
toDouble
(
pToken
,
&
dv
,
&
endptr
))
{
return
buildSyntaxErrMsg
(
pMsgBuf
,
"illegal float data"
,
pToken
->
z
);
return
buildSyntaxErrMsg
(
pMsgBuf
,
"illegal float data"
,
pToken
->
z
);
}
}
if
(((
dv
==
HUGE_VAL
||
dv
==
-
HUGE_VAL
)
&&
errno
==
ERANGE
)
||
dv
>
FLT_MAX
||
dv
<
-
FLT_MAX
||
isinf
(
dv
)
||
isnan
(
dv
))
{
if
(((
dv
==
HUGE_VAL
||
dv
==
-
HUGE_VAL
)
&&
errno
==
ERANGE
)
||
dv
>
FLT_MAX
||
dv
<
-
FLT_MAX
||
isinf
(
dv
)
||
isnan
(
dv
))
{
return
buildSyntaxErrMsg
(
pMsgBuf
,
"illegal float data"
,
pToken
->
z
);
return
buildSyntaxErrMsg
(
pMsgBuf
,
"illegal float data"
,
pToken
->
z
);
}
}
float
tmpVal
=
(
float
)
dv
;
float
tmpVal
=
(
float
)
dv
;
...
@@ -657,15 +659,15 @@ static FORCE_INLINE int32_t MemRowAppend(SMsgBuf* pMsgBuf, const void* value, in
...
@@ -657,15 +659,15 @@ static FORCE_INLINE int32_t MemRowAppend(SMsgBuf* pMsgBuf, const void* value, in
static
int32_t
parseBoundColumns
(
SInsertParseContext
*
pCxt
,
SParsedDataColInfo
*
pColList
,
SSchema
*
pSchema
)
{
static
int32_t
parseBoundColumns
(
SInsertParseContext
*
pCxt
,
SParsedDataColInfo
*
pColList
,
SSchema
*
pSchema
)
{
col_id_t
nCols
=
pColList
->
numOfCols
;
col_id_t
nCols
=
pColList
->
numOfCols
;
pColList
->
numOfBound
=
0
;
pColList
->
numOfBound
=
0
;
pColList
->
boundNullLen
=
0
;
pColList
->
boundNullLen
=
0
;
memset
(
pColList
->
boundColumns
,
0
,
sizeof
(
col_id_t
)
*
nCols
);
memset
(
pColList
->
boundColumns
,
0
,
sizeof
(
col_id_t
)
*
nCols
);
for
(
col_id_t
i
=
0
;
i
<
nCols
;
++
i
)
{
for
(
col_id_t
i
=
0
;
i
<
nCols
;
++
i
)
{
pColList
->
cols
[
i
].
valStat
=
VAL_STAT_NONE
;
pColList
->
cols
[
i
].
valStat
=
VAL_STAT_NONE
;
}
}
SToken
sToken
;
SToken
sToken
;
bool
isOrdered
=
true
;
bool
isOrdered
=
true
;
col_id_t
lastColIdx
=
-
1
;
// last column found
col_id_t
lastColIdx
=
-
1
;
// last column found
while
(
1
)
{
while
(
1
)
{
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
...
@@ -729,13 +731,13 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
...
@@ -729,13 +731,13 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
}
}
typedef
struct
SKvParam
{
typedef
struct
SKvParam
{
SKVRowBuilder
*
builder
;
SKVRowBuilder
*
builder
;
SSchema
*
schema
;
SSchema
*
schema
;
char
buf
[
TSDB_MAX_TAGS_LEN
];
char
buf
[
TSDB_MAX_TAGS_LEN
];
}
SKvParam
;
}
SKvParam
;
static
int32_t
KvRowAppend
(
SMsgBuf
*
pMsgBuf
,
const
void
*
value
,
int32_t
len
,
void
*
param
)
{
static
int32_t
KvRowAppend
(
SMsgBuf
*
pMsgBuf
,
const
void
*
value
,
int32_t
len
,
void
*
param
)
{
SKvParam
*
pa
=
(
SKvParam
*
)
param
;
SKvParam
*
pa
=
(
SKvParam
*
)
param
;
int8_t
type
=
pa
->
schema
->
type
;
int8_t
type
=
pa
->
schema
->
type
;
int16_t
colId
=
pa
->
schema
->
colId
;
int16_t
colId
=
pa
->
schema
->
colId
;
...
@@ -749,7 +751,8 @@ static int32_t KvRowAppend(SMsgBuf* pMsgBuf, const void *value, int32_t len, voi
...
@@ -749,7 +751,8 @@ static int32_t KvRowAppend(SMsgBuf* pMsgBuf, const void *value, int32_t len, voi
if
(
!
taosMbsToUcs4
(
value
,
len
,
(
TdUcs4
*
)
varDataVal
(
pa
->
buf
),
pa
->
schema
->
bytes
-
VARSTR_HEADER_SIZE
,
&
output
))
{
if
(
!
taosMbsToUcs4
(
value
,
len
,
(
TdUcs4
*
)
varDataVal
(
pa
->
buf
),
pa
->
schema
->
bytes
-
VARSTR_HEADER_SIZE
,
&
output
))
{
char
buf
[
512
]
=
{
0
};
char
buf
[
512
]
=
{
0
};
snprintf
(
buf
,
tListLen
(
buf
),
"%s"
,
strerror
(
errno
));
snprintf
(
buf
,
tListLen
(
buf
),
"%s"
,
strerror
(
errno
));
return
buildSyntaxErrMsg
(
pMsgBuf
,
buf
,
value
);;
return
buildSyntaxErrMsg
(
pMsgBuf
,
buf
,
value
);
;
}
}
varDataSetLen
(
pa
->
buf
,
output
);
varDataSetLen
(
pa
->
buf
,
output
);
...
@@ -765,7 +768,6 @@ static int32_t buildCreateTbReq(SInsertParseContext* pCxt, const SName* pName, S
...
@@ -765,7 +768,6 @@ static int32_t buildCreateTbReq(SInsertParseContext* pCxt, const SName* pName, S
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
pName
,
dbFName
);
tNameGetFullDbName
(
pName
,
dbFName
);
pCxt
->
createTblReq
.
type
=
TD_CHILD_TABLE
;
pCxt
->
createTblReq
.
type
=
TD_CHILD_TABLE
;
pCxt
->
createTblReq
.
dbFName
=
strdup
(
dbFName
);
pCxt
->
createTblReq
.
name
=
strdup
(
pName
->
tname
);
pCxt
->
createTblReq
.
name
=
strdup
(
pName
->
tname
);
pCxt
->
createTblReq
.
ctbCfg
.
suid
=
pCxt
->
pTableMeta
->
suid
;
pCxt
->
createTblReq
.
ctbCfg
.
suid
=
pCxt
->
pTableMeta
->
suid
;
pCxt
->
createTblReq
.
ctbCfg
.
pTag
=
row
;
pCxt
->
createTblReq
.
ctbCfg
.
pTag
=
row
;
...
@@ -780,13 +782,14 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint
...
@@ -780,13 +782,14 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint
}
}
SKvParam
param
=
{.
builder
=
&
pCxt
->
tagsBuilder
};
SKvParam
param
=
{.
builder
=
&
pCxt
->
tagsBuilder
};
SToken
sToken
;
SToken
sToken
;
char
tmpTokenBuf
[
TSDB_MAX_BYTES_PER_ROW
]
=
{
0
};
// used for deleting Escape character: \\, \', \"
char
tmpTokenBuf
[
TSDB_MAX_BYTES_PER_ROW
]
=
{
0
};
// used for deleting Escape character: \\, \', \"
for
(
int
i
=
0
;
i
<
pCxt
->
tags
.
numOfBound
;
++
i
)
{
for
(
int
i
=
0
;
i
<
pCxt
->
tags
.
numOfBound
;
++
i
)
{
NEXT_TOKEN_WITH_PREV
(
pCxt
->
pSql
,
sToken
);
NEXT_TOKEN_WITH_PREV
(
pCxt
->
pSql
,
sToken
);
SSchema
*
pTagSchema
=
&
pSchema
[
pCxt
->
tags
.
boundColumns
[
i
]
-
1
];
// colId starts with 1
SSchema
*
pTagSchema
=
&
pSchema
[
pCxt
->
tags
.
boundColumns
[
i
]
-
1
];
// colId starts with 1
param
.
schema
=
pTagSchema
;
param
.
schema
=
pTagSchema
;
CHECK_CODE
(
parseValueToken
(
&
pCxt
->
pSql
,
&
sToken
,
pTagSchema
,
precision
,
tmpTokenBuf
,
KvRowAppend
,
&
param
,
&
pCxt
->
msg
));
CHECK_CODE
(
parseValueToken
(
&
pCxt
->
pSql
,
&
sToken
,
pTagSchema
,
precision
,
tmpTokenBuf
,
KvRowAppend
,
&
param
,
&
pCxt
->
msg
));
}
}
SKVRow
row
=
tdGetKVRowFromBuilder
(
&
pCxt
->
tagsBuilder
);
SKVRow
row
=
tdGetKVRowFromBuilder
(
&
pCxt
->
tagsBuilder
);
...
@@ -822,7 +825,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SToken* pTbnameToken)
...
@@ -822,7 +825,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SToken* pTbnameToken)
createSName
(
&
name
,
pTbnameToken
,
pCxt
->
pComCxt
,
&
pCxt
->
msg
);
createSName
(
&
name
,
pTbnameToken
,
pCxt
->
pComCxt
,
&
pCxt
->
msg
);
char
tbFName
[
TSDB_TABLE_FNAME_LEN
];
char
tbFName
[
TSDB_TABLE_FNAME_LEN
];
tNameExtractFullName
(
&
name
,
tbFName
);
tNameExtractFullName
(
&
name
,
tbFName
);
int32_t
len
=
strlen
(
tbFName
);
int32_t
len
=
strlen
(
tbFName
);
STableMeta
**
pMeta
=
taosHashGet
(
pCxt
->
pSubTableHashObj
,
tbFName
,
len
);
STableMeta
**
pMeta
=
taosHashGet
(
pCxt
->
pSubTableHashObj
,
tbFName
,
len
);
if
(
NULL
!=
pMeta
)
{
if
(
NULL
!=
pMeta
)
{
return
cloneTableMeta
(
*
pMeta
,
&
pCxt
->
pTableMeta
);
return
cloneTableMeta
(
*
pMeta
,
&
pCxt
->
pTableMeta
);
...
@@ -864,17 +867,18 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SToken* pTbnameToken)
...
@@ -864,17 +867,18 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, SToken* pTbnameToken)
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int
parseOneRow
(
SInsertParseContext
*
pCxt
,
STableDataBlocks
*
pDataBlocks
,
int16_t
timePrec
,
int32_t
*
len
,
char
*
tmpTokenBuf
)
{
static
int
parseOneRow
(
SInsertParseContext
*
pCxt
,
STableDataBlocks
*
pDataBlocks
,
int16_t
timePrec
,
int32_t
*
len
,
char
*
tmpTokenBuf
)
{
SParsedDataColInfo
*
spd
=
&
pDataBlocks
->
boundColumnInfo
;
SParsedDataColInfo
*
spd
=
&
pDataBlocks
->
boundColumnInfo
;
SRowBuilder
*
pBuilder
=
&
pDataBlocks
->
rowBuilder
;
SRowBuilder
*
pBuilder
=
&
pDataBlocks
->
rowBuilder
;
STSRow
*
row
=
(
STSRow
*
)(
pDataBlocks
->
pData
+
pDataBlocks
->
size
);
// skip the SSubmitBlk header
STSRow
*
row
=
(
STSRow
*
)(
pDataBlocks
->
pData
+
pDataBlocks
->
size
);
// skip the SSubmitBlk header
tdSRowResetBuf
(
pBuilder
,
row
);
tdSRowResetBuf
(
pBuilder
,
row
);
bool
isParseBindParam
=
false
;
bool
isParseBindParam
=
false
;
SSchema
*
schema
=
getTableColumnSchema
(
pDataBlocks
->
pTableMeta
);
SSchema
*
schema
=
getTableColumnSchema
(
pDataBlocks
->
pTableMeta
);
SMemParam
param
=
{.
rb
=
pBuilder
};
SMemParam
param
=
{.
rb
=
pBuilder
};
SToken
sToken
=
{
0
};
SToken
sToken
=
{
0
};
// 1. set the parsed value from sql string
// 1. set the parsed value from sql string
for
(
int
i
=
0
;
i
<
spd
->
numOfBound
;
++
i
)
{
for
(
int
i
=
0
;
i
<
spd
->
numOfBound
;
++
i
)
{
NEXT_TOKEN_WITH_PREV
(
pCxt
->
pSql
,
sToken
);
NEXT_TOKEN_WITH_PREV
(
pCxt
->
pSql
,
sToken
);
...
@@ -885,7 +889,7 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks,
...
@@ -885,7 +889,7 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks,
if
(
PRIMARYKEY_TIMESTAMP_COL_ID
==
pSchema
->
colId
)
{
if
(
PRIMARYKEY_TIMESTAMP_COL_ID
==
pSchema
->
colId
)
{
TSKEY
tsKey
=
TD_ROW_KEY
(
row
);
TSKEY
tsKey
=
TD_ROW_KEY
(
row
);
if
(
checkTimestamp
(
pDataBlocks
,
(
const
char
*
)
&
tsKey
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
checkTimestamp
(
pDataBlocks
,
(
const
char
*
)
&
tsKey
)
!=
TSDB_CODE_SUCCESS
)
{
buildSyntaxErrMsg
(
&
pCxt
->
msg
,
"client time/server time can not be mixed up"
,
sToken
.
z
);
buildSyntaxErrMsg
(
&
pCxt
->
msg
,
"client time/server time can not be mixed up"
,
sToken
.
z
);
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
return
TSDB_CODE_TSC_INVALID_TIME_STAMP
;
}
}
...
@@ -911,11 +915,11 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks,
...
@@ -911,11 +915,11 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks,
// pSql -> (field1_value, ...) [(field1_value2, ...) ...]
// pSql -> (field1_value, ...) [(field1_value2, ...) ...]
static
int32_t
parseValues
(
SInsertParseContext
*
pCxt
,
STableDataBlocks
*
pDataBlock
,
int
maxRows
,
int32_t
*
numOfRows
)
{
static
int32_t
parseValues
(
SInsertParseContext
*
pCxt
,
STableDataBlocks
*
pDataBlock
,
int
maxRows
,
int32_t
*
numOfRows
)
{
STableComInfo
tinfo
=
getTableInfo
(
pDataBlock
->
pTableMeta
);
STableComInfo
tinfo
=
getTableInfo
(
pDataBlock
->
pTableMeta
);
int32_t
extendedRowSize
=
getExtendedRowSize
(
pDataBlock
);
int32_t
extendedRowSize
=
getExtendedRowSize
(
pDataBlock
);
CHECK_CODE
(
initRowBuilder
(
&
pDataBlock
->
rowBuilder
,
pDataBlock
->
pTableMeta
->
sversion
,
&
pDataBlock
->
boundColumnInfo
));
CHECK_CODE
(
initRowBuilder
(
&
pDataBlock
->
rowBuilder
,
pDataBlock
->
pTableMeta
->
sversion
,
&
pDataBlock
->
boundColumnInfo
));
(
*
numOfRows
)
=
0
;
(
*
numOfRows
)
=
0
;
char
tmpTokenBuf
[
TSDB_MAX_BYTES_PER_ROW
]
=
{
0
};
// used for deleting Escape character: \\, \', \"
char
tmpTokenBuf
[
TSDB_MAX_BYTES_PER_ROW
]
=
{
0
};
// used for deleting Escape character: \\, \', \"
SToken
sToken
;
SToken
sToken
;
while
(
1
)
{
while
(
1
)
{
int32_t
index
=
0
;
int32_t
index
=
0
;
...
@@ -934,7 +938,7 @@ static int32_t parseValues(SInsertParseContext* pCxt, STableDataBlocks* pDataBlo
...
@@ -934,7 +938,7 @@ static int32_t parseValues(SInsertParseContext* pCxt, STableDataBlocks* pDataBlo
int32_t
len
=
0
;
int32_t
len
=
0
;
CHECK_CODE
(
parseOneRow
(
pCxt
,
pDataBlock
,
tinfo
.
precision
,
&
len
,
tmpTokenBuf
));
CHECK_CODE
(
parseOneRow
(
pCxt
,
pDataBlock
,
tinfo
.
precision
,
&
len
,
tmpTokenBuf
));
pDataBlock
->
size
+=
extendedRowSize
;
//
len;
pDataBlock
->
size
+=
extendedRowSize
;
//
len;
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
if
(
TK_NK_RP
!=
sToken
.
type
)
{
if
(
TK_NK_RP
!=
sToken
.
type
)
{
...
@@ -945,19 +949,19 @@ static int32_t parseValues(SInsertParseContext* pCxt, STableDataBlocks* pDataBlo
...
@@ -945,19 +949,19 @@ static int32_t parseValues(SInsertParseContext* pCxt, STableDataBlocks* pDataBlo
}
}
if
(
0
==
(
*
numOfRows
))
{
if
(
0
==
(
*
numOfRows
))
{
return
buildSyntaxErrMsg
(
&
pCxt
->
msg
,
"no any data points"
,
NULL
);
return
buildSyntaxErrMsg
(
&
pCxt
->
msg
,
"no any data points"
,
NULL
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
parseValuesClause
(
SInsertParseContext
*
pCxt
,
STableDataBlocks
*
dataBuf
)
{
static
int32_t
parseValuesClause
(
SInsertParseContext
*
pCxt
,
STableDataBlocks
*
dataBuf
)
{
int32_t
maxNumOfRows
;
int32_t
maxNumOfRows
;
CHECK_CODE
(
allocateMemIfNeed
(
dataBuf
,
getExtendedRowSize
(
dataBuf
),
&
maxNumOfRows
));
CHECK_CODE
(
allocateMemIfNeed
(
dataBuf
,
getExtendedRowSize
(
dataBuf
),
&
maxNumOfRows
));
int32_t
numOfRows
=
0
;
int32_t
numOfRows
=
0
;
CHECK_CODE
(
parseValues
(
pCxt
,
dataBuf
,
maxNumOfRows
,
&
numOfRows
));
CHECK_CODE
(
parseValues
(
pCxt
,
dataBuf
,
maxNumOfRows
,
&
numOfRows
));
SSubmitBlk
*
pBlocks
=
(
SSubmitBlk
*
)(
dataBuf
->
pData
);
SSubmitBlk
*
pBlocks
=
(
SSubmitBlk
*
)(
dataBuf
->
pData
);
if
(
TSDB_CODE_SUCCESS
!=
setBlockInfo
(
pBlocks
,
dataBuf
,
numOfRows
))
{
if
(
TSDB_CODE_SUCCESS
!=
setBlockInfo
(
pBlocks
,
dataBuf
,
numOfRows
))
{
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"too many rows in sql, total number of rows should be less than 32767"
);
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"too many rows in sql, total number of rows should be less than 32767"
);
}
}
...
@@ -968,7 +972,6 @@ static int32_t parseValuesClause(SInsertParseContext* pCxt, STableDataBlocks* da
...
@@ -968,7 +972,6 @@ static int32_t parseValuesClause(SInsertParseContext* pCxt, STableDataBlocks* da
}
}
static
void
destroyCreateSubTbReq
(
SVCreateTbReq
*
pReq
)
{
static
void
destroyCreateSubTbReq
(
SVCreateTbReq
*
pReq
)
{
taosMemoryFreeClear
(
pReq
->
dbFName
);
taosMemoryFreeClear
(
pReq
->
name
);
taosMemoryFreeClear
(
pReq
->
name
);
taosMemoryFreeClear
(
pReq
->
ctbCfg
.
pTag
);
taosMemoryFreeClear
(
pReq
->
ctbCfg
.
pTag
);
}
}
...
@@ -1023,7 +1026,8 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
...
@@ -1023,7 +1026,8 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
// no data in the sql string anymore.
// no data in the sql string anymore.
if
(
sToken
.
n
==
0
)
{
if
(
sToken
.
n
==
0
)
{
if
(
0
==
pCxt
->
totalNum
)
{
if
(
0
==
pCxt
->
totalNum
)
{
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"no data in sql"
);;
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"no data in sql"
);
;
}
}
break
;
break
;
}
}
...
@@ -1031,7 +1035,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
...
@@ -1031,7 +1035,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
SToken
tbnameToken
=
sToken
;
SToken
tbnameToken
=
sToken
;
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
// USING cluase
// USING cluase
if
(
TK_USING
==
sToken
.
type
)
{
if
(
TK_USING
==
sToken
.
type
)
{
CHECK_CODE
(
parseUsingClause
(
pCxt
,
&
tbnameToken
));
CHECK_CODE
(
parseUsingClause
(
pCxt
,
&
tbnameToken
));
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
...
@@ -1039,10 +1043,11 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
...
@@ -1039,10 +1043,11 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
CHECK_CODE
(
getTableMeta
(
pCxt
,
&
tbnameToken
));
CHECK_CODE
(
getTableMeta
(
pCxt
,
&
tbnameToken
));
}
}
STableDataBlocks
*
dataBuf
=
NULL
;
STableDataBlocks
*
dataBuf
=
NULL
;
CHECK_CODE
(
getDataBlockFromList
(
pCxt
->
pTableBlockHashObj
,
pCxt
->
pTableMeta
->
uid
,
TSDB_DEFAULT_PAYLOAD_SIZE
,
CHECK_CODE
(
getDataBlockFromList
(
pCxt
->
pTableBlockHashObj
,
pCxt
->
pTableMeta
->
uid
,
TSDB_DEFAULT_PAYLOAD_SIZE
,
sizeof
(
SSubmitBlk
),
getTableInfo
(
pCxt
->
pTableMeta
).
rowSize
,
pCxt
->
pTableMeta
,
&
dataBuf
,
NULL
,
&
pCxt
->
createTblReq
));
sizeof
(
SSubmitBlk
),
getTableInfo
(
pCxt
->
pTableMeta
).
rowSize
,
pCxt
->
pTableMeta
,
&
dataBuf
,
NULL
,
&
pCxt
->
createTblReq
));
if
(
TK_NK_LP
==
sToken
.
type
)
{
if
(
TK_NK_LP
==
sToken
.
type
)
{
// pSql -> field1_name, ...)
// pSql -> field1_name, ...)
CHECK_CODE
(
parseBoundColumns
(
pCxt
,
&
dataBuf
->
boundColumnInfo
,
getTableColumnSchema
(
pCxt
->
pTableMeta
)));
CHECK_CODE
(
parseBoundColumns
(
pCxt
,
&
dataBuf
->
boundColumnInfo
,
getTableColumnSchema
(
pCxt
->
pTableMeta
)));
...
@@ -1071,7 +1076,8 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
...
@@ -1071,7 +1076,8 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
return
buildSyntaxErrMsg
(
&
pCxt
->
msg
,
"keyword VALUES or FILE is expected"
,
sToken
.
z
);
return
buildSyntaxErrMsg
(
&
pCxt
->
msg
,
"keyword VALUES or FILE is expected"
,
sToken
.
z
);
}
}
// merge according to vgId
// merge according to vgId
if
(
!
TSDB_QUERY_HAS_TYPE
(
pCxt
->
pOutput
->
insertType
,
TSDB_QUERY_TYPE_STMT_INSERT
)
&&
taosHashGetSize
(
pCxt
->
pTableBlockHashObj
)
>
0
)
{
if
(
!
TSDB_QUERY_HAS_TYPE
(
pCxt
->
pOutput
->
insertType
,
TSDB_QUERY_TYPE_STMT_INSERT
)
&&
taosHashGetSize
(
pCxt
->
pTableBlockHashObj
)
>
0
)
{
CHECK_CODE
(
mergeTableDataBlocks
(
pCxt
->
pTableBlockHashObj
,
pCxt
->
pOutput
->
payloadType
,
&
pCxt
->
pVgDataBlocks
));
CHECK_CODE
(
mergeTableDataBlocks
(
pCxt
->
pTableBlockHashObj
,
pCxt
->
pOutput
->
payloadType
,
&
pCxt
->
pVgDataBlocks
));
}
}
return
buildOutput
(
pCxt
);
return
buildOutput
(
pCxt
);
...
@@ -1085,19 +1091,18 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
...
@@ -1085,19 +1091,18 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
// [...];
// [...];
int32_t
parseInsertSql
(
SParseContext
*
pContext
,
SQuery
**
pQuery
)
{
int32_t
parseInsertSql
(
SParseContext
*
pContext
,
SQuery
**
pQuery
)
{
SInsertParseContext
context
=
{
SInsertParseContext
context
=
{
.
pComCxt
=
pContext
,
.
pComCxt
=
pContext
,
.
pSql
=
(
char
*
)
pContext
->
pSql
,
.
pSql
=
(
char
*
)
pContext
->
pSql
,
.
msg
=
{.
buf
=
pContext
->
pMsg
,
.
len
=
pContext
->
msgLen
},
.
msg
=
{.
buf
=
pContext
->
pMsg
,
.
len
=
pContext
->
msgLen
},
.
pTableMeta
=
NULL
,
.
pTableMeta
=
NULL
,
.
pVgroupsHashObj
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
false
),
.
pVgroupsHashObj
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
false
),
.
pTableBlockHashObj
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
false
),
.
pTableBlockHashObj
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
false
),
.
pSubTableHashObj
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_VARCHAR
),
true
,
false
),
.
pSubTableHashObj
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_VARCHAR
),
true
,
false
),
.
totalNum
=
0
,
.
totalNum
=
0
,
.
pOutput
=
(
SVnodeModifOpStmt
*
)
nodesMakeNode
(
QUERY_NODE_VNODE_MODIF_STMT
)
.
pOutput
=
(
SVnodeModifOpStmt
*
)
nodesMakeNode
(
QUERY_NODE_VNODE_MODIF_STMT
)};
};
if
(
NULL
==
context
.
pVgroupsHashObj
||
NULL
==
context
.
pTableBlockHashObj
||
NULL
==
context
.
pSubTableHashObj
||
if
(
NULL
==
context
.
pVgroupsHashObj
||
NULL
==
context
.
pTableBlockHashObj
||
NULL
==
context
.
pOutput
)
{
NULL
==
context
.
pSubTableHashObj
||
NULL
==
context
.
pOutput
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
b7281e4d
...
@@ -251,6 +251,9 @@ static void setColumnInfoByExpr(const STableNode* pTable, SExprNode* pExpr, SCol
...
@@ -251,6 +251,9 @@ static void setColumnInfoByExpr(const STableNode* pTable, SExprNode* pExpr, SCol
pCol
->
colType
=
pProjCol
->
colType
;
pCol
->
colType
=
pProjCol
->
colType
;
}
}
strcpy
(
pCol
->
colName
,
pExpr
->
aliasName
);
strcpy
(
pCol
->
colName
,
pExpr
->
aliasName
);
if
(
'\0'
==
pCol
->
node
.
aliasName
[
0
])
{
strcpy
(
pCol
->
node
.
aliasName
,
pCol
->
colName
);
}
pCol
->
node
.
resType
=
pExpr
->
resType
;
pCol
->
node
.
resType
=
pExpr
->
resType
;
}
}
...
@@ -381,28 +384,15 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) {
...
@@ -381,28 +384,15 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) {
}
}
res
=
(
found
?
DEAL_RES_CONTINUE
:
translateColumnWithoutPrefix
(
pCxt
,
pCol
));
res
=
(
found
?
DEAL_RES_CONTINUE
:
translateColumnWithoutPrefix
(
pCxt
,
pCol
));
}
}
return
res
;
if
(
DEAL_RES_ERROR
==
res
)
{
return
res
;
}
if
(
SQL_CLAUSE_WINDOW
==
pCxt
->
currClause
&&
QUERY_NODE_STATE_WINDOW
==
nodeType
(
pCxt
->
pCurrStmt
->
pWindow
))
{
if
(
!
IS_INTEGER_TYPE
(
pCol
->
node
.
resType
.
type
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE
);
}
if
(
COLUMN_TYPE_TAG
==
pCol
->
colType
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_STATE_WIN_COL
);
}
if
(
TSDB_SUPER_TABLE
==
pCol
->
tableType
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_STATE_WIN_TABLE
);
}
}
return
DEAL_RES_CONTINUE
;
}
}
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 +482,10 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
...
@@ -492,8 +482,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 +799,7 @@ static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) {
...
@@ -807,7 +799,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 +825,8 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
...
@@ -833,7 +825,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 +835,7 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
...
@@ -842,7 +835,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 +863,7 @@ static int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STabl
...
@@ -870,7 +863,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 +877,20 @@ static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, SN
...
@@ -884,18 +877,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 +922,7 @@ static int32_t createMultiResFuncs(SFunctionNode* pSrcFunc, SNodeList* pExprs, S
...
@@ -927,7 +922,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 +941,7 @@ static int32_t createMultiResFuncs(SFunctionNode* pSrcFunc, SNodeList* pExprs, S
...
@@ -946,7 +941,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 +963,8 @@ static bool isCountStar(SNode* pNode) {
...
@@ -968,8 +963,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 +1118,7 @@ static int32_t translateGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
...
@@ -1123,9 +1118,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 +1146,8 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode*
...
@@ -1153,8 +1146,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 +1158,19 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode*
...
@@ -1165,18 +1158,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
);
...
@@ -1193,9 +1187,27 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode*
...
@@ -1193,9 +1187,27 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode*
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
EDealRes
checkStateExpr
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
STranslateContext
*
pCxt
=
pContext
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
if
(
!
IS_INTEGER_TYPE
(
pCol
->
node
.
resType
.
type
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_STATE_WIN_TYPE
);
}
if
(
COLUMN_TYPE_TAG
==
pCol
->
colType
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_STATE_WIN_COL
);
}
if
(
TSDB_SUPER_TABLE
==
pCol
->
tableType
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_STATE_WIN_TABLE
);
}
}
return
DEAL_RES_CONTINUE
;
}
static
int32_t
checkStateWindow
(
STranslateContext
*
pCxt
,
SStateWindowNode
*
pState
)
{
static
int32_t
checkStateWindow
(
STranslateContext
*
pCxt
,
SStateWindowNode
*
pState
)
{
nodesWalkExprPostOrder
(
pState
->
pExpr
,
checkStateExpr
,
pCxt
);
// todo check for "function not support for state_window"
// todo check for "function not support for state_window"
return
TSDB_CODE_SUCCESS
;
return
pCxt
->
errCode
;
}
}
static
int32_t
checkSessionWindow
(
STranslateContext
*
pCxt
,
SSessionWindowNode
*
pSession
)
{
static
int32_t
checkSessionWindow
(
STranslateContext
*
pCxt
,
SSessionWindowNode
*
pSession
)
{
...
@@ -1286,14 +1298,14 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
...
@@ -1286,14 +1298,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 +1374,8 @@ static int32_t checkRangeOption(STranslateContext* pCxt, const char* pName, SVal
...
@@ -1362,7 +1374,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 +1470,12 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
...
@@ -1457,9 +1470,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 +1532,8 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p
...
@@ -1516,7 +1532,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 +1586,7 @@ static int32_t checkCreateDatabase(STranslateContext* pCxt, SCreateDatabaseStmt*
...
@@ -1569,7 +1586,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 +1622,7 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS
...
@@ -1605,7 +1622,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 +1836,7 @@ static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt
...
@@ -1819,7 +1836,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 +2122,7 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt
...
@@ -2105,7 +2122,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 +2135,7 @@ static int32_t buildCreateFullTextReq(STranslateContext* pCxt, SCreateIndexStmt*
...
@@ -2118,7 +2135,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 +2191,8 @@ static int16_t getCreateComponentNodeMsgType(ENodeType type) {
...
@@ -2174,7 +2191,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 +2213,8 @@ static int16_t getDropComponentNodeMsgType(ENodeType type) {
...
@@ -2195,7 +2213,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 +2318,13 @@ static int32_t translateCreateStream(STranslateContext* pCxt, SCreateStreamStmt*
...
@@ -2299,11 +2318,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 +2476,7 @@ static int32_t extractSelectResultSchema(const SSelectStmt* pSelect, int32_t* nu
...
@@ -2455,9 +2476,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,16 +2739,19 @@ typedef struct SVgroupTablesBatch {
...
@@ -2720,16 +2739,19 @@ 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
);
}
}
static
void
destroyCreateTbReq
(
SVCreateTbReq
*
pReq
)
{
static
void
destroyCreateTbReq
(
SVCreateTbReq
*
pReq
)
{
taosMemoryFreeClear
(
pReq
->
dbFName
);
taosMemoryFreeClear
(
pReq
->
name
);
taosMemoryFreeClear
(
pReq
->
name
);
taosMemoryFreeClear
(
pReq
->
ntbCfg
.
pSchema
);
taosMemoryFreeClear
(
pReq
->
ntbCfg
.
pSchema
);
}
}
...
@@ -2766,10 +2788,9 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
...
@@ -2766,10 +2788,9 @@ static int32_t buildNormalTableBatchReq(int32_t acctId, const SCreateTableStmt*
SVCreateTbReq
req
=
{
0
};
SVCreateTbReq
req
=
{
0
};
req
.
type
=
TD_NORMAL_TABLE
;
req
.
type
=
TD_NORMAL_TABLE
;
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
;
...
@@ -2825,7 +2846,6 @@ static void destroyCreateTbReqBatch(SVgroupTablesBatch* pTbBatch) {
...
@@ -2825,7 +2846,6 @@ static void destroyCreateTbReqBatch(SVgroupTablesBatch* pTbBatch) {
size_t
size
=
taosArrayGetSize
(
pTbBatch
->
req
.
pArray
);
size_t
size
=
taosArrayGetSize
(
pTbBatch
->
req
.
pArray
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SVCreateTbReq
*
pTableReq
=
taosArrayGet
(
pTbBatch
->
req
.
pArray
,
i
);
SVCreateTbReq
*
pTableReq
=
taosArrayGet
(
pTbBatch
->
req
.
pArray
,
i
);
taosMemoryFreeClear
(
pTableReq
->
dbFName
);
taosMemoryFreeClear
(
pTableReq
->
name
);
taosMemoryFreeClear
(
pTableReq
->
name
);
if
(
pTableReq
->
type
==
TSDB_NORMAL_TABLE
)
{
if
(
pTableReq
->
type
==
TSDB_NORMAL_TABLE
)
{
...
@@ -2911,7 +2931,6 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, c
...
@@ -2911,7 +2931,6 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, c
struct
SVCreateTbReq
req
=
{
0
};
struct
SVCreateTbReq
req
=
{
0
};
req
.
type
=
TD_CHILD_TABLE
;
req
.
type
=
TD_CHILD_TABLE
;
req
.
dbFName
=
strdup
(
dbFName
);
req
.
name
=
strdup
(
pTableName
);
req
.
name
=
strdup
(
pTableName
);
req
.
ctbCfg
.
suid
=
suid
;
req
.
ctbCfg
.
suid
=
suid
;
req
.
ctbCfg
.
pTag
=
row
;
req
.
ctbCfg
.
pTag
=
row
;
...
@@ -3174,7 +3193,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
...
@@ -3174,7 +3193,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
浏览文件 @
b7281e4d
...
@@ -134,7 +134,6 @@ typedef union {
...
@@ -134,7 +134,6 @@ typedef union {
#define ParseCTX_STORE
#define ParseCTX_STORE
#define YYNSTATE 568
#define YYNSTATE 568
#define YYNRULE 433
#define YYNRULE 433
#define YYNRULE_WITH_ACTION 433
#define YYNTOKEN 220
#define YYNTOKEN 220
#define YY_MAX_SHIFT 567
#define YY_MAX_SHIFT 567
#define YY_MIN_SHIFTREDUCE 843
#define YY_MIN_SHIFTREDUCE 843
...
@@ -588,28 +587,7 @@ static const YYCODETYPE yy_lookahead[] = {
...
@@ -588,28 +587,7 @@ static const YYCODETYPE yy_lookahead[] = {
/* 1840 */
334
,
334
,
334
,
334
,
334
,
334
,
334
,
334
,
334
,
334
,
/* 1840 */
334
,
334
,
334
,
334
,
334
,
334
,
334
,
334
,
334
,
334
,
/* 1850 */
334
,
334
,
334
,
334
,
334
,
286
,
287
,
288
,
289
,
290
,
/* 1850 */
334
,
334
,
334
,
334
,
334
,
286
,
287
,
288
,
289
,
290
,
/* 1860 */
291
,
334
,
293
,
334
,
334
,
334
,
334
,
334
,
334
,
334
,
/* 1860 */
291
,
334
,
293
,
334
,
334
,
334
,
334
,
334
,
334
,
334
,
/* 1870 */
334
,
334
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 1870 */
334
,
334
,
/* 1880 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 1890 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 1900 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 1910 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 1920 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 1930 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 1940 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 1950 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 1960 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 1970 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 1980 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 1990 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 2000 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 2010 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 2020 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 2030 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 2040 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 2050 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 2060 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 2070 */
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
220
,
/* 2080 */
220
,
220
,
220
,
};
};
#define YY_SHIFT_COUNT (567)
#define YY_SHIFT_COUNT (567)
#define YY_SHIFT_MIN (0)
#define YY_SHIFT_MIN (0)
...
@@ -2050,18 +2028,15 @@ static YYACTIONTYPE yy_find_shift_action(
...
@@ -2050,18 +2028,15 @@ static YYACTIONTYPE yy_find_shift_action(
do
{
do
{
i
=
yy_shift_ofst
[
stateno
];
i
=
yy_shift_ofst
[
stateno
];
assert
(
i
>=
0
);
assert
(
i
>=
0
);
assert
(
i
<=
YY_ACTTAB_COUNT
);
/* assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); */
assert
(
i
+
YYNTOKEN
<=
(
int
)
YY_NLOOKAHEAD
);
assert
(
iLookAhead
!=
YYNOCODE
);
assert
(
iLookAhead
!=
YYNOCODE
);
assert
(
iLookAhead
<
YYNTOKEN
);
assert
(
iLookAhead
<
YYNTOKEN
);
i
+=
iLookAhead
;
i
+=
iLookAhead
;
assert
(
i
<
(
int
)
YY_NLOOKAHEAD
);
if
(
i
>=
YY_NLOOKAHEAD
||
yy_lookahead
[
i
]
!=
iLookAhead
){
if
(
yy_lookahead
[
i
]
!=
iLookAhead
){
#ifdef YYFALLBACK
#ifdef YYFALLBACK
YYCODETYPE
iFallback
;
/* Fallback token */
YYCODETYPE
iFallback
;
/* Fallback token */
assert
(
iLookAhead
<
sizeof
(
yyFallback
)
/
sizeof
(
yyFallback
[
0
])
);
if
(
iLookAhead
<
sizeof
(
yyFallback
)
/
sizeof
(
yyFallback
[
0
])
iFallback
=
yyFallback
[
iLookAhead
];
&&
(
iFallback
=
yyFallback
[
iLookAhead
])
!=
0
){
if
(
iFallback
!=
0
){
#ifndef NDEBUG
#ifndef NDEBUG
if
(
yyTraceFILE
){
if
(
yyTraceFILE
){
fprintf
(
yyTraceFILE
,
"%sFALLBACK %s => %s
\n
"
,
fprintf
(
yyTraceFILE
,
"%sFALLBACK %s => %s
\n
"
,
...
@@ -2076,8 +2051,16 @@ static YYACTIONTYPE yy_find_shift_action(
...
@@ -2076,8 +2051,16 @@ static YYACTIONTYPE yy_find_shift_action(
#ifdef YYWILDCARD
#ifdef YYWILDCARD
{
{
int
j
=
i
-
iLookAhead
+
YYWILDCARD
;
int
j
=
i
-
iLookAhead
+
YYWILDCARD
;
assert
(
j
<
(
int
)(
sizeof
(
yy_lookahead
)
/
sizeof
(
yy_lookahead
[
0
]))
);
if
(
if
(
yy_lookahead
[
j
]
==
YYWILDCARD
&&
iLookAhead
>
0
){
#if YY_SHIFT_MIN+YYWILDCARD<0
j
>=
0
&&
#endif
#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT
j
<
YY_ACTTAB_COUNT
&&
#endif
j
<
(
int
)(
sizeof
(
yy_lookahead
)
/
sizeof
(
yy_lookahead
[
0
]))
&&
yy_lookahead
[
j
]
==
YYWILDCARD
&&
iLookAhead
>
0
){
#ifndef NDEBUG
#ifndef NDEBUG
if
(
yyTraceFILE
){
if
(
yyTraceFILE
){
fprintf
(
yyTraceFILE
,
"%sWILDCARD %s => %s
\n
"
,
fprintf
(
yyTraceFILE
,
"%sWILDCARD %s => %s
\n
"
,
...
@@ -2091,7 +2074,6 @@ static YYACTIONTYPE yy_find_shift_action(
...
@@ -2091,7 +2074,6 @@ static YYACTIONTYPE yy_find_shift_action(
#endif
/* YYWILDCARD */
#endif
/* YYWILDCARD */
return
yy_default
[
stateno
];
return
yy_default
[
stateno
];
}
else
{
}
else
{
assert
(
i
>=
0
&&
i
<
sizeof
(
yy_action
)
/
sizeof
(
yy_action
[
0
])
);
return
yy_action
[
i
];
return
yy_action
[
i
];
}
}
}
while
(
1
);
}
while
(
1
);
...
@@ -2210,880 +2192,446 @@ static void yy_shift(
...
@@ -2210,880 +2192,446 @@ static void yy_shift(
yyTraceShift
(
yypParser
,
yyNewState
,
"Shift"
);
yyTraceShift
(
yypParser
,
yyNewState
,
"Shift"
);
}
}
/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
/* The following table contains information about every rule that
** of that rule */
** is used during the reduce.
static
const
YYCODETYPE
yyRuleInfoLhs
[]
=
{
*/
220
,
/* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */
static
const
struct
{
220
,
/* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */
YYCODETYPE
lhs
;
/* Symbol on the left-hand side of the rule */
221
,
/* (2) account_options ::= */
signed
char
nrhs
;
/* Negative of the number of RHS symbols in the rule */
221
,
/* (3) account_options ::= account_options PPS literal */
}
yyRuleInfo
[]
=
{
221
,
/* (4) account_options ::= account_options TSERIES literal */
{
220
,
-
6
},
/* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */
221
,
/* (5) account_options ::= account_options STORAGE literal */
{
220
,
-
4
},
/* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */
221
,
/* (6) account_options ::= account_options STREAMS literal */
{
221
,
0
},
/* (2) account_options ::= */
221
,
/* (7) account_options ::= account_options QTIME literal */
{
221
,
-
3
},
/* (3) account_options ::= account_options PPS literal */
221
,
/* (8) account_options ::= account_options DBS literal */
{
221
,
-
3
},
/* (4) account_options ::= account_options TSERIES literal */
221
,
/* (9) account_options ::= account_options USERS literal */
{
221
,
-
3
},
/* (5) account_options ::= account_options STORAGE literal */
221
,
/* (10) account_options ::= account_options CONNS literal */
{
221
,
-
3
},
/* (6) account_options ::= account_options STREAMS literal */
221
,
/* (11) account_options ::= account_options STATE literal */
{
221
,
-
3
},
/* (7) account_options ::= account_options QTIME literal */
222
,
/* (12) alter_account_options ::= alter_account_option */
{
221
,
-
3
},
/* (8) account_options ::= account_options DBS literal */
222
,
/* (13) alter_account_options ::= alter_account_options alter_account_option */
{
221
,
-
3
},
/* (9) account_options ::= account_options USERS literal */
224
,
/* (14) alter_account_option ::= PASS literal */
{
221
,
-
3
},
/* (10) account_options ::= account_options CONNS literal */
224
,
/* (15) alter_account_option ::= PPS literal */
{
221
,
-
3
},
/* (11) account_options ::= account_options STATE literal */
224
,
/* (16) alter_account_option ::= TSERIES literal */
{
222
,
-
1
},
/* (12) alter_account_options ::= alter_account_option */
224
,
/* (17) alter_account_option ::= STORAGE literal */
{
222
,
-
2
},
/* (13) alter_account_options ::= alter_account_options alter_account_option */
224
,
/* (18) alter_account_option ::= STREAMS literal */
{
224
,
-
2
},
/* (14) alter_account_option ::= PASS literal */
224
,
/* (19) alter_account_option ::= QTIME literal */
{
224
,
-
2
},
/* (15) alter_account_option ::= PPS literal */
224
,
/* (20) alter_account_option ::= DBS literal */
{
224
,
-
2
},
/* (16) alter_account_option ::= TSERIES literal */
224
,
/* (21) alter_account_option ::= USERS literal */
{
224
,
-
2
},
/* (17) alter_account_option ::= STORAGE literal */
224
,
/* (22) alter_account_option ::= CONNS literal */
{
224
,
-
2
},
/* (18) alter_account_option ::= STREAMS literal */
224
,
/* (23) alter_account_option ::= STATE literal */
{
224
,
-
2
},
/* (19) alter_account_option ::= QTIME literal */
220
,
/* (24) cmd ::= CREATE USER user_name PASS NK_STRING */
{
224
,
-
2
},
/* (20) alter_account_option ::= DBS literal */
220
,
/* (25) cmd ::= ALTER USER user_name PASS NK_STRING */
{
224
,
-
2
},
/* (21) alter_account_option ::= USERS literal */
220
,
/* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */
{
224
,
-
2
},
/* (22) alter_account_option ::= CONNS literal */
220
,
/* (27) cmd ::= DROP USER user_name */
{
224
,
-
2
},
/* (23) alter_account_option ::= STATE literal */
220
,
/* (28) cmd ::= CREATE DNODE dnode_endpoint */
{
220
,
-
5
},
/* (24) cmd ::= CREATE USER user_name PASS NK_STRING */
220
,
/* (29) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */
{
220
,
-
5
},
/* (25) cmd ::= ALTER USER user_name PASS NK_STRING */
220
,
/* (30) cmd ::= DROP DNODE NK_INTEGER */
{
220
,
-
5
},
/* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */
220
,
/* (31) cmd ::= DROP DNODE dnode_endpoint */
{
220
,
-
3
},
/* (27) cmd ::= DROP USER user_name */
220
,
/* (32) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */
{
220
,
-
3
},
/* (28) cmd ::= CREATE DNODE dnode_endpoint */
220
,
/* (33) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */
{
220
,
-
5
},
/* (29) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */
220
,
/* (34) cmd ::= ALTER ALL DNODES NK_STRING */
{
220
,
-
3
},
/* (30) cmd ::= DROP DNODE NK_INTEGER */
220
,
/* (35) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */
{
220
,
-
3
},
/* (31) cmd ::= DROP DNODE dnode_endpoint */
226
,
/* (36) dnode_endpoint ::= NK_STRING */
{
220
,
-
4
},
/* (32) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */
227
,
/* (37) dnode_host_name ::= NK_ID */
{
220
,
-
5
},
/* (33) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */
227
,
/* (38) dnode_host_name ::= NK_IPTOKEN */
{
220
,
-
4
},
/* (34) cmd ::= ALTER ALL DNODES NK_STRING */
220
,
/* (39) cmd ::= ALTER LOCAL NK_STRING */
{
220
,
-
5
},
/* (35) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */
220
,
/* (40) cmd ::= ALTER LOCAL NK_STRING NK_STRING */
{
226
,
-
1
},
/* (36) dnode_endpoint ::= NK_STRING */
220
,
/* (41) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */
{
227
,
-
1
},
/* (37) dnode_host_name ::= NK_ID */
220
,
/* (42) cmd ::= DROP QNODE ON DNODE NK_INTEGER */
{
227
,
-
1
},
/* (38) dnode_host_name ::= NK_IPTOKEN */
220
,
/* (43) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */
{
220
,
-
3
},
/* (39) cmd ::= ALTER LOCAL NK_STRING */
220
,
/* (44) cmd ::= DROP BNODE ON DNODE NK_INTEGER */
{
220
,
-
4
},
/* (40) cmd ::= ALTER LOCAL NK_STRING NK_STRING */
220
,
/* (45) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */
{
220
,
-
5
},
/* (41) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */
220
,
/* (46) cmd ::= DROP SNODE ON DNODE NK_INTEGER */
{
220
,
-
5
},
/* (42) cmd ::= DROP QNODE ON DNODE NK_INTEGER */
220
,
/* (47) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */
{
220
,
-
5
},
/* (43) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */
220
,
/* (48) cmd ::= DROP MNODE ON DNODE NK_INTEGER */
{
220
,
-
5
},
/* (44) cmd ::= DROP BNODE ON DNODE NK_INTEGER */
220
,
/* (49) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */
{
220
,
-
5
},
/* (45) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */
220
,
/* (50) cmd ::= DROP DATABASE exists_opt db_name */
{
220
,
-
5
},
/* (46) cmd ::= DROP SNODE ON DNODE NK_INTEGER */
220
,
/* (51) cmd ::= USE db_name */
{
220
,
-
5
},
/* (47) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */
220
,
/* (52) cmd ::= ALTER DATABASE db_name alter_db_options */
{
220
,
-
5
},
/* (48) cmd ::= DROP MNODE ON DNODE NK_INTEGER */
228
,
/* (53) not_exists_opt ::= IF NOT EXISTS */
{
220
,
-
5
},
/* (49) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */
228
,
/* (54) not_exists_opt ::= */
{
220
,
-
4
},
/* (50) cmd ::= DROP DATABASE exists_opt db_name */
231
,
/* (55) exists_opt ::= IF EXISTS */
{
220
,
-
2
},
/* (51) cmd ::= USE db_name */
231
,
/* (56) exists_opt ::= */
{
220
,
-
4
},
/* (52) cmd ::= ALTER DATABASE db_name alter_db_options */
230
,
/* (57) db_options ::= */
{
228
,
-
3
},
/* (53) not_exists_opt ::= IF NOT EXISTS */
230
,
/* (58) db_options ::= db_options BLOCKS NK_INTEGER */
{
228
,
0
},
/* (54) not_exists_opt ::= */
230
,
/* (59) db_options ::= db_options CACHE NK_INTEGER */
{
231
,
-
2
},
/* (55) exists_opt ::= IF EXISTS */
230
,
/* (60) db_options ::= db_options CACHELAST NK_INTEGER */
{
231
,
0
},
/* (56) exists_opt ::= */
230
,
/* (61) db_options ::= db_options COMP NK_INTEGER */
{
230
,
0
},
/* (57) db_options ::= */
230
,
/* (62) db_options ::= db_options DAYS NK_INTEGER */
{
230
,
-
3
},
/* (58) db_options ::= db_options BLOCKS NK_INTEGER */
230
,
/* (63) db_options ::= db_options DAYS NK_VARIABLE */
{
230
,
-
3
},
/* (59) db_options ::= db_options CACHE NK_INTEGER */
230
,
/* (64) db_options ::= db_options FSYNC NK_INTEGER */
{
230
,
-
3
},
/* (60) db_options ::= db_options CACHELAST NK_INTEGER */
230
,
/* (65) db_options ::= db_options MAXROWS NK_INTEGER */
{
230
,
-
3
},
/* (61) db_options ::= db_options COMP NK_INTEGER */
230
,
/* (66) db_options ::= db_options MINROWS NK_INTEGER */
{
230
,
-
3
},
/* (62) db_options ::= db_options DAYS NK_INTEGER */
230
,
/* (67) db_options ::= db_options KEEP integer_list */
{
230
,
-
3
},
/* (63) db_options ::= db_options DAYS NK_VARIABLE */
230
,
/* (68) db_options ::= db_options KEEP variable_list */
{
230
,
-
3
},
/* (64) db_options ::= db_options FSYNC NK_INTEGER */
230
,
/* (69) db_options ::= db_options PRECISION NK_STRING */
{
230
,
-
3
},
/* (65) db_options ::= db_options MAXROWS NK_INTEGER */
230
,
/* (70) db_options ::= db_options QUORUM NK_INTEGER */
{
230
,
-
3
},
/* (66) db_options ::= db_options MINROWS NK_INTEGER */
230
,
/* (71) db_options ::= db_options REPLICA NK_INTEGER */
{
230
,
-
3
},
/* (67) db_options ::= db_options KEEP integer_list */
230
,
/* (72) db_options ::= db_options TTL NK_INTEGER */
{
230
,
-
3
},
/* (68) db_options ::= db_options KEEP variable_list */
230
,
/* (73) db_options ::= db_options WAL NK_INTEGER */
{
230
,
-
3
},
/* (69) db_options ::= db_options PRECISION NK_STRING */
230
,
/* (74) db_options ::= db_options VGROUPS NK_INTEGER */
{
230
,
-
3
},
/* (70) db_options ::= db_options QUORUM NK_INTEGER */
230
,
/* (75) db_options ::= db_options SINGLE_STABLE NK_INTEGER */
{
230
,
-
3
},
/* (71) db_options ::= db_options REPLICA NK_INTEGER */
230
,
/* (76) db_options ::= db_options STREAM_MODE NK_INTEGER */
{
230
,
-
3
},
/* (72) db_options ::= db_options TTL NK_INTEGER */
230
,
/* (77) db_options ::= db_options RETENTIONS retention_list */
{
230
,
-
3
},
/* (73) db_options ::= db_options WAL NK_INTEGER */
232
,
/* (78) alter_db_options ::= alter_db_option */
{
230
,
-
3
},
/* (74) db_options ::= db_options VGROUPS NK_INTEGER */
232
,
/* (79) alter_db_options ::= alter_db_options alter_db_option */
{
230
,
-
3
},
/* (75) db_options ::= db_options SINGLE_STABLE NK_INTEGER */
236
,
/* (80) alter_db_option ::= BLOCKS NK_INTEGER */
{
230
,
-
3
},
/* (76) db_options ::= db_options STREAM_MODE NK_INTEGER */
236
,
/* (81) alter_db_option ::= FSYNC NK_INTEGER */
{
230
,
-
3
},
/* (77) db_options ::= db_options RETENTIONS retention_list */
236
,
/* (82) alter_db_option ::= KEEP integer_list */
{
232
,
-
1
},
/* (78) alter_db_options ::= alter_db_option */
236
,
/* (83) alter_db_option ::= KEEP variable_list */
{
232
,
-
2
},
/* (79) alter_db_options ::= alter_db_options alter_db_option */
236
,
/* (84) alter_db_option ::= WAL NK_INTEGER */
{
236
,
-
2
},
/* (80) alter_db_option ::= BLOCKS NK_INTEGER */
236
,
/* (85) alter_db_option ::= QUORUM NK_INTEGER */
{
236
,
-
2
},
/* (81) alter_db_option ::= FSYNC NK_INTEGER */
236
,
/* (86) alter_db_option ::= CACHELAST NK_INTEGER */
{
236
,
-
2
},
/* (82) alter_db_option ::= KEEP integer_list */
236
,
/* (87) alter_db_option ::= REPLICA NK_INTEGER */
{
236
,
-
2
},
/* (83) alter_db_option ::= KEEP variable_list */
233
,
/* (88) integer_list ::= NK_INTEGER */
{
236
,
-
2
},
/* (84) alter_db_option ::= WAL NK_INTEGER */
233
,
/* (89) integer_list ::= integer_list NK_COMMA NK_INTEGER */
{
236
,
-
2
},
/* (85) alter_db_option ::= QUORUM NK_INTEGER */
234
,
/* (90) variable_list ::= NK_VARIABLE */
{
236
,
-
2
},
/* (86) alter_db_option ::= CACHELAST NK_INTEGER */
234
,
/* (91) variable_list ::= variable_list NK_COMMA NK_VARIABLE */
{
236
,
-
2
},
/* (87) alter_db_option ::= REPLICA NK_INTEGER */
235
,
/* (92) retention_list ::= retention */
{
233
,
-
1
},
/* (88) integer_list ::= NK_INTEGER */
235
,
/* (93) retention_list ::= retention_list NK_COMMA retention */
{
233
,
-
3
},
/* (89) integer_list ::= integer_list NK_COMMA NK_INTEGER */
237
,
/* (94) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */
{
234
,
-
1
},
/* (90) variable_list ::= NK_VARIABLE */
220
,
/* (95) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */
{
234
,
-
3
},
/* (91) variable_list ::= variable_list NK_COMMA NK_VARIABLE */
220
,
/* (96) cmd ::= CREATE TABLE multi_create_clause */
{
235
,
-
1
},
/* (92) retention_list ::= retention */
220
,
/* (97) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */
{
235
,
-
3
},
/* (93) retention_list ::= retention_list NK_COMMA retention */
220
,
/* (98) cmd ::= DROP TABLE multi_drop_clause */
{
237
,
-
3
},
/* (94) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */
220
,
/* (99) cmd ::= DROP STABLE exists_opt full_table_name */
{
220
,
-
9
},
/* (95) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */
220
,
/* (100) cmd ::= ALTER TABLE alter_table_clause */
{
220
,
-
3
},
/* (96) cmd ::= CREATE TABLE multi_create_clause */
220
,
/* (101) cmd ::= ALTER STABLE alter_table_clause */
{
220
,
-
9
},
/* (97) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */
245
,
/* (102) alter_table_clause ::= full_table_name alter_table_options */
{
220
,
-
3
},
/* (98) cmd ::= DROP TABLE multi_drop_clause */
245
,
/* (103) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */
{
220
,
-
4
},
/* (99) cmd ::= DROP STABLE exists_opt full_table_name */
245
,
/* (104) alter_table_clause ::= full_table_name DROP COLUMN column_name */
{
220
,
-
3
},
/* (100) cmd ::= ALTER TABLE alter_table_clause */
245
,
/* (105) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */
{
220
,
-
3
},
/* (101) cmd ::= ALTER STABLE alter_table_clause */
245
,
/* (106) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */
{
245
,
-
2
},
/* (102) alter_table_clause ::= full_table_name alter_table_options */
245
,
/* (107) alter_table_clause ::= full_table_name ADD TAG column_name type_name */
{
245
,
-
5
},
/* (103) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */
245
,
/* (108) alter_table_clause ::= full_table_name DROP TAG column_name */
{
245
,
-
4
},
/* (104) alter_table_clause ::= full_table_name DROP COLUMN column_name */
245
,
/* (109) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */
{
245
,
-
5
},
/* (105) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */
245
,
/* (110) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */
{
245
,
-
5
},
/* (106) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */
245
,
/* (111) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */
{
245
,
-
5
},
/* (107) alter_table_clause ::= full_table_name ADD TAG column_name type_name */
242
,
/* (112) multi_create_clause ::= create_subtable_clause */
{
245
,
-
4
},
/* (108) alter_table_clause ::= full_table_name DROP TAG column_name */
242
,
/* (113) multi_create_clause ::= multi_create_clause create_subtable_clause */
{
245
,
-
5
},
/* (109) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */
249
,
/* (114) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */
{
245
,
-
5
},
/* (110) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */
244
,
/* (115) multi_drop_clause ::= drop_table_clause */
{
245
,
-
6
},
/* (111) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */
244
,
/* (116) multi_drop_clause ::= multi_drop_clause drop_table_clause */
{
242
,
-
1
},
/* (112) multi_create_clause ::= create_subtable_clause */
252
,
/* (117) drop_table_clause ::= exists_opt full_table_name */
{
242
,
-
2
},
/* (113) multi_create_clause ::= multi_create_clause create_subtable_clause */
250
,
/* (118) specific_tags_opt ::= */
{
249
,
-
9
},
/* (114) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */
250
,
/* (119) specific_tags_opt ::= NK_LP col_name_list NK_RP */
{
244
,
-
1
},
/* (115) multi_drop_clause ::= drop_table_clause */
238
,
/* (120) full_table_name ::= table_name */
{
244
,
-
2
},
/* (116) multi_drop_clause ::= multi_drop_clause drop_table_clause */
238
,
/* (121) full_table_name ::= db_name NK_DOT table_name */
{
252
,
-
2
},
/* (117) drop_table_clause ::= exists_opt full_table_name */
239
,
/* (122) column_def_list ::= column_def */
{
250
,
0
},
/* (118) specific_tags_opt ::= */
239
,
/* (123) column_def_list ::= column_def_list NK_COMMA column_def */
{
250
,
-
3
},
/* (119) specific_tags_opt ::= NK_LP col_name_list NK_RP */
255
,
/* (124) column_def ::= column_name type_name */
{
238
,
-
1
},
/* (120) full_table_name ::= table_name */
255
,
/* (125) column_def ::= column_name type_name COMMENT NK_STRING */
{
238
,
-
3
},
/* (121) full_table_name ::= db_name NK_DOT table_name */
248
,
/* (126) type_name ::= BOOL */
{
239
,
-
1
},
/* (122) column_def_list ::= column_def */
248
,
/* (127) type_name ::= TINYINT */
{
239
,
-
3
},
/* (123) column_def_list ::= column_def_list NK_COMMA column_def */
248
,
/* (128) type_name ::= SMALLINT */
{
255
,
-
2
},
/* (124) column_def ::= column_name type_name */
248
,
/* (129) type_name ::= INT */
{
255
,
-
4
},
/* (125) column_def ::= column_name type_name COMMENT NK_STRING */
248
,
/* (130) type_name ::= INTEGER */
{
248
,
-
1
},
/* (126) type_name ::= BOOL */
248
,
/* (131) type_name ::= BIGINT */
{
248
,
-
1
},
/* (127) type_name ::= TINYINT */
248
,
/* (132) type_name ::= FLOAT */
{
248
,
-
1
},
/* (128) type_name ::= SMALLINT */
248
,
/* (133) type_name ::= DOUBLE */
{
248
,
-
1
},
/* (129) type_name ::= INT */
248
,
/* (134) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */
{
248
,
-
1
},
/* (130) type_name ::= INTEGER */
248
,
/* (135) type_name ::= TIMESTAMP */
{
248
,
-
1
},
/* (131) type_name ::= BIGINT */
248
,
/* (136) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */
{
248
,
-
1
},
/* (132) type_name ::= FLOAT */
248
,
/* (137) type_name ::= TINYINT UNSIGNED */
{
248
,
-
1
},
/* (133) type_name ::= DOUBLE */
248
,
/* (138) type_name ::= SMALLINT UNSIGNED */
{
248
,
-
4
},
/* (134) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */
248
,
/* (139) type_name ::= INT UNSIGNED */
{
248
,
-
1
},
/* (135) type_name ::= TIMESTAMP */
248
,
/* (140) type_name ::= BIGINT UNSIGNED */
{
248
,
-
4
},
/* (136) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */
248
,
/* (141) type_name ::= JSON */
{
248
,
-
2
},
/* (137) type_name ::= TINYINT UNSIGNED */
248
,
/* (142) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */
{
248
,
-
2
},
/* (138) type_name ::= SMALLINT UNSIGNED */
248
,
/* (143) type_name ::= MEDIUMBLOB */
{
248
,
-
2
},
/* (139) type_name ::= INT UNSIGNED */
248
,
/* (144) type_name ::= BLOB */
{
248
,
-
2
},
/* (140) type_name ::= BIGINT UNSIGNED */
248
,
/* (145) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */
{
248
,
-
1
},
/* (141) type_name ::= JSON */
248
,
/* (146) type_name ::= DECIMAL */
{
248
,
-
4
},
/* (142) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */
248
,
/* (147) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */
{
248
,
-
1
},
/* (143) type_name ::= MEDIUMBLOB */
248
,
/* (148) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */
{
248
,
-
1
},
/* (144) type_name ::= BLOB */
240
,
/* (149) tags_def_opt ::= */
{
248
,
-
4
},
/* (145) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */
240
,
/* (150) tags_def_opt ::= tags_def */
{
248
,
-
1
},
/* (146) type_name ::= DECIMAL */
243
,
/* (151) tags_def ::= TAGS NK_LP column_def_list NK_RP */
{
248
,
-
4
},
/* (147) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */
241
,
/* (152) table_options ::= */
{
248
,
-
6
},
/* (148) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */
241
,
/* (153) table_options ::= table_options COMMENT NK_STRING */
{
240
,
0
},
/* (149) tags_def_opt ::= */
241
,
/* (154) table_options ::= table_options KEEP integer_list */
{
240
,
-
1
},
/* (150) tags_def_opt ::= tags_def */
241
,
/* (155) table_options ::= table_options KEEP variable_list */
{
243
,
-
4
},
/* (151) tags_def ::= TAGS NK_LP column_def_list NK_RP */
241
,
/* (156) table_options ::= table_options TTL NK_INTEGER */
{
241
,
0
},
/* (152) table_options ::= */
241
,
/* (157) table_options ::= table_options SMA NK_LP col_name_list NK_RP */
{
241
,
-
3
},
/* (153) table_options ::= table_options COMMENT NK_STRING */
241
,
/* (158) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */
{
241
,
-
3
},
/* (154) table_options ::= table_options KEEP integer_list */
241
,
/* (159) table_options ::= table_options FILE_FACTOR NK_FLOAT */
{
241
,
-
3
},
/* (155) table_options ::= table_options KEEP variable_list */
241
,
/* (160) table_options ::= table_options DELAY NK_INTEGER */
{
241
,
-
3
},
/* (156) table_options ::= table_options TTL NK_INTEGER */
246
,
/* (161) alter_table_options ::= alter_table_option */
{
241
,
-
5
},
/* (157) table_options ::= table_options SMA NK_LP col_name_list NK_RP */
246
,
/* (162) alter_table_options ::= alter_table_options alter_table_option */
{
241
,
-
5
},
/* (158) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */
257
,
/* (163) alter_table_option ::= COMMENT NK_STRING */
{
241
,
-
3
},
/* (159) table_options ::= table_options FILE_FACTOR NK_FLOAT */
257
,
/* (164) alter_table_option ::= KEEP integer_list */
{
241
,
-
3
},
/* (160) table_options ::= table_options DELAY NK_INTEGER */
257
,
/* (165) alter_table_option ::= KEEP variable_list */
{
246
,
-
1
},
/* (161) alter_table_options ::= alter_table_option */
257
,
/* (166) alter_table_option ::= TTL NK_INTEGER */
{
246
,
-
2
},
/* (162) alter_table_options ::= alter_table_options alter_table_option */
253
,
/* (167) col_name_list ::= col_name */
{
257
,
-
2
},
/* (163) alter_table_option ::= COMMENT NK_STRING */
253
,
/* (168) col_name_list ::= col_name_list NK_COMMA col_name */
{
257
,
-
2
},
/* (164) alter_table_option ::= KEEP integer_list */
258
,
/* (169) col_name ::= column_name */
{
257
,
-
2
},
/* (165) alter_table_option ::= KEEP variable_list */
220
,
/* (170) cmd ::= SHOW DNODES */
{
257
,
-
2
},
/* (166) alter_table_option ::= TTL NK_INTEGER */
220
,
/* (171) cmd ::= SHOW USERS */
{
253
,
-
1
},
/* (167) col_name_list ::= col_name */
220
,
/* (172) cmd ::= SHOW DATABASES */
{
253
,
-
3
},
/* (168) col_name_list ::= col_name_list NK_COMMA col_name */
220
,
/* (173) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */
{
258
,
-
1
},
/* (169) col_name ::= column_name */
220
,
/* (174) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */
{
220
,
-
2
},
/* (170) cmd ::= SHOW DNODES */
220
,
/* (175) cmd ::= SHOW db_name_cond_opt VGROUPS */
{
220
,
-
2
},
/* (171) cmd ::= SHOW USERS */
220
,
/* (176) cmd ::= SHOW MNODES */
{
220
,
-
2
},
/* (172) cmd ::= SHOW DATABASES */
220
,
/* (177) cmd ::= SHOW MODULES */
{
220
,
-
4
},
/* (173) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */
220
,
/* (178) cmd ::= SHOW QNODES */
{
220
,
-
4
},
/* (174) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */
220
,
/* (179) cmd ::= SHOW FUNCTIONS */
{
220
,
-
3
},
/* (175) cmd ::= SHOW db_name_cond_opt VGROUPS */
220
,
/* (180) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */
{
220
,
-
2
},
/* (176) cmd ::= SHOW MNODES */
220
,
/* (181) cmd ::= SHOW STREAMS */
{
220
,
-
2
},
/* (177) cmd ::= SHOW MODULES */
220
,
/* (182) cmd ::= SHOW ACCOUNTS */
{
220
,
-
2
},
/* (178) cmd ::= SHOW QNODES */
220
,
/* (183) cmd ::= SHOW APPS */
{
220
,
-
2
},
/* (179) cmd ::= SHOW FUNCTIONS */
220
,
/* (184) cmd ::= SHOW CONNECTIONS */
{
220
,
-
5
},
/* (180) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */
220
,
/* (185) cmd ::= SHOW LICENCE */
{
220
,
-
2
},
/* (181) cmd ::= SHOW STREAMS */
220
,
/* (186) cmd ::= SHOW GRANTS */
{
220
,
-
2
},
/* (182) cmd ::= SHOW ACCOUNTS */
220
,
/* (187) cmd ::= SHOW CREATE DATABASE db_name */
{
220
,
-
2
},
/* (183) cmd ::= SHOW APPS */
220
,
/* (188) cmd ::= SHOW CREATE TABLE full_table_name */
{
220
,
-
2
},
/* (184) cmd ::= SHOW CONNECTIONS */
220
,
/* (189) cmd ::= SHOW CREATE STABLE full_table_name */
{
220
,
-
2
},
/* (185) cmd ::= SHOW LICENCE */
220
,
/* (190) cmd ::= SHOW QUERIES */
{
220
,
-
2
},
/* (186) cmd ::= SHOW GRANTS */
220
,
/* (191) cmd ::= SHOW SCORES */
{
220
,
-
4
},
/* (187) cmd ::= SHOW CREATE DATABASE db_name */
220
,
/* (192) cmd ::= SHOW TOPICS */
{
220
,
-
4
},
/* (188) cmd ::= SHOW CREATE TABLE full_table_name */
220
,
/* (193) cmd ::= SHOW VARIABLES */
{
220
,
-
4
},
/* (189) cmd ::= SHOW CREATE STABLE full_table_name */
220
,
/* (194) cmd ::= SHOW BNODES */
{
220
,
-
2
},
/* (190) cmd ::= SHOW QUERIES */
220
,
/* (195) cmd ::= SHOW SNODES */
{
220
,
-
2
},
/* (191) cmd ::= SHOW SCORES */
259
,
/* (196) db_name_cond_opt ::= */
{
220
,
-
2
},
/* (192) cmd ::= SHOW TOPICS */
259
,
/* (197) db_name_cond_opt ::= db_name NK_DOT */
{
220
,
-
2
},
/* (193) cmd ::= SHOW VARIABLES */
260
,
/* (198) like_pattern_opt ::= */
{
220
,
-
2
},
/* (194) cmd ::= SHOW BNODES */
260
,
/* (199) like_pattern_opt ::= LIKE NK_STRING */
{
220
,
-
2
},
/* (195) cmd ::= SHOW SNODES */
261
,
/* (200) table_name_cond ::= table_name */
{
259
,
0
},
/* (196) db_name_cond_opt ::= */
262
,
/* (201) from_db_opt ::= */
{
259
,
-
2
},
/* (197) db_name_cond_opt ::= db_name NK_DOT */
262
,
/* (202) from_db_opt ::= FROM db_name */
{
260
,
0
},
/* (198) like_pattern_opt ::= */
256
,
/* (203) func_name_list ::= func_name */
{
260
,
-
2
},
/* (199) like_pattern_opt ::= LIKE NK_STRING */
256
,
/* (204) func_name_list ::= func_name_list NK_COMMA col_name */
{
261
,
-
1
},
/* (200) table_name_cond ::= table_name */
263
,
/* (205) func_name ::= function_name */
{
262
,
0
},
/* (201) from_db_opt ::= */
220
,
/* (206) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */
{
262
,
-
2
},
/* (202) from_db_opt ::= FROM db_name */
220
,
/* (207) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */
{
256
,
-
1
},
/* (203) func_name_list ::= func_name */
220
,
/* (208) cmd ::= DROP INDEX exists_opt index_name ON table_name */
{
256
,
-
3
},
/* (204) func_name_list ::= func_name_list NK_COMMA col_name */
266
,
/* (209) index_options ::= */
{
263
,
-
1
},
/* (205) func_name ::= function_name */
266
,
/* (210) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */
{
220
,
-
8
},
/* (206) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */
266
,
/* (211) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */
{
220
,
-
10
},
/* (207) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */
267
,
/* (212) func_list ::= func */
{
220
,
-
6
},
/* (208) cmd ::= DROP INDEX exists_opt index_name ON table_name */
267
,
/* (213) func_list ::= func_list NK_COMMA func */
{
266
,
0
},
/* (209) index_options ::= */
270
,
/* (214) func ::= function_name NK_LP expression_list NK_RP */
{
266
,
-
9
},
/* (210) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */
220
,
/* (215) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */
{
266
,
-
11
},
/* (211) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */
220
,
/* (216) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */
{
267
,
-
1
},
/* (212) func_list ::= func */
220
,
/* (217) cmd ::= DROP TOPIC exists_opt topic_name */
{
267
,
-
3
},
/* (213) func_list ::= func_list NK_COMMA func */
220
,
/* (218) cmd ::= DESC full_table_name */
{
270
,
-
4
},
/* (214) func ::= function_name NK_LP expression_list NK_RP */
220
,
/* (219) cmd ::= DESCRIBE full_table_name */
{
220
,
-
6
},
/* (215) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */
220
,
/* (220) cmd ::= RESET QUERY CACHE */
{
220
,
-
6
},
/* (216) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */
220
,
/* (221) cmd ::= EXPLAIN analyze_opt explain_options query_expression */
{
220
,
-
4
},
/* (217) cmd ::= DROP TOPIC exists_opt topic_name */
274
,
/* (222) analyze_opt ::= */
{
220
,
-
2
},
/* (218) cmd ::= DESC full_table_name */
274
,
/* (223) analyze_opt ::= ANALYZE */
{
220
,
-
2
},
/* (219) cmd ::= DESCRIBE full_table_name */
275
,
/* (224) explain_options ::= */
{
220
,
-
3
},
/* (220) cmd ::= RESET QUERY CACHE */
275
,
/* (225) explain_options ::= explain_options VERBOSE NK_BOOL */
{
220
,
-
4
},
/* (221) cmd ::= EXPLAIN analyze_opt explain_options query_expression */
275
,
/* (226) explain_options ::= explain_options RATIO NK_FLOAT */
{
274
,
0
},
/* (222) analyze_opt ::= */
220
,
/* (227) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */
{
274
,
-
1
},
/* (223) analyze_opt ::= ANALYZE */
220
,
/* (228) cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */
{
275
,
0
},
/* (224) explain_options ::= */
220
,
/* (229) cmd ::= DROP FUNCTION function_name */
{
275
,
-
3
},
/* (225) explain_options ::= explain_options VERBOSE NK_BOOL */
276
,
/* (230) agg_func_opt ::= */
{
275
,
-
3
},
/* (226) explain_options ::= explain_options RATIO NK_FLOAT */
276
,
/* (231) agg_func_opt ::= AGGREGATE */
{
220
,
-
6
},
/* (227) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */
277
,
/* (232) bufsize_opt ::= */
{
220
,
-
9
},
/* (228) cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */
277
,
/* (233) bufsize_opt ::= BUFSIZE NK_INTEGER */
{
220
,
-
3
},
/* (229) cmd ::= DROP FUNCTION function_name */
220
,
/* (234) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */
{
276
,
0
},
/* (230) agg_func_opt ::= */
220
,
/* (235) cmd ::= DROP STREAM exists_opt stream_name */
{
276
,
-
1
},
/* (231) agg_func_opt ::= AGGREGATE */
280
,
/* (236) into_opt ::= */
{
277
,
0
},
/* (232) bufsize_opt ::= */
280
,
/* (237) into_opt ::= INTO full_table_name */
{
277
,
-
2
},
/* (233) bufsize_opt ::= BUFSIZE NK_INTEGER */
279
,
/* (238) stream_options ::= */
{
220
,
-
8
},
/* (234) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */
279
,
/* (239) stream_options ::= stream_options TRIGGER AT_ONCE */
{
220
,
-
4
},
/* (235) cmd ::= DROP STREAM exists_opt stream_name */
279
,
/* (240) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */
{
280
,
0
},
/* (236) into_opt ::= */
279
,
/* (241) stream_options ::= stream_options WATERMARK duration_literal */
{
280
,
-
2
},
/* (237) into_opt ::= INTO full_table_name */
220
,
/* (242) cmd ::= KILL CONNECTION NK_INTEGER */
{
279
,
0
},
/* (238) stream_options ::= */
220
,
/* (243) cmd ::= KILL QUERY NK_INTEGER */
{
279
,
-
3
},
/* (239) stream_options ::= stream_options TRIGGER AT_ONCE */
220
,
/* (244) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */
{
279
,
-
3
},
/* (240) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */
220
,
/* (245) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */
{
279
,
-
3
},
/* (241) stream_options ::= stream_options WATERMARK duration_literal */
220
,
/* (246) cmd ::= SPLIT VGROUP NK_INTEGER */
{
220
,
-
3
},
/* (242) cmd ::= KILL CONNECTION NK_INTEGER */
281
,
/* (247) dnode_list ::= DNODE NK_INTEGER */
{
220
,
-
3
},
/* (243) cmd ::= KILL QUERY NK_INTEGER */
281
,
/* (248) dnode_list ::= dnode_list DNODE NK_INTEGER */
{
220
,
-
4
},
/* (244) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */
220
,
/* (249) cmd ::= SYNCDB db_name REPLICA */
{
220
,
-
4
},
/* (245) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */
220
,
/* (250) cmd ::= query_expression */
{
220
,
-
3
},
/* (246) cmd ::= SPLIT VGROUP NK_INTEGER */
223
,
/* (251) literal ::= NK_INTEGER */
{
281
,
-
2
},
/* (247) dnode_list ::= DNODE NK_INTEGER */
223
,
/* (252) literal ::= NK_FLOAT */
{
281
,
-
3
},
/* (248) dnode_list ::= dnode_list DNODE NK_INTEGER */
223
,
/* (253) literal ::= NK_STRING */
{
220
,
-
3
},
/* (249) cmd ::= SYNCDB db_name REPLICA */
223
,
/* (254) literal ::= NK_BOOL */
{
220
,
-
1
},
/* (250) cmd ::= query_expression */
223
,
/* (255) literal ::= TIMESTAMP NK_STRING */
{
223
,
-
1
},
/* (251) literal ::= NK_INTEGER */
223
,
/* (256) literal ::= duration_literal */
{
223
,
-
1
},
/* (252) literal ::= NK_FLOAT */
223
,
/* (257) literal ::= NULL */
{
223
,
-
1
},
/* (253) literal ::= NK_STRING */
223
,
/* (258) literal ::= NK_QUESTION */
{
223
,
-
1
},
/* (254) literal ::= NK_BOOL */
268
,
/* (259) duration_literal ::= NK_VARIABLE */
{
223
,
-
2
},
/* (255) literal ::= TIMESTAMP NK_STRING */
282
,
/* (260) signed ::= NK_INTEGER */
{
223
,
-
1
},
/* (256) literal ::= duration_literal */
282
,
/* (261) signed ::= NK_PLUS NK_INTEGER */
{
223
,
-
1
},
/* (257) literal ::= NULL */
282
,
/* (262) signed ::= NK_MINUS NK_INTEGER */
{
223
,
-
1
},
/* (258) literal ::= NK_QUESTION */
282
,
/* (263) signed ::= NK_FLOAT */
{
268
,
-
1
},
/* (259) duration_literal ::= NK_VARIABLE */
282
,
/* (264) signed ::= NK_PLUS NK_FLOAT */
{
282
,
-
1
},
/* (260) signed ::= NK_INTEGER */
282
,
/* (265) signed ::= NK_MINUS NK_FLOAT */
{
282
,
-
2
},
/* (261) signed ::= NK_PLUS NK_INTEGER */
283
,
/* (266) signed_literal ::= signed */
{
282
,
-
2
},
/* (262) signed ::= NK_MINUS NK_INTEGER */
283
,
/* (267) signed_literal ::= NK_STRING */
{
282
,
-
1
},
/* (263) signed ::= NK_FLOAT */
283
,
/* (268) signed_literal ::= NK_BOOL */
{
282
,
-
2
},
/* (264) signed ::= NK_PLUS NK_FLOAT */
283
,
/* (269) signed_literal ::= TIMESTAMP NK_STRING */
{
282
,
-
2
},
/* (265) signed ::= NK_MINUS NK_FLOAT */
283
,
/* (270) signed_literal ::= duration_literal */
{
283
,
-
1
},
/* (266) signed_literal ::= signed */
283
,
/* (271) signed_literal ::= NULL */
{
283
,
-
1
},
/* (267) signed_literal ::= NK_STRING */
251
,
/* (272) literal_list ::= signed_literal */
{
283
,
-
1
},
/* (268) signed_literal ::= NK_BOOL */
251
,
/* (273) literal_list ::= literal_list NK_COMMA signed_literal */
{
283
,
-
2
},
/* (269) signed_literal ::= TIMESTAMP NK_STRING */
229
,
/* (274) db_name ::= NK_ID */
{
283
,
-
1
},
/* (270) signed_literal ::= duration_literal */
254
,
/* (275) table_name ::= NK_ID */
{
283
,
-
1
},
/* (271) signed_literal ::= NULL */
247
,
/* (276) column_name ::= NK_ID */
{
251
,
-
1
},
/* (272) literal_list ::= signed_literal */
264
,
/* (277) function_name ::= NK_ID */
{
251
,
-
3
},
/* (273) literal_list ::= literal_list NK_COMMA signed_literal */
284
,
/* (278) table_alias ::= NK_ID */
{
229
,
-
1
},
/* (274) db_name ::= NK_ID */
285
,
/* (279) column_alias ::= NK_ID */
{
254
,
-
1
},
/* (275) table_name ::= NK_ID */
225
,
/* (280) user_name ::= NK_ID */
{
247
,
-
1
},
/* (276) column_name ::= NK_ID */
265
,
/* (281) index_name ::= NK_ID */
{
264
,
-
1
},
/* (277) function_name ::= NK_ID */
272
,
/* (282) topic_name ::= NK_ID */
{
284
,
-
1
},
/* (278) table_alias ::= NK_ID */
278
,
/* (283) stream_name ::= NK_ID */
{
285
,
-
1
},
/* (279) column_alias ::= NK_ID */
286
,
/* (284) expression ::= literal */
{
225
,
-
1
},
/* (280) user_name ::= NK_ID */
286
,
/* (285) expression ::= pseudo_column */
{
265
,
-
1
},
/* (281) index_name ::= NK_ID */
286
,
/* (286) expression ::= column_reference */
{
272
,
-
1
},
/* (282) topic_name ::= NK_ID */
286
,
/* (287) expression ::= function_expression */
{
278
,
-
1
},
/* (283) stream_name ::= NK_ID */
286
,
/* (288) expression ::= subquery */
{
286
,
-
1
},
/* (284) expression ::= literal */
286
,
/* (289) expression ::= NK_LP expression NK_RP */
{
286
,
-
1
},
/* (285) expression ::= pseudo_column */
286
,
/* (290) expression ::= NK_PLUS expression */
{
286
,
-
1
},
/* (286) expression ::= column_reference */
286
,
/* (291) expression ::= NK_MINUS expression */
{
286
,
-
1
},
/* (287) expression ::= function_expression */
286
,
/* (292) expression ::= expression NK_PLUS expression */
{
286
,
-
1
},
/* (288) expression ::= subquery */
286
,
/* (293) expression ::= expression NK_MINUS expression */
{
286
,
-
3
},
/* (289) expression ::= NK_LP expression NK_RP */
286
,
/* (294) expression ::= expression NK_STAR expression */
{
286
,
-
2
},
/* (290) expression ::= NK_PLUS expression */
286
,
/* (295) expression ::= expression NK_SLASH expression */
{
286
,
-
2
},
/* (291) expression ::= NK_MINUS expression */
286
,
/* (296) expression ::= expression NK_REM expression */
{
286
,
-
3
},
/* (292) expression ::= expression NK_PLUS expression */
286
,
/* (297) expression ::= column_reference NK_ARROW NK_STRING */
{
286
,
-
3
},
/* (293) expression ::= expression NK_MINUS expression */
271
,
/* (298) expression_list ::= expression */
{
286
,
-
3
},
/* (294) expression ::= expression NK_STAR expression */
271
,
/* (299) expression_list ::= expression_list NK_COMMA expression */
{
286
,
-
3
},
/* (295) expression ::= expression NK_SLASH expression */
288
,
/* (300) column_reference ::= column_name */
{
286
,
-
3
},
/* (296) expression ::= expression NK_REM expression */
288
,
/* (301) column_reference ::= table_name NK_DOT column_name */
{
286
,
-
3
},
/* (297) expression ::= column_reference NK_ARROW NK_STRING */
287
,
/* (302) pseudo_column ::= ROWTS */
{
271
,
-
1
},
/* (298) expression_list ::= expression */
287
,
/* (303) pseudo_column ::= TBNAME */
{
271
,
-
3
},
/* (299) expression_list ::= expression_list NK_COMMA expression */
287
,
/* (304) pseudo_column ::= QSTARTTS */
{
288
,
-
1
},
/* (300) column_reference ::= column_name */
287
,
/* (305) pseudo_column ::= QENDTS */
{
288
,
-
3
},
/* (301) column_reference ::= table_name NK_DOT column_name */
287
,
/* (306) pseudo_column ::= WSTARTTS */
{
287
,
-
1
},
/* (302) pseudo_column ::= ROWTS */
287
,
/* (307) pseudo_column ::= WENDTS */
{
287
,
-
1
},
/* (303) pseudo_column ::= TBNAME */
287
,
/* (308) pseudo_column ::= WDURATION */
{
287
,
-
1
},
/* (304) pseudo_column ::= QSTARTTS */
289
,
/* (309) function_expression ::= function_name NK_LP expression_list NK_RP */
{
287
,
-
1
},
/* (305) pseudo_column ::= QENDTS */
289
,
/* (310) function_expression ::= star_func NK_LP star_func_para_list NK_RP */
{
287
,
-
1
},
/* (306) pseudo_column ::= WSTARTTS */
289
,
/* (311) function_expression ::= CAST NK_LP expression AS type_name NK_RP */
{
287
,
-
1
},
/* (307) pseudo_column ::= WENDTS */
289
,
/* (312) function_expression ::= noarg_func NK_LP NK_RP */
{
287
,
-
1
},
/* (308) pseudo_column ::= WDURATION */
293
,
/* (313) noarg_func ::= NOW */
{
289
,
-
4
},
/* (309) function_expression ::= function_name NK_LP expression_list NK_RP */
293
,
/* (314) noarg_func ::= TODAY */
{
289
,
-
4
},
/* (310) function_expression ::= star_func NK_LP star_func_para_list NK_RP */
293
,
/* (315) noarg_func ::= TIMEZONE */
{
289
,
-
6
},
/* (311) function_expression ::= CAST NK_LP expression AS type_name NK_RP */
291
,
/* (316) star_func ::= COUNT */
{
289
,
-
3
},
/* (312) function_expression ::= noarg_func NK_LP NK_RP */
291
,
/* (317) star_func ::= FIRST */
{
293
,
-
1
},
/* (313) noarg_func ::= NOW */
291
,
/* (318) star_func ::= LAST */
{
293
,
-
1
},
/* (314) noarg_func ::= TODAY */
291
,
/* (319) star_func ::= LAST_ROW */
{
293
,
-
1
},
/* (315) noarg_func ::= TIMEZONE */
292
,
/* (320) star_func_para_list ::= NK_STAR */
{
291
,
-
1
},
/* (316) star_func ::= COUNT */
292
,
/* (321) star_func_para_list ::= other_para_list */
{
291
,
-
1
},
/* (317) star_func ::= FIRST */
294
,
/* (322) other_para_list ::= star_func_para */
{
291
,
-
1
},
/* (318) star_func ::= LAST */
294
,
/* (323) other_para_list ::= other_para_list NK_COMMA star_func_para */
{
291
,
-
1
},
/* (319) star_func ::= LAST_ROW */
295
,
/* (324) star_func_para ::= expression */
{
292
,
-
1
},
/* (320) star_func_para_list ::= NK_STAR */
295
,
/* (325) star_func_para ::= table_name NK_DOT NK_STAR */
{
292
,
-
1
},
/* (321) star_func_para_list ::= other_para_list */
296
,
/* (326) predicate ::= expression compare_op expression */
{
294
,
-
1
},
/* (322) other_para_list ::= star_func_para */
296
,
/* (327) predicate ::= expression BETWEEN expression AND expression */
{
294
,
-
3
},
/* (323) other_para_list ::= other_para_list NK_COMMA star_func_para */
296
,
/* (328) predicate ::= expression NOT BETWEEN expression AND expression */
{
295
,
-
1
},
/* (324) star_func_para ::= expression */
296
,
/* (329) predicate ::= expression IS NULL */
{
295
,
-
3
},
/* (325) star_func_para ::= table_name NK_DOT NK_STAR */
296
,
/* (330) predicate ::= expression IS NOT NULL */
{
296
,
-
3
},
/* (326) predicate ::= expression compare_op expression */
296
,
/* (331) predicate ::= expression in_op in_predicate_value */
{
296
,
-
5
},
/* (327) predicate ::= expression BETWEEN expression AND expression */
297
,
/* (332) compare_op ::= NK_LT */
{
296
,
-
6
},
/* (328) predicate ::= expression NOT BETWEEN expression AND expression */
297
,
/* (333) compare_op ::= NK_GT */
{
296
,
-
3
},
/* (329) predicate ::= expression IS NULL */
297
,
/* (334) compare_op ::= NK_LE */
{
296
,
-
4
},
/* (330) predicate ::= expression IS NOT NULL */
297
,
/* (335) compare_op ::= NK_GE */
{
296
,
-
3
},
/* (331) predicate ::= expression in_op in_predicate_value */
297
,
/* (336) compare_op ::= NK_NE */
{
297
,
-
1
},
/* (332) compare_op ::= NK_LT */
297
,
/* (337) compare_op ::= NK_EQ */
{
297
,
-
1
},
/* (333) compare_op ::= NK_GT */
297
,
/* (338) compare_op ::= LIKE */
{
297
,
-
1
},
/* (334) compare_op ::= NK_LE */
297
,
/* (339) compare_op ::= NOT LIKE */
{
297
,
-
1
},
/* (335) compare_op ::= NK_GE */
297
,
/* (340) compare_op ::= MATCH */
{
297
,
-
1
},
/* (336) compare_op ::= NK_NE */
297
,
/* (341) compare_op ::= NMATCH */
{
297
,
-
1
},
/* (337) compare_op ::= NK_EQ */
297
,
/* (342) compare_op ::= CONTAINS */
{
297
,
-
1
},
/* (338) compare_op ::= LIKE */
298
,
/* (343) in_op ::= IN */
{
297
,
-
2
},
/* (339) compare_op ::= NOT LIKE */
298
,
/* (344) in_op ::= NOT IN */
{
297
,
-
1
},
/* (340) compare_op ::= MATCH */
299
,
/* (345) in_predicate_value ::= NK_LP expression_list NK_RP */
{
297
,
-
1
},
/* (341) compare_op ::= NMATCH */
300
,
/* (346) boolean_value_expression ::= boolean_primary */
{
297
,
-
1
},
/* (342) compare_op ::= CONTAINS */
300
,
/* (347) boolean_value_expression ::= NOT boolean_primary */
{
298
,
-
1
},
/* (343) in_op ::= IN */
300
,
/* (348) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
{
298
,
-
2
},
/* (344) in_op ::= NOT IN */
300
,
/* (349) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
{
299
,
-
3
},
/* (345) in_predicate_value ::= NK_LP expression_list NK_RP */
301
,
/* (350) boolean_primary ::= predicate */
{
300
,
-
1
},
/* (346) boolean_value_expression ::= boolean_primary */
301
,
/* (351) boolean_primary ::= NK_LP boolean_value_expression NK_RP */
{
300
,
-
2
},
/* (347) boolean_value_expression ::= NOT boolean_primary */
302
,
/* (352) common_expression ::= expression */
{
300
,
-
3
},
/* (348) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
302
,
/* (353) common_expression ::= boolean_value_expression */
{
300
,
-
3
},
/* (349) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
303
,
/* (354) from_clause ::= FROM table_reference_list */
{
301
,
-
1
},
/* (350) boolean_primary ::= predicate */
304
,
/* (355) table_reference_list ::= table_reference */
{
301
,
-
3
},
/* (351) boolean_primary ::= NK_LP boolean_value_expression NK_RP */
304
,
/* (356) table_reference_list ::= table_reference_list NK_COMMA table_reference */
{
302
,
-
1
},
/* (352) common_expression ::= expression */
305
,
/* (357) table_reference ::= table_primary */
{
302
,
-
1
},
/* (353) common_expression ::= boolean_value_expression */
305
,
/* (358) table_reference ::= joined_table */
{
303
,
-
2
},
/* (354) from_clause ::= FROM table_reference_list */
306
,
/* (359) table_primary ::= table_name alias_opt */
{
304
,
-
1
},
/* (355) table_reference_list ::= table_reference */
306
,
/* (360) table_primary ::= db_name NK_DOT table_name alias_opt */
{
304
,
-
3
},
/* (356) table_reference_list ::= table_reference_list NK_COMMA table_reference */
306
,
/* (361) table_primary ::= subquery alias_opt */
{
305
,
-
1
},
/* (357) table_reference ::= table_primary */
306
,
/* (362) table_primary ::= parenthesized_joined_table */
{
305
,
-
1
},
/* (358) table_reference ::= joined_table */
308
,
/* (363) alias_opt ::= */
{
306
,
-
2
},
/* (359) table_primary ::= table_name alias_opt */
308
,
/* (364) alias_opt ::= table_alias */
{
306
,
-
4
},
/* (360) table_primary ::= db_name NK_DOT table_name alias_opt */
308
,
/* (365) alias_opt ::= AS table_alias */
{
306
,
-
2
},
/* (361) table_primary ::= subquery alias_opt */
309
,
/* (366) parenthesized_joined_table ::= NK_LP joined_table NK_RP */
{
306
,
-
1
},
/* (362) table_primary ::= parenthesized_joined_table */
309
,
/* (367) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
{
308
,
0
},
/* (363) alias_opt ::= */
307
,
/* (368) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
{
308
,
-
1
},
/* (364) alias_opt ::= table_alias */
310
,
/* (369) join_type ::= */
{
308
,
-
2
},
/* (365) alias_opt ::= AS table_alias */
310
,
/* (370) join_type ::= INNER */
{
309
,
-
3
},
/* (366) parenthesized_joined_table ::= NK_LP joined_table NK_RP */
312
,
/* (371) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
{
309
,
-
3
},
/* (367) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
313
,
/* (372) set_quantifier_opt ::= */
{
307
,
-
6
},
/* (368) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
313
,
/* (373) set_quantifier_opt ::= DISTINCT */
{
310
,
0
},
/* (369) join_type ::= */
313
,
/* (374) set_quantifier_opt ::= ALL */
{
310
,
-
1
},
/* (370) join_type ::= INNER */
314
,
/* (375) select_list ::= NK_STAR */
{
312
,
-
9
},
/* (371) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
314
,
/* (376) select_list ::= select_sublist */
{
313
,
0
},
/* (372) set_quantifier_opt ::= */
320
,
/* (377) select_sublist ::= select_item */
{
313
,
-
1
},
/* (373) set_quantifier_opt ::= DISTINCT */
320
,
/* (378) select_sublist ::= select_sublist NK_COMMA select_item */
{
313
,
-
1
},
/* (374) set_quantifier_opt ::= ALL */
321
,
/* (379) select_item ::= common_expression */
{
314
,
-
1
},
/* (375) select_list ::= NK_STAR */
321
,
/* (380) select_item ::= common_expression column_alias */
{
314
,
-
1
},
/* (376) select_list ::= select_sublist */
321
,
/* (381) select_item ::= common_expression AS column_alias */
{
320
,
-
1
},
/* (377) select_sublist ::= select_item */
321
,
/* (382) select_item ::= table_name NK_DOT NK_STAR */
{
320
,
-
3
},
/* (378) select_sublist ::= select_sublist NK_COMMA select_item */
315
,
/* (383) where_clause_opt ::= */
{
321
,
-
1
},
/* (379) select_item ::= common_expression */
315
,
/* (384) where_clause_opt ::= WHERE search_condition */
{
321
,
-
2
},
/* (380) select_item ::= common_expression column_alias */
316
,
/* (385) partition_by_clause_opt ::= */
{
321
,
-
3
},
/* (381) select_item ::= common_expression AS column_alias */
316
,
/* (386) partition_by_clause_opt ::= PARTITION BY expression_list */
{
321
,
-
3
},
/* (382) select_item ::= table_name NK_DOT NK_STAR */
317
,
/* (387) twindow_clause_opt ::= */
{
315
,
0
},
/* (383) where_clause_opt ::= */
317
,
/* (388) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */
{
315
,
-
2
},
/* (384) where_clause_opt ::= WHERE search_condition */
317
,
/* (389) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */
{
316
,
0
},
/* (385) partition_by_clause_opt ::= */
317
,
/* (390) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
{
316
,
-
3
},
/* (386) partition_by_clause_opt ::= PARTITION BY expression_list */
317
,
/* (391) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
{
317
,
0
},
/* (387) twindow_clause_opt ::= */
269
,
/* (392) sliding_opt ::= */
{
317
,
-
6
},
/* (388) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */
269
,
/* (393) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
{
317
,
-
4
},
/* (389) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */
322
,
/* (394) fill_opt ::= */
{
317
,
-
6
},
/* (390) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
322
,
/* (395) fill_opt ::= FILL NK_LP fill_mode NK_RP */
{
317
,
-
8
},
/* (391) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
322
,
/* (396) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
{
269
,
0
},
/* (392) sliding_opt ::= */
323
,
/* (397) fill_mode ::= NONE */
{
269
,
-
4
},
/* (393) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
323
,
/* (398) fill_mode ::= PREV */
{
322
,
0
},
/* (394) fill_opt ::= */
323
,
/* (399) fill_mode ::= NULL */
{
322
,
-
4
},
/* (395) fill_opt ::= FILL NK_LP fill_mode NK_RP */
323
,
/* (400) fill_mode ::= LINEAR */
{
322
,
-
6
},
/* (396) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
323
,
/* (401) fill_mode ::= NEXT */
{
323
,
-
1
},
/* (397) fill_mode ::= NONE */
318
,
/* (402) group_by_clause_opt ::= */
{
323
,
-
1
},
/* (398) fill_mode ::= PREV */
318
,
/* (403) group_by_clause_opt ::= GROUP BY group_by_list */
{
323
,
-
1
},
/* (399) fill_mode ::= NULL */
324
,
/* (404) group_by_list ::= expression */
{
323
,
-
1
},
/* (400) fill_mode ::= LINEAR */
324
,
/* (405) group_by_list ::= group_by_list NK_COMMA expression */
{
323
,
-
1
},
/* (401) fill_mode ::= NEXT */
319
,
/* (406) having_clause_opt ::= */
{
318
,
0
},
/* (402) group_by_clause_opt ::= */
319
,
/* (407) having_clause_opt ::= HAVING search_condition */
{
318
,
-
3
},
/* (403) group_by_clause_opt ::= GROUP BY group_by_list */
273
,
/* (408) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
{
324
,
-
1
},
/* (404) group_by_list ::= expression */
325
,
/* (409) query_expression_body ::= query_primary */
{
324
,
-
3
},
/* (405) group_by_list ::= group_by_list NK_COMMA expression */
325
,
/* (410) query_expression_body ::= query_expression_body UNION ALL query_expression_body */
{
319
,
0
},
/* (406) having_clause_opt ::= */
329
,
/* (411) query_primary ::= query_specification */
{
319
,
-
2
},
/* (407) having_clause_opt ::= HAVING search_condition */
326
,
/* (412) order_by_clause_opt ::= */
{
273
,
-
4
},
/* (408) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
326
,
/* (413) order_by_clause_opt ::= ORDER BY sort_specification_list */
{
325
,
-
1
},
/* (409) query_expression_body ::= query_primary */
327
,
/* (414) slimit_clause_opt ::= */
{
325
,
-
4
},
/* (410) query_expression_body ::= query_expression_body UNION ALL query_expression_body */
327
,
/* (415) slimit_clause_opt ::= SLIMIT NK_INTEGER */
{
329
,
-
1
},
/* (411) query_primary ::= query_specification */
327
,
/* (416) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
{
326
,
0
},
/* (412) order_by_clause_opt ::= */
327
,
/* (417) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
{
326
,
-
3
},
/* (413) order_by_clause_opt ::= ORDER BY sort_specification_list */
328
,
/* (418) limit_clause_opt ::= */
{
327
,
0
},
/* (414) slimit_clause_opt ::= */
328
,
/* (419) limit_clause_opt ::= LIMIT NK_INTEGER */
{
327
,
-
2
},
/* (415) slimit_clause_opt ::= SLIMIT NK_INTEGER */
328
,
/* (420) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
{
327
,
-
4
},
/* (416) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
328
,
/* (421) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
{
327
,
-
4
},
/* (417) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
290
,
/* (422) subquery ::= NK_LP query_expression NK_RP */
{
328
,
0
},
/* (418) limit_clause_opt ::= */
311
,
/* (423) search_condition ::= common_expression */
{
328
,
-
2
},
/* (419) limit_clause_opt ::= LIMIT NK_INTEGER */
330
,
/* (424) sort_specification_list ::= sort_specification */
{
328
,
-
4
},
/* (420) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
330
,
/* (425) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
{
328
,
-
4
},
/* (421) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
331
,
/* (426) sort_specification ::= expression ordering_specification_opt null_ordering_opt */
{
290
,
-
3
},
/* (422) subquery ::= NK_LP query_expression NK_RP */
332
,
/* (427) ordering_specification_opt ::= */
{
311
,
-
1
},
/* (423) search_condition ::= common_expression */
332
,
/* (428) ordering_specification_opt ::= ASC */
{
330
,
-
1
},
/* (424) sort_specification_list ::= sort_specification */
332
,
/* (429) ordering_specification_opt ::= DESC */
{
330
,
-
3
},
/* (425) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
333
,
/* (430) null_ordering_opt ::= */
{
331
,
-
3
},
/* (426) sort_specification ::= expression ordering_specification_opt null_ordering_opt */
333
,
/* (431) null_ordering_opt ::= NULLS FIRST */
{
332
,
0
},
/* (427) ordering_specification_opt ::= */
333
,
/* (432) null_ordering_opt ::= NULLS LAST */
{
332
,
-
1
},
/* (428) ordering_specification_opt ::= ASC */
};
{
332
,
-
1
},
/* (429) ordering_specification_opt ::= DESC */
{
333
,
0
},
/* (430) null_ordering_opt ::= */
/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
{
333
,
-
2
},
/* (431) null_ordering_opt ::= NULLS FIRST */
** of symbols on the right-hand side of that rule. */
{
333
,
-
2
},
/* (432) null_ordering_opt ::= NULLS LAST */
static
const
signed
char
yyRuleInfoNRhs
[]
=
{
-
6
,
/* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */
-
4
,
/* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */
0
,
/* (2) account_options ::= */
-
3
,
/* (3) account_options ::= account_options PPS literal */
-
3
,
/* (4) account_options ::= account_options TSERIES literal */
-
3
,
/* (5) account_options ::= account_options STORAGE literal */
-
3
,
/* (6) account_options ::= account_options STREAMS literal */
-
3
,
/* (7) account_options ::= account_options QTIME literal */
-
3
,
/* (8) account_options ::= account_options DBS literal */
-
3
,
/* (9) account_options ::= account_options USERS literal */
-
3
,
/* (10) account_options ::= account_options CONNS literal */
-
3
,
/* (11) account_options ::= account_options STATE literal */
-
1
,
/* (12) alter_account_options ::= alter_account_option */
-
2
,
/* (13) alter_account_options ::= alter_account_options alter_account_option */
-
2
,
/* (14) alter_account_option ::= PASS literal */
-
2
,
/* (15) alter_account_option ::= PPS literal */
-
2
,
/* (16) alter_account_option ::= TSERIES literal */
-
2
,
/* (17) alter_account_option ::= STORAGE literal */
-
2
,
/* (18) alter_account_option ::= STREAMS literal */
-
2
,
/* (19) alter_account_option ::= QTIME literal */
-
2
,
/* (20) alter_account_option ::= DBS literal */
-
2
,
/* (21) alter_account_option ::= USERS literal */
-
2
,
/* (22) alter_account_option ::= CONNS literal */
-
2
,
/* (23) alter_account_option ::= STATE literal */
-
5
,
/* (24) cmd ::= CREATE USER user_name PASS NK_STRING */
-
5
,
/* (25) cmd ::= ALTER USER user_name PASS NK_STRING */
-
5
,
/* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */
-
3
,
/* (27) cmd ::= DROP USER user_name */
-
3
,
/* (28) cmd ::= CREATE DNODE dnode_endpoint */
-
5
,
/* (29) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */
-
3
,
/* (30) cmd ::= DROP DNODE NK_INTEGER */
-
3
,
/* (31) cmd ::= DROP DNODE dnode_endpoint */
-
4
,
/* (32) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */
-
5
,
/* (33) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */
-
4
,
/* (34) cmd ::= ALTER ALL DNODES NK_STRING */
-
5
,
/* (35) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */
-
1
,
/* (36) dnode_endpoint ::= NK_STRING */
-
1
,
/* (37) dnode_host_name ::= NK_ID */
-
1
,
/* (38) dnode_host_name ::= NK_IPTOKEN */
-
3
,
/* (39) cmd ::= ALTER LOCAL NK_STRING */
-
4
,
/* (40) cmd ::= ALTER LOCAL NK_STRING NK_STRING */
-
5
,
/* (41) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */
-
5
,
/* (42) cmd ::= DROP QNODE ON DNODE NK_INTEGER */
-
5
,
/* (43) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */
-
5
,
/* (44) cmd ::= DROP BNODE ON DNODE NK_INTEGER */
-
5
,
/* (45) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */
-
5
,
/* (46) cmd ::= DROP SNODE ON DNODE NK_INTEGER */
-
5
,
/* (47) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */
-
5
,
/* (48) cmd ::= DROP MNODE ON DNODE NK_INTEGER */
-
5
,
/* (49) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */
-
4
,
/* (50) cmd ::= DROP DATABASE exists_opt db_name */
-
2
,
/* (51) cmd ::= USE db_name */
-
4
,
/* (52) cmd ::= ALTER DATABASE db_name alter_db_options */
-
3
,
/* (53) not_exists_opt ::= IF NOT EXISTS */
0
,
/* (54) not_exists_opt ::= */
-
2
,
/* (55) exists_opt ::= IF EXISTS */
0
,
/* (56) exists_opt ::= */
0
,
/* (57) db_options ::= */
-
3
,
/* (58) db_options ::= db_options BLOCKS NK_INTEGER */
-
3
,
/* (59) db_options ::= db_options CACHE NK_INTEGER */
-
3
,
/* (60) db_options ::= db_options CACHELAST NK_INTEGER */
-
3
,
/* (61) db_options ::= db_options COMP NK_INTEGER */
-
3
,
/* (62) db_options ::= db_options DAYS NK_INTEGER */
-
3
,
/* (63) db_options ::= db_options DAYS NK_VARIABLE */
-
3
,
/* (64) db_options ::= db_options FSYNC NK_INTEGER */
-
3
,
/* (65) db_options ::= db_options MAXROWS NK_INTEGER */
-
3
,
/* (66) db_options ::= db_options MINROWS NK_INTEGER */
-
3
,
/* (67) db_options ::= db_options KEEP integer_list */
-
3
,
/* (68) db_options ::= db_options KEEP variable_list */
-
3
,
/* (69) db_options ::= db_options PRECISION NK_STRING */
-
3
,
/* (70) db_options ::= db_options QUORUM NK_INTEGER */
-
3
,
/* (71) db_options ::= db_options REPLICA NK_INTEGER */
-
3
,
/* (72) db_options ::= db_options TTL NK_INTEGER */
-
3
,
/* (73) db_options ::= db_options WAL NK_INTEGER */
-
3
,
/* (74) db_options ::= db_options VGROUPS NK_INTEGER */
-
3
,
/* (75) db_options ::= db_options SINGLE_STABLE NK_INTEGER */
-
3
,
/* (76) db_options ::= db_options STREAM_MODE NK_INTEGER */
-
3
,
/* (77) db_options ::= db_options RETENTIONS retention_list */
-
1
,
/* (78) alter_db_options ::= alter_db_option */
-
2
,
/* (79) alter_db_options ::= alter_db_options alter_db_option */
-
2
,
/* (80) alter_db_option ::= BLOCKS NK_INTEGER */
-
2
,
/* (81) alter_db_option ::= FSYNC NK_INTEGER */
-
2
,
/* (82) alter_db_option ::= KEEP integer_list */
-
2
,
/* (83) alter_db_option ::= KEEP variable_list */
-
2
,
/* (84) alter_db_option ::= WAL NK_INTEGER */
-
2
,
/* (85) alter_db_option ::= QUORUM NK_INTEGER */
-
2
,
/* (86) alter_db_option ::= CACHELAST NK_INTEGER */
-
2
,
/* (87) alter_db_option ::= REPLICA NK_INTEGER */
-
1
,
/* (88) integer_list ::= NK_INTEGER */
-
3
,
/* (89) integer_list ::= integer_list NK_COMMA NK_INTEGER */
-
1
,
/* (90) variable_list ::= NK_VARIABLE */
-
3
,
/* (91) variable_list ::= variable_list NK_COMMA NK_VARIABLE */
-
1
,
/* (92) retention_list ::= retention */
-
3
,
/* (93) retention_list ::= retention_list NK_COMMA retention */
-
3
,
/* (94) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */
-
9
,
/* (95) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */
-
3
,
/* (96) cmd ::= CREATE TABLE multi_create_clause */
-
9
,
/* (97) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */
-
3
,
/* (98) cmd ::= DROP TABLE multi_drop_clause */
-
4
,
/* (99) cmd ::= DROP STABLE exists_opt full_table_name */
-
3
,
/* (100) cmd ::= ALTER TABLE alter_table_clause */
-
3
,
/* (101) cmd ::= ALTER STABLE alter_table_clause */
-
2
,
/* (102) alter_table_clause ::= full_table_name alter_table_options */
-
5
,
/* (103) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */
-
4
,
/* (104) alter_table_clause ::= full_table_name DROP COLUMN column_name */
-
5
,
/* (105) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */
-
5
,
/* (106) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */
-
5
,
/* (107) alter_table_clause ::= full_table_name ADD TAG column_name type_name */
-
4
,
/* (108) alter_table_clause ::= full_table_name DROP TAG column_name */
-
5
,
/* (109) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */
-
5
,
/* (110) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */
-
6
,
/* (111) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */
-
1
,
/* (112) multi_create_clause ::= create_subtable_clause */
-
2
,
/* (113) multi_create_clause ::= multi_create_clause create_subtable_clause */
-
9
,
/* (114) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */
-
1
,
/* (115) multi_drop_clause ::= drop_table_clause */
-
2
,
/* (116) multi_drop_clause ::= multi_drop_clause drop_table_clause */
-
2
,
/* (117) drop_table_clause ::= exists_opt full_table_name */
0
,
/* (118) specific_tags_opt ::= */
-
3
,
/* (119) specific_tags_opt ::= NK_LP col_name_list NK_RP */
-
1
,
/* (120) full_table_name ::= table_name */
-
3
,
/* (121) full_table_name ::= db_name NK_DOT table_name */
-
1
,
/* (122) column_def_list ::= column_def */
-
3
,
/* (123) column_def_list ::= column_def_list NK_COMMA column_def */
-
2
,
/* (124) column_def ::= column_name type_name */
-
4
,
/* (125) column_def ::= column_name type_name COMMENT NK_STRING */
-
1
,
/* (126) type_name ::= BOOL */
-
1
,
/* (127) type_name ::= TINYINT */
-
1
,
/* (128) type_name ::= SMALLINT */
-
1
,
/* (129) type_name ::= INT */
-
1
,
/* (130) type_name ::= INTEGER */
-
1
,
/* (131) type_name ::= BIGINT */
-
1
,
/* (132) type_name ::= FLOAT */
-
1
,
/* (133) type_name ::= DOUBLE */
-
4
,
/* (134) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */
-
1
,
/* (135) type_name ::= TIMESTAMP */
-
4
,
/* (136) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */
-
2
,
/* (137) type_name ::= TINYINT UNSIGNED */
-
2
,
/* (138) type_name ::= SMALLINT UNSIGNED */
-
2
,
/* (139) type_name ::= INT UNSIGNED */
-
2
,
/* (140) type_name ::= BIGINT UNSIGNED */
-
1
,
/* (141) type_name ::= JSON */
-
4
,
/* (142) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */
-
1
,
/* (143) type_name ::= MEDIUMBLOB */
-
1
,
/* (144) type_name ::= BLOB */
-
4
,
/* (145) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */
-
1
,
/* (146) type_name ::= DECIMAL */
-
4
,
/* (147) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */
-
6
,
/* (148) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */
0
,
/* (149) tags_def_opt ::= */
-
1
,
/* (150) tags_def_opt ::= tags_def */
-
4
,
/* (151) tags_def ::= TAGS NK_LP column_def_list NK_RP */
0
,
/* (152) table_options ::= */
-
3
,
/* (153) table_options ::= table_options COMMENT NK_STRING */
-
3
,
/* (154) table_options ::= table_options KEEP integer_list */
-
3
,
/* (155) table_options ::= table_options KEEP variable_list */
-
3
,
/* (156) table_options ::= table_options TTL NK_INTEGER */
-
5
,
/* (157) table_options ::= table_options SMA NK_LP col_name_list NK_RP */
-
5
,
/* (158) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */
-
3
,
/* (159) table_options ::= table_options FILE_FACTOR NK_FLOAT */
-
3
,
/* (160) table_options ::= table_options DELAY NK_INTEGER */
-
1
,
/* (161) alter_table_options ::= alter_table_option */
-
2
,
/* (162) alter_table_options ::= alter_table_options alter_table_option */
-
2
,
/* (163) alter_table_option ::= COMMENT NK_STRING */
-
2
,
/* (164) alter_table_option ::= KEEP integer_list */
-
2
,
/* (165) alter_table_option ::= KEEP variable_list */
-
2
,
/* (166) alter_table_option ::= TTL NK_INTEGER */
-
1
,
/* (167) col_name_list ::= col_name */
-
3
,
/* (168) col_name_list ::= col_name_list NK_COMMA col_name */
-
1
,
/* (169) col_name ::= column_name */
-
2
,
/* (170) cmd ::= SHOW DNODES */
-
2
,
/* (171) cmd ::= SHOW USERS */
-
2
,
/* (172) cmd ::= SHOW DATABASES */
-
4
,
/* (173) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */
-
4
,
/* (174) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */
-
3
,
/* (175) cmd ::= SHOW db_name_cond_opt VGROUPS */
-
2
,
/* (176) cmd ::= SHOW MNODES */
-
2
,
/* (177) cmd ::= SHOW MODULES */
-
2
,
/* (178) cmd ::= SHOW QNODES */
-
2
,
/* (179) cmd ::= SHOW FUNCTIONS */
-
5
,
/* (180) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */
-
2
,
/* (181) cmd ::= SHOW STREAMS */
-
2
,
/* (182) cmd ::= SHOW ACCOUNTS */
-
2
,
/* (183) cmd ::= SHOW APPS */
-
2
,
/* (184) cmd ::= SHOW CONNECTIONS */
-
2
,
/* (185) cmd ::= SHOW LICENCE */
-
2
,
/* (186) cmd ::= SHOW GRANTS */
-
4
,
/* (187) cmd ::= SHOW CREATE DATABASE db_name */
-
4
,
/* (188) cmd ::= SHOW CREATE TABLE full_table_name */
-
4
,
/* (189) cmd ::= SHOW CREATE STABLE full_table_name */
-
2
,
/* (190) cmd ::= SHOW QUERIES */
-
2
,
/* (191) cmd ::= SHOW SCORES */
-
2
,
/* (192) cmd ::= SHOW TOPICS */
-
2
,
/* (193) cmd ::= SHOW VARIABLES */
-
2
,
/* (194) cmd ::= SHOW BNODES */
-
2
,
/* (195) cmd ::= SHOW SNODES */
0
,
/* (196) db_name_cond_opt ::= */
-
2
,
/* (197) db_name_cond_opt ::= db_name NK_DOT */
0
,
/* (198) like_pattern_opt ::= */
-
2
,
/* (199) like_pattern_opt ::= LIKE NK_STRING */
-
1
,
/* (200) table_name_cond ::= table_name */
0
,
/* (201) from_db_opt ::= */
-
2
,
/* (202) from_db_opt ::= FROM db_name */
-
1
,
/* (203) func_name_list ::= func_name */
-
3
,
/* (204) func_name_list ::= func_name_list NK_COMMA col_name */
-
1
,
/* (205) func_name ::= function_name */
-
8
,
/* (206) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */
-
10
,
/* (207) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */
-
6
,
/* (208) cmd ::= DROP INDEX exists_opt index_name ON table_name */
0
,
/* (209) index_options ::= */
-
9
,
/* (210) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */
-
11
,
/* (211) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */
-
1
,
/* (212) func_list ::= func */
-
3
,
/* (213) func_list ::= func_list NK_COMMA func */
-
4
,
/* (214) func ::= function_name NK_LP expression_list NK_RP */
-
6
,
/* (215) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */
-
6
,
/* (216) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */
-
4
,
/* (217) cmd ::= DROP TOPIC exists_opt topic_name */
-
2
,
/* (218) cmd ::= DESC full_table_name */
-
2
,
/* (219) cmd ::= DESCRIBE full_table_name */
-
3
,
/* (220) cmd ::= RESET QUERY CACHE */
-
4
,
/* (221) cmd ::= EXPLAIN analyze_opt explain_options query_expression */
0
,
/* (222) analyze_opt ::= */
-
1
,
/* (223) analyze_opt ::= ANALYZE */
0
,
/* (224) explain_options ::= */
-
3
,
/* (225) explain_options ::= explain_options VERBOSE NK_BOOL */
-
3
,
/* (226) explain_options ::= explain_options RATIO NK_FLOAT */
-
6
,
/* (227) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */
-
9
,
/* (228) cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */
-
3
,
/* (229) cmd ::= DROP FUNCTION function_name */
0
,
/* (230) agg_func_opt ::= */
-
1
,
/* (231) agg_func_opt ::= AGGREGATE */
0
,
/* (232) bufsize_opt ::= */
-
2
,
/* (233) bufsize_opt ::= BUFSIZE NK_INTEGER */
-
8
,
/* (234) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */
-
4
,
/* (235) cmd ::= DROP STREAM exists_opt stream_name */
0
,
/* (236) into_opt ::= */
-
2
,
/* (237) into_opt ::= INTO full_table_name */
0
,
/* (238) stream_options ::= */
-
3
,
/* (239) stream_options ::= stream_options TRIGGER AT_ONCE */
-
3
,
/* (240) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */
-
3
,
/* (241) stream_options ::= stream_options WATERMARK duration_literal */
-
3
,
/* (242) cmd ::= KILL CONNECTION NK_INTEGER */
-
3
,
/* (243) cmd ::= KILL QUERY NK_INTEGER */
-
4
,
/* (244) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */
-
4
,
/* (245) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */
-
3
,
/* (246) cmd ::= SPLIT VGROUP NK_INTEGER */
-
2
,
/* (247) dnode_list ::= DNODE NK_INTEGER */
-
3
,
/* (248) dnode_list ::= dnode_list DNODE NK_INTEGER */
-
3
,
/* (249) cmd ::= SYNCDB db_name REPLICA */
-
1
,
/* (250) cmd ::= query_expression */
-
1
,
/* (251) literal ::= NK_INTEGER */
-
1
,
/* (252) literal ::= NK_FLOAT */
-
1
,
/* (253) literal ::= NK_STRING */
-
1
,
/* (254) literal ::= NK_BOOL */
-
2
,
/* (255) literal ::= TIMESTAMP NK_STRING */
-
1
,
/* (256) literal ::= duration_literal */
-
1
,
/* (257) literal ::= NULL */
-
1
,
/* (258) literal ::= NK_QUESTION */
-
1
,
/* (259) duration_literal ::= NK_VARIABLE */
-
1
,
/* (260) signed ::= NK_INTEGER */
-
2
,
/* (261) signed ::= NK_PLUS NK_INTEGER */
-
2
,
/* (262) signed ::= NK_MINUS NK_INTEGER */
-
1
,
/* (263) signed ::= NK_FLOAT */
-
2
,
/* (264) signed ::= NK_PLUS NK_FLOAT */
-
2
,
/* (265) signed ::= NK_MINUS NK_FLOAT */
-
1
,
/* (266) signed_literal ::= signed */
-
1
,
/* (267) signed_literal ::= NK_STRING */
-
1
,
/* (268) signed_literal ::= NK_BOOL */
-
2
,
/* (269) signed_literal ::= TIMESTAMP NK_STRING */
-
1
,
/* (270) signed_literal ::= duration_literal */
-
1
,
/* (271) signed_literal ::= NULL */
-
1
,
/* (272) literal_list ::= signed_literal */
-
3
,
/* (273) literal_list ::= literal_list NK_COMMA signed_literal */
-
1
,
/* (274) db_name ::= NK_ID */
-
1
,
/* (275) table_name ::= NK_ID */
-
1
,
/* (276) column_name ::= NK_ID */
-
1
,
/* (277) function_name ::= NK_ID */
-
1
,
/* (278) table_alias ::= NK_ID */
-
1
,
/* (279) column_alias ::= NK_ID */
-
1
,
/* (280) user_name ::= NK_ID */
-
1
,
/* (281) index_name ::= NK_ID */
-
1
,
/* (282) topic_name ::= NK_ID */
-
1
,
/* (283) stream_name ::= NK_ID */
-
1
,
/* (284) expression ::= literal */
-
1
,
/* (285) expression ::= pseudo_column */
-
1
,
/* (286) expression ::= column_reference */
-
1
,
/* (287) expression ::= function_expression */
-
1
,
/* (288) expression ::= subquery */
-
3
,
/* (289) expression ::= NK_LP expression NK_RP */
-
2
,
/* (290) expression ::= NK_PLUS expression */
-
2
,
/* (291) expression ::= NK_MINUS expression */
-
3
,
/* (292) expression ::= expression NK_PLUS expression */
-
3
,
/* (293) expression ::= expression NK_MINUS expression */
-
3
,
/* (294) expression ::= expression NK_STAR expression */
-
3
,
/* (295) expression ::= expression NK_SLASH expression */
-
3
,
/* (296) expression ::= expression NK_REM expression */
-
3
,
/* (297) expression ::= column_reference NK_ARROW NK_STRING */
-
1
,
/* (298) expression_list ::= expression */
-
3
,
/* (299) expression_list ::= expression_list NK_COMMA expression */
-
1
,
/* (300) column_reference ::= column_name */
-
3
,
/* (301) column_reference ::= table_name NK_DOT column_name */
-
1
,
/* (302) pseudo_column ::= ROWTS */
-
1
,
/* (303) pseudo_column ::= TBNAME */
-
1
,
/* (304) pseudo_column ::= QSTARTTS */
-
1
,
/* (305) pseudo_column ::= QENDTS */
-
1
,
/* (306) pseudo_column ::= WSTARTTS */
-
1
,
/* (307) pseudo_column ::= WENDTS */
-
1
,
/* (308) pseudo_column ::= WDURATION */
-
4
,
/* (309) function_expression ::= function_name NK_LP expression_list NK_RP */
-
4
,
/* (310) function_expression ::= star_func NK_LP star_func_para_list NK_RP */
-
6
,
/* (311) function_expression ::= CAST NK_LP expression AS type_name NK_RP */
-
3
,
/* (312) function_expression ::= noarg_func NK_LP NK_RP */
-
1
,
/* (313) noarg_func ::= NOW */
-
1
,
/* (314) noarg_func ::= TODAY */
-
1
,
/* (315) noarg_func ::= TIMEZONE */
-
1
,
/* (316) star_func ::= COUNT */
-
1
,
/* (317) star_func ::= FIRST */
-
1
,
/* (318) star_func ::= LAST */
-
1
,
/* (319) star_func ::= LAST_ROW */
-
1
,
/* (320) star_func_para_list ::= NK_STAR */
-
1
,
/* (321) star_func_para_list ::= other_para_list */
-
1
,
/* (322) other_para_list ::= star_func_para */
-
3
,
/* (323) other_para_list ::= other_para_list NK_COMMA star_func_para */
-
1
,
/* (324) star_func_para ::= expression */
-
3
,
/* (325) star_func_para ::= table_name NK_DOT NK_STAR */
-
3
,
/* (326) predicate ::= expression compare_op expression */
-
5
,
/* (327) predicate ::= expression BETWEEN expression AND expression */
-
6
,
/* (328) predicate ::= expression NOT BETWEEN expression AND expression */
-
3
,
/* (329) predicate ::= expression IS NULL */
-
4
,
/* (330) predicate ::= expression IS NOT NULL */
-
3
,
/* (331) predicate ::= expression in_op in_predicate_value */
-
1
,
/* (332) compare_op ::= NK_LT */
-
1
,
/* (333) compare_op ::= NK_GT */
-
1
,
/* (334) compare_op ::= NK_LE */
-
1
,
/* (335) compare_op ::= NK_GE */
-
1
,
/* (336) compare_op ::= NK_NE */
-
1
,
/* (337) compare_op ::= NK_EQ */
-
1
,
/* (338) compare_op ::= LIKE */
-
2
,
/* (339) compare_op ::= NOT LIKE */
-
1
,
/* (340) compare_op ::= MATCH */
-
1
,
/* (341) compare_op ::= NMATCH */
-
1
,
/* (342) compare_op ::= CONTAINS */
-
1
,
/* (343) in_op ::= IN */
-
2
,
/* (344) in_op ::= NOT IN */
-
3
,
/* (345) in_predicate_value ::= NK_LP expression_list NK_RP */
-
1
,
/* (346) boolean_value_expression ::= boolean_primary */
-
2
,
/* (347) boolean_value_expression ::= NOT boolean_primary */
-
3
,
/* (348) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
-
3
,
/* (349) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
-
1
,
/* (350) boolean_primary ::= predicate */
-
3
,
/* (351) boolean_primary ::= NK_LP boolean_value_expression NK_RP */
-
1
,
/* (352) common_expression ::= expression */
-
1
,
/* (353) common_expression ::= boolean_value_expression */
-
2
,
/* (354) from_clause ::= FROM table_reference_list */
-
1
,
/* (355) table_reference_list ::= table_reference */
-
3
,
/* (356) table_reference_list ::= table_reference_list NK_COMMA table_reference */
-
1
,
/* (357) table_reference ::= table_primary */
-
1
,
/* (358) table_reference ::= joined_table */
-
2
,
/* (359) table_primary ::= table_name alias_opt */
-
4
,
/* (360) table_primary ::= db_name NK_DOT table_name alias_opt */
-
2
,
/* (361) table_primary ::= subquery alias_opt */
-
1
,
/* (362) table_primary ::= parenthesized_joined_table */
0
,
/* (363) alias_opt ::= */
-
1
,
/* (364) alias_opt ::= table_alias */
-
2
,
/* (365) alias_opt ::= AS table_alias */
-
3
,
/* (366) parenthesized_joined_table ::= NK_LP joined_table NK_RP */
-
3
,
/* (367) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
-
6
,
/* (368) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
0
,
/* (369) join_type ::= */
-
1
,
/* (370) join_type ::= INNER */
-
9
,
/* (371) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
0
,
/* (372) set_quantifier_opt ::= */
-
1
,
/* (373) set_quantifier_opt ::= DISTINCT */
-
1
,
/* (374) set_quantifier_opt ::= ALL */
-
1
,
/* (375) select_list ::= NK_STAR */
-
1
,
/* (376) select_list ::= select_sublist */
-
1
,
/* (377) select_sublist ::= select_item */
-
3
,
/* (378) select_sublist ::= select_sublist NK_COMMA select_item */
-
1
,
/* (379) select_item ::= common_expression */
-
2
,
/* (380) select_item ::= common_expression column_alias */
-
3
,
/* (381) select_item ::= common_expression AS column_alias */
-
3
,
/* (382) select_item ::= table_name NK_DOT NK_STAR */
0
,
/* (383) where_clause_opt ::= */
-
2
,
/* (384) where_clause_opt ::= WHERE search_condition */
0
,
/* (385) partition_by_clause_opt ::= */
-
3
,
/* (386) partition_by_clause_opt ::= PARTITION BY expression_list */
0
,
/* (387) twindow_clause_opt ::= */
-
6
,
/* (388) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */
-
4
,
/* (389) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */
-
6
,
/* (390) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
-
8
,
/* (391) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
0
,
/* (392) sliding_opt ::= */
-
4
,
/* (393) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
0
,
/* (394) fill_opt ::= */
-
4
,
/* (395) fill_opt ::= FILL NK_LP fill_mode NK_RP */
-
6
,
/* (396) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
-
1
,
/* (397) fill_mode ::= NONE */
-
1
,
/* (398) fill_mode ::= PREV */
-
1
,
/* (399) fill_mode ::= NULL */
-
1
,
/* (400) fill_mode ::= LINEAR */
-
1
,
/* (401) fill_mode ::= NEXT */
0
,
/* (402) group_by_clause_opt ::= */
-
3
,
/* (403) group_by_clause_opt ::= GROUP BY group_by_list */
-
1
,
/* (404) group_by_list ::= expression */
-
3
,
/* (405) group_by_list ::= group_by_list NK_COMMA expression */
0
,
/* (406) having_clause_opt ::= */
-
2
,
/* (407) having_clause_opt ::= HAVING search_condition */
-
4
,
/* (408) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
-
1
,
/* (409) query_expression_body ::= query_primary */
-
4
,
/* (410) query_expression_body ::= query_expression_body UNION ALL query_expression_body */
-
1
,
/* (411) query_primary ::= query_specification */
0
,
/* (412) order_by_clause_opt ::= */
-
3
,
/* (413) order_by_clause_opt ::= ORDER BY sort_specification_list */
0
,
/* (414) slimit_clause_opt ::= */
-
2
,
/* (415) slimit_clause_opt ::= SLIMIT NK_INTEGER */
-
4
,
/* (416) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
-
4
,
/* (417) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
0
,
/* (418) limit_clause_opt ::= */
-
2
,
/* (419) limit_clause_opt ::= LIMIT NK_INTEGER */
-
4
,
/* (420) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
-
4
,
/* (421) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
-
3
,
/* (422) subquery ::= NK_LP query_expression NK_RP */
-
1
,
/* (423) search_condition ::= common_expression */
-
1
,
/* (424) sort_specification_list ::= sort_specification */
-
3
,
/* (425) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
-
3
,
/* (426) sort_specification ::= expression ordering_specification_opt null_ordering_opt */
0
,
/* (427) ordering_specification_opt ::= */
-
1
,
/* (428) ordering_specification_opt ::= ASC */
-
1
,
/* (429) ordering_specification_opt ::= DESC */
0
,
/* (430) null_ordering_opt ::= */
-
2
,
/* (431) null_ordering_opt ::= NULLS FIRST */
-
2
,
/* (432) null_ordering_opt ::= NULLS LAST */
};
};
static
void
yy_accept
(
yyParser
*
);
/* Forward Declaration */
static
void
yy_accept
(
yyParser
*
);
/* Forward Declaration */
...
@@ -3115,17 +2663,14 @@ static YYACTIONTYPE yy_reduce(
...
@@ -3115,17 +2663,14 @@ static YYACTIONTYPE yy_reduce(
yymsp
=
yypParser
->
yytos
;
yymsp
=
yypParser
->
yytos
;
#ifndef NDEBUG
#ifndef NDEBUG
if
(
yyTraceFILE
&&
yyruleno
<
(
int
)(
sizeof
(
yyRuleName
)
/
sizeof
(
yyRuleName
[
0
]))
){
if
(
yyTraceFILE
&&
yyruleno
<
(
int
)(
sizeof
(
yyRuleName
)
/
sizeof
(
yyRuleName
[
0
]))
){
yysize
=
yyRuleInfo
NRhs
[
yyruleno
]
;
yysize
=
yyRuleInfo
[
yyruleno
].
nrhs
;
if
(
yysize
){
if
(
yysize
){
fprintf
(
yyTraceFILE
,
"%sReduce %d [%s]
%s, pop back
to state %d.
\n
"
,
fprintf
(
yyTraceFILE
,
"%sReduce %d [%s]
, go
to state %d.
\n
"
,
yyTracePrompt
,
yyTracePrompt
,
yyruleno
,
yyRuleName
[
yyruleno
],
yyruleno
,
yyRuleName
[
yyruleno
],
yymsp
[
yysize
].
stateno
);
yyruleno
<
YYNRULE_WITH_ACTION
?
""
:
" without external action"
,
yymsp
[
yysize
].
stateno
);
}
else
{
}
else
{
fprintf
(
yyTraceFILE
,
"%sReduce %d [%s]%s.
\n
"
,
fprintf
(
yyTraceFILE
,
"%sReduce %d [%s].
\n
"
,
yyTracePrompt
,
yyruleno
,
yyRuleName
[
yyruleno
],
yyTracePrompt
,
yyruleno
,
yyRuleName
[
yyruleno
]);
yyruleno
<
YYNRULE_WITH_ACTION
?
""
:
" without external action"
);
}
}
}
}
#endif
/* NDEBUG */
#endif
/* NDEBUG */
...
@@ -3133,7 +2678,7 @@ static YYACTIONTYPE yy_reduce(
...
@@ -3133,7 +2678,7 @@ static YYACTIONTYPE yy_reduce(
/* Check that the stack is large enough to grow by a single entry
/* Check that the stack is large enough to grow by a single entry
** if the RHS of the rule is empty. This ensures that there is room
** if the RHS of the rule is empty. This ensures that there is room
** enough on the stack to push the LHS value */
** enough on the stack to push the LHS value */
if
(
yyRuleInfo
NRhs
[
yyruleno
]
==
0
){
if
(
yyRuleInfo
[
yyruleno
].
nrhs
==
0
){
#ifdef YYTRACKMAXSTACKDEPTH
#ifdef YYTRACKMAXSTACKDEPTH
if
(
(
int
)(
yypParser
->
yytos
-
yypParser
->
yystack
)
>
yypParser
->
yyhwm
){
if
(
(
int
)(
yypParser
->
yytos
-
yypParser
->
yystack
)
>
yypParser
->
yyhwm
){
yypParser
->
yyhwm
++
;
yypParser
->
yyhwm
++
;
...
@@ -3988,11 +3533,11 @@ static YYACTIONTYPE yy_reduce(
...
@@ -3988,11 +3533,11 @@ static YYACTIONTYPE yy_reduce(
yymsp
[
0
].
minor
.
yy456
=
yylhsminor
.
yy456
;
yymsp
[
0
].
minor
.
yy456
=
yylhsminor
.
yy456
;
break
;
break
;
case
257
:
/* literal ::= NULL */
case
257
:
/* literal ::= NULL */
{
yylhsminor
.
yy456
=
createRawExprNode
(
pCxt
,
&
yymsp
[
0
].
minor
.
yy0
,
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_NULL
,
NULL
));
}
{
yylhsminor
.
yy456
=
createRawExprNode
(
pCxt
,
&
yymsp
[
0
].
minor
.
yy0
,
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_NULL
,
&
yymsp
[
0
].
minor
.
yy0
));
}
yymsp
[
0
].
minor
.
yy456
=
yylhsminor
.
yy456
;
yymsp
[
0
].
minor
.
yy456
=
yylhsminor
.
yy456
;
break
;
break
;
case
258
:
/* literal ::= NK_QUESTION */
case
258
:
/* literal ::= NK_QUESTION */
{
yylhsminor
.
yy456
=
createRawExprNode
(
pCxt
,
&
yymsp
[
0
].
minor
.
yy0
,
createPlaceholderValueNode
(
pCxt
));
}
{
yylhsminor
.
yy456
=
createRawExprNode
(
pCxt
,
&
yymsp
[
0
].
minor
.
yy0
,
createPlaceholderValueNode
(
pCxt
,
&
yymsp
[
0
].
minor
.
yy0
));
}
yymsp
[
0
].
minor
.
yy456
=
yylhsminor
.
yy456
;
yymsp
[
0
].
minor
.
yy456
=
yylhsminor
.
yy456
;
break
;
break
;
case
259
:
/* duration_literal ::= NK_VARIABLE */
case
259
:
/* duration_literal ::= NK_VARIABLE */
...
@@ -4185,7 +3730,7 @@ static YYACTIONTYPE yy_reduce(
...
@@ -4185,7 +3730,7 @@ static YYACTIONTYPE yy_reduce(
{
{
SToken
s
=
getTokenFromRawExprNode
(
pCxt
,
yymsp
[
-
5
].
minor
.
yy456
);
SToken
s
=
getTokenFromRawExprNode
(
pCxt
,
yymsp
[
-
5
].
minor
.
yy456
);
SToken
e
=
getTokenFromRawExprNode
(
pCxt
,
yymsp
[
0
].
minor
.
yy456
);
SToken
e
=
getTokenFromRawExprNode
(
pCxt
,
yymsp
[
0
].
minor
.
yy456
);
yylhsminor
.
yy456
=
createRawExprNodeExt
(
pCxt
,
&
s
,
&
e
,
createNotBetweenAnd
(
pCxt
,
releaseRawExprNode
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy456
),
releaseRawExprNode
(
pCxt
,
yymsp
[
-
5
].
minor
.
yy456
),
releaseRawExprNode
(
pCxt
,
yymsp
[
0
].
minor
.
yy456
)));
yylhsminor
.
yy456
=
createRawExprNodeExt
(
pCxt
,
&
s
,
&
e
,
createNotBetweenAnd
(
pCxt
,
releaseRawExprNode
(
pCxt
,
yymsp
[
-
5
].
minor
.
yy456
),
releaseRawExprNode
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy456
),
releaseRawExprNode
(
pCxt
,
yymsp
[
0
].
minor
.
yy456
)));
}
}
yymsp
[
-
5
].
minor
.
yy456
=
yylhsminor
.
yy456
;
yymsp
[
-
5
].
minor
.
yy456
=
yylhsminor
.
yy456
;
break
;
break
;
...
@@ -4436,9 +3981,9 @@ static YYACTIONTYPE yy_reduce(
...
@@ -4436,9 +3981,9 @@ static YYACTIONTYPE yy_reduce(
break
;
break
;
/********** End reduce actions ************************************************/
/********** End reduce actions ************************************************/
};
};
assert
(
yyruleno
<
sizeof
(
yyRuleInfo
Lhs
)
/
sizeof
(
yyRuleInfoLhs
[
0
])
);
assert
(
yyruleno
<
sizeof
(
yyRuleInfo
)
/
sizeof
(
yyRuleInfo
[
0
])
);
yygoto
=
yyRuleInfo
Lhs
[
yyruleno
]
;
yygoto
=
yyRuleInfo
[
yyruleno
].
lhs
;
yysize
=
yyRuleInfo
NRhs
[
yyruleno
]
;
yysize
=
yyRuleInfo
[
yyruleno
].
nrhs
;
yyact
=
yy_find_reduce_action
(
yymsp
[
yysize
].
stateno
,(
YYCODETYPE
)
yygoto
);
yyact
=
yy_find_reduce_action
(
yymsp
[
yysize
].
stateno
,(
YYCODETYPE
)
yygoto
);
/* There are no SHIFTREDUCE actions on nonterminals because the table
/* There are no SHIFTREDUCE actions on nonterminals because the table
...
@@ -4726,10 +4271,11 @@ void Parse(
...
@@ -4726,10 +4271,11 @@ void Parse(
*/
*/
int
ParseFallback
(
int
iToken
){
int
ParseFallback
(
int
iToken
){
#ifdef YYFALLBACK
#ifdef YYFALLBACK
assert
(
iToken
<
(
int
)(
sizeof
(
yyFallback
)
/
sizeof
(
yyFallback
[
0
]))
);
if
(
iToken
<
(
int
)(
sizeof
(
yyFallback
)
/
sizeof
(
yyFallback
[
0
]))
){
return
yyFallback
[
iToken
];
return
yyFallback
[
iToken
];
}
#else
#else
(
void
)
iToken
;
(
void
)
iToken
;
return
0
;
#endif
#endif
return
0
;
}
}
source/libs/parser/test/parserTestUtil.h
浏览文件 @
b7281e4d
...
@@ -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/planOptimizer.c
浏览文件 @
b7281e4d
...
@@ -77,6 +77,10 @@ static bool osdMayBeOptimized(SLogicNode* pNode) {
...
@@ -77,6 +77,10 @@ static bool osdMayBeOptimized(SLogicNode* pNode) {
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
!=
nodeType
(
pNode
))
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
!=
nodeType
(
pNode
))
{
return
false
;
return
false
;
}
}
// todo: release after function splitting
if
(
TSDB_SUPER_TABLE
==
((
SScanLogicNode
*
)
pNode
)
->
pMeta
->
tableType
)
{
return
false
;
}
if
(
NULL
==
pNode
->
pParent
||
if
(
NULL
==
pNode
->
pParent
||
(
QUERY_NODE_LOGIC_PLAN_WINDOW
!=
nodeType
(
pNode
->
pParent
)
&&
QUERY_NODE_LOGIC_PLAN_AGG
!=
nodeType
(
pNode
->
pParent
)))
{
(
QUERY_NODE_LOGIC_PLAN_WINDOW
!=
nodeType
(
pNode
->
pParent
)
&&
QUERY_NODE_LOGIC_PLAN_AGG
!=
nodeType
(
pNode
->
pParent
)))
{
return
false
;
return
false
;
...
...
source/libs/planner/src/planner.c
浏览文件 @
b7281e4d
...
@@ -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
浏览文件 @
b7281e4d
/*
* 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
浏览文件 @
b7281e4d
/*
* 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);
bool
g_isDump
=
false
;
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/
dnode/vnode/src/vnd/vnodeWrite.c
→
source/
libs/planner/test/planTestUtil.h
浏览文件 @
b7281e4d
...
@@ -13,6 +13,25 @@
...
@@ -13,6 +13,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "vnodeInt.h"
#ifndef PLAN_TEST_UTIL_H
#define PLAN_TEST_UTIL_H
/* ------------------------ STATIC METHODS ------------------------ */
#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_
;
};
extern
bool
g_isDump
;
#endif // PLAN_TEST_UTIL_H
source/libs/planner/test/plannerTest.cpp
浏览文件 @
b7281e4d
...
@@ -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/planner/test/plannerTestMain.cpp
浏览文件 @
b7281e4d
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include "mockCatalog.h"
#include "mockCatalog.h"
#include "planTestUtil.h"
class
PlannerEnv
:
public
testing
::
Environment
{
class
PlannerEnv
:
public
testing
::
Environment
{
public:
public:
...
@@ -34,8 +35,27 @@ public:
...
@@ -34,8 +35,27 @@ public:
virtual
~
PlannerEnv
()
{}
virtual
~
PlannerEnv
()
{}
};
};
static
void
parseArg
(
int
argc
,
char
*
argv
[])
{
int
opt
=
0
;
const
char
*
optstring
=
""
;
static
struct
option
long_options
[]
=
{
{
"dump"
,
no_argument
,
NULL
,
'd'
},
{
0
,
0
,
0
,
0
}
};
while
((
opt
=
getopt_long
(
argc
,
argv
,
optstring
,
long_options
,
NULL
))
!=
-
1
)
{
switch
(
opt
)
{
case
'd'
:
g_isDump
=
true
;
break
;
default:
break
;
}
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
testing
::
AddGlobalTestEnvironment
(
new
PlannerEnv
());
testing
::
AddGlobalTestEnvironment
(
new
PlannerEnv
());
testing
::
InitGoogleTest
(
&
argc
,
argv
);
testing
::
InitGoogleTest
(
&
argc
,
argv
);
parseArg
(
argc
,
argv
);
return
RUN_ALL_TESTS
();
return
RUN_ALL_TESTS
();
}
}
source/libs/scalar/inc/sclvector.h
浏览文件 @
b7281e4d
...
@@ -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
浏览文件 @
b7281e4d
...
@@ -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
浏览文件 @
b7281e4d
...
@@ -795,13 +795,6 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
...
@@ -795,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
)
{
...
@@ -867,13 +860,6 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
...
@@ -867,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
)
{
...
@@ -883,7 +869,11 @@ int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
...
@@ -883,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
);
...
@@ -897,18 +887,6 @@ int32_t toUnixtimestampFunction(SScalarParam *pInput, int32_t inputNum, SScalarP
...
@@ -897,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
);
...
@@ -930,7 +908,11 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
...
@@ -930,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
)
{
...
@@ -1096,16 +1078,9 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara
...
@@ -1096,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
);
}
}
...
@@ -1133,7 +1108,11 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
...
@@ -1133,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
浏览文件 @
b7281e4d
...
@@ -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/osThread.c
浏览文件 @
b7281e4d
...
@@ -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/tsim/query/time_process.sim
0 → 100644
浏览文件 @
b7281e4d
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready
endi
sql connect
print =============== create database
sql create database db
sql show databases
if $rows != 3 then
return -1
endi
sql use db
print =============== create super table and child table
sql create table stb1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int)
sql show stables
print $rows $data00 $data01 $data02
if $rows != 1 then
return -1
endi
sql create table ct1 using stb1 tags ( 1 )
sql create table ct2 using stb1 tags ( 2 )
sql create table ct3 using stb1 tags ( 3 )
sql create table ct4 using stb1 tags ( 4 )
sql show tables
print $rows $data00 $data10 $data20
if $rows != 4 then
return -1
endi
sql create table t1 (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp)
print =============== insert data into child table ct1 (s)
sql insert into ct1 values ( '2022-01-01 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct1 values ( '2022-01-01 01:01:06.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct1 values ( '2022-01-01 01:01:10.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct1 values ( '2022-01-01 01:01:16.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct1 values ( '2022-01-01 01:01:20.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct1 values ( '2022-01-01 01:01:26.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct1 values ( '2022-01-01 01:01:30.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", now+7a )
sql insert into ct1 values ( '2022-01-01 01:01:36.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", now+8a )
print =============== insert data into child table ct4 (y)
sql insert into ct4 values ( '2019-01-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
sql insert into ct4 values ( '2019-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into ct4 values ( '2019-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into ct4 values ( '2020-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into ct4 values ( '2020-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into ct4 values ( '2020-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into ct4 values ( '2020-12-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
sql insert into ct4 values ( '2021-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into ct4 values ( '2021-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
sql insert into ct4 values ( '2021-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
sql insert into ct4 values ( '2022-02-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
sql insert into ct4 values ( '2022-05-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL )
print =============== insert data into child table t1
sql insert into t1 values ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now+1a )
sql insert into t1 values ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now+2a )
sql insert into t1 values ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now+3a )
sql insert into t1 values ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now+4a )
sql insert into t1 values ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now+5a )
sql insert into t1 values ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now+6a )
sql insert into t1 values ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" )
sql insert into t1 values ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" )
sql insert into t1 values ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" )
print ================ start query ======================
print =============== step1
print =====sql : select timediff(ts , c10) from ct4
sql select cast(c1 as bigint) as b from ct4
print ===> $rows
if $rows != 1 then
return -1
endi
#=================================================
print =============== stop and restart taosd
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
check_dnode_ready_0:
$loop_cnt = $loop_cnt + 1
sleep 200
if $loop_cnt == 10 then
print ====> dnode not ready!
return -1
endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
return -1
endi
if $data04 != ready then
goto check_dnode_ready_0
endi
print =============== step2 after wal
print =============== clear
sql drop database db
sql show databases
if $rows != 2 then
return -1
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
tests/system-test/2-query/between.py
浏览文件 @
b7281e4d
...
@@ -22,8 +22,8 @@ class TDTestCase:
...
@@ -22,8 +22,8 @@ class TDTestCase:
(ts timestamp, c1 int, c2 float, c3 bigint, c4 double, c5 smallint, c6 tinyint)
(ts timestamp, c1 int, c2 float, c3 bigint, c4 double, c5 smallint, c6 tinyint)
tags(location binary(64), type int, isused bool , family nchar(64))'''
tags(location binary(64), type int, isused bool , family nchar(64))'''
)
)
tdSql
.
execute
(
"create table t1 using supt tags('beijing', 1, 1, '
自行车
')"
)
tdSql
.
execute
(
"create table t1 using supt tags('beijing', 1, 1, '
nchar1
')"
)
tdSql
.
execute
(
"create table t2 using supt tags('shanghai', 2, 0, '
拖拉机
')"
)
tdSql
.
execute
(
"create table t2 using supt tags('shanghai', 2, 0, '
nchar2
')"
)
tdLog
.
printNoPrefix
(
"==========step2:insert data"
)
tdLog
.
printNoPrefix
(
"==========step2:insert data"
)
for
i
in
range
(
10
):
for
i
in
range
(
10
):
...
@@ -45,16 +45,16 @@ class TDTestCase:
...
@@ -45,16 +45,16 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"==========step3:query timestamp type"
)
tdLog
.
printNoPrefix
(
"==========step3:query timestamp type"
)
tdSql
.
query
(
"select * from t1 where ts between now()-1m and now()+10m"
)
#
tdSql.query("select * from t1 where ts between now()-1m and now()+10m")
tdSql
.
checkRows
(
10
)
#
tdSql.checkRows(10)
tdSql
.
query
(
"select * from t1 where ts between '2021-01-01 00:00:00.000' and '2121-01-01 00:00:00.000'"
)
#
tdSql.query("select * from t1 where ts between '2021-01-01 00:00:00.000' and '2121-01-01 00:00:00.000'")
tdSql
.
checkRows
(
11
)
#
tdSql.checkRows(11)
tdSql
.
query
(
"select * from t1 where ts between '1969-01-01 00:00:00.000' and '1969-12-31 23:59:59.999'"
)
#
tdSql.query("select * from t1 where ts between '1969-01-01 00:00:00.000' and '1969-12-31 23:59:59.999'")
tdSql
.
checkRows
(
0
)
#
tdSql.checkRows(0)
tdSql
.
query
(
"select * from t1 where ts between -2793600 and 31507199"
)
#
tdSql.query("select * from t1 where ts between -2793600 and 31507199")
tdSql
.
checkRows
(
0
)
#
tdSql.checkRows(0)
tdSql
.
query
(
"select * from t1 where ts between 1609430400000 and 4765104000000"
)
#
tdSql.query("select * from t1 where ts between 1609430400000 and 4765104000000")
tdSql
.
checkRows
(
11
)
#
tdSql.checkRows(11)
tdLog
.
printNoPrefix
(
"==========step4:query int type"
)
tdLog
.
printNoPrefix
(
"==========step4:query int type"
)
...
@@ -64,10 +64,12 @@ class TDTestCase:
...
@@ -64,10 +64,12 @@ class TDTestCase:
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
tdSql
.
query
(
"select * from t1 where c1 between 32776 and 32767"
)
tdSql
.
query
(
"select * from t1 where c1 between 32776 and 32767"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
error
(
"select * from t1 where c1 between 'a' and 'e'"
)
tdSql
.
query
(
"select * from t1 where c1 between 'a' and 'e'"
)
tdSql
.
checkRows
(
0
)
# tdSql.query("select * from t1 where c1 between 0x64 and 0x69")
# tdSql.query("select * from t1 where c1 between 0x64 and 0x69")
# tdSql.checkRows(6)
# tdSql.checkRows(6)
tdSql
.
error
(
"select * from t1 where c1 not between 100 and 106"
)
# tdSql.query("select * from t1 where c1 not between 100 and 106")
# tdSql.checkRows(11)
tdSql
.
query
(
f
"select * from t1 where c1 between
{
2
**
31
-
2
}
and
{
2
**
31
+
1
}
"
)
tdSql
.
query
(
f
"select * from t1 where c1 between
{
2
**
31
-
2
}
and
{
2
**
31
+
1
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
error
(
f
"select * from t2 where c1 between null and
{
1
-
2
**
31
}
"
)
tdSql
.
error
(
f
"select * from t2 where c1 between null and
{
1
-
2
**
31
}
"
)
...
@@ -83,12 +85,14 @@ class TDTestCase:
...
@@ -83,12 +85,14 @@ class TDTestCase:
tdSql
.
checkRows
(
11
)
tdSql
.
checkRows
(
11
)
tdSql
.
query
(
"select * from t1 where c2 between 21.0 and 20.0"
)
tdSql
.
query
(
"select * from t1 where c2 between 21.0 and 20.0"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
error
(
"select * from t1 where c2 between 'DC3' and 'SYN'"
)
tdSql
.
query
(
"select * from t1 where c2 between 'DC3' and 'SYN'"
)
tdSql
.
error
(
"select * from t1 where c2 not between 0.1 and 0.2"
)
tdSql
.
checkRows
(
0
)
# tdSql.query(f"select * from t1 where c2 between {pow(10,38)*3.4} and {pow(10,38)*3.4+1}")
tdSql
.
query
(
"select * from t1 where c2 not between 0.1 and 0.2"
)
# tdSql.checkRows(11)
tdSql
.
query
(
f
"select * from t1 where c2 between
{
pow
(
10
,
38
)
*
3.4
}
and
{
pow
(
10
,
38
)
*
3.4
+
1
}
"
)
# tdSql.checkRows(1)
# tdSql.checkRows(1)
tdSql
.
query
(
f
"select * from t2 where c2 between
{
-
3.4
*
10
**
38
-
1
}
and
{
-
3.4
*
10
**
38
}
"
)
tdSql
.
query
(
f
"select * from t2 where c2 between
{
-
3.4
*
10
**
38
-
1
}
and
{
-
3.4
*
10
**
38
}
"
)
tdSql
.
checkRows
(
2
)
#
tdSql.checkRows(2)
tdSql
.
error
(
f
"select * from t2 where c2 between null and
{
-
3.4
*
10
**
38
}
"
)
tdSql
.
error
(
f
"select * from t2 where c2 between null and
{
-
3.4
*
10
**
38
}
"
)
# tdSql.checkRows(3)
# tdSql.checkRows(3)
...
@@ -96,15 +100,17 @@ class TDTestCase:
...
@@ -96,15 +100,17 @@ class TDTestCase:
tdSql
.
query
(
f
"select * from t1 where c3 between
{
2
**
31
}
and
{
2
**
31
+
10
}
"
)
tdSql
.
query
(
f
"select * from t1 where c3 between
{
2
**
31
}
and
{
2
**
31
+
10
}
"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
tdSql
.
error
(
f
"select * from t1 where c3 between
{
-
2
**
63
}
and
{
2
**
63
}
"
)
tdSql
.
query
(
f
"select * from t1 where c3 between
{
-
2
**
63
}
and
{
2
**
63
}
"
)
# tdSql.checkRows(11)
# tdSql.checkRows(11)
tdSql
.
query
(
f
"select * from t1 where c3 between
{
2
**
31
+
10
}
and
{
2
**
31
}
"
)
tdSql
.
query
(
f
"select * from t1 where c3 between
{
2
**
31
+
10
}
and
{
2
**
31
}
"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
error
(
"select * from t1 where c3 between 'a' and 'z'"
)
tdSql
.
query
(
"select * from t1 where c3 between 'a' and 'z'"
)
tdSql
.
error
(
"select * from t1 where c3 not between 1 and 2"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from t1 where c3 not between 1 and 2"
)
# tdSql.checkRows(0)
tdSql
.
query
(
f
"select * from t1 where c3 between
{
2
**
63
-
2
}
and
{
2
**
63
-
1
}
"
)
tdSql
.
query
(
f
"select * from t1 where c3 between
{
2
**
63
-
2
}
and
{
2
**
63
-
1
}
"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
error
(
f
"select * from t2 where c3 between
{
-
2
**
63
}
and
{
1
-
2
**
63
}
"
)
tdSql
.
query
(
f
"select * from t2 where c3 between
{
-
2
**
63
}
and
{
1
-
2
**
63
}
"
)
# tdSql.checkRows(3)
# tdSql.checkRows(3)
tdSql
.
error
(
f
"select * from t2 where c3 between null and
{
1
-
2
**
63
}
"
)
tdSql
.
error
(
f
"select * from t2 where c3 between null and
{
1
-
2
**
63
}
"
)
# tdSql.checkRows(2)
# tdSql.checkRows(2)
...
@@ -118,10 +124,12 @@ class TDTestCase:
...
@@ -118,10 +124,12 @@ class TDTestCase:
# tdSql.checkRows(0)
# tdSql.checkRows(0)
tdSql
.
query
(
f
"select * from t1 where c4 between
{
3.4
*
10
**
38
+
10
}
and
{
3.4
*
10
**
38
}
"
)
tdSql
.
query
(
f
"select * from t1 where c4 between
{
3.4
*
10
**
38
+
10
}
and
{
3.4
*
10
**
38
}
"
)
# tdSql.checkRows(0)
# tdSql.checkRows(0)
tdSql
.
error
(
"select * from t1 where c4 between 'a' and 'z'"
)
tdSql
.
query
(
"select * from t1 where c4 between 'a' and 'z'"
)
tdSql
.
error
(
"select * from t1 where c4 not between 1 and 2"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from t1 where c4 not between 1 and 2"
)
# tdSql.checkRows(0)
tdSql
.
query
(
f
"select * from t1 where c4 between
{
1.7
*
10
**
308
}
and
{
1.7
*
10
**
308
+
1
}
"
)
tdSql
.
query
(
f
"select * from t1 where c4 between
{
1.7
*
10
**
308
}
and
{
1.7
*
10
**
308
+
1
}
"
)
tdSql
.
checkRows
(
1
)
#
tdSql.checkRows(1)
tdSql
.
query
(
f
"select * from t2 where c4 between
{
-
1.7
*
10
**
308
-
1
}
and
{
-
1.7
*
10
**
308
}
"
)
tdSql
.
query
(
f
"select * from t2 where c4 between
{
-
1.7
*
10
**
308
-
1
}
and
{
-
1.7
*
10
**
308
}
"
)
# tdSql.checkRows(3)
# tdSql.checkRows(3)
tdSql
.
error
(
f
"select * from t2 where c4 between null and
{
-
1.7
*
10
**
308
}
"
)
tdSql
.
error
(
f
"select * from t2 where c4 between null and
{
-
1.7
*
10
**
308
}
"
)
...
@@ -135,8 +143,10 @@ class TDTestCase:
...
@@ -135,8 +143,10 @@ class TDTestCase:
tdSql
.
checkRows
(
9
)
tdSql
.
checkRows
(
9
)
tdSql
.
query
(
"select * from t1 where c5 between 136 and 127"
)
tdSql
.
query
(
"select * from t1 where c5 between 136 and 127"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
error
(
"select * from t1 where c5 between '~' and 'ˆ'"
)
tdSql
.
query
(
"select * from t1 where c5 between '~' and 'ˆ'"
)
tdSql
.
error
(
"select * from t1 where c5 not between 1 and 2"
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
"select * from t1 where c5 not between 1 and 2"
)
# tdSql.checkRows(0)
tdSql
.
query
(
"select * from t1 where c5 between 32767 and 32768"
)
tdSql
.
query
(
"select * from t1 where c5 between 32767 and 32768"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from t2 where c5 between -32768 and -32767"
)
tdSql
.
query
(
"select * from t2 where c5 between -32768 and -32767"
)
...
@@ -152,8 +162,10 @@ class TDTestCase:
...
@@ -152,8 +162,10 @@ class TDTestCase:
tdSql
.
checkRows
(
9
)
tdSql
.
checkRows
(
9
)
tdSql
.
query
(
"select * from t1 where c6 between 9 and 0"
)
tdSql
.
query
(
"select * from t1 where c6 between 9 and 0"
)
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
error
(
"select * from t1 where c6 between 'NUL' and 'HT'"
)
tdSql
.
query
(
"select * from t1 where c6 between 'NUL' and 'HT'"
)
tdSql
.
error
(
"select * from t1 where c6 not between 1 and 2"
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from t1 where c6 not between 1 and 2"
)
# tdSql.checkRows(1)
tdSql
.
query
(
"select * from t1 where c6 between 127 and 128"
)
tdSql
.
query
(
"select * from t1 where c6 between 127 and 128"
)
tdSql
.
checkRows
(
1
)
tdSql
.
checkRows
(
1
)
tdSql
.
query
(
"select * from t2 where c6 between -128 and -127"
)
tdSql
.
query
(
"select * from t2 where c6 between -128 and -127"
)
...
@@ -163,16 +175,16 @@ class TDTestCase:
...
@@ -163,16 +175,16 @@ class TDTestCase:
tdLog
.
printNoPrefix
(
"==========step10:invalid query type"
)
tdLog
.
printNoPrefix
(
"==========step10:invalid query type"
)
tdSql
.
query
(
"select * from supt where location between 'beijing' and 'shanghai'"
)
#
tdSql.query("select * from supt where location between 'beijing' and 'shanghai'")
tdSql
.
checkRows
(
23
)
#
tdSql.checkRows(23)
# 非0值均解析为1,因此"between 负值 and o"解析为"between 1 and 0"
#
#
非0值均解析为1,因此"between 负值 and o"解析为"between 1 and 0"
tdSql
.
query
(
"select * from supt where isused between 0 and 1"
)
#
tdSql.query("select * from supt where isused between 0 and 1")
tdSql
.
checkRows
(
23
)
#
tdSql.checkRows(23)
tdSql
.
query
(
"select * from supt where isused between -1 and 0"
)
#
tdSql.query("select * from supt where isused between -1 and 0")
tdSql
.
checkRows
(
0
)
#
tdSql.checkRows(0)
tdSql
.
error
(
"select * from supt where isused between false and true"
)
#
tdSql.error("select * from supt where isused between false and true")
tdSql
.
query
(
"select * from supt where family between '拖拉机' and '自行车'"
)
#
tdSql.query("select * from supt where family between '拖拉机' and '自行车'")
tdSql
.
checkRows
(
23
)
#
tdSql.checkRows(23)
tdLog
.
printNoPrefix
(
"==========step11:query HEX/OCT/BIN type"
)
tdLog
.
printNoPrefix
(
"==========step11:query HEX/OCT/BIN type"
)
...
...
tests/system-test/fulltest.sh
100644 → 100755
浏览文件 @
b7281e4d
python3 ./test.py
-f
2-query/
function_elapsed
.py
python3 ./test.py
-f
2-query/
between
.py
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录