Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b0a68df5
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1181
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b0a68df5
编写于
4月 22, 2022
作者:
X
Xiaoyu Wang
提交者:
GitHub
4月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11766 from taosdata/feature/3.0_wxy
fix: some syntax parsing problems
上级
b790102f
395ba3dc
变更
30
展开全部
隐藏空白更改
内联
并排
Showing
30 changed file
with
2819 addition
and
2434 deletion
+2819
-2434
include/common/tglobal.h
include/common/tglobal.h
+3
-0
include/common/tmsg.h
include/common/tmsg.h
+1
-3
include/common/ttokendef.h
include/common/ttokendef.h
+90
-88
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+8
-0
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+1
-0
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+2
-2
include/libs/planner/planner.h
include/libs/planner/planner.h
+2
-0
include/util/taoserror.h
include/util/taoserror.h
+4
-0
include/util/tdef.h
include/util/tdef.h
+0
-1
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+15
-12
source/common/src/tglobal.c
source/common/src/tglobal.c
+5
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+3
-2
source/common/src/ttime.c
source/common/src/ttime.c
+1
-1
source/dnode/mnode/impl/src/mndInfoSchema.c
source/dnode/mnode/impl/src/mndInfoSchema.c
+0
-10
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+0
-2
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+2
-2
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+2
-0
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+3
-2
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+11
-5
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+22
-10
source/libs/parser/src/parCalcConst.c
source/libs/parser/src/parCalcConst.c
+68
-25
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+1
-1
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+2
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+84
-56
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+15
-7
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+2457
-2200
source/libs/planner/inc/planInt.h
source/libs/planner/inc/planInt.h
+4
-0
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+2
-2
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+9
-1
tests/script/tsim/db/alter_option.sim
tests/script/tsim/db/alter_option.sim
+2
-2
未找到文件。
include/common/tglobal.h
浏览文件 @
b0a68df5
...
...
@@ -94,6 +94,9 @@ extern bool tsRetrieveBlockingModel; // retrieve threads will be blocked
extern
bool
tsKeepOriginalColumnName
;
extern
bool
tsDeadLockKillQuery
;
// query client
extern
int32_t
tsQueryPolicy
;
// client
extern
int32_t
tsMaxWildCardsLen
;
extern
int32_t
tsMaxRegexStringLen
;
...
...
include/common/tmsg.h
浏览文件 @
b0a68df5
...
...
@@ -1283,15 +1283,13 @@ typedef struct {
}
SMVCreateStreamRsp
,
SMSCreateStreamRsp
;
typedef
struct
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
name
[
TSDB_TOPIC_FNAME_LEN
];
// accout.topic
int8_t
igExists
;
int8_t
withTbName
;
int8_t
withSchema
;
int8_t
withTag
;
int8_t
withTagSchema
;
char
*
sql
;
char
*
ast
;
int64_t
subDbUid
;
char
subscribeDbName
[
TSDB_DB_NAME_LEN
];
}
SCMCreateTopicReq
;
...
...
include/common/ttokendef.h
浏览文件 @
b0a68df5
...
...
@@ -156,87 +156,96 @@
#define TK_INTERVAL 138
#define TK_TOPIC 139
#define TK_AS 140
#define TK_DESC 141
#define TK_DESCRIBE 142
#define TK_RESET 143
#define TK_QUERY 144
#define TK_EXPLAIN 145
#define TK_ANALYZE 146
#define TK_VERBOSE 147
#define TK_NK_BOOL 148
#define TK_RATIO 149
#define TK_COMPACT 150
#define TK_VNODES 151
#define TK_IN 152
#define TK_OUTPUTTYPE 153
#define TK_AGGREGATE 154
#define TK_BUFSIZE 155
#define TK_STREAM 156
#define TK_INTO 157
#define TK_TRIGGER 158
#define TK_AT_ONCE 159
#define TK_WINDOW_CLOSE 160
#define TK_WATERMARK 161
#define TK_KILL 162
#define TK_CONNECTION 163
#define TK_MERGE 164
#define TK_VGROUP 165
#define TK_REDISTRIBUTE 166
#define TK_SPLIT 167
#define TK_SYNCDB 168
#define TK_NULL 169
#define TK_NK_QUESTION 170
#define TK_NK_ARROW 171
#define TK_ROWTS 172
#define TK_TBNAME 173
#define TK_QSTARTTS 174
#define TK_QENDTS 175
#define TK_WSTARTTS 176
#define TK_WENDTS 177
#define TK_WDURATION 178
#define TK_CAST 179
#define TK_NOW 180
#define TK_TODAY 181
#define TK_TIMEZONE 182
#define TK_COUNT 183
#define TK_FIRST 184
#define TK_LAST 185
#define TK_LAST_ROW 186
#define TK_BETWEEN 187
#define TK_IS 188
#define TK_NK_LT 189
#define TK_NK_GT 190
#define TK_NK_LE 191
#define TK_NK_GE 192
#define TK_NK_NE 193
#define TK_MATCH 194
#define TK_NMATCH 195
#define TK_CONTAINS 196
#define TK_JOIN 197
#define TK_INNER 198
#define TK_SELECT 199
#define TK_DISTINCT 200
#define TK_WHERE 201
#define TK_PARTITION 202
#define TK_BY 203
#define TK_SESSION 204
#define TK_STATE_WINDOW 205
#define TK_SLIDING 206
#define TK_FILL 207
#define TK_VALUE 208
#define TK_NONE 209
#define TK_PREV 210
#define TK_LINEAR 211
#define TK_NEXT 212
#define TK_GROUP 213
#define TK_HAVING 214
#define TK_ORDER 215
#define TK_SLIMIT 216
#define TK_SOFFSET 217
#define TK_LIMIT 218
#define TK_OFFSET 219
#define TK_ASC 220
#define TK_NULLS 221
#define TK_WITH 141
#define TK_SCHEMA 142
#define TK_DESC 143
#define TK_DESCRIBE 144
#define TK_RESET 145
#define TK_QUERY 146
#define TK_EXPLAIN 147
#define TK_ANALYZE 148
#define TK_VERBOSE 149
#define TK_NK_BOOL 150
#define TK_RATIO 151
#define TK_COMPACT 152
#define TK_VNODES 153
#define TK_IN 154
#define TK_OUTPUTTYPE 155
#define TK_AGGREGATE 156
#define TK_BUFSIZE 157
#define TK_STREAM 158
#define TK_INTO 159
#define TK_TRIGGER 160
#define TK_AT_ONCE 161
#define TK_WINDOW_CLOSE 162
#define TK_WATERMARK 163
#define TK_KILL 164
#define TK_CONNECTION 165
#define TK_MERGE 166
#define TK_VGROUP 167
#define TK_REDISTRIBUTE 168
#define TK_SPLIT 169
#define TK_SYNCDB 170
#define TK_NULL 171
#define TK_NK_QUESTION 172
#define TK_NK_ARROW 173
#define TK_ROWTS 174
#define TK_TBNAME 175
#define TK_QSTARTTS 176
#define TK_QENDTS 177
#define TK_WSTARTTS 178
#define TK_WENDTS 179
#define TK_WDURATION 180
#define TK_CAST 181
#define TK_NOW 182
#define TK_TODAY 183
#define TK_TIMEZONE 184
#define TK_COUNT 185
#define TK_FIRST 186
#define TK_LAST 187
#define TK_LAST_ROW 188
#define TK_BETWEEN 189
#define TK_IS 190
#define TK_NK_LT 191
#define TK_NK_GT 192
#define TK_NK_LE 193
#define TK_NK_GE 194
#define TK_NK_NE 195
#define TK_MATCH 196
#define TK_NMATCH 197
#define TK_CONTAINS 198
#define TK_JOIN 199
#define TK_INNER 200
#define TK_SELECT 201
#define TK_DISTINCT 202
#define TK_WHERE 203
#define TK_PARTITION 204
#define TK_BY 205
#define TK_SESSION 206
#define TK_STATE_WINDOW 207
#define TK_SLIDING 208
#define TK_FILL 209
#define TK_VALUE 210
#define TK_NONE 211
#define TK_PREV 212
#define TK_LINEAR 213
#define TK_NEXT 214
#define TK_GROUP 215
#define TK_HAVING 216
#define TK_ORDER 217
#define TK_SLIMIT 218
#define TK_SOFFSET 219
#define TK_LIMIT 220
#define TK_OFFSET 221
#define TK_ASC 222
#define TK_NULLS 223
#define TK_ID 224
#define TK_NK_BITNOT 225
#define TK_INSERT 226
#define TK_VALUES 227
#define TK_IMPORT 228
#define TK_NK_SEMI 229
#define TK_FILE 230
#define TK_NK_SPACE 300
#define TK_NK_COMMENT 301
...
...
@@ -244,13 +253,6 @@
#define TK_NK_HEX 303 // hex number 0x123
#define TK_NK_OCT 304 // oct number
#define TK_NK_BIN 305 // bin format data 0b111
#define TK_NK_FILE 306
#define TK_NK_BITNOT 501
#define TK_INSERT 502
#define TK_VALUES 507
#define TK_IMPORT 509
#define TK_NK_SEMI 508
#define TK_NK_NIL 65535
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
b0a68df5
...
...
@@ -241,12 +241,20 @@ typedef struct SDropComponentNodeStmt {
int32_t
dnodeId
;
}
SDropComponentNodeStmt
;
typedef
struct
STopicOptions
{
ENodeType
type
;
bool
withTable
;
bool
withSchema
;
bool
withTag
;
}
STopicOptions
;
typedef
struct
SCreateTopicStmt
{
ENodeType
type
;
char
topicName
[
TSDB_TABLE_NAME_LEN
];
char
subscribeDbName
[
TSDB_DB_NAME_LEN
];
bool
ignoreExists
;
SNode
*
pQuery
;
STopicOptions
*
pOptions
;
}
SCreateTopicStmt
;
typedef
struct
SDropTopicStmt
{
...
...
include/libs/nodes/nodes.h
浏览文件 @
b0a68df5
...
...
@@ -84,6 +84,7 @@ typedef enum ENodeType {
QUERY_NODE_INDEX_OPTIONS
,
QUERY_NODE_EXPLAIN_OPTIONS
,
QUERY_NODE_STREAM_OPTIONS
,
QUERY_NODE_TOPIC_OPTIONS
,
// Statement nodes are used in parser and planner module.
QUERY_NODE_SET_OPERATOR
,
...
...
include/libs/nodes/querynodes.h
浏览文件 @
b0a68df5
...
...
@@ -237,8 +237,8 @@ typedef struct SSelectStmt {
SNodeList
*
pGroupByList
;
// SGroupingSetNode
SNode
*
pHaving
;
SNodeList
*
pOrderByList
;
// SOrderByExprNode
SNode
*
pLimit
;
SNode
*
pSlimit
;
S
Limit
Node
*
pLimit
;
S
Limit
Node
*
pSlimit
;
char
stmtName
[
TSDB_TABLE_NAME_LEN
];
uint8_t
precision
;
bool
isEmptyResult
;
...
...
include/libs/planner/planner.h
浏览文件 @
b0a68df5
...
...
@@ -35,6 +35,8 @@ typedef struct SPlanContext {
int8_t
triggerType
;
int64_t
watermark
;
bool
isStmtQuery
;
void
*
pTransporter
;
struct
SCatalog
*
pCatalog
;
}
SPlanContext
;
// Create the physical plan for the query, according to the AST.
...
...
include/util/taoserror.h
浏览文件 @
b0a68df5
...
...
@@ -615,6 +615,10 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2632)
#define TSDB_CODE_PAR_ONLY_ONE_JSON_TAG TAOS_DEF_ERROR_CODE(0, 0x2633)
#define TSDB_CODE_PAR_INCORRECT_NUM_OF_COL TAOS_DEF_ERROR_CODE(0, 0x2634)
#define TSDB_CODE_PAR_INCORRECT_TIMESTAMP_VAL TAOS_DEF_ERROR_CODE(0, 0x2635)
#define TSDB_CODE_PAR_INVALID_DAYS_VALUE TAOS_DEF_ERROR_CODE(0, 0x2636)
#define TSDB_CODE_PAR_OFFSET_LESS_ZERO TAOS_DEF_ERROR_CODE(0, 0x2637)
#define TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_BY TAOS_DEF_ERROR_CODE(0, 0x2638)
//planner
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
...
...
include/util/tdef.h
浏览文件 @
b0a68df5
...
...
@@ -118,7 +118,6 @@ extern const int32_t TYPE_BYTES[15];
#define TSDB_INS_TABLE_USER_USERS "user_users"
#define TSDB_INS_TABLE_LICENCES "grants"
#define TSDB_INS_TABLE_VGROUPS "vgroups"
#define TSDB_INS_TABLE_TOPICS "topics"
#define TSDB_INS_TABLE_CONSUMERS "consumers"
#define TSDB_INS_TABLE_SUBSCRIBES "subscribes"
#define TSDB_INS_TABLE_TRANS "trans"
...
...
source/client/src/clientImpl.c
浏览文件 @
b0a68df5
...
...
@@ -226,14 +226,17 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
int32_t
getPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SQueryPlan
**
pPlan
,
SArray
*
pNodeList
)
{
pRequest
->
type
=
pQuery
->
msgType
;
SPlanContext
cxt
=
{.
queryId
=
pRequest
->
requestId
,
.
acctId
=
pRequest
->
pTscObj
->
acctId
,
.
mgmtEpSet
=
getEpSet_s
(
&
pRequest
->
pTscObj
->
pAppInfo
->
mgmtEp
),
.
pAstRoot
=
pQuery
->
pRoot
,
.
showRewrite
=
pQuery
->
showRewrite
};
int32_t
code
=
qCreateQueryPlan
(
&
cxt
,
pPlan
,
pNodeList
);
if
(
code
!=
0
)
{
return
code
;
SPlanContext
cxt
=
{
.
queryId
=
pRequest
->
requestId
,
.
acctId
=
pRequest
->
pTscObj
->
acctId
,
.
mgmtEpSet
=
getEpSet_s
(
&
pRequest
->
pTscObj
->
pAppInfo
->
mgmtEp
),
.
pAstRoot
=
pQuery
->
pRoot
,
.
showRewrite
=
pQuery
->
showRewrite
,
.
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
};
int32_t
code
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
cxt
.
pCatalog
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
qCreateQueryPlan
(
&
cxt
,
pPlan
,
pNodeList
);
}
return
code
;
}
...
...
@@ -302,8 +305,6 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
}
SRequestObj
*
launchQueryImpl
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
int32_t
code
,
bool
keepQuery
)
{
SArray
*
pNodeList
=
taosArrayInit
(
4
,
sizeof
(
struct
SQueryNodeAddr
));
if
(
TSDB_CODE_SUCCESS
==
code
)
{
switch
(
pQuery
->
execMode
)
{
case
QUERY_EXEC_MODE_LOCAL
:
...
...
@@ -312,12 +313,15 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
case
QUERY_EXEC_MODE_RPC
:
code
=
execDdlQuery
(
pRequest
,
pQuery
);
break
;
case
QUERY_EXEC_MODE_SCHEDULE
:
case
QUERY_EXEC_MODE_SCHEDULE
:
{
SArray
*
pNodeList
=
taosArrayInit
(
4
,
sizeof
(
struct
SQueryNodeAddr
));
code
=
getPlan
(
pRequest
,
pQuery
,
&
pRequest
->
body
.
pDag
,
pNodeList
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
scheduleQuery
(
pRequest
,
pRequest
->
body
.
pDag
,
pNodeList
);
}
taosArrayDestroy
(
pNodeList
);
break
;
}
case
QUERY_EXEC_MODE_EMPTY_RESULT
:
pRequest
->
type
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
break
;
...
...
@@ -326,7 +330,6 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, int32_t code
}
}
taosArrayDestroy
(
pNodeList
);
if
(
!
keepQuery
)
{
qDestroyQuery
(
pQuery
);
}
...
...
source/common/src/tglobal.c
浏览文件 @
b0a68df5
...
...
@@ -80,6 +80,9 @@ int32_t tsTelemInterval = 86400;
char
tsTelemServer
[
TSDB_FQDN_LEN
]
=
"telemetry.taosdata.com"
;
uint16_t
tsTelemPort
=
80
;
// query
int32_t
tsQueryPolicy
=
1
;
/*
* denote if the server needs to compress response message at the application layer to client, including query rsp,
* metricmeta rsp, and multi-meter query rsp message body. The client compress the submit message to server.
...
...
@@ -322,6 +325,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"keepColumnName"
,
tsKeepOriginalColumnName
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"maxBinaryDisplayWidth"
,
tsMaxBinaryDisplayWidth
,
1
,
65536
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"queryPolicy"
,
tsQueryPolicy
,
1
,
3
,
1
)
!=
0
)
return
-
1
;
tsNumOfTaskQueueThreads
=
tsNumOfCores
/
4
;
tsNumOfTaskQueueThreads
=
TRANGE
(
tsNumOfTaskQueueThreads
,
1
,
2
);
...
...
@@ -515,6 +519,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
tsKeepOriginalColumnName
=
cfgGetItem
(
pCfg
,
"keepColumnName"
)
->
bval
;
tsMaxBinaryDisplayWidth
=
cfgGetItem
(
pCfg
,
"maxBinaryDisplayWidth"
)
->
i32
;
tsNumOfTaskQueueThreads
=
cfgGetItem
(
pCfg
,
"numOfTaskQueueThreads"
)
->
i32
;
tsQueryPolicy
=
cfgGetItem
(
pCfg
,
"queryPolicy"
)
->
i32
;
return
0
;
}
...
...
source/common/src/tmsg.c
浏览文件 @
b0a68df5
...
...
@@ -2734,11 +2734,11 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withTbName
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withSchema
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withTag
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
withTagSchema
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
sqlLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
astLen
)
<
0
)
return
-
1
;
if
(
sqlLen
>
0
&&
tEncodeCStr
(
&
encoder
,
pReq
->
sql
)
<
0
)
return
-
1
;
if
(
astLen
>
0
&&
tEncodeCStr
(
&
encoder
,
pReq
->
ast
)
<
0
)
return
-
1
;
if
(
0
==
astLen
&&
tEncodeCStr
(
&
encoder
,
pReq
->
subscribeDbName
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
...
...
@@ -2760,7 +2760,6 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withTbName
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withSchema
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withTag
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
withTagSchema
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
sqlLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
astLen
)
<
0
)
return
-
1
;
...
...
@@ -2774,6 +2773,8 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR
pReq
->
ast
=
taosMemoryCalloc
(
1
,
astLen
+
1
);
if
(
pReq
->
ast
==
NULL
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
ast
)
<
0
)
return
-
1
;
}
else
{
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
subscribeDbName
)
<
0
)
return
-
1
;
}
tEndDecode
(
&
decoder
);
...
...
source/common/src/ttime.c
浏览文件 @
b0a68df5
...
...
@@ -412,7 +412,7 @@ int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char
int32_t
convertStringToTimestamp
(
int16_t
type
,
char
*
inputData
,
int64_t
timePrec
,
int64_t
*
timeVal
)
{
int32_t
charLen
=
varDataLen
(
inputData
);
char
*
newColData
;
if
(
type
==
TSDB_DATA_TYPE_BINARY
)
{
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_VARBINARY
)
{
newColData
=
taosMemoryCalloc
(
1
,
charLen
+
1
);
memcpy
(
newColData
,
varDataVal
(
inputData
),
charLen
);
bool
ret
=
taosParseTime
(
newColData
,
timeVal
,
charLen
,
(
int32_t
)
timePrec
,
tsDaylight
);
...
...
source/dnode/mnode/impl/src/mndInfoSchema.c
浏览文件 @
b0a68df5
...
...
@@ -199,15 +199,6 @@ static const SInfosTableSchema vgroupsSchema[] = {
{.
name
=
"file_size"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
};
// TODO put into perf schema
static
const
SInfosTableSchema
topicSchema
[]
=
{
{.
name
=
"topic_name"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"db_name"
,
.
bytes
=
SYSTABLE_SCH_DB_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"sql"
,
.
bytes
=
1024
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"row_len"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
};
static
const
SInfosTableSchema
consumerSchema
[]
=
{
{.
name
=
"client_id"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
{.
name
=
"group_id"
,
.
bytes
=
SYSTABLE_SCH_TABLE_NAME_LEN
,
.
type
=
TSDB_DATA_TYPE_VARCHAR
},
...
...
@@ -291,7 +282,6 @@ static const SInfosTableMeta infosMeta[] = {
{
TSDB_INS_TABLE_USER_USERS
,
userUsersSchema
,
tListLen
(
userUsersSchema
)},
{
TSDB_INS_TABLE_LICENCES
,
grantsSchema
,
tListLen
(
grantsSchema
)},
{
TSDB_INS_TABLE_VGROUPS
,
vgroupsSchema
,
tListLen
(
vgroupsSchema
)},
{
TSDB_INS_TABLE_TOPICS
,
topicSchema
,
tListLen
(
topicSchema
)},
{
TSDB_INS_TABLE_CONSUMERS
,
consumerSchema
,
tListLen
(
consumerSchema
)},
{
TSDB_INS_TABLE_SUBSCRIBES
,
subscribeSchema
,
tListLen
(
subscribeSchema
)},
{
TSDB_INS_TABLE_TRANS
,
transSchema
,
tListLen
(
transSchema
)},
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
b0a68df5
...
...
@@ -84,8 +84,6 @@ static int32_t convertToRetrieveType(char* name, int32_t len) {
type
=
TSDB_MGMT_TABLE_GRANTS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_VGROUPS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_VGROUP
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_TOPICS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_TOPICS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_CONSUMERS
,
len
)
==
0
)
{
type
=
TSDB_MGMT_TABLE_CONSUMERS
;
}
else
if
(
strncasecmp
(
name
,
TSDB_INS_TABLE_SUBSCRIBES
,
len
)
==
0
)
{
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
b0a68df5
...
...
@@ -2465,10 +2465,10 @@ static int32_t jsonToSelectStmt(const SJson* pJson, void* pObj) {
code
=
jsonToNodeList
(
pJson
,
jkSelectStmtOrderBy
,
&
pNode
->
pOrderByList
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkSelectStmtLimit
,
&
pNode
->
pLimit
);
code
=
jsonToNodeObject
(
pJson
,
jkSelectStmtLimit
,
(
SNode
**
)
&
pNode
->
pLimit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkSelectStmtSlimit
,
&
pNode
->
pSlimit
);
code
=
jsonToNodeObject
(
pJson
,
jkSelectStmtSlimit
,
(
SNode
**
)
&
pNode
->
pSlimit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetStringValue
(
pJson
,
jkSelectStmtStmtName
,
pNode
->
stmtName
);
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
b0a68df5
...
...
@@ -86,6 +86,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SExplainOptions
));
case
QUERY_NODE_STREAM_OPTIONS
:
return
makeNode
(
type
,
sizeof
(
SStreamOptions
));
case
QUERY_NODE_TOPIC_OPTIONS
:
return
makeNode
(
type
,
sizeof
(
STopicOptions
));
case
QUERY_NODE_SET_OPERATOR
:
return
makeNode
(
type
,
sizeof
(
SSetOperator
));
case
QUERY_NODE_SELECT_STMT
:
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
b0a68df5
...
...
@@ -128,7 +128,7 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, STo
SNode
*
createAlterDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SNode
*
pOptions
);
SNode
*
createTableOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
setTableAlterOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
SAlterOption
*
pAlterOption
);
SNode
*
createColumnDefNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pColName
,
SDataType
dataType
,
const
SToken
*
pComment
);
SNode
*
createColumnDefNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pColName
,
SDataType
dataType
,
const
SToken
*
pComment
);
SDataType
createDataType
(
uint8_t
type
);
SDataType
createVarLenDataType
(
uint8_t
type
,
const
SToken
*
pLen
);
SNode
*
createCreateTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNodeList
*
pCols
,
SNodeList
*
pTags
,
SNode
*
pOptions
);
...
...
@@ -157,7 +157,8 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pIndexName
,
SToken
*
pTableName
);
SNode
*
createCreateComponentNodeStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDnodeId
);
SNode
*
createDropComponentNodeStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
const
SToken
*
pDnodeId
);
SNode
*
createCreateTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pQuery
,
const
SToken
*
pSubscribeDbName
);
SNode
*
createTopicOptions
(
SAstCreateContext
*
pCxt
);
SNode
*
createCreateTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pQuery
,
const
SToken
*
pSubscribeDbName
,
SNode
*
pOptions
);
SNode
*
createDropTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pTopicName
);
SNode
*
createAlterLocalStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pConfig
,
const
SToken
*
pValue
);
SNode
*
createDefaultExplainOptions
(
SAstCreateContext
*
pCxt
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
b0a68df5
...
...
@@ -35,14 +35,11 @@
%left OR.
%left AND.
//%right NOT.
%left UNION ALL MINUS EXCEPT INTERSECT.
%left NK_BITAND NK_BITOR NK_LSHIFT NK_RSHIFT.
%left NK_PLUS NK_MINUS.
//%left DIVIDE TIMES.
%left NK_STAR NK_SLASH NK_REM.
%left NK_CONCAT.
//%right NK_BITNOT.
/************************************************ create/alter account *****************************************/
cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options. { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
...
...
@@ -387,10 +384,17 @@ func_list(A) ::= func_list(B) NK_COMMA func(C).
func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); }
/************************************************ create/drop topic ***************************************************/
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, C, NULL); }
cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS db_name(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, NULL, &C); }
cmd ::= CREATE TOPIC not_exists_opt(A)
topic_name(B) topic_options(D) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, C, NULL, D); }
cmd ::= CREATE TOPIC not_exists_opt(A)
topic_name(B) topic_options(D) AS db_name(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, NULL, &C, D); }
cmd ::= DROP TOPIC exists_opt(A) topic_name(B). { pCxt->pRootNode = createDropTopicStmt(pCxt, A, &B); }
topic_options(A) ::= . { A = createTopicOptions(pCxt); }
topic_options(A) ::= topic_options(B) WITH TABLE. { ((STopicOptions*)B)->withTable = true; A = B; }
topic_options(A) ::= topic_options(B) WITH SCHEMA. { ((STopicOptions*)B)->withSchema = true; A = B; }
topic_options(A) ::= topic_options(B) WITH TAG. { ((STopicOptions*)B)->withTag = true; A = B; }
/************************************************ desc/describe *******************************************************/
cmd ::= DESC full_table_name(A). { pCxt->pRootNode = createDescribeStmt(pCxt, A); }
cmd ::= DESCRIBE full_table_name(A). { pCxt->pRootNode = createDescribeStmt(pCxt, A); }
...
...
@@ -887,3 +891,5 @@ ordering_specification_opt(A) ::= DESC.
null_ordering_opt(A) ::= . { A = NULL_ORDER_DEFAULT; }
null_ordering_opt(A) ::= NULLS FIRST. { A = NULL_ORDER_FIRST; }
null_ordering_opt(A) ::= NULLS LAST. { A = NULL_ORDER_LAST; }
%fallback ID NK_BITNOT INSERT VALUES IMPORT NK_SEMI FILE.
source/libs/parser/src/parAstCreater.c
浏览文件 @
b0a68df5
...
...
@@ -146,44 +146,42 @@ static bool checkDbName(SAstCreateContext* pCxt, SToken* pDbName, bool query) {
pCxt
->
valid
=
false
;
}
}
else
{
trimEscape
(
pDbName
);
if
(
pDbName
->
n
>=
TSDB_DB_NAME_LEN
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
pDbName
->
z
);
pCxt
->
valid
=
false
;
}
}
if
(
pCxt
->
valid
)
{
trimEscape
(
pDbName
);
}
return
pCxt
->
valid
;
}
static
bool
checkTableName
(
SAstCreateContext
*
pCxt
,
SToken
*
pTableName
)
{
trimEscape
(
pTableName
);
if
(
NULL
!=
pTableName
&&
pTableName
->
n
>=
TSDB_TABLE_NAME_LEN
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
pTableName
->
z
);
pCxt
->
valid
=
false
;
return
false
;
}
trimEscape
(
pTableName
);
return
true
;
}
static
bool
checkColumnName
(
SAstCreateContext
*
pCxt
,
SToken
*
pColumnName
)
{
trimEscape
(
pColumnName
);
if
(
NULL
!=
pColumnName
&&
pColumnName
->
n
>=
TSDB_COL_NAME_LEN
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
pColumnName
->
z
);
pCxt
->
valid
=
false
;
return
false
;
}
trimEscape
(
pColumnName
);
return
true
;
}
static
bool
checkIndexName
(
SAstCreateContext
*
pCxt
,
SToken
*
pIndexName
)
{
trimEscape
(
pIndexName
);
if
(
NULL
!=
pIndexName
&&
pIndexName
->
n
>=
TSDB_INDEX_NAME_LEN
)
{
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
,
pIndexName
->
z
);
pCxt
->
valid
=
false
;
return
false
;
}
trimEscape
(
pIndexName
);
return
true
;
}
...
...
@@ -609,14 +607,14 @@ SNode* addOrderByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pOrder
SNode
*
addSlimitClause
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
SNode
*
pSlimit
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pStmt
))
{
((
SSelectStmt
*
)
pStmt
)
->
pSlimit
=
pSlimit
;
((
SSelectStmt
*
)
pStmt
)
->
pSlimit
=
(
SLimitNode
*
)
pSlimit
;
}
return
pStmt
;
}
SNode
*
addLimitClause
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
SNode
*
pLimit
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pStmt
))
{
((
SSelectStmt
*
)
pStmt
)
->
pLimit
=
pLimit
;
((
SSelectStmt
*
)
pStmt
)
->
pLimit
=
(
SLimitNode
*
)
pLimit
;
}
return
pStmt
;
}
...
...
@@ -771,7 +769,10 @@ SNode* setTableAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOptio
return
pOptions
;
}
SNode
*
createColumnDefNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pColName
,
SDataType
dataType
,
const
SToken
*
pComment
)
{
SNode
*
createColumnDefNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pColName
,
SDataType
dataType
,
const
SToken
*
pComment
)
{
if
(
!
checkColumnName
(
pCxt
,
pColName
))
{
return
NULL
;
}
SColumnDefNode
*
pCol
=
(
SColumnDefNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN_DEF
);
CHECK_OUT_OF_MEM
(
pCol
);
strncpy
(
pCol
->
colName
,
pColName
->
z
,
pColName
->
n
);
...
...
@@ -1101,7 +1102,17 @@ SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, cons
return
(
SNode
*
)
pStmt
;
}
SNode
*
createCreateTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pQuery
,
const
SToken
*
pSubscribeDbName
)
{
SNode
*
createTopicOptions
(
SAstCreateContext
*
pCxt
)
{
STopicOptions
*
pOptions
=
nodesMakeNode
(
QUERY_NODE_TOPIC_OPTIONS
);
CHECK_OUT_OF_MEM
(
pOptions
);
pOptions
->
withTable
=
false
;
pOptions
->
withSchema
=
false
;
pOptions
->
withTag
=
false
;
return
(
SNode
*
)
pOptions
;
}
SNode
*
createCreateTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pQuery
,
const
SToken
*
pSubscribeDbName
,
SNode
*
pOptions
)
{
SCreateTopicStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_CREATE_TOPIC_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
strncpy
(
pStmt
->
topicName
,
pTopicName
->
z
,
pTopicName
->
n
);
...
...
@@ -1110,6 +1121,7 @@ SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const S
if
(
NULL
!=
pSubscribeDbName
)
{
strncpy
(
pStmt
->
subscribeDbName
,
pSubscribeDbName
->
z
,
pSubscribeDbName
->
n
);
}
pStmt
->
pOptions
=
(
STopicOptions
*
)
pOptions
;
return
(
SNode
*
)
pStmt
;
}
...
...
source/libs/parser/src/parCalcConst.c
浏览文件 @
b0a68df5
...
...
@@ -16,12 +16,15 @@
#include "functionMgt.h"
#include "parInt.h"
#include "scalar.h"
#include "ttime.h"
typedef
struct
SCalcConstContext
{
SParseContext
*
pParseCxt
;
SMsgBuf
msgBuf
;
int32_t
code
;
}
SCalcConstContext
;
static
int32_t
calcConstQuery
(
SNode
*
pStmt
);
static
int32_t
calcConstQuery
(
S
CalcConstContext
*
pCxt
,
S
Node
*
pStmt
);
static
EDealRes
doCalcConst
(
SNode
**
pNode
,
SCalcConstContext
*
pCxt
)
{
SNode
*
pNew
=
NULL
;
...
...
@@ -35,10 +38,45 @@ static EDealRes doCalcConst(SNode** pNode, SCalcConstContext* pCxt) {
return
DEAL_RES_CONTINUE
;
}
static
bool
isTimestampCol
(
SNode
*
pNode
)
{
if
(
NULL
==
pNode
)
{
return
false
;
}
return
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
)
&&
TSDB_DATA_TYPE_TIMESTAMP
==
((
SExprNode
*
)
pNode
)
->
resType
.
type
);
}
static
EDealRes
stringToTimestamp
(
SCalcConstContext
*
pCxt
,
uint8_t
precision
,
SValueNode
*
pVal
)
{
switch
(
pVal
->
node
.
resType
.
type
)
{
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
{
int64_t
val
=
0
;
if
(
TSDB_CODE_SUCCESS
!=
convertStringToTimestamp
(
pVal
->
node
.
resType
.
type
,
pVal
->
datum
.
p
,
precision
,
&
val
))
{
pCxt
->
code
=
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INCORRECT_TIMESTAMP_VAL
,
varDataVal
(
pVal
->
datum
.
p
));
return
DEAL_RES_ERROR
;
}
pVal
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
pVal
->
node
.
resType
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_TIMESTAMP
].
bytes
;
taosMemoryFreeClear
(
pVal
->
datum
.
p
);
pVal
->
datum
.
i
=
val
;
break
;
}
default:
break
;
}
return
DEAL_RES_CONTINUE
;
}
static
EDealRes
calcConstOperator
(
SOperatorNode
**
pNode
,
void
*
pContext
)
{
SCalcConstContext
*
pCxt
=
pContext
;
SOperatorNode
*
pOp
=
*
pNode
;
if
(
QUERY_NODE_VALUE
==
nodeType
(
pOp
->
pLeft
)
&&
(
NULL
==
pOp
->
pRight
||
QUERY_NODE_VALUE
==
nodeType
(
pOp
->
pRight
)))
{
return
doCalcConst
((
SNode
**
)
pNode
,
(
SCalcConstContext
*
)
pContext
);
return
doCalcConst
((
SNode
**
)
pNode
,
pCxt
);
}
if
(
isTimestampCol
(
pOp
->
pLeft
)
&&
(
NULL
==
pOp
->
pRight
||
QUERY_NODE_VALUE
==
nodeType
(
pOp
->
pRight
)))
{
return
stringToTimestamp
(
pCxt
,
((
SColumnNode
*
)
pOp
->
pLeft
)
->
node
.
resType
.
precision
,
(
SValueNode
*
)
pOp
->
pRight
);
}
else
if
(
isTimestampCol
(
pOp
->
pRight
)
&&
QUERY_NODE_VALUE
==
nodeType
(
pOp
->
pLeft
))
{
return
stringToTimestamp
(
pCxt
,
((
SColumnNode
*
)
pOp
->
pRight
)
->
node
.
resType
.
precision
,
(
SValueNode
*
)
pOp
->
pLeft
);
}
return
DEAL_RES_CONTINUE
;
}
...
...
@@ -71,7 +109,7 @@ static EDealRes calcConstLogicCond(SLogicConditionNode** pNode, void* pContext)
static
EDealRes
calcConstSubquery
(
STempTableNode
**
pNode
,
void
*
pContext
)
{
SCalcConstContext
*
pCxt
=
pContext
;
pCxt
->
code
=
calcConstQuery
((
*
pNode
)
->
pSubquery
);
pCxt
->
code
=
calcConstQuery
(
pCxt
,
(
*
pNode
)
->
pSubquery
);
return
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
?
DEAL_RES_CONTINUE
:
DEAL_RES_ERROR
);
}
...
...
@@ -185,39 +223,38 @@ static int32_t calcConstCondition(SCalcConstContext* pCxt, SSelectStmt* pSelect,
return
pCxt
->
code
;
}
static
int32_t
calcConstSelect
(
SSelectStmt
*
pSelect
)
{
SCalcConstContext
cxt
=
{
.
code
=
TSDB_CODE_SUCCESS
};
nodesRewriteExprsPostOrder
(
pSelect
->
pProjectionList
,
calcConst
,
&
cxt
);
if
(
TSDB_CODE_SUCCESS
==
cxt
.
code
)
{
cxt
.
code
=
calcConstFromTable
(
&
cxt
,
pSelect
);
static
int32_t
calcConstSelect
(
SCalcConstContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
nodesRewriteExprsPostOrder
(
pSelect
->
pProjectionList
,
calcConst
,
pCxt
);
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
)
{
pCxt
->
code
=
calcConstFromTable
(
pCxt
,
pSelect
);
}
if
(
TSDB_CODE_SUCCESS
==
cxt
.
code
)
{
cxt
.
code
=
calcConstCondition
(
&
c
xt
,
pSelect
,
&
pSelect
->
pWhere
);
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
)
{
pCxt
->
code
=
calcConstCondition
(
pC
xt
,
pSelect
,
&
pSelect
->
pWhere
);
}
if
(
TSDB_CODE_SUCCESS
==
cxt
.
code
)
{
nodesRewriteExprsPostOrder
(
pSelect
->
pPartitionByList
,
calcConst
,
&
c
xt
);
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
)
{
nodesRewriteExprsPostOrder
(
pSelect
->
pPartitionByList
,
calcConst
,
pC
xt
);
}
if
(
TSDB_CODE_SUCCESS
==
cxt
.
code
)
{
nodesRewriteExprPostOrder
(
&
pSelect
->
pWindow
,
calcConst
,
&
c
xt
);
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
)
{
nodesRewriteExprPostOrder
(
&
pSelect
->
pWindow
,
calcConst
,
pC
xt
);
}
if
(
TSDB_CODE_SUCCESS
==
cxt
.
code
)
{
nodesRewriteExprsPostOrder
(
pSelect
->
pGroupByList
,
calcConst
,
&
c
xt
);
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
)
{
nodesRewriteExprsPostOrder
(
pSelect
->
pGroupByList
,
calcConst
,
pC
xt
);
}
if
(
TSDB_CODE_SUCCESS
==
cxt
.
code
)
{
cxt
.
code
=
calcConstCondition
(
&
c
xt
,
pSelect
,
&
pSelect
->
pHaving
);
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
)
{
pCxt
->
code
=
calcConstCondition
(
pC
xt
,
pSelect
,
&
pSelect
->
pHaving
);
}
if
(
TSDB_CODE_SUCCESS
==
cxt
.
code
)
{
nodesRewriteExprsPostOrder
(
pSelect
->
pOrderByList
,
calcConst
,
&
c
xt
);
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
code
)
{
nodesRewriteExprsPostOrder
(
pSelect
->
pOrderByList
,
calcConst
,
pC
xt
);
}
return
cxt
.
code
;
return
pCxt
->
code
;
}
static
int32_t
calcConstQuery
(
SNode
*
pStmt
)
{
static
int32_t
calcConstQuery
(
S
CalcConstContext
*
pCxt
,
S
Node
*
pStmt
)
{
switch
(
nodeType
(
pStmt
))
{
case
QUERY_NODE_SELECT_STMT
:
return
calcConstSelect
((
SSelectStmt
*
)
pStmt
);
return
calcConstSelect
(
pCxt
,
(
SSelectStmt
*
)
pStmt
);
case
QUERY_NODE_EXPLAIN_STMT
:
return
calcConstQuery
(((
SExplainStmt
*
)
pStmt
)
->
pQuery
);
return
calcConstQuery
(
pCxt
,
((
SExplainStmt
*
)
pStmt
)
->
pQuery
);
default:
break
;
}
...
...
@@ -237,7 +274,13 @@ static bool isEmptyResultQuery(SNode* pStmt) {
}
int32_t
calculateConstant
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
)
{
int32_t
code
=
calcConstQuery
(
pQuery
->
pRoot
);
SCalcConstContext
cxt
=
{
.
pParseCxt
=
pParseCxt
,
.
msgBuf
.
buf
=
pParseCxt
->
pMsg
,
.
msgBuf
.
len
=
pParseCxt
->
msgLen
,
.
code
=
TSDB_CODE_SUCCESS
};
int32_t
code
=
calcConstQuery
(
&
cxt
,
pQuery
->
pRoot
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pQuery
->
execMode
=
isEmptyResultQuery
(
pQuery
->
pRoot
)
?
QUERY_EXEC_MODE_EMPTY_RESULT
:
pQuery
->
execMode
;
}
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
b0a68df5
...
...
@@ -1116,7 +1116,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) {
}
// FILE csv_file_path
if
(
TK_
NK_
FILE
==
sToken
.
type
)
{
if
(
TK_FILE
==
sToken
.
type
)
{
// pSql -> csv_file_path
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
if
(
0
==
sToken
.
n
||
(
TK_NK_STRING
!=
sToken
.
type
&&
TK_NK_ID
!=
sToken
.
type
))
{
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
b0a68df5
...
...
@@ -148,6 +148,7 @@ static SKeyword keywordTable[] = {
{
"RESET"
,
TK_RESET
},
{
"RETENTIONS"
,
TK_RETENTIONS
},
{
"ROLLUP"
,
TK_ROLLUP
},
{
"SCHEMA"
,
TK_SCHEMA
},
{
"SCORES"
,
TK_SCORES
},
{
"SELECT"
,
TK_SELECT
},
{
"SESSION"
,
TK_SESSION
},
...
...
@@ -202,6 +203,7 @@ static SKeyword keywordTable[] = {
{
"WATERMARK"
,
TK_WATERMARK
},
{
"WHERE"
,
TK_WHERE
},
{
"WINDOW_CLOSE"
,
TK_WINDOW_CLOSE
},
{
"WITH"
,
TK_WITH
},
{
"_QENDTS"
,
TK_QENDTS
},
{
"_QSTARTTS"
,
TK_QSTARTTS
},
{
"_ROWTS"
,
TK_ROWTS
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
b0a68df5
...
...
@@ -119,10 +119,8 @@ static int32_t getTableMetaImpl(STranslateContext* pCxt, const SName* pName, STa
}
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
};
strcpy
(
name
.
dbname
,
pDbName
);
strcpy
(
name
.
tname
,
pTableName
);
return
getTableMetaImpl
(
pCxt
,
&
name
,
pMeta
);
SName
name
;
return
getTableMetaImpl
(
pCxt
,
toName
(
pCxt
->
pParseCxt
->
acctId
,
pDbName
,
pTableName
,
&
name
),
pMeta
);
}
static
int32_t
getTableDistVgInfo
(
STranslateContext
*
pCxt
,
const
SName
*
pName
,
SArray
**
pVgInfo
)
{
...
...
@@ -181,10 +179,8 @@ static int32_t getTableHashVgroupImpl(STranslateContext* pCxt, const SName* pNam
static
int32_t
getTableHashVgroup
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
const
char
*
pTableName
,
SVgroupInfo
*
pInfo
)
{
SName
name
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
name
.
dbname
,
pDbName
);
strcpy
(
name
.
tname
,
pTableName
);
return
getTableHashVgroupImpl
(
pCxt
,
&
name
,
pInfo
);
SName
name
;
return
getTableHashVgroupImpl
(
pCxt
,
toName
(
pCxt
->
pParseCxt
->
acctId
,
pDbName
,
pTableName
,
&
name
),
pInfo
);
}
static
int32_t
getDBVgVersion
(
STranslateContext
*
pCxt
,
const
char
*
pDbFName
,
int32_t
*
pVersion
,
int64_t
*
pDbId
,
...
...
@@ -938,7 +934,7 @@ static int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STabl
return
TSDB_CODE_SUCCESS
;
}
}
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
pTableAlias
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
pTableAlias
);
}
static
int32_t
createTableAllCols
(
STranslateContext
*
pCxt
,
SColumnNode
*
pCol
,
SNodeList
**
pOutput
)
{
...
...
@@ -1346,6 +1342,18 @@ static int32_t translateFrom(STranslateContext* pCxt, SSelectStmt* pSelect) {
return
code
;
}
static
int32_t
checkLimit
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
if
((
NULL
!=
pSelect
->
pLimit
&&
pSelect
->
pLimit
->
offset
<
0
)
||
(
NULL
!=
pSelect
->
pSlimit
&&
pSelect
->
pSlimit
->
offset
<
0
))
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_OFFSET_LESS_ZERO
);
}
if
(
NULL
!=
pSelect
->
pSlimit
&&
NULL
==
pSelect
->
pPartitionByList
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_BY
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateSelect
(
STranslateContext
*
pCxt
,
SSelectStmt
*
pSelect
)
{
pCxt
->
pCurrStmt
=
pSelect
;
int32_t
code
=
translateFrom
(
pCxt
,
pSelect
);
...
...
@@ -1373,6 +1381,9 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkAggColCoexist
(
pCxt
,
pSelect
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkLimit
(
pCxt
,
pSelect
);
}
return
code
;
}
...
...
@@ -1537,11 +1548,11 @@ static int32_t checkRangeOption(STranslateContext* pCxt, const char* pName, SVal
}
if
(
pVal
->
isDuration
&&
(
TIME_UNIT_MINUTE
!=
pVal
->
unit
&&
TIME_UNIT_HOUR
!=
pVal
->
unit
&&
TIME_UNIT_DAY
!=
pVal
->
unit
))
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_OPTION_UNIT
,
pName
,
pVal
->
unit
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_OPTION_UNIT
,
pName
,
pVal
->
unit
);
}
int64_t
val
=
getBigintFromValueNode
(
pVal
);
if
(
val
<
minVal
||
val
>
maxVal
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_RANGE_OPTION
,
pName
,
val
,
minVal
,
maxVal
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_RANGE_OPTION
,
pName
,
val
,
minVal
,
maxVal
);
}
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1567,7 +1578,7 @@ static int32_t checkDbPrecisionOption(STranslateContext* pCxt, SValueNode* pVal)
}
else
if
(
0
==
strcmp
(
pRrecision
,
TSDB_TIME_PRECISION_NANO_STR
))
{
convertValueFromStrToInt
(
pVal
,
TSDB_TIME_PRECISION_NANO
);
}
else
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_STR_OPTION
,
"precision"
,
pVal
->
datum
.
p
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_STR_OPTION
,
"precision"
,
pVal
->
datum
.
p
);
}
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1580,7 +1591,7 @@ static int32_t checkDbEnumOption(STranslateContext* pCxt, const char* pName, SVa
}
int64_t
val
=
pVal
->
datum
.
i
;
if
(
val
!=
v1
&&
val
!=
v2
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_ENUM_OPTION
,
pName
,
val
,
v1
,
v2
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ENUM_OPTION
,
pName
,
val
,
v1
,
v2
);
}
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1593,7 +1604,7 @@ static int32_t checkTtlOption(STranslateContext* pCxt, SValueNode* pVal) {
}
int64_t
val
=
pVal
->
datum
.
i
;
if
(
val
<
TSDB_MIN_DB_TTL
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_TTL_OPTION
,
val
,
TSDB_MIN_DB_TTL
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_TTL_OPTION
,
val
,
TSDB_MIN_DB_TTL
);
}
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1606,7 +1617,7 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
int32_t
numOfKeep
=
LIST_LENGTH
(
pKeep
);
if
(
numOfKeep
>
3
||
numOfKeep
<
1
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_KEEP_NUM
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_KEEP_NUM
);
}
SNode
*
pNode
=
NULL
;
...
...
@@ -1637,7 +1648,7 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
(
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
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_KEEP_UNIT
,
pKeep0
->
unit
,
pKeep1
->
unit
,
pKeep2
->
unit
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_KEEP_UNIT
,
pKeep0
->
unit
,
pKeep1
->
unit
,
pKeep2
->
unit
);
}
int32_t
daysToKeep0
=
getBigintFromValueNode
(
pKeep0
);
...
...
@@ -1645,12 +1656,12 @@ static int32_t checkKeepOption(STranslateContext* pCxt, SNodeList* pKeep) {
int32_t
daysToKeep2
=
getBigintFromValueNode
(
pKeep2
);
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
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_KEEP_VALUE
,
daysToKeep0
,
daysToKeep1
,
daysToKeep2
,
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_KEEP_VALUE
,
daysToKeep0
,
daysToKeep1
,
daysToKeep2
,
TSDB_MIN_KEEP
,
TSDB_MAX_KEEP
);
}
if
(
!
((
daysToKeep0
<=
daysToKeep1
)
&&
(
daysToKeep1
<=
daysToKeep2
)))
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_KEEP_ORDER
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_KEEP_ORDER
);
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1662,7 +1673,7 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete
}
if
(
LIST_LENGTH
(
pRetentions
)
>
3
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_RETENTIONS_OPTION
);
}
SNode
*
pNode
=
NULL
;
...
...
@@ -1678,7 +1689,28 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
checkDatabaseOptions
(
STranslateContext
*
pCxt
,
SDatabaseOptions
*
pOptions
)
{
static
int32_t
checkOptionsDependency
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
SDatabaseOptions
*
pOptions
,
bool
alter
)
{
if
(
NULL
==
pOptions
->
pDaysPerFile
&&
NULL
==
pOptions
->
pKeep
)
{
return
TSDB_CODE_SUCCESS
;
}
int64_t
daysPerFile
=
GET_OPTION_VAL
(
pOptions
->
pDaysPerFile
,
alter
?
-
1
:
TSDB_DEFAULT_DAYS_PER_FILE
);
int64_t
daysToKeep0
=
GET_OPTION_VAL
(
nodesListGetNode
(
pOptions
->
pKeep
,
0
),
alter
?
-
1
:
TSDB_DEFAULT_KEEP
);
if
(
alter
&&
(
-
1
==
daysPerFile
||
-
1
==
daysToKeep0
))
{
SDbCfgInfo
dbCfg
;
int32_t
code
=
getDBCfg
(
pCxt
,
pDbName
,
&
dbCfg
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
daysPerFile
=
(
-
1
==
daysPerFile
?
dbCfg
.
daysPerFile
:
daysPerFile
);
daysToKeep0
=
(
-
1
==
daysPerFile
?
dbCfg
.
daysToKeep0
:
daysToKeep0
);
}
if
(
daysPerFile
>
daysToKeep0
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_DAYS_VALUE
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
checkDatabaseOptions
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
SDatabaseOptions
*
pOptions
,
bool
alter
)
{
int32_t
code
=
checkRangeOption
(
pCxt
,
"totalBlocks"
,
pOptions
->
pNumOfBlocks
,
TSDB_MIN_TOTAL_BLOCKS
,
TSDB_MAX_TOTAL_BLOCKS
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
@@ -1739,11 +1771,14 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, SDatabaseOptions* p
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkDbEnumOption
(
pCxt
,
"strict"
,
pOptions
->
pStrict
,
TSDB_DB_STRICT_OFF
,
TSDB_DB_STRICT_ON
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkOptionsDependency
(
pCxt
,
pDbName
,
pOptions
,
alter
);
}
return
code
;
}
static
int32_t
checkCreateDatabase
(
STranslateContext
*
pCxt
,
SCreateDatabaseStmt
*
pStmt
)
{
return
checkDatabaseOptions
(
pCxt
,
pStmt
->
pOptions
);
return
checkDatabaseOptions
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
pOptions
,
false
);
}
typedef
int32_t
(
*
FSerializeFunc
)(
void
*
pBuf
,
int32_t
bufLen
,
void
*
pReq
);
...
...
@@ -1807,7 +1842,7 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt,
}
static
int32_t
translateAlterDatabase
(
STranslateContext
*
pCxt
,
SAlterDatabaseStmt
*
pStmt
)
{
int32_t
code
=
checkDatabaseOptions
(
pCxt
,
pStmt
->
pOptions
);
int32_t
code
=
checkDatabaseOptions
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
pOptions
,
true
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
...
...
@@ -1868,7 +1903,7 @@ static int32_t checkTableCommentOption(STranslateContext* pCxt, SValueNode* pVal
return
pCxt
->
errCode
;
}
if
(
pVal
->
node
.
resType
.
bytes
>=
TSDB_STB_COMMENT_LEN
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_COMMENT_OPTION
,
TSDB_STB_COMMENT_LEN
-
1
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_COMMENT_OPTION
,
TSDB_STB_COMMENT_LEN
-
1
);
}
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -1880,7 +1915,7 @@ static int32_t checTableFactorOption(STranslateContext* pCxt, SValueNode* pVal)
return
pCxt
->
errCode
;
}
if
(
pVal
->
datum
.
d
<
TSDB_MIN_DB_FILE_FACTOR
||
pVal
->
datum
.
d
>
TSDB_MAX_DB_FILE_FACTOR
)
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_F_RANGE_OPTION
,
"file_factor"
,
pVal
->
datum
.
d
,
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_F_RANGE_OPTION
,
"file_factor"
,
pVal
->
datum
.
d
,
TSDB_MIN_DB_FILE_FACTOR
,
TSDB_MAX_DB_FILE_FACTOR
);
}
}
...
...
@@ -1921,12 +1956,12 @@ static int32_t checkTableRollupOption(STranslateContext* pCxt, SNodeList* pFuncs
}
if
(
1
!=
LIST_LENGTH
(
pFuncs
))
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_ROLLUP_OPTION
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ROLLUP_OPTION
);
}
SFunctionNode
*
pFunc
=
nodesListGetNode
(
pFuncs
,
0
);
SFmGetFuncInfoParam
param
=
{
.
pCtg
=
pCxt
->
pParseCxt
->
pCatalog
,
.
pRpc
=
pCxt
->
pParseCxt
->
pTransporter
,
.
pMgmtEps
=
&
pCxt
->
pParseCxt
->
mgmtEpSet
};
if
(
TSDB_CODE_SUCCESS
!=
fmGetFuncInfo
(
&
param
,
pFunc
->
functionName
,
&
pFunc
->
funcId
,
&
pFunc
->
funcType
))
{
return
generate
DealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_FUNTION
,
pFunc
->
functionName
);
return
generate
SyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_FUNTION
,
pFunc
->
functionName
);
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2200,10 +2235,8 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
pReq
->
numOfSmas
=
LIST_LENGTH
(
pStmt
->
pOptions
->
pSma
);
}
SName
tableName
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
tableName
.
dbname
,
pStmt
->
dbName
);
strcpy
(
tableName
.
tname
,
pStmt
->
tableName
);
tNameExtractFullName
(
&
tableName
,
pReq
->
name
);
SName
tableName
;
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
tableName
),
pReq
->
name
);
return
buildRollupAst
(
pCxt
,
pStmt
,
pReq
);
}
...
...
@@ -2253,10 +2286,8 @@ static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt
}
static
int32_t
translateDropSuperTable
(
STranslateContext
*
pCxt
,
SDropSuperTableStmt
*
pStmt
)
{
SName
tableName
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
tableName
.
dbname
,
pStmt
->
dbName
);
strcpy
(
tableName
.
tname
,
pStmt
->
tableName
);
return
doTranslateDropSuperTable
(
pCxt
,
&
tableName
,
pStmt
->
ignoreNotExists
);
SName
tableName
;
return
doTranslateDropSuperTable
(
pCxt
,
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
tableName
),
pStmt
->
ignoreNotExists
);
}
static
int32_t
setAlterTableField
(
SAlterTableStmt
*
pStmt
,
SMAltertbReq
*
pAlterReq
)
{
...
...
@@ -2296,10 +2327,8 @@ static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAltertbReq* pAlterRe
static
int32_t
translateAlterTable
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
SMAltertbReq
alterReq
=
{
0
};
SName
tableName
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
tableName
.
dbname
,
pStmt
->
dbName
);
strcpy
(
tableName
.
tname
,
pStmt
->
tableName
);
tNameExtractFullName
(
&
tableName
,
alterReq
.
name
);
SName
tableName
;
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
tableName
),
alterReq
.
name
);
alterReq
.
alterType
=
pStmt
->
alterType
;
alterReq
.
numOfFields
=
1
;
if
(
TSDB_ALTER_TABLE_UPDATE_OPTIONS
==
pStmt
->
alterType
)
{
...
...
@@ -2389,8 +2418,6 @@ static int32_t nodeTypeToShowType(ENodeType nt) {
return
TSDB_MGMT_TABLE_GRANTS
;
case
QUERY_NODE_SHOW_QUERIES_STMT
:
return
TSDB_MGMT_TABLE_QUERIES
;
case
QUERY_NODE_SHOW_TOPICS_STMT
:
return
0
;
// todo
case
QUERY_NODE_SHOW_VARIABLE_STMT
:
return
0
;
// todo
default:
...
...
@@ -2452,10 +2479,8 @@ static int32_t getSmaIndexAst(STranslateContext* pCxt, SCreateIndexStmt* pStmt,
}
static
int32_t
buildCreateSmaReq
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
,
SMCreateSmaReq
*
pReq
)
{
SName
name
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
strcpy
(
name
.
tname
,
pStmt
->
indexName
);
tNameExtractFullName
(
&
name
,
pReq
->
name
);
SName
name
;
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
db
,
pStmt
->
indexName
,
&
name
),
pReq
->
name
);
strcpy
(
name
.
tname
,
pStmt
->
tableName
);
name
.
tname
[
strlen
(
pStmt
->
tableName
)]
=
'\0'
;
tNameExtractFullName
(
&
name
,
pReq
->
stb
);
...
...
@@ -2610,11 +2635,14 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SName
name
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
}
;
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
strcpy
(
name
.
tname
,
pStmt
->
topicN
ame
);
tNameExtractFullName
(
&
name
,
createReq
.
name
);
SName
name
;
// tNameSetDbName(&name, pCxt->pParseCxt->acctId, pCxt->pParseCxt->db, strlen(pCxt->pParseCxt->db)
);
// tNameGetFullDbName(&name, createReq.n
ame);
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
db
,
pStmt
->
topicName
,
&
name
)
,
createReq
.
name
);
createReq
.
igExists
=
pStmt
->
ignoreExists
;
createReq
.
withTbName
=
pStmt
->
pOptions
->
withTable
;
createReq
.
withSchema
=
pStmt
->
pOptions
->
withSchema
;
createReq
.
withTag
=
pStmt
->
pOptions
->
withTag
;
int32_t
code
=
buildCmdMsg
(
pCxt
,
TDMT_MND_CREATE_TOPIC
,
(
FSerializeFunc
)
tSerializeSCMCreateTopicReq
,
&
createReq
);
tFreeSCMCreateTopicReq
(
&
createReq
);
...
...
@@ -2624,10 +2652,8 @@ static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* p
static
int32_t
translateDropTopic
(
STranslateContext
*
pCxt
,
SDropTopicStmt
*
pStmt
)
{
SMDropTopicReq
dropReq
=
{
0
};
SName
name
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
strcpy
(
name
.
tname
,
pStmt
->
topicName
);
tNameExtractFullName
(
&
name
,
dropReq
.
name
);
SName
name
;
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
db
,
pStmt
->
topicName
,
&
name
),
dropReq
.
name
);
dropReq
.
igNotExists
=
pStmt
->
ignoreNotExists
;
return
buildCmdMsg
(
pCxt
,
TDMT_MND_DROP_TOPIC
,
(
FSerializeFunc
)
tSerializeSMDropTopicReq
,
&
dropReq
);
...
...
@@ -2666,10 +2692,8 @@ static int32_t translateCreateStream(STranslateContext* pCxt, SCreateStreamStmt*
createReq
.
igExists
=
pStmt
->
ignoreExists
;
SName
name
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
strcpy
(
name
.
tname
,
pStmt
->
streamName
);
tNameExtractFullName
(
&
name
,
createReq
.
name
);
SName
name
;
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
db
,
pStmt
->
streamName
,
&
name
),
createReq
.
name
);
if
(
'\0'
!=
pStmt
->
targetTabName
[
0
])
{
strcpy
(
name
.
dbname
,
pStmt
->
targetDbName
);
...
...
@@ -2984,6 +3008,7 @@ static const char* getSysDbName(ENodeType type) {
return
TSDB_INFORMATION_SCHEMA_DB
;
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_TOPICS_STMT
:
return
TSDB_PERFORMANCE_SCHEMA_DB
;
default:
break
;
...
...
@@ -3029,6 +3054,8 @@ static const char* getSysTableName(ENodeType type) {
return
TSDB_PERFS_TABLE_CONNECTIONS
;
case
QUERY_NODE_SHOW_QUERIES_STMT
:
return
TSDB_PERFS_TABLE_QUERIES
;
case
QUERY_NODE_SHOW_TOPICS_STMT
:
return
TSDB_PERFS_TABLE_TOPICS
;
default:
break
;
}
...
...
@@ -3550,6 +3577,7 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
case
QUERY_NODE_SHOW_CONNECTIONS_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_CLUSTER_STMT
:
case
QUERY_NODE_SHOW_TOPICS_STMT
:
code
=
rewriteShow
(
pCxt
,
pQuery
);
break
;
case
QUERY_NODE_CREATE_TABLE_STMT
:
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
b0a68df5
...
...
@@ -23,15 +23,15 @@ static char* getSyntaxErrFormat(int32_t errCode) {
case
TSDB_CODE_PAR_INCOMPLETE_SQL
:
return
"Incomplete SQL statement"
;
case
TSDB_CODE_PAR_INVALID_COLUMN
:
return
"Invalid column name
: %s"
;
return
"Invalid column name: %s"
;
case
TSDB_CODE_PAR_TABLE_NOT_EXIST
:
return
"Table does not exist
: %s"
;
return
"Table does not exist: %s"
;
case
TSDB_CODE_PAR_AMBIGUOUS_COLUMN
:
return
"Column ambiguously defined
: %s"
;
return
"Column ambiguously defined: %s"
;
case
TSDB_CODE_PAR_WRONG_VALUE_TYPE
:
return
"Invalid value type
: %s"
;
return
"Invalid value type: %s"
;
case
TSDB_CODE_PAR_INVALID_FUNTION
:
return
"Invalid function name
: %s"
;
return
"Invalid function name: %s"
;
case
TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
:
return
"There mustn't be aggregation"
;
case
TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT
:
...
...
@@ -45,7 +45,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
case
TSDB_CODE_PAR_TAGS_NOT_MATCHED
:
return
"Tags number not matched"
;
case
TSDB_CODE_PAR_INVALID_TAG_NAME
:
return
"Invalid tag name
: %s"
;
return
"Invalid tag name: %s"
;
case
TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG
:
return
"Name or password too long"
;
case
TSDB_CODE_PAR_PASSWD_EMPTY
:
...
...
@@ -61,7 +61,7 @@ static char* getSyntaxErrFormat(int32_t errCode) {
case
TSDB_CODE_PAR_DB_NOT_SPECIFIED
:
return
"Database not specified"
;
case
TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME
:
return
"Invalid identifier name
: %s"
;
return
"Invalid identifier name: %s"
;
case
TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR
:
return
"Corresponding super table not in this db"
;
case
TSDB_CODE_PAR_INVALID_RANGE_OPTION
:
...
...
@@ -120,6 +120,14 @@ static char* getSyntaxErrFormat(int32_t errCode) {
return
"Only one tag if there is a json tag"
;
case
TSDB_CODE_PAR_INCORRECT_NUM_OF_COL
:
return
"Query block has incorrect number of result columns"
;
case
TSDB_CODE_PAR_INCORRECT_TIMESTAMP_VAL
:
return
"Incorrect TIMESTAMP value: %s"
;
case
TSDB_CODE_PAR_INVALID_DAYS_VALUE
:
return
"Invalid days value, should be keep2 >= keep1 >= keep0 >= days"
;
case
TSDB_CODE_PAR_OFFSET_LESS_ZERO
:
return
"soffset/offset can not be less than 0"
;
case
TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_BY
:
return
"slimit/soffset only available for PARTITION BY query"
;
case
TSDB_CODE_OUT_OF_MEMORY
:
return
"Out of memory"
;
default:
...
...
source/libs/parser/src/sql.c
浏览文件 @
b0a68df5
此差异已折叠。
点击以展开。
source/libs/planner/inc/planInt.h
浏览文件 @
b0a68df5
...
...
@@ -22,6 +22,10 @@ extern "C" {
#include "planner.h"
#define QUERY_POLICY_VNODE 1
#define QUERY_POLICY_HYBRID 2
#define QUERY_POLICY_QNODE 3
#define planFatal(param, ...) qFatal("PLAN: " param, __VA_ARGS__)
#define planError(param, ...) qError("PLAN: " param, __VA_ARGS__)
#define planWarn(param, ...) qWarn("PLAN: " param, __VA_ARGS__)
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
b0a68df5
...
...
@@ -639,8 +639,8 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
}
if
(
NULL
!=
pSelect
->
pLimit
)
{
pProject
->
limit
=
((
SLimitNode
*
)
pSelect
->
pLimit
)
->
limit
;
pProject
->
offset
=
((
SLimitNode
*
)
pSelect
->
pLimit
)
->
offset
;
pProject
->
limit
=
pSelect
->
pLimit
->
limit
;
pProject
->
offset
=
pSelect
->
pLimit
->
offset
;
}
else
{
pProject
->
limit
=
-
1
;
pProject
->
offset
=
-
1
;
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
b0a68df5
...
...
@@ -16,6 +16,8 @@
#include "planInt.h"
#include "functionMgt.h"
#include "tglobal.h"
#include "catalog.h"
typedef
struct
SSlotIdInfo
{
int16_t
slotId
;
...
...
@@ -1233,7 +1235,13 @@ int32_t createPhysiPlan(SPlanContext* pCxt, SQueryLogicPlan* pLogicPlan, SQueryP
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
code
=
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
pPlan
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
tsQueryPolicy
>
QUERY_POLICY_VNODE
)
{
code
=
catalogGetQnodeList
(
pCxt
->
pCatalog
,
pCxt
->
pTransporter
,
&
pCxt
->
mgmtEpSet
,
pExecNodeList
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
pPlan
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
setExplainInfo
(
pCxt
,
*
pPlan
);
}
...
...
tests/script/tsim/db/alter_option.sim
浏览文件 @
b0a68df5
...
...
@@ -183,10 +183,10 @@ sql_error alter database db days 0
sql_error alter database db days 14400 # set over than keep
print ============== modify keep
sql alter database db keep
2
000
sql alter database db keep
3456
000
sql show databases
print keep $data7_db
if $data7_db !=
2000,2000,2
000 then
if $data7_db !=
3456000,3456000,3456
000 then
return -1
endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录