Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ce166fb1
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ce166fb1
编写于
5月 31, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: error in data precision of super table query
上级
0418e6c0
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
795 addition
and
772 deletion
+795
-772
include/common/ttokendef.h
include/common/ttokendef.h
+78
-78
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+1
-0
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+1
-1
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+1
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+29
-13
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+678
-676
source/libs/parser/test/parInitialDTest.cpp
source/libs/parser/test/parInitialDTest.cpp
+3
-3
source/libs/parser/test/parSelectTest.cpp
source/libs/parser/test/parSelectTest.cpp
+2
-0
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+2
-0
未找到文件。
include/common/ttokendef.h
浏览文件 @
ce166fb1
...
...
@@ -162,84 +162,84 @@
#define TK_INTERVAL 144
#define TK_TOPIC 145
#define TK_AS 146
#define TK_C
GROUP
147
#define TK_
WITH
148
#define TK_
SCHEMA
149
#define TK_
DESC
150
#define TK_DESC
RIBE
151
#define TK_
RESET
152
#define TK_
QUERY
153
#define TK_
CACHE
154
#define TK_
EXPLAIN
155
#define TK_
ANALYZE
156
#define TK_
VERBOS
E 157
#define TK_
NK_BOOL
158
#define TK_
RATIO
159
#define TK_
COMPACT
160
#define TK_
VNODES
161
#define TK_
IN
162
#define TK_
OUTPUTTYPE
163
#define TK_
AGGREGATE
164
#define TK_
BUFSIZE
165
#define TK_
STREAM
166
#define TK_
INTO
167
#define TK_
TRIGGER
168
#define TK_
AT_ONCE
169
#define TK_
WINDOW_CLOSE
170
#define TK_W
ATERMARK
171
#define TK_
KILL
172
#define TK_
CONNECTION
173
#define TK_
TRANSACTION
174
#define TK_
MERGE
175
#define TK_
VGROUP
176
#define TK_
REDISTRIBUTE
177
#define TK_
SPLIT
178
#define TK_S
YNCDB
179
#define TK_
NULL
180
#define TK_N
K_QUESTION
181
#define TK_NK_
ARROW
182
#define TK_
ROWTS
183
#define TK_
TBNAME
184
#define TK_
QSTARTTS
185
#define TK_Q
ENDTS
186
#define TK_
WSTARTTS
187
#define TK_W
ENDTS
188
#define TK_W
DURATION
189
#define TK_
CAST
190
#define TK_
NOW
191
#define TK_
TODAY
192
#define TK_T
IMEZONE
193
#define TK_
COUNT
194
#define TK_
FIRS
T 195
#define TK_
LAST
196
#define TK_LAST
_ROW
197
#define TK_
BETWEEN
198
#define TK_
IS
199
#define TK_
NK_LT
200
#define TK_NK_
G
T 201
#define TK_NK_
LE
202
#define TK_NK_
G
E 203
#define TK_NK_
N
E 204
#define TK_
MATCH
205
#define TK_
NMATCH
206
#define TK_
CONTAINS
207
#define TK_
JOIN
208
#define TK_
INNER
209
#define TK_
SELECT
210
#define TK_
DISTINCT
211
#define TK_
WHERE
212
#define TK_
PARTITION
213
#define TK_
BY
214
#define TK_
SESSION
215
#define TK_S
TATE_WINDOW
216
#define TK_S
LIDING
217
#define TK_
FILL
218
#define TK_
VALUE
219
#define TK_
NONE
220
#define TK_
PREV
221
#define TK_
LINEAR
222
#define TK_
NEXT
223
#define TK_
GROUP
224
#define TK_C
ONSUMER
147
#define TK_
GROUP
148
#define TK_
WITH
149
#define TK_
SCHEMA
150
#define TK_DESC
151
#define TK_
DESCRIBE
152
#define TK_
RESET
153
#define TK_
QUERY
154
#define TK_
CACHE
155
#define TK_
EXPLAIN
156
#define TK_
ANALYZ
E 157
#define TK_
VERBOSE
158
#define TK_
NK_BOOL
159
#define TK_
RATIO
160
#define TK_
COMPACT
161
#define TK_
VNODES
162
#define TK_
IN
163
#define TK_
OUTPUTTYPE
164
#define TK_
AGGREGATE
165
#define TK_
BUFSIZE
166
#define TK_
STREAM
167
#define TK_
INTO
168
#define TK_
TRIGGER
169
#define TK_
AT_ONCE
170
#define TK_W
INDOW_CLOSE
171
#define TK_
WATERMARK
172
#define TK_
KILL
173
#define TK_
CONNECTION
174
#define TK_
TRANSACTION
175
#define TK_
MERGE
176
#define TK_
VGROUP
177
#define TK_
REDISTRIBUTE
178
#define TK_S
PLIT
179
#define TK_
SYNCDB
180
#define TK_N
ULL
181
#define TK_NK_
QUESTION
182
#define TK_
NK_ARROW
183
#define TK_
ROWTS
184
#define TK_
TBNAME
185
#define TK_Q
STARTTS
186
#define TK_
QENDTS
187
#define TK_W
STARTTS
188
#define TK_W
ENDTS
189
#define TK_
WDURATION
190
#define TK_
CAST
191
#define TK_
NOW
192
#define TK_T
ODAY
193
#define TK_
TIMEZONE
194
#define TK_
COUN
T 195
#define TK_
FIRST
196
#define TK_LAST
197
#define TK_
LAST_ROW
198
#define TK_
BETWEEN
199
#define TK_
IS
200
#define TK_NK_
L
T 201
#define TK_NK_
GT
202
#define TK_NK_
L
E 203
#define TK_NK_
G
E 204
#define TK_
NK_NE
205
#define TK_
MATCH
206
#define TK_
NMATCH
207
#define TK_
CONTAINS
208
#define TK_
JOIN
209
#define TK_
INNER
210
#define TK_
SELECT
211
#define TK_
DISTINCT
212
#define TK_
WHERE
213
#define TK_
PARTITION
214
#define TK_
BY
215
#define TK_S
ESSION
216
#define TK_S
TATE_WINDOW
217
#define TK_
SLIDING
218
#define TK_
FILL
219
#define TK_
VALUE
220
#define TK_
NONE
221
#define TK_
PREV
222
#define TK_
LINEAR
223
#define TK_
NEXT
224
#define TK_HAVING 225
#define TK_ORDER 226
#define TK_SLIMIT 227
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
ce166fb1
...
...
@@ -305,6 +305,7 @@ static SNode* logicNodeCopy(const SLogicNode* pSrc, SLogicNode* pDst) {
CLONE_NODE_FIELD
(
pConditions
);
CLONE_NODE_LIST_FIELD
(
pChildren
);
COPY_SCALAR_FIELD
(
optimizedFlag
);
COPY_SCALAR_FIELD
(
precision
);
return
(
SNode
*
)
pDst
;
}
...
...
source/libs/parser/inc/sql.y
浏览文件 @
ce166fb1
...
...
@@ -408,7 +408,7 @@ cmd ::= CREATE TOPIC not_exists_opt(A)
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); }
cmd ::= DROP C
GROUP exists_opt(A) cgroup_name(B) ON topic_name(C).
{ pCxt->pRootNode = createDropCGroupStmt(pCxt, A, &B, &C); }
cmd ::= DROP C
ONSUMER GROUP exists_opt(A) cgroup_name(B) ON topic_name(C).
{ pCxt->pRootNode = createDropCGroupStmt(pCxt, A, &B, &C); }
topic_options(A) ::= . { A = createTopicOptions(pCxt); }
topic_options(A) ::= topic_options(B) WITH TABLE. { ((STopicOptions*)B)->withTable = true; A = B; }
...
...
source/libs/parser/src/parTokenizer.c
浏览文件 @
ce166fb1
...
...
@@ -53,7 +53,6 @@ static SKeyword keywordTable[] = {
{
"CACHE"
,
TK_CACHE
},
{
"CACHELAST"
,
TK_CACHELAST
},
{
"CAST"
,
TK_CAST
},
{
"CGROUP"
,
TK_CGROUP
},
{
"CLUSTER"
,
TK_CLUSTER
},
{
"COLUMN"
,
TK_COLUMN
},
{
"COMMENT"
,
TK_COMMENT
},
...
...
@@ -62,6 +61,7 @@ static SKeyword keywordTable[] = {
{
"CONNS"
,
TK_CONNS
},
{
"CONNECTION"
,
TK_CONNECTION
},
{
"CONNECTIONS"
,
TK_CONNECTIONS
},
{
"CONSUMER"
,
TK_CONSUMER
},
{
"COUNT"
,
TK_COUNT
},
{
"CREATE"
,
TK_CREATE
},
{
"DATABASE"
,
TK_DATABASE
},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
ce166fb1
...
...
@@ -465,20 +465,22 @@ static bool isPrimaryKey(STempTableNode* pTable, SNode* pExpr) {
return
isPrimaryKeyImpl
(
pTable
,
pExpr
);
}
static
bool
findAndSetColumn
(
SColumnNode
**
pColRef
,
const
STableNode
*
pTable
)
{
static
int32_t
findAndSetColumn
(
STranslateContext
*
pCxt
,
SColumnNode
**
pColRef
,
const
STableNode
*
pTable
,
bool
*
pFound
)
{
SColumnNode
*
pCol
=
*
pColRef
;
bool
f
ound
=
false
;
*
pF
ound
=
false
;
if
(
QUERY_NODE_REAL_TABLE
==
nodeType
(
pTable
))
{
const
STableMeta
*
pMeta
=
((
SRealTableNode
*
)
pTable
)
->
pMeta
;
if
(
isInternalPrimaryKey
(
pCol
))
{
setColumnInfoBySchema
((
SRealTableNode
*
)
pTable
,
pMeta
->
schema
,
false
,
pCol
);
return
true
;
*
pFound
=
true
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
nums
=
pMeta
->
tableInfo
.
numOfTags
+
pMeta
->
tableInfo
.
numOfColumns
;
for
(
int32_t
i
=
0
;
i
<
nums
;
++
i
)
{
if
(
0
==
strcmp
(
pCol
->
colName
,
pMeta
->
schema
[
i
].
name
))
{
setColumnInfoBySchema
((
SRealTableNode
*
)
pTable
,
pMeta
->
schema
+
i
,
(
i
>=
pMeta
->
tableInfo
.
numOfColumns
),
pCol
);
f
ound
=
true
;
*
pF
ound
=
true
;
break
;
}
}
...
...
@@ -489,13 +491,15 @@ static bool findAndSetColumn(SColumnNode** pColRef, const STableNode* pTable) {
SExprNode
*
pExpr
=
(
SExprNode
*
)
pNode
;
if
(
0
==
strcmp
(
pCol
->
colName
,
pExpr
->
aliasName
)
||
(
isPrimaryKey
((
STempTableNode
*
)
pTable
,
pNode
)
&&
isInternalPrimaryKey
(
pCol
)))
{
if
(
*
pFound
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_AMBIGUOUS_COLUMN
,
pCol
->
colName
);
}
setColumnInfoByExpr
(
pTable
,
pExpr
,
pColRef
);
found
=
true
;
break
;
*
pFound
=
true
;
}
}
}
return
found
;
return
TSDB_CODE_SUCCESS
;
}
static
EDealRes
translateColumnWithPrefix
(
STranslateContext
*
pCxt
,
SColumnNode
**
pCol
)
{
...
...
@@ -506,7 +510,12 @@ static EDealRes translateColumnWithPrefix(STranslateContext* pCxt, SColumnNode**
STableNode
*
pTable
=
taosArrayGetP
(
pTables
,
i
);
if
(
belongTable
(
pCxt
->
pParseCxt
->
db
,
(
*
pCol
),
pTable
))
{
foundTable
=
true
;
if
(
findAndSetColumn
(
pCol
,
pTable
))
{
bool
foundCol
=
false
;
pCxt
->
errCode
=
findAndSetColumn
(
pCxt
,
pCol
,
pTable
,
&
foundCol
);
if
(
TSDB_CODE_SUCCESS
!=
pCxt
->
errCode
)
{
return
DEAL_RES_ERROR
;
}
if
(
foundCol
)
{
break
;
}
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_INVALID_COLUMN
,
(
*
pCol
)
->
colName
);
...
...
@@ -525,14 +534,19 @@ static EDealRes translateColumnWithoutPrefix(STranslateContext* pCxt, SColumnNod
bool
isInternalPk
=
isInternalPrimaryKey
(
*
pCol
);
for
(
size_t
i
=
0
;
i
<
nums
;
++
i
)
{
STableNode
*
pTable
=
taosArrayGetP
(
pTables
,
i
);
if
(
findAndSetColumn
(
pCol
,
pTable
))
{
bool
foundCol
=
false
;
pCxt
->
errCode
=
findAndSetColumn
(
pCxt
,
pCol
,
pTable
,
&
foundCol
);
if
(
TSDB_CODE_SUCCESS
!=
pCxt
->
errCode
)
{
return
DEAL_RES_ERROR
;
}
if
(
foundCol
)
{
if
(
found
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_AMBIGUOUS_COLUMN
,
(
*
pCol
)
->
colName
);
}
found
=
true
;
if
(
isInternalPk
)
{
break
;
}
}
if
(
isInternalPk
)
{
break
;
}
}
if
(
!
found
)
{
...
...
@@ -1939,7 +1953,9 @@ static int32_t createPrimaryKeyColByTable(STranslateContext* pCxt, STableNode* p
}
pCol
->
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
strcpy
(
pCol
->
colName
,
PK_TS_COL_INTERNAL_NAME
);
if
(
!
findAndSetColumn
(
&
pCol
,
pTable
))
{
bool
found
=
false
;
int32_t
code
=
findAndSetColumn
(
pCxt
,
&
pCol
,
pTable
,
&
found
);
if
(
TSDB_CODE_SUCCESS
!=
code
||
!
found
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_TIMELINE_FUNC
);
}
*
pPrimaryKey
=
(
SNode
*
)
pCol
;
...
...
source/libs/parser/src/sql.c
浏览文件 @
ce166fb1
此差异已折叠。
点击以展开。
source/libs/parser/test/parInitialDTest.cpp
浏览文件 @
ce166fb1
...
...
@@ -32,7 +32,7 @@ TEST_F(ParserInitialDTest, dropBnode) {
run
(
"DROP BNODE ON DNODE 1"
);
}
// DROP CGROUP [ IF EXISTS ] cgroup_name ON topic_name
// DROP C
ONSUMER
GROUP [ IF EXISTS ] cgroup_name ON topic_name
TEST_F
(
ParserInitialDTest
,
dropCGroup
)
{
useDb
(
"root"
,
"test"
);
...
...
@@ -56,10 +56,10 @@ TEST_F(ParserInitialDTest, dropCGroup) {
});
setDropCgroupReqFunc
(
"tp1"
,
"cg1"
);
run
(
"DROP CGROUP cg1 ON tp1"
);
run
(
"DROP C
ONSUMER
GROUP cg1 ON tp1"
);
setDropCgroupReqFunc
(
"tp1"
,
"cg1"
,
1
);
run
(
"DROP CGROUP IF EXISTS cg1 ON tp1"
);
run
(
"DROP C
ONSUMER
GROUP IF EXISTS cg1 ON tp1"
);
}
// todo drop database
...
...
source/libs/parser/test/parSelectTest.cpp
浏览文件 @
ce166fb1
...
...
@@ -252,6 +252,8 @@ TEST_F(ParserSelectTest, semanticError) {
// TSDB_CODE_PAR_AMBIGUOUS_COLUMN
run
(
"SELECT c2 FROM t1 tt1, t1 tt2 WHERE tt1.c1 = tt2.c1"
,
TSDB_CODE_PAR_AMBIGUOUS_COLUMN
,
PARSER_STAGE_TRANSLATE
);
run
(
"SELECT c2 FROM (SELECT c1 c2, c2 FROM t1)"
,
TSDB_CODE_PAR_AMBIGUOUS_COLUMN
,
PARSER_STAGE_TRANSLATE
);
// TSDB_CODE_PAR_WRONG_VALUE_TYPE
run
(
"SELECT timestamp '2010a' FROM t1"
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
PARSER_STAGE_TRANSLATE
);
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
ce166fb1
...
...
@@ -124,6 +124,7 @@ static int32_t createChildLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelec
SLogicNode
*
pNode
=
NULL
;
int32_t
code
=
func
(
pCxt
,
pSelect
,
&
pNode
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pNode
)
{
pNode
->
precision
=
pSelect
->
precision
;
code
=
pushLogicNode
(
pCxt
,
pRoot
,
pNode
);
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
...
...
@@ -400,6 +401,7 @@ static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSel
nodesDestroyNode
(
pNode
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pNode
->
precision
=
pSelect
->
precision
;
*
pLogicNode
=
pNode
;
}
return
code
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录