Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3feca940
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看板
提交
3feca940
编写于
4月 10, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/node
上级
14ec5b67
4188f3fa
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
318 addition
and
192 deletion
+318
-192
include/common/tmsg.h
include/common/tmsg.h
+23
-7
include/common/tmsgdef.h
include/common/tmsgdef.h
+2
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+55
-4
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+238
-181
未找到文件。
include/common/tmsg.h
浏览文件 @
3feca940
...
@@ -622,7 +622,6 @@ typedef struct {
...
@@ -622,7 +622,6 @@ typedef struct {
int32_t
tSerializeSDbCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
const
SDbCfgRsp
*
pRsp
);
int32_t
tSerializeSDbCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
const
SDbCfgRsp
*
pRsp
);
int32_t
tDeserializeSDbCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
SDbCfgRsp
*
pRsp
);
int32_t
tDeserializeSDbCfgRsp
(
void
*
buf
,
int32_t
bufLen
,
SDbCfgRsp
*
pRsp
);
typedef
struct
{
typedef
struct
{
int32_t
rowNum
;
int32_t
rowNum
;
}
SQnodeListReq
;
}
SQnodeListReq
;
...
@@ -1023,8 +1022,9 @@ int32_t tDeserializeSMCfgDnodeReq(void* buf, int32_t bufLen, SMCfgDnodeReq* pReq
...
@@ -1023,8 +1022,9 @@ int32_t tDeserializeSMCfgDnodeReq(void* buf, int32_t bufLen, SMCfgDnodeReq* pReq
typedef
struct
{
typedef
struct
{
int32_t
dnodeId
;
int32_t
dnodeId
;
}
SMCreateMnodeReq
,
SMDropMnodeReq
,
SDDropMnodeReq
,
SMCreateQnodeReq
,
SMDropQnodeReq
,
SDCreateQnodeReq
,
SDDropQnodeReq
,
SMCreateSnodeReq
,
SMDropSnodeReq
,
}
SMCreateMnodeReq
,
SMDropMnodeReq
,
SDDropMnodeReq
,
SMCreateQnodeReq
,
SMDropQnodeReq
,
SDCreateQnodeReq
,
SDDropQnodeReq
,
SDCreateSnodeReq
,
SDDropSnodeReq
,
SMCreateBnodeReq
,
SMDropBnodeReq
,
SDCreateBnodeReq
,
SDDropBnodeReq
;
SMCreateSnodeReq
,
SMDropSnodeReq
,
SDCreateSnodeReq
,
SDDropSnodeReq
,
SMCreateBnodeReq
,
SMDropBnodeReq
,
SDCreateBnodeReq
,
SDDropBnodeReq
;
int32_t
tSerializeSCreateDropMQSBNodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateQnodeReq
*
pReq
);
int32_t
tSerializeSCreateDropMQSBNodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateQnodeReq
*
pReq
);
int32_t
tDeserializeSCreateDropMQSBNodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateQnodeReq
*
pReq
);
int32_t
tDeserializeSCreateDropMQSBNodeReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateQnodeReq
*
pReq
);
...
@@ -2298,6 +2298,22 @@ static FORCE_INLINE void* tDecodeTSmaWrapper(void* buf, STSmaWrapper* pSW) {
...
@@ -2298,6 +2298,22 @@ static FORCE_INLINE void* tDecodeTSmaWrapper(void* buf, STSmaWrapper* pSW) {
return
buf
;
return
buf
;
}
}
typedef
struct
{
int
idx
;
}
SMCreateFullTextReq
;
int32_t
tSerializeSMCreateFullTextReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateFullTextReq
*
pReq
);
int32_t
tDeserializeSMCreateFullTextReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateFullTextReq
*
pReq
);
void
tFreeSMCreateFullTextReq
(
SMCreateFullTextReq
*
pReq
);
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
int8_t
igNotExists
;
}
SMDropFullTextReq
;
int32_t
tSerializeSMDropFullTextReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropFullTextReq
*
pReq
);
int32_t
tDeserializeSMDropFullTextReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropFullTextReq
*
pReq
);
typedef
struct
{
typedef
struct
{
char
indexFName
[
TSDB_INDEX_FNAME_LEN
];
char
indexFName
[
TSDB_INDEX_FNAME_LEN
];
}
SUserIndexReq
;
}
SUserIndexReq
;
...
...
include/common/tmsgdef.h
浏览文件 @
3feca940
...
@@ -155,6 +155,8 @@ enum {
...
@@ -155,6 +155,8 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_STREAM
,
"mnode-create-stream"
,
SCMCreateStreamReq
,
SCMCreateStreamRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_STREAM
,
"mnode-create-stream"
,
SCMCreateStreamReq
,
SCMCreateStreamRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_STREAM
,
"mnode-alter-stream"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_ALTER_STREAM
,
"mnode-alter-stream"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_STREAM
,
"mnode-drop-stream"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_STREAM
,
"mnode-drop-stream"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_CREATE_INDEX
,
"mnode-create-index"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_DROP_INDEX
,
"mnode-drop-index"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GET_DB_CFG
,
"mnode-get-db-cfg"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GET_DB_CFG
,
"mnode-get-db-cfg"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GET_INDEX
,
"mnode-get-index"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_GET_INDEX
,
"mnode-get-index"
,
NULL
,
NULL
)
...
...
source/common/src/tmsg.c
浏览文件 @
3feca940
...
@@ -385,7 +385,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -385,7 +385,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
if
(
pReq
->
rollup
)
{
if
(
pReq
->
rollup
)
{
pReq
->
stbCfg
.
pRSmaParam
=
(
SRSmaParam
*
)
taosMemoryMalloc
(
sizeof
(
SRSmaParam
));
pReq
->
stbCfg
.
pRSmaParam
=
(
SRSmaParam
*
)
taosMemoryMalloc
(
sizeof
(
SRSmaParam
));
SRSmaParam
*
param
=
pReq
->
stbCfg
.
pRSmaParam
;
SRSmaParam
*
param
=
pReq
->
stbCfg
.
pRSmaParam
;
buf
=
taosDecodeBinaryTo
(
buf
,
(
void
*
)
&
param
->
xFilesFactor
,
sizeof
(
param
->
xFilesFactor
));
buf
=
taosDecodeBinaryTo
(
buf
,
(
void
*
)
&
param
->
xFilesFactor
,
sizeof
(
param
->
xFilesFactor
));
buf
=
taosDecodeFixedI32
(
buf
,
&
param
->
delay
);
buf
=
taosDecodeFixedI32
(
buf
,
&
param
->
delay
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
nFuncIds
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
nFuncIds
);
if
(
param
->
nFuncIds
>
0
)
{
if
(
param
->
nFuncIds
>
0
)
{
...
@@ -418,7 +418,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -418,7 +418,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
if
(
pReq
->
rollup
)
{
if
(
pReq
->
rollup
)
{
pReq
->
ntbCfg
.
pRSmaParam
=
(
SRSmaParam
*
)
taosMemoryMalloc
(
sizeof
(
SRSmaParam
));
pReq
->
ntbCfg
.
pRSmaParam
=
(
SRSmaParam
*
)
taosMemoryMalloc
(
sizeof
(
SRSmaParam
));
SRSmaParam
*
param
=
pReq
->
ntbCfg
.
pRSmaParam
;
SRSmaParam
*
param
=
pReq
->
ntbCfg
.
pRSmaParam
;
buf
=
taosDecodeBinaryTo
(
buf
,
(
void
*
)
&
param
->
xFilesFactor
,
sizeof
(
param
->
xFilesFactor
));
buf
=
taosDecodeBinaryTo
(
buf
,
(
void
*
)
&
param
->
xFilesFactor
,
sizeof
(
param
->
xFilesFactor
));
buf
=
taosDecodeFixedI32
(
buf
,
&
param
->
delay
);
buf
=
taosDecodeFixedI32
(
buf
,
&
param
->
delay
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
nFuncIds
);
buf
=
taosDecodeFixedI8
(
buf
,
&
param
->
nFuncIds
);
if
(
param
->
nFuncIds
>
0
)
{
if
(
param
->
nFuncIds
>
0
)
{
...
@@ -788,6 +788,7 @@ int32_t tSerializeSMDropSmaReq(void *buf, int32_t bufLen, SMDropSmaReq *pReq) {
...
@@ -788,6 +788,7 @@ int32_t tSerializeSMDropSmaReq(void *buf, int32_t bufLen, SMDropSmaReq *pReq) {
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igNotExists
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igNotExists
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
...
@@ -808,6 +809,56 @@ int32_t tDeserializeSMDropSmaReq(void *buf, int32_t bufLen, SMDropSmaReq *pReq)
...
@@ -808,6 +809,56 @@ int32_t tDeserializeSMDropSmaReq(void *buf, int32_t bufLen, SMDropSmaReq *pReq)
tCoderClear
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
return
0
;
}
}
int32_t
tSerializeSMCreateFullTextReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateFullTextReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSMCreateFullTextReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateFullTextReq
*
pReq
)
{
SCoder
decoder
=
{
0
};
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
void
tFreeSMCreateFullTextReq
(
SMCreateFullTextReq
*
pReq
)
{
// impl later
return
;
}
int32_t
tSerializeSMDropFullTextReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropFullTextReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igNotExists
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tCoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSMDropFullTextReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropFullTextReq
*
pReq
)
{
SCoder
decoder
=
{
0
};
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igNotExists
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSStatusReq
(
void
*
buf
,
int32_t
bufLen
,
SStatusReq
*
pReq
)
{
int32_t
tSerializeSStatusReq
(
void
*
buf
,
int32_t
bufLen
,
SStatusReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
SCoder
encoder
=
{
0
};
...
@@ -2912,7 +2963,7 @@ int32_t tDecodeSMqCMCommitOffsetReq(SCoder *decoder, SMqCMCommitOffsetReq *pReq)
...
@@ -2912,7 +2963,7 @@ int32_t tDecodeSMqCMCommitOffsetReq(SCoder *decoder, SMqCMCommitOffsetReq *pReq)
return
0
;
return
0
;
}
}
int32_t
tSerializeSExplainRsp
(
void
*
buf
,
int32_t
bufLen
,
SExplainRsp
*
pRsp
)
{
int32_t
tSerializeSExplainRsp
(
void
*
buf
,
int32_t
bufLen
,
SExplainRsp
*
pRsp
)
{
SCoder
encoder
=
{
0
};
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
...
@@ -2932,7 +2983,7 @@ int32_t tSerializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp) {
...
@@ -2932,7 +2983,7 @@ int32_t tSerializeSExplainRsp(void* buf, int32_t bufLen, SExplainRsp* pRsp) {
return
tlen
;
return
tlen
;
}
}
int32_t
tDeserializeSExplainRsp
(
void
*
buf
,
int32_t
bufLen
,
SExplainRsp
*
pRsp
)
{
int32_t
tDeserializeSExplainRsp
(
void
*
buf
,
int32_t
bufLen
,
SExplainRsp
*
pRsp
)
{
SCoder
decoder
=
{
0
};
SCoder
decoder
=
{
0
};
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
tCoderInit
(
&
decoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_DECODER
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
3feca940
...
@@ -44,13 +44,9 @@ typedef struct SFullDatabaseName {
...
@@ -44,13 +44,9 @@ typedef struct SFullDatabaseName {
static
int32_t
translateSubquery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
);
static
int32_t
translateSubquery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
);
static
int32_t
translateQuery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
);
static
int32_t
translateQuery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
);
static
bool
afterGroupBy
(
ESqlClause
clause
)
{
static
bool
afterGroupBy
(
ESqlClause
clause
)
{
return
clause
>
SQL_CLAUSE_GROUP_BY
;
}
return
clause
>
SQL_CLAUSE_GROUP_BY
;
}
static
bool
beforeHaving
(
ESqlClause
clause
)
{
static
bool
beforeHaving
(
ESqlClause
clause
)
{
return
clause
<
SQL_CLAUSE_HAVING
;
}
return
clause
<
SQL_CLAUSE_HAVING
;
}
#define generateDealNodeErrMsg(pCxt, code, ...) \
#define generateDealNodeErrMsg(pCxt, code, ...) \
({ \
({ \
...
@@ -113,13 +109,14 @@ static int32_t getTableMetaImpl(STranslateContext* pCxt, const SName* pName, STa
...
@@ -113,13 +109,14 @@ static int32_t getTableMetaImpl(STranslateContext* pCxt, const SName* pName, STa
code
=
catalogGetTableMeta
(
pParCxt
->
pCatalog
,
pParCxt
->
pTransporter
,
&
pParCxt
->
mgmtEpSet
,
pName
,
pMeta
);
code
=
catalogGetTableMeta
(
pParCxt
->
pCatalog
,
pParCxt
->
pTransporter
,
&
pParCxt
->
mgmtEpSet
,
pName
,
pMeta
);
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
parserError
(
"catalogGetTableMeta error, code:%s, dbName:%s, tbName:%s"
,
tstrerror
(
code
),
pName
->
dbname
,
pName
->
tname
);
parserError
(
"catalogGetTableMeta error, code:%s, dbName:%s, tbName:%s"
,
tstrerror
(
code
),
pName
->
dbname
,
pName
->
tname
);
}
}
return
code
;
return
code
;
}
}
static
int32_t
getTableMeta
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
const
char
*
pTableName
,
STableMeta
**
pMeta
)
{
static
int32_t
getTableMeta
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
const
char
*
pTableName
,
STableMeta
**
pMeta
)
{
SName
name
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SName
name
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
name
.
dbname
,
pDbName
);
strcpy
(
name
.
dbname
,
pDbName
);
strcpy
(
name
.
tname
,
pTableName
);
strcpy
(
name
.
tname
,
pTableName
);
return
getTableMetaImpl
(
pCxt
,
&
name
,
pMeta
);
return
getTableMetaImpl
(
pCxt
,
&
name
,
pMeta
);
...
@@ -135,7 +132,8 @@ static int32_t getTableDistVgInfo(STranslateContext* pCxt, const SName* pName, S
...
@@ -135,7 +132,8 @@ static int32_t getTableDistVgInfo(STranslateContext* pCxt, const SName* pName, S
code
=
catalogGetTableDistVgInfo
(
pParCxt
->
pCatalog
,
pParCxt
->
pTransporter
,
&
pParCxt
->
mgmtEpSet
,
pName
,
pVgInfo
);
code
=
catalogGetTableDistVgInfo
(
pParCxt
->
pCatalog
,
pParCxt
->
pTransporter
,
&
pParCxt
->
mgmtEpSet
,
pName
,
pVgInfo
);
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
parserError
(
"catalogGetTableDistVgInfo error, code:%s, dbName:%s, tbName:%s"
,
tstrerror
(
code
),
pName
->
dbname
,
pName
->
tname
);
parserError
(
"catalogGetTableDistVgInfo error, code:%s, dbName:%s, tbName:%s"
,
tstrerror
(
code
),
pName
->
dbname
,
pName
->
tname
);
}
}
return
code
;
return
code
;
}
}
...
@@ -172,19 +170,22 @@ static int32_t getTableHashVgroupImpl(STranslateContext* pCxt, const SName* pNam
...
@@ -172,19 +170,22 @@ static int32_t getTableHashVgroupImpl(STranslateContext* pCxt, const SName* pNam
code
=
catalogGetTableHashVgroup
(
pParCxt
->
pCatalog
,
pParCxt
->
pTransporter
,
&
pParCxt
->
mgmtEpSet
,
pName
,
pInfo
);
code
=
catalogGetTableHashVgroup
(
pParCxt
->
pCatalog
,
pParCxt
->
pTransporter
,
&
pParCxt
->
mgmtEpSet
,
pName
,
pInfo
);
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
parserError
(
"catalogGetTableHashVgroup error, code:%s, dbName:%s, tbName:%s"
,
tstrerror
(
code
),
pName
->
dbname
,
pName
->
tname
);
parserError
(
"catalogGetTableHashVgroup error, code:%s, dbName:%s, tbName:%s"
,
tstrerror
(
code
),
pName
->
dbname
,
pName
->
tname
);
}
}
return
code
;
return
code
;
}
}
static
int32_t
getTableHashVgroup
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
const
char
*
pTableName
,
SVgroupInfo
*
pInfo
)
{
static
int32_t
getTableHashVgroup
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
const
char
*
pTableName
,
SName
name
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SVgroupInfo
*
pInfo
)
{
SName
name
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
name
.
dbname
,
pDbName
);
strcpy
(
name
.
dbname
,
pDbName
);
strcpy
(
name
.
tname
,
pTableName
);
strcpy
(
name
.
tname
,
pTableName
);
return
getTableHashVgroupImpl
(
pCxt
,
&
name
,
pInfo
);
return
getTableHashVgroupImpl
(
pCxt
,
&
name
,
pInfo
);
}
}
static
int32_t
getDBVgVersion
(
STranslateContext
*
pCxt
,
const
char
*
pDbFName
,
int32_t
*
pVersion
,
int64_t
*
pDbId
,
int32_t
*
pTableNum
)
{
static
int32_t
getDBVgVersion
(
STranslateContext
*
pCxt
,
const
char
*
pDbFName
,
int32_t
*
pVersion
,
int64_t
*
pDbId
,
int32_t
*
pTableNum
)
{
SParseContext
*
pParCxt
=
pCxt
->
pParseCxt
;
SParseContext
*
pParCxt
=
pCxt
->
pParseCxt
;
int32_t
code
=
collectUseDatabaseImpl
(
pDbFName
,
pCxt
->
pDbs
);
int32_t
code
=
collectUseDatabaseImpl
(
pDbFName
,
pCxt
->
pDbs
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -216,7 +217,8 @@ static SNodeList* getProjectList(SNode* pNode) {
...
@@ -216,7 +217,8 @@ static SNodeList* getProjectList(SNode* pNode) {
return
NULL
;
return
NULL
;
}
}
static
void
setColumnInfoBySchema
(
const
SRealTableNode
*
pTable
,
const
SSchema
*
pColSchema
,
bool
isTag
,
SColumnNode
*
pCol
)
{
static
void
setColumnInfoBySchema
(
const
SRealTableNode
*
pTable
,
const
SSchema
*
pColSchema
,
bool
isTag
,
SColumnNode
*
pCol
)
{
strcpy
(
pCol
->
dbName
,
pTable
->
table
.
dbName
);
strcpy
(
pCol
->
dbName
,
pTable
->
table
.
dbName
);
strcpy
(
pCol
->
tableAlias
,
pTable
->
table
.
tableAlias
);
strcpy
(
pCol
->
tableAlias
,
pTable
->
table
.
tableAlias
);
strcpy
(
pCol
->
tableName
,
pTable
->
table
.
tableName
);
strcpy
(
pCol
->
tableName
,
pTable
->
table
.
tableName
);
...
@@ -253,7 +255,8 @@ static void setColumnInfoByExpr(const STableNode* pTable, SExprNode* pExpr, SCol
...
@@ -253,7 +255,8 @@ static void setColumnInfoByExpr(const STableNode* pTable, SExprNode* pExpr, SCol
static
int32_t
createColumnNodeByTable
(
STranslateContext
*
pCxt
,
const
STableNode
*
pTable
,
SNodeList
*
pList
)
{
static
int32_t
createColumnNodeByTable
(
STranslateContext
*
pCxt
,
const
STableNode
*
pTable
,
SNodeList
*
pList
)
{
if
(
QUERY_NODE_REAL_TABLE
==
nodeType
(
pTable
))
{
if
(
QUERY_NODE_REAL_TABLE
==
nodeType
(
pTable
))
{
const
STableMeta
*
pMeta
=
((
SRealTableNode
*
)
pTable
)
->
pMeta
;
const
STableMeta
*
pMeta
=
((
SRealTableNode
*
)
pTable
)
->
pMeta
;
int32_t
nums
=
pMeta
->
tableInfo
.
numOfColumns
+
((
TSDB_SUPER_TABLE
==
pMeta
->
tableType
)
?
pMeta
->
tableInfo
.
numOfTags
:
0
);
int32_t
nums
=
pMeta
->
tableInfo
.
numOfColumns
+
((
TSDB_SUPER_TABLE
==
pMeta
->
tableType
)
?
pMeta
->
tableInfo
.
numOfTags
:
0
);
for
(
int32_t
i
=
0
;
i
<
nums
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
nums
;
++
i
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
pCol
)
{
if
(
NULL
==
pCol
)
{
...
@@ -378,7 +381,8 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) {
...
@@ -378,7 +381,8 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) {
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
uint8_t
precision
=
(
NULL
!=
pCxt
->
pCurrStmt
?
pCxt
->
pCurrStmt
->
precision
:
pVal
->
node
.
resType
.
precision
);
uint8_t
precision
=
(
NULL
!=
pCxt
->
pCurrStmt
?
pCxt
->
pCurrStmt
->
precision
:
pVal
->
node
.
resType
.
precision
);
if
(
pVal
->
isDuration
)
{
if
(
pVal
->
isDuration
)
{
if
(
parseNatualDuration
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
&
pVal
->
datum
.
i
,
&
pVal
->
unit
,
precision
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
parseNatualDuration
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
&
pVal
->
datum
.
i
,
&
pVal
->
unit
,
precision
)
!=
TSDB_CODE_SUCCESS
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
}
}
else
{
}
else
{
...
@@ -422,7 +426,8 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
...
@@ -422,7 +426,8 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
break
;
break
;
}
}
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
if
(
taosParseTime
(
pVal
->
literal
,
&
pVal
->
datum
.
i
,
pVal
->
node
.
resType
.
bytes
,
precision
,
tsDaylight
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
taosParseTime
(
pVal
->
literal
,
&
pVal
->
datum
.
i
,
pVal
->
node
.
resType
.
bytes
,
precision
,
tsDaylight
)
!=
TSDB_CODE_SUCCESS
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
}
break
;
break
;
...
@@ -453,15 +458,15 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
...
@@ -453,15 +458,15 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) {
SDataType
ldt
=
((
SExprNode
*
)(
pOp
->
pLeft
))
->
resType
;
SDataType
ldt
=
((
SExprNode
*
)(
pOp
->
pLeft
))
->
resType
;
SDataType
rdt
=
((
SExprNode
*
)(
pOp
->
pRight
))
->
resType
;
SDataType
rdt
=
((
SExprNode
*
)(
pOp
->
pRight
))
->
resType
;
if
(
nodesIsArithmeticOp
(
pOp
))
{
if
(
nodesIsArithmeticOp
(
pOp
))
{
if
(
TSDB_DATA_TYPE_JSON
==
ldt
.
type
||
TSDB_DATA_TYPE_BLOB
==
ldt
.
type
||
if
(
TSDB_DATA_TYPE_JSON
==
ldt
.
type
||
TSDB_DATA_TYPE_BLOB
==
ldt
.
type
||
TSDB_DATA_TYPE_JSON
==
rdt
.
type
||
TSDB_DATA_TYPE_
JSON
==
rdt
.
type
||
TSDB_DATA_TYPE_
BLOB
==
rdt
.
type
)
{
TSDB_DATA_TYPE_BLOB
==
rdt
.
type
)
{
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
);
}
}
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_DOUBLE
;
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_DOUBLE
;
pOp
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_DOUBLE
].
bytes
;
pOp
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_DOUBLE
].
bytes
;
}
else
if
(
nodesIsComparisonOp
(
pOp
))
{
}
else
if
(
nodesIsComparisonOp
(
pOp
))
{
if
(
TSDB_DATA_TYPE_JSON
==
ldt
.
type
||
TSDB_DATA_TYPE_BLOB
==
ldt
.
type
||
if
(
TSDB_DATA_TYPE_JSON
==
ldt
.
type
||
TSDB_DATA_TYPE_BLOB
==
ldt
.
type
||
TSDB_DATA_TYPE_JSON
==
rdt
.
type
||
TSDB_DATA_TYPE_
JSON
==
rdt
.
type
||
TSDB_DATA_TYPE_
BLOB
==
rdt
.
type
)
{
TSDB_DATA_TYPE_BLOB
==
rdt
.
type
)
{
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
);
}
}
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BOOL
;
pOp
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BOOL
;
...
@@ -527,9 +532,7 @@ static int32_t translateExprList(STranslateContext* pCxt, SNodeList* pList) {
...
@@ -527,9 +532,7 @@ static int32_t translateExprList(STranslateContext* pCxt, SNodeList* pList) {
return
pCxt
->
errCode
;
return
pCxt
->
errCode
;
}
}
static
bool
isAliasColumn
(
SColumnNode
*
pCol
)
{
static
bool
isAliasColumn
(
SColumnNode
*
pCol
)
{
return
(
'\0'
==
pCol
->
tableAlias
[
0
]);
}
return
(
'\0'
==
pCol
->
tableAlias
[
0
]);
}
static
bool
isDistinctOrderBy
(
STranslateContext
*
pCxt
)
{
static
bool
isDistinctOrderBy
(
STranslateContext
*
pCxt
)
{
return
(
SQL_CLAUSE_ORDER_BY
==
pCxt
->
currClause
&&
pCxt
->
pCurrStmt
->
isDistinct
);
return
(
SQL_CLAUSE_ORDER_BY
==
pCxt
->
currClause
&&
pCxt
->
pCurrStmt
->
isDistinct
);
...
@@ -561,7 +564,8 @@ static EDealRes doCheckExprForGroupBy(SNode* pNode, void* pContext) {
...
@@ -561,7 +564,8 @@ static EDealRes doCheckExprForGroupBy(SNode* pNode, void* pContext) {
if
(
!
nodesIsExprNode
(
pNode
)
||
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
)
&&
isAliasColumn
((
SColumnNode
*
)
pNode
)))
{
if
(
!
nodesIsExprNode
(
pNode
)
||
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
)
&&
isAliasColumn
((
SColumnNode
*
)
pNode
)))
{
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
pNode
)
&&
fmIsAggFunc
(((
SFunctionNode
*
)
pNode
)
->
funcId
)
&&
!
isDistinctOrderBy
(
pCxt
))
{
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
pNode
)
&&
fmIsAggFunc
(((
SFunctionNode
*
)
pNode
)
->
funcId
)
&&
!
isDistinctOrderBy
(
pCxt
))
{
return
DEAL_RES_IGNORE_CHILD
;
return
DEAL_RES_IGNORE_CHILD
;
}
}
SNode
*
pGroupNode
;
SNode
*
pGroupNode
;
...
@@ -571,7 +575,8 @@ static EDealRes doCheckExprForGroupBy(SNode* pNode, void* pContext) {
...
@@ -571,7 +575,8 @@ static EDealRes doCheckExprForGroupBy(SNode* pNode, void* pContext) {
}
}
}
}
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
)
||
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
)
||
(
QUERY_NODE_FUNCTION
==
nodeType
(
pNode
)
&&
fmIsAggFunc
(((
SFunctionNode
*
)
pNode
)
->
funcId
)
&&
isDistinctOrderBy
(
pCxt
)))
{
(
QUERY_NODE_FUNCTION
==
nodeType
(
pNode
)
&&
fmIsAggFunc
(((
SFunctionNode
*
)
pNode
)
->
funcId
)
&&
isDistinctOrderBy
(
pCxt
)))
{
return
generateDealNodeErrMsg
(
pCxt
,
getGroupByErrorCode
(
pCxt
));
return
generateDealNodeErrMsg
(
pCxt
,
getGroupByErrorCode
(
pCxt
));
}
}
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
...
@@ -612,7 +617,7 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
...
@@ -612,7 +617,7 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
if
(
NULL
!=
pSelect
->
pGroupByList
)
{
if
(
NULL
!=
pSelect
->
pGroupByList
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
CheckAggColCoexistCxt
cxt
=
{
.
pTranslateCxt
=
pCxt
,
.
existAggFunc
=
false
,
.
existCol
=
false
};
CheckAggColCoexistCxt
cxt
=
{
.
pTranslateCxt
=
pCxt
,
.
existAggFunc
=
false
,
.
existCol
=
false
};
nodesWalkExprs
(
pSelect
->
pProjectionList
,
doCheckAggColCoexist
,
&
cxt
);
nodesWalkExprs
(
pSelect
->
pProjectionList
,
doCheckAggColCoexist
,
&
cxt
);
if
(
!
pSelect
->
isDistinct
)
{
if
(
!
pSelect
->
isDistinct
)
{
nodesWalkExprs
(
pSelect
->
pOrderByList
,
doCheckAggColCoexist
,
&
cxt
);
nodesWalkExprs
(
pSelect
->
pOrderByList
,
doCheckAggColCoexist
,
&
cxt
);
...
@@ -631,7 +636,7 @@ static int32_t toVgroupsInfo(SArray* pVgs, SVgroupsInfo** pVgsInfo) {
...
@@ -631,7 +636,7 @@ static int32_t toVgroupsInfo(SArray* pVgs, SVgroupsInfo** pVgsInfo) {
}
}
(
*
pVgsInfo
)
->
numOfVgroups
=
vgroupNum
;
(
*
pVgsInfo
)
->
numOfVgroups
=
vgroupNum
;
for
(
int32_t
i
=
0
;
i
<
vgroupNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
vgroupNum
;
++
i
)
{
SVgroupInfo
*
vg
=
taosArrayGet
(
pVgs
,
i
);
SVgroupInfo
*
vg
=
taosArrayGet
(
pVgs
,
i
);
(
*
pVgsInfo
)
->
vgroups
[
i
]
=
*
vg
;
(
*
pVgsInfo
)
->
vgroups
[
i
]
=
*
vg
;
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -704,8 +709,9 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
...
@@ -704,8 +709,9 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
SRealTableNode
*
pRealTable
=
(
SRealTableNode
*
)
pTable
;
SRealTableNode
*
pRealTable
=
(
SRealTableNode
*
)
pTable
;
pRealTable
->
ratio
=
(
NULL
!=
pCxt
->
pExplainOpt
?
pCxt
->
pExplainOpt
->
ratio
:
1
.
0
);
pRealTable
->
ratio
=
(
NULL
!=
pCxt
->
pExplainOpt
?
pCxt
->
pExplainOpt
->
ratio
:
1
.
0
);
SName
name
;
SName
name
;
code
=
getTableMetaImpl
(
pCxt
,
code
=
getTableMetaImpl
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pRealTable
->
table
.
dbName
,
pRealTable
->
table
.
tableName
,
&
name
),
&
(
pRealTable
->
pMeta
));
pCxt
,
toName
(
pCxt
->
pParseCxt
->
acctId
,
pRealTable
->
table
.
dbName
,
pRealTable
->
table
.
tableName
,
&
name
),
&
(
pRealTable
->
pMeta
));
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
pRealTable
->
table
.
tableName
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
pRealTable
->
table
.
tableName
);
}
}
...
@@ -791,7 +797,8 @@ static SNode* createFirstLastFunc(SFunctionNode* pSrcFunc, SColumnNode* pCol) {
...
@@ -791,7 +797,8 @@ static SNode* createFirstLastFunc(SFunctionNode* pSrcFunc, SColumnNode* pCol) {
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
);
snprintf
(
pFunc
->
node
.
aliasName
,
sizeof
(
pFunc
->
node
.
aliasName
),
(
FUNCTION_TYPE_FIRST
==
pSrcFunc
->
funcType
?
"first(%s)"
:
"last(%s)"
),
pCol
->
colName
);
snprintf
(
pFunc
->
node
.
aliasName
,
sizeof
(
pFunc
->
node
.
aliasName
),
(
FUNCTION_TYPE_FIRST
==
pSrcFunc
->
funcType
?
"first(%s)"
:
"last(%s)"
),
pCol
->
colName
);
return
(
SNode
*
)
pFunc
;
return
(
SNode
*
)
pFunc
;
}
}
...
@@ -870,7 +877,8 @@ static int32_t getPositionValue(const SValueNode* pVal) {
...
@@ -870,7 +877,8 @@ static int32_t getPositionValue(const SValueNode* pVal) {
return
-
1
;
return
-
1
;
}
}
static
int32_t
translateOrderByPosition
(
STranslateContext
*
pCxt
,
SNodeList
*
pProjectionList
,
SNodeList
*
pOrderByList
,
bool
*
pOther
)
{
static
int32_t
translateOrderByPosition
(
STranslateContext
*
pCxt
,
SNodeList
*
pProjectionList
,
SNodeList
*
pOrderByList
,
bool
*
pOther
)
{
*
pOther
=
false
;
*
pOther
=
false
;
SNode
*
pNode
=
NULL
;
SNode
*
pNode
=
NULL
;
WHERE_EACH
(
pNode
,
pOrderByList
)
{
WHERE_EACH
(
pNode
,
pOrderByList
)
{
...
@@ -1047,11 +1055,7 @@ static int32_t buildCreateDbRetentions(const SNodeList* pRetentions, SCreateDbRe
...
@@ -1047,11 +1055,7 @@ static int32_t buildCreateDbRetentions(const SNodeList* pRetentions, SCreateDbRe
pFreq
=
(
SValueNode
*
)
nodesListGetNode
(((
SNodeListNode
*
)
pNode
)
->
pNodeList
,
0
);
pFreq
=
(
SValueNode
*
)
nodesListGetNode
(((
SNodeListNode
*
)
pNode
)
->
pNodeList
,
0
);
pKeep
=
(
SValueNode
*
)
nodesListGetNode
(((
SNodeListNode
*
)
pNode
)
->
pNodeList
,
1
);
pKeep
=
(
SValueNode
*
)
nodesListGetNode
(((
SNodeListNode
*
)
pNode
)
->
pNodeList
,
1
);
SRetention
retention
=
{
SRetention
retention
=
{
.
freq
=
pFreq
->
datum
.
i
,
.
freq
=
pFreq
->
datum
.
i
,
.
freqUnit
=
pFreq
->
unit
,
.
keep
=
pKeep
->
datum
.
i
,
.
keepUnit
=
pKeep
->
unit
};
.
freqUnit
=
pFreq
->
unit
,
.
keep
=
pKeep
->
datum
.
i
,
.
keepUnit
=
pKeep
->
unit
};
taosArrayPush
(
pReq
->
pRetensions
,
&
retention
);
taosArrayPush
(
pReq
->
pRetensions
,
&
retention
);
}
}
pReq
->
numOfRetensions
=
taosArrayGetSize
(
pReq
->
pRetensions
);
pReq
->
numOfRetensions
=
taosArrayGetSize
(
pReq
->
pRetensions
);
...
@@ -1088,7 +1092,8 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS
...
@@ -1088,7 +1092,8 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS
return
buildCreateDbRetentions
(
pStmt
->
pOptions
->
pRetentions
,
pReq
);
return
buildCreateDbRetentions
(
pStmt
->
pOptions
->
pRetentions
,
pReq
);
}
}
static
int32_t
checkRangeOption
(
STranslateContext
*
pCxt
,
const
char
*
pName
,
SValueNode
*
pVal
,
int32_t
minVal
,
int32_t
maxVal
)
{
static
int32_t
checkRangeOption
(
STranslateContext
*
pCxt
,
const
char
*
pName
,
SValueNode
*
pVal
,
int32_t
minVal
,
int32_t
maxVal
)
{
if
(
NULL
!=
pVal
)
{
if
(
NULL
!=
pVal
)
{
if
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
pVal
))
{
if
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
pVal
))
{
return
pCxt
->
errCode
;
return
pCxt
->
errCode
;
...
@@ -1187,7 +1192,8 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
...
@@ -1187,7 +1192,8 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
int32_t
daysToKeep2
=
((
SValueNode
*
)
nodesListGetNode
(
pKeep
,
2
))
->
datum
.
i
;
int32_t
daysToKeep2
=
((
SValueNode
*
)
nodesListGetNode
(
pKeep
,
2
))
->
datum
.
i
;
if
(
daysToKeep0
<
TSDB_MIN_KEEP
||
daysToKeep1
<
TSDB_MIN_KEEP
||
daysToKeep2
<
TSDB_MIN_KEEP
||
if
(
daysToKeep0
<
TSDB_MIN_KEEP
||
daysToKeep1
<
TSDB_MIN_KEEP
||
daysToKeep2
<
TSDB_MIN_KEEP
||
daysToKeep0
>
TSDB_MAX_KEEP
||
daysToKeep1
>
TSDB_MAX_KEEP
||
daysToKeep2
>
TSDB_MAX_KEEP
)
{
daysToKeep0
>
TSDB_MAX_KEEP
||
daysToKeep1
>
TSDB_MAX_KEEP
||
daysToKeep2
>
TSDB_MAX_KEEP
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_KEEP_VALUE
,
daysToKeep0
,
daysToKeep1
,
daysToKeep2
,
TSDB_MIN_KEEP
,
TSDB_MAX_KEEP
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_KEEP_VALUE
,
daysToKeep0
,
daysToKeep1
,
daysToKeep2
,
TSDB_MIN_KEEP
,
TSDB_MAX_KEEP
);
}
}
if
(
!
((
daysToKeep0
<=
daysToKeep1
)
&&
(
daysToKeep1
<=
daysToKeep2
)))
{
if
(
!
((
daysToKeep0
<=
daysToKeep1
)
&&
(
daysToKeep1
<=
daysToKeep2
)))
{
...
@@ -1220,27 +1226,33 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete
...
@@ -1220,27 +1226,33 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete
}
}
static
int32_t
checkDatabaseOptions
(
STranslateContext
*
pCxt
,
SDatabaseOptions
*
pOptions
)
{
static
int32_t
checkDatabaseOptions
(
STranslateContext
*
pCxt
,
SDatabaseOptions
*
pOptions
)
{
int32_t
code
=
checkRangeOption
(
pCxt
,
"totalBlocks"
,
pOptions
->
pNumOfBlocks
,
TSDB_MIN_TOTAL_BLOCKS
,
TSDB_MAX_TOTAL_BLOCKS
);
int32_t
code
=
checkRangeOption
(
pCxt
,
"totalBlocks"
,
pOptions
->
pNumOfBlocks
,
TSDB_MIN_TOTAL_BLOCKS
,
TSDB_MAX_TOTAL_BLOCKS
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkRangeOption
(
pCxt
,
"cacheBlockSize"
,
pOptions
->
pCacheBlockSize
,
TSDB_MIN_CACHE_BLOCK_SIZE
,
TSDB_MAX_CACHE_BLOCK_SIZE
);
code
=
checkRangeOption
(
pCxt
,
"cacheBlockSize"
,
pOptions
->
pCacheBlockSize
,
TSDB_MIN_CACHE_BLOCK_SIZE
,
TSDB_MAX_CACHE_BLOCK_SIZE
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkRangeOption
(
pCxt
,
"cacheLast"
,
pOptions
->
pCachelast
,
TSDB_MIN_DB_CACHE_LAST_ROW
,
TSDB_MAX_DB_CACHE_LAST_ROW
);
code
=
checkRangeOption
(
pCxt
,
"cacheLast"
,
pOptions
->
pCachelast
,
TSDB_MIN_DB_CACHE_LAST_ROW
,
TSDB_MAX_DB_CACHE_LAST_ROW
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
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
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkRangeOption
(
pCxt
,
"maxRowsPerBlock"
,
pOptions
->
pMaxRowsPerBlock
,
TSDB_MIN_MAX_ROW_FBLOCK
,
TSDB_MAX_MAX_ROW_FBLOCK
);
code
=
checkRangeOption
(
pCxt
,
"maxRowsPerBlock"
,
pOptions
->
pMaxRowsPerBlock
,
TSDB_MIN_MAX_ROW_FBLOCK
,
TSDB_MAX_MAX_ROW_FBLOCK
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkRangeOption
(
pCxt
,
"minRowsPerBlock"
,
pOptions
->
pMinRowsPerBlock
,
TSDB_MIN_MIN_ROW_FBLOCK
,
TSDB_MAX_MIN_ROW_FBLOCK
);
code
=
checkRangeOption
(
pCxt
,
"minRowsPerBlock"
,
pOptions
->
pMinRowsPerBlock
,
TSDB_MIN_MIN_ROW_FBLOCK
,
TSDB_MAX_MIN_ROW_FBLOCK
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkKeepOption
(
pCxt
,
pOptions
->
pKeep
);
code
=
checkKeepOption
(
pCxt
,
pOptions
->
pKeep
);
...
@@ -1252,7 +1264,8 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p
...
@@ -1252,7 +1264,8 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p
code
=
checkRangeOption
(
pCxt
,
"quorum"
,
pOptions
->
pQuorum
,
TSDB_MIN_DB_QUORUM_OPTION
,
TSDB_MAX_DB_QUORUM_OPTION
);
code
=
checkRangeOption
(
pCxt
,
"quorum"
,
pOptions
->
pQuorum
,
TSDB_MIN_DB_QUORUM_OPTION
,
TSDB_MAX_DB_QUORUM_OPTION
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkDbEnumOption
(
pCxt
,
"replications"
,
pOptions
->
pReplica
,
TSDB_MIN_DB_REPLICA_OPTION
,
TSDB_MAX_DB_REPLICA_OPTION
);
code
=
checkDbEnumOption
(
pCxt
,
"replications"
,
pOptions
->
pReplica
,
TSDB_MIN_DB_REPLICA_OPTION
,
TSDB_MAX_DB_REPLICA_OPTION
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkTtlOption
(
pCxt
,
pOptions
->
pTtl
);
code
=
checkTtlOption
(
pCxt
,
pOptions
->
pTtl
);
...
@@ -1264,10 +1277,12 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p
...
@@ -1264,10 +1277,12 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p
code
=
checkRangeOption
(
pCxt
,
"vgroups"
,
pOptions
->
pNumOfVgroups
,
TSDB_MIN_VNODES_PER_DB
,
TSDB_MAX_VNODES_PER_DB
);
code
=
checkRangeOption
(
pCxt
,
"vgroups"
,
pOptions
->
pNumOfVgroups
,
TSDB_MIN_VNODES_PER_DB
,
TSDB_MAX_VNODES_PER_DB
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkDbEnumOption
(
pCxt
,
"singleStable"
,
pOptions
->
pSingleStable
,
TSDB_MIN_DB_SINGLE_STABLE_OPTION
,
TSDB_MAX_DB_SINGLE_STABLE_OPTION
);
code
=
checkDbEnumOption
(
pCxt
,
"singleStable"
,
pOptions
->
pSingleStable
,
TSDB_MIN_DB_SINGLE_STABLE_OPTION
,
TSDB_MAX_DB_SINGLE_STABLE_OPTION
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkDbEnumOption
(
pCxt
,
"streamMode"
,
pOptions
->
pStreamMode
,
TSDB_MIN_DB_STREAM_MODE_OPTION
,
TSDB_MAX_DB_STREAM_MODE_OPTION
);
code
=
checkDbEnumOption
(
pCxt
,
"streamMode"
,
pOptions
->
pStreamMode
,
TSDB_MIN_DB_STREAM_MODE_OPTION
,
TSDB_MAX_DB_STREAM_MODE_OPTION
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkDbRetentionsOption
(
pCxt
,
pOptions
->
pRetentions
);
code
=
checkDbRetentionsOption
(
pCxt
,
pOptions
->
pRetentions
);
...
@@ -1384,7 +1399,7 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray) {
...
@@ -1384,7 +1399,7 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray) {
SNode
*
pNode
;
SNode
*
pNode
;
FOREACH
(
pNode
,
pList
)
{
FOREACH
(
pNode
,
pList
)
{
SColumnDefNode
*
pCol
=
(
SColumnDefNode
*
)
pNode
;
SColumnDefNode
*
pCol
=
(
SColumnDefNode
*
)
pNode
;
SField
field
=
{
.
type
=
pCol
->
dataType
.
type
,
.
bytes
=
calcTypeBytes
(
pCol
->
dataType
)
};
SField
field
=
{.
type
=
pCol
->
dataType
.
type
,
.
bytes
=
calcTypeBytes
(
pCol
->
dataType
)
};
strcpy
(
field
.
name
,
pCol
->
colName
);
strcpy
(
field
.
name
,
pCol
->
colName
);
taosArrayPush
(
*
pArray
,
&
field
);
taosArrayPush
(
*
pArray
,
&
field
);
}
}
...
@@ -1396,7 +1411,7 @@ static int32_t columnNodeToField(SNodeList* pList, SArray** pArray) {
...
@@ -1396,7 +1411,7 @@ static int32_t columnNodeToField(SNodeList* pList, SArray** pArray) {
SNode
*
pNode
;
SNode
*
pNode
;
FOREACH
(
pNode
,
pList
)
{
FOREACH
(
pNode
,
pList
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
SField
field
=
{
.
type
=
pCol
->
node
.
resType
.
type
,
.
bytes
=
calcTypeBytes
(
pCol
->
node
.
resType
)
};
SField
field
=
{.
type
=
pCol
->
node
.
resType
.
type
,
.
bytes
=
calcTypeBytes
(
pCol
->
node
.
resType
)
};
strcpy
(
field
.
name
,
pCol
->
colName
);
strcpy
(
field
.
name
,
pCol
->
colName
);
taosArrayPush
(
*
pArray
,
&
field
);
taosArrayPush
(
*
pArray
,
&
field
);
}
}
...
@@ -1431,7 +1446,8 @@ static int32_t checTableFactorOption(STranslateContext* pCxt, SValueNode* pVal)
...
@@ -1431,7 +1446,8 @@ static int32_t checTableFactorOption(STranslateContext* pCxt, SValueNode* pVal)
return
pCxt
->
errCode
;
return
pCxt
->
errCode
;
}
}
if
(
pVal
->
datum
.
d
<
TSDB_MIN_DB_FILE_FACTOR
||
pVal
->
datum
.
d
>
TSDB_MAX_DB_FILE_FACTOR
)
{
if
(
pVal
->
datum
.
d
<
TSDB_MIN_DB_FILE_FACTOR
||
pVal
->
datum
.
d
>
TSDB_MAX_DB_FILE_FACTOR
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_F_RANGE_OPTION
,
"file_factor"
,
pVal
->
datum
.
d
,
TSDB_MIN_DB_FILE_FACTOR
,
TSDB_MAX_DB_FILE_FACTOR
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_F_RANGE_OPTION
,
"file_factor"
,
pVal
->
datum
.
d
,
TSDB_MIN_DB_FILE_FACTOR
,
TSDB_MAX_DB_FILE_FACTOR
);
}
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -1440,9 +1456,7 @@ static int32_t checTableFactorOption(STranslateContext* pCxt, SValueNode* pVal)
...
@@ -1440,9 +1456,7 @@ static int32_t checTableFactorOption(STranslateContext* pCxt, SValueNode* pVal)
static
int32_t
checkTableSmaOption
(
STranslateContext
*
pCxt
,
SCreateTableStmt
*
pStmt
)
{
static
int32_t
checkTableSmaOption
(
STranslateContext
*
pCxt
,
SCreateTableStmt
*
pStmt
)
{
if
(
NULL
!=
pStmt
->
pOptions
->
pSma
)
{
if
(
NULL
!=
pStmt
->
pOptions
->
pSma
)
{
SNode
*
pNode
=
NULL
;
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pStmt
->
pCols
)
{
FOREACH
(
pNode
,
pStmt
->
pCols
)
{
((
SColumnDefNode
*
)
pNode
)
->
sma
=
false
;
}
((
SColumnDefNode
*
)
pNode
)
->
sma
=
false
;
}
FOREACH
(
pNode
,
pStmt
->
pOptions
->
pSma
)
{
FOREACH
(
pNode
,
pStmt
->
pOptions
->
pSma
)
{
SColumnNode
*
pSmaCol
=
(
SColumnNode
*
)
pNode
;
SColumnNode
*
pSmaCol
=
(
SColumnNode
*
)
pNode
;
SColumnDefNode
*
pColDef
=
findColDef
(
pStmt
->
pCols
,
pSmaCol
);
SColumnDefNode
*
pColDef
=
findColDef
(
pStmt
->
pCols
,
pSmaCol
);
...
@@ -1524,7 +1538,7 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt
...
@@ -1524,7 +1538,7 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt
createReq
.
numOfSmas
=
LIST_LENGTH
(
pStmt
->
pOptions
->
pSma
);
createReq
.
numOfSmas
=
LIST_LENGTH
(
pStmt
->
pOptions
->
pSma
);
}
}
SName
tableName
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SName
tableName
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
tableName
.
dbname
,
pStmt
->
dbName
);
strcpy
(
tableName
.
dbname
,
pStmt
->
dbName
);
strcpy
(
tableName
.
tname
,
pStmt
->
tableName
);
strcpy
(
tableName
.
tname
,
pStmt
->
tableName
);
tNameExtractFullName
(
&
tableName
,
createReq
.
name
);
tNameExtractFullName
(
&
tableName
,
createReq
.
name
);
...
@@ -1593,7 +1607,7 @@ static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt
...
@@ -1593,7 +1607,7 @@ static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt
}
}
static
int32_t
translateDropSuperTable
(
STranslateContext
*
pCxt
,
SDropSuperTableStmt
*
pStmt
)
{
static
int32_t
translateDropSuperTable
(
STranslateContext
*
pCxt
,
SDropSuperTableStmt
*
pStmt
)
{
SName
tableName
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SName
tableName
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
tableName
.
dbname
,
pStmt
->
dbName
);
strcpy
(
tableName
.
dbname
,
pStmt
->
dbName
);
strcpy
(
tableName
.
tname
,
pStmt
->
tableName
);
strcpy
(
tableName
.
tname
,
pStmt
->
tableName
);
return
doTranslateDropSuperTable
(
pCxt
,
&
tableName
,
pStmt
->
ignoreNotExists
);
return
doTranslateDropSuperTable
(
pCxt
,
&
tableName
,
pStmt
->
ignoreNotExists
);
...
@@ -1612,7 +1626,7 @@ static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAltertbReq* pAlterRe
...
@@ -1612,7 +1626,7 @@ static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAltertbReq* pAlterRe
case
TSDB_ALTER_TABLE_DROP_COLUMN
:
case
TSDB_ALTER_TABLE_DROP_COLUMN
:
case
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
:
case
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
:
case
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
:
{
case
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
:
{
TAOS_FIELD
field
=
{
.
type
=
pStmt
->
dataType
.
type
,
.
bytes
=
pStmt
->
dataType
.
bytes
};
TAOS_FIELD
field
=
{
.
type
=
pStmt
->
dataType
.
type
,
.
bytes
=
pStmt
->
dataType
.
bytes
};
strcpy
(
field
.
name
,
pStmt
->
colName
);
strcpy
(
field
.
name
,
pStmt
->
colName
);
taosArrayPush
(
pAlterReq
->
pFields
,
&
field
);
taosArrayPush
(
pAlterReq
->
pFields
,
&
field
);
break
;
break
;
...
@@ -1636,7 +1650,7 @@ static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAltertbReq* pAlterRe
...
@@ -1636,7 +1650,7 @@ static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAltertbReq* pAlterRe
static
int32_t
translateAlterTable
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
static
int32_t
translateAlterTable
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
SMAltertbReq
alterReq
=
{
0
};
SMAltertbReq
alterReq
=
{
0
};
SName
tableName
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SName
tableName
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
tableName
.
dbname
,
pStmt
->
dbName
);
strcpy
(
tableName
.
dbname
,
pStmt
->
dbName
);
strcpy
(
tableName
.
tname
,
pStmt
->
tableName
);
strcpy
(
tableName
.
tname
,
pStmt
->
tableName
);
tNameExtractFullName
(
&
tableName
,
alterReq
.
name
);
tNameExtractFullName
(
&
tableName
,
alterReq
.
name
);
...
@@ -1849,7 +1863,7 @@ static int32_t nodeTypeToShowType(ENodeType nt) {
...
@@ -1849,7 +1863,7 @@ static int32_t nodeTypeToShowType(ENodeType nt) {
}
}
static
int32_t
translateShow
(
STranslateContext
*
pCxt
,
SShowStmt
*
pStmt
)
{
static
int32_t
translateShow
(
STranslateContext
*
pCxt
,
SShowStmt
*
pStmt
)
{
SShowReq
showReq
=
{
.
type
=
nodeTypeToShowType
(
nodeType
(
pStmt
))
};
SShowReq
showReq
=
{
.
type
=
nodeTypeToShowType
(
nodeType
(
pStmt
))
};
pCxt
->
pCmdMsg
=
taosMemoryMalloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
taosMemoryMalloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
...
@@ -1914,9 +1928,7 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS
...
@@ -1914,9 +1928,7 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS
strcpy
(
pFunc
->
functionName
,
"_wstartts"
);
strcpy
(
pFunc
->
functionName
,
"_wstartts"
);
nodesListPushFront
(
pSelect
->
pProjectionList
,
pFunc
);
nodesListPushFront
(
pSelect
->
pProjectionList
,
pFunc
);
SNode
*
pProject
=
NULL
;
SNode
*
pProject
=
NULL
;
FOREACH
(
pProject
,
pSelect
->
pProjectionList
)
{
FOREACH
(
pProject
,
pSelect
->
pProjectionList
)
{
sprintf
(((
SExprNode
*
)
pProject
)
->
aliasName
,
"#sma_%p"
,
pProject
);
}
sprintf
(((
SExprNode
*
)
pProject
)
->
aliasName
,
"#sma_%p"
,
pProject
);
}
SIntervalWindowNode
*
pInterval
=
nodesMakeNode
(
QUERY_NODE_INTERVAL_WINDOW
);
SIntervalWindowNode
*
pInterval
=
nodesMakeNode
(
QUERY_NODE_INTERVAL_WINDOW
);
if
(
NULL
==
pInterval
)
{
if
(
NULL
==
pInterval
)
{
...
@@ -1946,7 +1958,7 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS
...
@@ -1946,7 +1958,7 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS
}
}
static
int32_t
buildCreateSmaReq
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
,
SMCreateSmaReq
*
pReq
)
{
static
int32_t
buildCreateSmaReq
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
,
SMCreateSmaReq
*
pReq
)
{
SName
name
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SName
name
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
strcpy
(
name
.
tname
,
pStmt
->
indexName
);
strcpy
(
name
.
tname
,
pStmt
->
indexName
);
tNameExtractFullName
(
&
name
,
pReq
->
name
);
tNameExtractFullName
(
&
name
,
pReq
->
name
);
...
@@ -1957,8 +1969,10 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm
...
@@ -1957,8 +1969,10 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm
pReq
->
interval
=
((
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
->
datum
.
i
;
pReq
->
interval
=
((
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
->
datum
.
i
;
pReq
->
intervalUnit
=
((
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
->
unit
;
pReq
->
intervalUnit
=
((
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
->
unit
;
pReq
->
offset
=
(
NULL
!=
pStmt
->
pOptions
->
pOffset
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pOffset
)
->
datum
.
i
:
0
);
pReq
->
offset
=
(
NULL
!=
pStmt
->
pOptions
->
pOffset
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pOffset
)
->
datum
.
i
:
0
);
pReq
->
sliding
=
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
datum
.
i
:
pReq
->
interval
);
pReq
->
sliding
=
pReq
->
slidingUnit
=
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
unit
:
pReq
->
intervalUnit
);
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
datum
.
i
:
pReq
->
interval
);
pReq
->
slidingUnit
=
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
unit
:
pReq
->
intervalUnit
);
int32_t
code
=
getSmaIndexDstVgId
(
pCxt
,
pStmt
->
tableName
,
&
pReq
->
dstVgId
);
int32_t
code
=
getSmaIndexDstVgId
(
pCxt
,
pStmt
->
tableName
,
&
pReq
->
dstVgId
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -1976,12 +1990,15 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm
...
@@ -1976,12 +1990,15 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm
static
int32_t
translateCreateSmaIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
static
int32_t
translateCreateSmaIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
if
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
||
if
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
||
(
NULL
!=
pStmt
->
pOptions
->
pOffset
&&
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pOffset
))
||
(
NULL
!=
pStmt
->
pOptions
->
pOffset
&&
(
NULL
!=
pStmt
->
pOptions
->
pSliding
&&
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)))
{
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pOffset
))
||
(
NULL
!=
pStmt
->
pOptions
->
pSliding
&&
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)))
{
return
pCxt
->
errCode
;
return
pCxt
->
errCode
;
}
}
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
)
{
return
code
;
return
code
;
...
@@ -2003,14 +2020,49 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt
...
@@ -2003,14 +2020,49 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
buildCreateFullTextReq
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
,
SMCreateFullTextReq
*
pReq
)
{
// impl later
return
0
;
}
static
int32_t
translateCreateFullTextIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
if
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
||
(
NULL
!=
pStmt
->
pOptions
->
pOffset
&&
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pOffset
))
||
(
NULL
!=
pStmt
->
pOptions
->
pSliding
&&
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)))
{
return
pCxt
->
errCode
;
}
SMCreateFullTextReq
createFTReq
=
{
0
};
int32_t
code
=
buildCreateFullTextReq
(
pCxt
,
pStmt
,
&
createFTReq
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
pCxt
->
pCmdMsg
=
taosMemoryMalloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_CREATE_INDEX
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSMCreateFullTextReq
(
NULL
,
0
,
&
createFTReq
);
pCxt
->
pCmdMsg
->
pMsg
=
taosMemoryMalloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
tSerializeSMCreateFullTextReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
createFTReq
);
tFreeSMCreateFullTextReq
(
&
createFTReq
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateCreateIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
static
int32_t
translateCreateIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
if
(
INDEX_TYPE_SMA
==
pStmt
->
indexType
)
{
if
(
INDEX_TYPE_SMA
==
pStmt
->
indexType
)
{
return
translateCreateSmaIndex
(
pCxt
,
pStmt
);
return
translateCreateSmaIndex
(
pCxt
,
pStmt
);
}
else
{
}
else
if
(
INDEX_TYPE_FULLTEXT
==
pStmt
->
indexType
)
{
return
translateCreateFullTextIndex
(
pCxt
,
pStmt
);
// todo fulltext index
// todo fulltext index
return
TSDB_CODE_FAILED
;
}
}
return
TSDB_CODE_FAILED
;
}
}
static
int32_t
translateDropIndex
(
STranslateContext
*
pCxt
,
SDropIndexStmt
*
pStmt
)
{
static
int32_t
translateDropIndex
(
STranslateContext
*
pCxt
,
SDropIndexStmt
*
pStmt
)
{
...
@@ -2051,7 +2103,7 @@ static int16_t getCreateComponentNodeMsgType(ENodeType type) {
...
@@ -2051,7 +2103,7 @@ 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
};
pCxt
->
pCmdMsg
=
taosMemoryMalloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
taosMemoryMalloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
...
@@ -2086,7 +2138,7 @@ static int16_t getDropComponentNodeMsgType(ENodeType type) {
...
@@ -2086,7 +2138,7 @@ 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
};
pCxt
->
pCmdMsg
=
taosMemoryMalloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
taosMemoryMalloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
...
@@ -2113,7 +2165,7 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p
...
@@ -2113,7 +2165,7 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesNodeToString
(
pStmt
->
pQuery
,
false
,
&
createReq
.
ast
,
NULL
);
code
=
nodesNodeToString
(
pStmt
->
pQuery
,
false
,
&
createReq
.
ast
,
NULL
);
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
return
code
;
}
}
}
else
{
}
else
{
...
@@ -2125,7 +2177,7 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p
...
@@ -2125,7 +2177,7 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
SName
name
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SName
name
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
strcpy
(
name
.
tname
,
pStmt
->
topicName
);
strcpy
(
name
.
tname
,
pStmt
->
topicName
);
tNameExtractFullName
(
&
name
,
createReq
.
name
);
tNameExtractFullName
(
&
name
,
createReq
.
name
);
...
@@ -2151,7 +2203,7 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p
...
@@ -2151,7 +2203,7 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p
static
int32_t
translateDropTopic
(
STranslateContext
*
pCxt
,
SDropTopicStmt
*
pStmt
)
{
static
int32_t
translateDropTopic
(
STranslateContext
*
pCxt
,
SDropTopicStmt
*
pStmt
)
{
SMDropTopicReq
dropReq
=
{
0
};
SMDropTopicReq
dropReq
=
{
0
};
SName
name
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
SName
name
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
strcpy
(
name
.
tname
,
pStmt
->
topicName
);
strcpy
(
name
.
tname
,
pStmt
->
topicName
);
tNameExtractFullName
(
&
name
,
dropReq
.
name
);
tNameExtractFullName
(
&
name
,
dropReq
.
name
);
...
@@ -2316,7 +2368,7 @@ static int32_t extractSelectResultSchema(const SSelectStmt* pSelect, int32_t* nu
...
@@ -2316,7 +2368,7 @@ static int32_t extractSelectResultSchema(const SSelectStmt* pSelect, int32_t* nu
(
*
pSchema
)[
index
].
bytes
=
pExpr
->
resType
.
bytes
;
(
*
pSchema
)[
index
].
bytes
=
pExpr
->
resType
.
bytes
;
(
*
pSchema
)[
index
].
colId
=
index
+
1
;
(
*
pSchema
)[
index
].
colId
=
index
+
1
;
strcpy
((
*
pSchema
)[
index
].
name
,
pExpr
->
aliasName
);
strcpy
((
*
pSchema
)[
index
].
name
,
pExpr
->
aliasName
);
index
+=
1
;
index
+=
1
;
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -2507,7 +2559,8 @@ static int32_t createShowCondition(const SShowStmt* pShow, SSelectStmt* pSelect)
...
@@ -2507,7 +2559,8 @@ static int32_t createShowCondition(const SShowStmt* pShow, SSelectStmt* pSelect)
SNode
*
pDbCond
=
NULL
;
SNode
*
pDbCond
=
NULL
;
SNode
*
pTbCond
=
NULL
;
SNode
*
pTbCond
=
NULL
;
if
(
TSDB_CODE_SUCCESS
!=
createOperatorNode
(
OP_TYPE_EQUAL
,
"db_name"
,
pShow
->
pDbName
,
&
pDbCond
)
||
if
(
TSDB_CODE_SUCCESS
!=
createOperatorNode
(
OP_TYPE_EQUAL
,
"db_name"
,
pShow
->
pDbName
,
&
pDbCond
)
||
TSDB_CODE_SUCCESS
!=
createOperatorNode
(
OP_TYPE_LIKE
,
getTbNameColName
(
nodeType
(
pShow
)),
pShow
->
pTbNamePattern
,
&
pTbCond
))
{
TSDB_CODE_SUCCESS
!=
createOperatorNode
(
OP_TYPE_LIKE
,
getTbNameColName
(
nodeType
(
pShow
)),
pShow
->
pTbNamePattern
,
&
pTbCond
))
{
nodesDestroyNode
(
pDbCond
);
nodesDestroyNode
(
pDbCond
);
nodesDestroyNode
(
pTbCond
);
nodesDestroyNode
(
pTbCond
);
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -2582,16 +2635,15 @@ static int32_t buildSmaParam(STableOptions* pOptions, SVCreateTbReq* pReq) {
...
@@ -2582,16 +2635,15 @@ static int32_t buildSmaParam(STableOptions* pOptions, SVCreateTbReq* pReq) {
}
}
int32_t
index
=
0
;
int32_t
index
=
0
;
SNode
*
pFunc
=
NULL
;
SNode
*
pFunc
=
NULL
;
FOREACH
(
pFunc
,
pOptions
->
pFuncs
)
{
FOREACH
(
pFunc
,
pOptions
->
pFuncs
)
{
pReq
->
ntbCfg
.
pRSmaParam
->
pFuncIds
[
index
++
]
=
((
SFunctionNode
*
)
pFunc
)
->
funcId
;
}
pReq
->
ntbCfg
.
pRSmaParam
->
pFuncIds
[
index
++
]
=
((
SFunctionNode
*
)
pFunc
)
->
funcId
;
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
buildNormalTableBatchReq
(
int32_t
acctId
,
const
SCreateTableStmt
*
pStmt
,
const
SVgroupInfo
*
pVgroupInfo
,
SVgroupTablesBatch
*
pBatch
)
{
static
int32_t
buildNormalTableBatchReq
(
int32_t
acctId
,
const
SCreateTableStmt
*
pStmt
,
const
SVgroupInfo
*
pVgroupInfo
,
SVgroupTablesBatch
*
pBatch
)
{
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
SName
name
=
{
.
type
=
TSDB_DB_NAME_T
,
.
acctId
=
acctId
};
SName
name
=
{
.
type
=
TSDB_DB_NAME_T
,
.
acctId
=
acctId
};
strcpy
(
name
.
dbname
,
pStmt
->
dbName
);
strcpy
(
name
.
dbname
,
pStmt
->
dbName
);
tNameGetFullDbName
(
&
name
,
dbFName
);
tNameGetFullDbName
(
&
name
,
dbFName
);
...
@@ -2646,7 +2698,7 @@ static int32_t serializeVgroupTablesBatch(SVgroupTablesBatch* pTbBatch, SArray*
...
@@ -2646,7 +2698,7 @@ static int32_t serializeVgroupTablesBatch(SVgroupTablesBatch* pTbBatch, SArray*
pVgData
->
vg
=
pTbBatch
->
info
;
pVgData
->
vg
=
pTbBatch
->
info
;
pVgData
->
pData
=
buf
;
pVgData
->
pData
=
buf
;
pVgData
->
size
=
tlen
;
pVgData
->
size
=
tlen
;
pVgData
->
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
pTbBatch
->
req
.
pArray
);
pVgData
->
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
pTbBatch
->
req
.
pArray
);
taosArrayPush
(
pBufArray
,
&
pVgData
);
taosArrayPush
(
pBufArray
,
&
pVgData
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -2654,7 +2706,7 @@ static int32_t serializeVgroupTablesBatch(SVgroupTablesBatch* pTbBatch, SArray*
...
@@ -2654,7 +2706,7 @@ static int32_t serializeVgroupTablesBatch(SVgroupTablesBatch* pTbBatch, SArray*
static
void
destroyCreateTbReqBatch
(
SVgroupTablesBatch
*
pTbBatch
)
{
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
->
dbFName
);
taosMemoryFreeClear
(
pTableReq
->
name
);
taosMemoryFreeClear
(
pTableReq
->
name
);
...
@@ -2691,7 +2743,8 @@ static void destroyCreateTbReqArray(SArray* pArray) {
...
@@ -2691,7 +2743,8 @@ static void destroyCreateTbReqArray(SArray* pArray) {
taosArrayDestroy
(
pArray
);
taosArrayDestroy
(
pArray
);
}
}
static
int32_t
buildCreateTableDataBlock
(
int32_t
acctId
,
const
SCreateTableStmt
*
pStmt
,
const
SVgroupInfo
*
pInfo
,
SArray
**
pBufArray
)
{
static
int32_t
buildCreateTableDataBlock
(
int32_t
acctId
,
const
SCreateTableStmt
*
pStmt
,
const
SVgroupInfo
*
pInfo
,
SArray
**
pBufArray
)
{
*
pBufArray
=
taosArrayInit
(
1
,
POINTER_BYTES
);
*
pBufArray
=
taosArrayInit
(
1
,
POINTER_BYTES
);
if
(
NULL
==
*
pBufArray
)
{
if
(
NULL
==
*
pBufArray
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -2732,10 +2785,10 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) {
...
@@ -2732,10 +2785,10 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) {
return
code
;
return
code
;
}
}
static
void
addCreateTbReqIntoVgroup
(
int32_t
acctId
,
SHashObj
*
pVgroupHashmap
,
static
void
addCreateTbReqIntoVgroup
(
int32_t
acctId
,
SHashObj
*
pVgroupHashmap
,
const
char
*
pDbName
,
const
char
*
pDbName
,
const
char
*
pTableName
,
SKVRow
row
,
uint64_t
suid
,
SVgroupInfo
*
pVgInfo
)
{
const
char
*
pTableName
,
SKVRow
row
,
uint64_t
suid
,
SVgroupInfo
*
pVgInfo
)
{
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
SName
name
=
{
.
type
=
TSDB_DB_NAME_T
,
.
acctId
=
acctId
};
SName
name
=
{
.
type
=
TSDB_DB_NAME_T
,
.
acctId
=
acctId
};
strcpy
(
name
.
dbname
,
pDbName
);
strcpy
(
name
.
dbname
,
pDbName
);
tNameGetFullDbName
(
&
name
,
dbFName
);
tNameGetFullDbName
(
&
name
,
dbFName
);
...
@@ -2761,7 +2814,8 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap,
...
@@ -2761,7 +2814,8 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap,
}
}
}
}
static
int32_t
addValToKVRow
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
,
const
SSchema
*
pSchema
,
SKVRowBuilder
*
pBuilder
)
{
static
int32_t
addValToKVRow
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
,
const
SSchema
*
pSchema
,
SKVRowBuilder
*
pBuilder
)
{
if
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
pVal
))
{
if
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
pVal
))
{
return
pCxt
->
errCode
;
return
pCxt
->
errCode
;
}
}
...
@@ -2775,14 +2829,16 @@ static int32_t addValToKVRow(STranslateContext* pCxt, SValueNode* pVal, const SS
...
@@ -2775,14 +2829,16 @@ static int32_t addValToKVRow(STranslateContext* pCxt, SValueNode* pVal, const SS
return
code
;
return
code
;
}
}
static
int32_t
buildKVRowForBindTags
(
STranslateContext
*
pCxt
,
SCreateSubTableClause
*
pStmt
,
STableMeta
*
pSuperTableMeta
,
SKVRowBuilder
*
pBuilder
)
{
static
int32_t
buildKVRowForBindTags
(
STranslateContext
*
pCxt
,
SCreateSubTableClause
*
pStmt
,
STableMeta
*
pSuperTableMeta
,
SKVRowBuilder
*
pBuilder
)
{
int32_t
numOfTags
=
getNumOfTags
(
pSuperTableMeta
);
int32_t
numOfTags
=
getNumOfTags
(
pSuperTableMeta
);
if
(
LIST_LENGTH
(
pStmt
->
pValsOfTags
)
!=
LIST_LENGTH
(
pStmt
->
pSpecificTags
)
||
numOfTags
<
LIST_LENGTH
(
pStmt
->
pValsOfTags
))
{
if
(
LIST_LENGTH
(
pStmt
->
pValsOfTags
)
!=
LIST_LENGTH
(
pStmt
->
pSpecificTags
)
||
numOfTags
<
LIST_LENGTH
(
pStmt
->
pValsOfTags
))
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TAGS_NOT_MATCHED
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TAGS_NOT_MATCHED
);
}
}
SSchema
*
pTagSchema
=
getTableTagSchema
(
pSuperTableMeta
);
SSchema
*
pTagSchema
=
getTableTagSchema
(
pSuperTableMeta
);
SNode
*
pTag
,
*
pVal
;
SNode
*
pTag
,
*
pVal
;
FORBOTH
(
pTag
,
pStmt
->
pSpecificTags
,
pVal
,
pStmt
->
pValsOfTags
)
{
FORBOTH
(
pTag
,
pStmt
->
pSpecificTags
,
pVal
,
pStmt
->
pValsOfTags
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pTag
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pTag
;
SSchema
*
pSchema
=
NULL
;
SSchema
*
pSchema
=
NULL
;
...
@@ -2804,7 +2860,8 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
...
@@ -2804,7 +2860,8 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
buildKVRowForAllTags
(
STranslateContext
*
pCxt
,
SCreateSubTableClause
*
pStmt
,
STableMeta
*
pSuperTableMeta
,
SKVRowBuilder
*
pBuilder
)
{
static
int32_t
buildKVRowForAllTags
(
STranslateContext
*
pCxt
,
SCreateSubTableClause
*
pStmt
,
STableMeta
*
pSuperTableMeta
,
SKVRowBuilder
*
pBuilder
)
{
if
(
getNumOfTags
(
pSuperTableMeta
)
!=
LIST_LENGTH
(
pStmt
->
pValsOfTags
))
{
if
(
getNumOfTags
(
pSuperTableMeta
)
!=
LIST_LENGTH
(
pStmt
->
pValsOfTags
))
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TAGS_NOT_MATCHED
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TAGS_NOT_MATCHED
);
}
}
...
@@ -2864,7 +2921,8 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
...
@@ -2864,7 +2921,8 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
code
=
getTableHashVgroup
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
info
);
code
=
getTableHashVgroup
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
info
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
addCreateTbReqIntoVgroup
(
pCxt
->
pParseCxt
->
acctId
,
pVgroupHashmap
,
pStmt
->
dbName
,
pStmt
->
tableName
,
row
,
pSuperTableMeta
->
uid
,
&
info
);
addCreateTbReqIntoVgroup
(
pCxt
->
pParseCxt
->
acctId
,
pVgroupHashmap
,
pStmt
->
dbName
,
pStmt
->
tableName
,
row
,
pSuperTableMeta
->
uid
,
&
info
);
}
}
taosMemoryFreeClear
(
pSuperTableMeta
);
taosMemoryFreeClear
(
pSuperTableMeta
);
...
@@ -3028,13 +3086,12 @@ int32_t translate(SParseContext* pParseCxt, SQuery* pQuery) {
...
@@ -3028,13 +3086,12 @@ int32_t translate(SParseContext* pParseCxt, SQuery* pQuery) {
STranslateContext
cxt
=
{
STranslateContext
cxt
=
{
.
pParseCxt
=
pParseCxt
,
.
pParseCxt
=
pParseCxt
,
.
errCode
=
TSDB_CODE_SUCCESS
,
.
errCode
=
TSDB_CODE_SUCCESS
,
.
msgBuf
=
{
.
buf
=
pParseCxt
->
pMsg
,
.
len
=
pParseCxt
->
msgLen
},
.
msgBuf
=
{.
buf
=
pParseCxt
->
pMsg
,
.
len
=
pParseCxt
->
msgLen
},
.
pNsLevel
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
POINTER_BYTES
),
.
pNsLevel
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
POINTER_BYTES
),
.
currLevel
=
0
,
.
currLevel
=
0
,
.
currClause
=
0
,
.
currClause
=
0
,
.
pDbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
),
.
pDbs
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
),
.
pTables
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
)
.
pTables
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
)};
};
if
(
NULL
==
cxt
.
pNsLevel
)
{
if
(
NULL
==
cxt
.
pNsLevel
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录