Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8adeccbf
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看板
未验证
提交
8adeccbf
编写于
3月 17, 2022
作者:
X
Xiaoyu Wang
提交者:
GitHub
3月 17, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10784 from taosdata/feature/3.0_query_integrate_wxy
TD-14043 show statement bugfix
上级
ee7f8bd8
0f6573d5
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
45 addition
and
36 deletion
+45
-36
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+10
-3
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+1
-0
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+2
-2
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+17
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+4
-21
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+7
-5
source/libs/parser/test/parserAstTest.cpp
source/libs/parser/test/parserAstTest.cpp
+4
-4
未找到文件。
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
8adeccbf
...
...
@@ -1040,7 +1040,7 @@ static int32_t datumToJson(const void* pObj, SJson* pJson) {
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
code
=
tjsonAddStringToObject
(
pJson
,
jkValueDatum
,
pNode
->
datum
.
p
);
code
=
tjsonAddStringToObject
(
pJson
,
jkValueDatum
,
varDataVal
(
pNode
->
datum
.
p
)
);
break
;
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_DECIMAL
:
...
...
@@ -1103,9 +1103,16 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) {
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
code
=
tjsonDupStringValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
p
);
case
TSDB_DATA_TYPE_VARBINARY
:
{
pNode
->
datum
.
p
=
calloc
(
1
,
pNode
->
node
.
resType
.
bytes
);
if
(
NULL
==
pNode
->
datum
.
p
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
break
;
}
varDataSetLen
(
pNode
->
datum
.
p
,
pNode
->
node
.
resType
.
bytes
);
code
=
tjsonGetStringValue
(
pJson
,
jkValueDatum
,
varDataVal
(
pNode
->
datum
.
p
));
break
;
}
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_DECIMAL
:
case
TSDB_DATA_TYPE_BLOB
:
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
8adeccbf
...
...
@@ -80,6 +80,7 @@ SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode
SNode
*
createColumnNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pTableAlias
,
const
SToken
*
pColumnName
);
SNode
*
createValueNode
(
SAstCreateContext
*
pCxt
,
int32_t
dataType
,
const
SToken
*
pLiteral
);
SNode
*
createDurationValueNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLiteral
);
SNode
*
createDefaultDatabaseCondValue
(
SAstCreateContext
*
pCxt
);
SNode
*
setProjectionAlias
(
SAstCreateContext
*
pCxt
,
SNode
*
pNode
,
const
SToken
*
pAlias
);
SNode
*
createLogicConditionNode
(
SAstCreateContext
*
pCxt
,
ELogicConditionType
type
,
SNode
*
pParam1
,
SNode
*
pParam2
);
SNode
*
createOperatorNode
(
SAstCreateContext
*
pCxt
,
EOperatorType
type
,
SNode
*
pLeft
,
SNode
*
pRight
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
8adeccbf
...
...
@@ -203,7 +203,7 @@ cmd ::= SHOW FUNCTIONS.
cmd ::= SHOW INDEXES FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, A, B); }
cmd ::= SHOW STREAMS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); }
db_name_cond_opt(A) ::= . { A =
NULL
; }
db_name_cond_opt(A) ::= . { A =
createDefaultDatabaseCondValue(pCxt)
; }
db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
like_pattern_opt(A) ::= . { A = NULL; }
...
...
@@ -211,7 +211,7 @@ like_pattern_opt(A) ::= LIKE NK_STRING(B).
table_name_cond(A) ::= table_name(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
from_db_opt(A) ::= . { A =
NULL
; }
from_db_opt(A) ::= . { A =
createDefaultDatabaseCondValue(pCxt)
; }
from_db_opt(A) ::= FROM db_name(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); }
/************************************************ select **************************************************************/
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
8adeccbf
...
...
@@ -489,9 +489,12 @@ SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken*
SValueNode
*
val
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
CHECK_OUT_OF_MEM
(
val
);
val
->
literal
=
strndup
(
pLiteral
->
z
,
pLiteral
->
n
);
if
(
IS_VAR_DATA_TYPE
(
dataType
)
||
TSDB_DATA_TYPE_TIMESTAMP
==
dataType
)
{
trimString
(
pLiteral
->
z
,
pLiteral
->
n
,
val
->
literal
,
pLiteral
->
n
);
}
CHECK_OUT_OF_MEM
(
val
->
literal
);
val
->
node
.
resType
.
type
=
dataType
;
val
->
node
.
resType
.
bytes
=
tDataTypes
[
dataType
].
bytes
;
val
->
node
.
resType
.
bytes
=
IS_VAR_DATA_TYPE
(
dataType
)
?
strlen
(
val
->
literal
)
:
tDataTypes
[
dataType
].
bytes
;
if
(
TSDB_DATA_TYPE_TIMESTAMP
==
dataType
)
{
val
->
node
.
resType
.
precision
=
TSDB_TIME_PRECISION_MILLI
;
}
...
...
@@ -513,6 +516,19 @@ SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral)
return
(
SNode
*
)
val
;
}
SNode
*
createDefaultDatabaseCondValue
(
SAstCreateContext
*
pCxt
)
{
SValueNode
*
val
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
CHECK_OUT_OF_MEM
(
val
);
val
->
literal
=
strdup
(
pCxt
->
pQueryCxt
->
db
);
CHECK_OUT_OF_MEM
(
val
->
literal
);
val
->
isDuration
=
false
;
val
->
translate
=
false
;
val
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BINARY
;
val
->
node
.
resType
.
bytes
=
strlen
(
val
->
literal
);
val
->
node
.
resType
.
precision
=
TSDB_TIME_PRECISION_MILLI
;
return
(
SNode
*
)
val
;
}
SNode
*
createLogicConditionNode
(
SAstCreateContext
*
pCxt
,
ELogicConditionType
type
,
SNode
*
pParam1
,
SNode
*
pParam2
)
{
SLogicConditionNode
*
cond
=
(
SLogicConditionNode
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_CONDITION
);
CHECK_OUT_OF_MEM
(
cond
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
8adeccbf
...
...
@@ -307,15 +307,6 @@ static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) {
return
found
?
DEAL_RES_CONTINUE
:
translateColumnWithoutPrefix
(
pCxt
,
pCol
);
}
static
int32_t
trimStringWithVarFormat
(
const
char
*
src
,
int32_t
len
,
bool
format
,
char
*
dst
)
{
char
*
dstVal
=
dst
;
if
(
format
)
{
varDataSetLen
(
dst
,
len
);
dstVal
=
varDataVal
(
dst
);
}
return
trimString
(
src
,
len
,
dstVal
,
len
);
}
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
if
(
pVal
->
isDuration
)
{
char
unit
=
0
;
...
...
@@ -355,26 +346,18 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
{
int32_t
n
=
strlen
(
pVal
->
literal
);
pVal
->
datum
.
p
=
calloc
(
1
,
n
+
VARSTR_HEADER_SIZE
);
pVal
->
datum
.
p
=
calloc
(
1
,
pVal
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
);
if
(
NULL
==
pVal
->
datum
.
p
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_OUT_OF_MEMORY
);
}
trimStringWithVarFormat
(
pVal
->
literal
,
n
,
true
,
pVal
->
datum
.
p
);
varDataSetLen
(
pVal
->
datum
.
p
,
pVal
->
node
.
resType
.
bytes
);
strcpy
(
varDataVal
(
pVal
->
datum
.
p
),
pVal
->
literal
);
break
;
}
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
int32_t
n
=
strlen
(
pVal
->
literal
);
char
*
tmp
=
calloc
(
1
,
n
);
if
(
NULL
==
tmp
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_OUT_OF_MEMORY
);
}
int32_t
len
=
trimStringWithVarFormat
(
pVal
->
literal
,
n
,
false
,
tmp
);
if
(
taosParseTime
(
tmp
,
&
pVal
->
datum
.
i
,
len
,
pVal
->
node
.
resType
.
precision
,
tsDaylight
)
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
tmp
);
if
(
taosParseTime
(
pVal
->
literal
,
&
pVal
->
datum
.
i
,
pVal
->
node
.
resType
.
bytes
,
pVal
->
node
.
resType
.
precision
,
tsDaylight
)
!=
TSDB_CODE_SUCCESS
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
tfree
(
tmp
);
break
;
}
case
TSDB_DATA_TYPE_JSON
:
...
...
source/libs/parser/src/sql.c
浏览文件 @
8adeccbf
...
...
@@ -2284,8 +2284,14 @@ static YYACTIONTYPE yy_reduce(
{
pCxt
->
pRootNode
=
createShowStmt
(
pCxt
,
QUERY_NODE_SHOW_STREAMS_STMT
,
NULL
,
NULL
);
}
break
;
case
101
:
/* db_name_cond_opt ::= */
case
103
:
/* like_pattern_opt ::= */
yytestcase
(
yyruleno
==
103
);
case
106
:
/* from_db_opt ::= */
yytestcase
(
yyruleno
==
106
);
{
yymsp
[
1
].
minor
.
yy68
=
createDefaultDatabaseCondValue
(
pCxt
);
}
break
;
case
102
:
/* db_name_cond_opt ::= db_name NK_DOT */
{
yylhsminor
.
yy68
=
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_BINARY
,
&
yymsp
[
-
1
].
minor
.
yy5
);
}
yymsp
[
-
1
].
minor
.
yy68
=
yylhsminor
.
yy68
;
break
;
case
103
:
/* like_pattern_opt ::= */
case
198
:
/* where_clause_opt ::= */
yytestcase
(
yyruleno
==
198
);
case
202
:
/* twindow_clause_opt ::= */
yytestcase
(
yyruleno
==
202
);
case
207
:
/* sliding_opt ::= */
yytestcase
(
yyruleno
==
207
);
...
...
@@ -2295,10 +2301,6 @@ static YYACTIONTYPE yy_reduce(
case
233
:
/* limit_clause_opt ::= */
yytestcase
(
yyruleno
==
233
);
{
yymsp
[
1
].
minor
.
yy68
=
NULL
;
}
break
;
case
102
:
/* db_name_cond_opt ::= db_name NK_DOT */
{
yylhsminor
.
yy68
=
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_BINARY
,
&
yymsp
[
-
1
].
minor
.
yy5
);
}
yymsp
[
-
1
].
minor
.
yy68
=
yylhsminor
.
yy68
;
break
;
case
104
:
/* like_pattern_opt ::= LIKE NK_STRING */
{
yymsp
[
-
1
].
minor
.
yy68
=
createValueNode
(
pCxt
,
TSDB_DATA_TYPE_BINARY
,
&
yymsp
[
0
].
minor
.
yy0
);
}
break
;
...
...
source/libs/parser/test/parserAstTest.cpp
浏览文件 @
8adeccbf
...
...
@@ -409,11 +409,11 @@ TEST_F(ParserTest, createTable) {
TEST_F
(
ParserTest
,
showTables
)
{
setDatabase
(
"root"
,
"test"
);
//
bind("show tables");
//
ASSERT_TRUE(run());
bind
(
"show tables"
);
ASSERT_TRUE
(
run
());
//
bind("show test.tables");
//
ASSERT_TRUE(run());
bind
(
"show test.tables"
);
ASSERT_TRUE
(
run
());
bind
(
"show tables like 'c%'"
);
ASSERT_TRUE
(
run
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录