Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
8880e515
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8880e515
编写于
5月 09, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-3949]
上级
f28e7b4e
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
917 addition
and
842 deletion
+917
-842
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+7
-8
src/query/inc/qSqlparser.h
src/query/inc/qSqlparser.h
+11
-5
src/query/inc/sql.y
src/query/inc/sql.y
+7
-1
src/query/src/qSqlParser.c
src/query/src/qSqlParser.c
+56
-13
src/query/src/sql.c
src/query/src/sql.c
+836
-815
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
8880e515
...
...
@@ -6689,8 +6689,8 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) {
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
}
S
TableName
Pair
*
p1
=
taosArrayGet
(
pFromInfo
->
list
,
0
);
SStrToken
srcToken
=
{.
z
=
p1
->
name
.
z
,
.
n
=
p1
->
n
ame
.
n
,
.
type
=
TK_STRING
};
S
RelElement
Pair
*
p1
=
taosArrayGet
(
pFromInfo
->
list
,
0
);
SStrToken
srcToken
=
{.
z
=
p1
->
tableName
.
z
,
.
n
=
p1
->
tableN
ame
.
n
,
.
type
=
TK_STRING
};
if
(
tscValidateName
(
&
srcToken
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
...
...
@@ -7085,8 +7085,8 @@ static int32_t doLoadAllTableMeta(SSqlObj* pSql, SQueryInfo* pQueryInfo, SSqlNod
tscAddEmptyMetaInfo
(
pQueryInfo
);
}
S
TableName
Pair
*
item
=
taosArrayGet
(
pSqlNode
->
from
->
list
,
i
);
SStrToken
*
oriName
=
&
item
->
n
ame
;
S
RelElement
Pair
*
item
=
taosArrayGet
(
pSqlNode
->
from
->
list
,
i
);
SStrToken
*
oriName
=
&
item
->
tableN
ame
;
if
(
oriName
->
type
==
TK_INTEGER
||
oriName
->
type
==
TK_FLOAT
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
...
...
@@ -7284,10 +7284,9 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
pQueryInfo
->
window
.
skey
=
pQueryInfo
->
window
.
skey
/
1000
;
pQueryInfo
->
window
.
ekey
=
pQueryInfo
->
window
.
ekey
/
1000
;
}
}
else
{
// set the time rang
if
(
taosArrayGetSize
(
pSqlNode
->
from
->
list
)
>
1
)
{
// If it is a join query, no where clause is not allowed.
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"condition missing for join query "
);
}
else
{
if
(
taosArrayGetSize
(
pSqlNode
->
from
->
list
)
>
1
)
{
// Cross join not allowed yet
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"cross join not supported yet"
);
}
}
...
...
src/query/inc/qSqlparser.h
浏览文件 @
8880e515
...
...
@@ -107,14 +107,19 @@ typedef struct SSqlNode {
struct
tSqlExpr
*
pHaving
;
// having clause [optional]
}
SSqlNode
;
typedef
struct
STableNamePair
{
SStrToken
name
;
typedef
struct
SRelElementPair
{
union
{
SStrToken
tableName
;
SArray
*
pSubquery
;
//SSqlNode *pSubquery;
};
SStrToken
aliasName
;
}
S
TableName
Pair
;
}
S
RelElement
Pair
;
typedef
struct
SRelationInfo
{
int32_t
type
;
// nested query|table name list
SArray
*
list
;
// SArray<S
TableName
Pair>|SArray<SSqlNode*>
SArray
*
list
;
// SArray<S
RelElement
Pair>|SArray<SSqlNode*>
}
SRelationInfo
;
typedef
struct
SCreatedTableInfo
{
...
...
@@ -254,8 +259,9 @@ SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int
SArray
*
tVariantListAppendToken
(
SArray
*
pList
,
SStrToken
*
pAliasToken
,
uint8_t
sortOrder
);
SRelationInfo
*
setTableNameList
(
SRelationInfo
*
pFromInfo
,
SStrToken
*
pName
,
SStrToken
*
pAlias
);
SRelationInfo
*
setSubquery
(
SRelationInfo
*
pFromInfo
,
SArray
*
pSqlNode
);
//SRelationInfo *setSubquery(SRelationInfo* pFromInfo, SRelElementPair* p
);
void
*
destroyRelationInfo
(
SRelationInfo
*
pFromInfo
);
SRelationInfo
*
addSubqueryElem
(
SRelationInfo
*
pRelationInfo
,
SArray
*
pSub
,
SStrToken
*
pAlias
);
// sql expr leaf node
tSqlExpr
*
tSqlExprCreateIdValue
(
SStrToken
*
pToken
,
int32_t
optrType
);
...
...
src/query/inc/sql.y
浏览文件 @
8880e515
...
...
@@ -508,7 +508,13 @@ distinct(X) ::= . { X.n = 0;}
%type from {SRelationInfo*}
%destructor from {destroyRelationInfo($$);}
from(A) ::= FROM tablelist(X). {A = X;}
from(A) ::= FROM LP union(Y) RP. {A = setSubquery(NULL, Y);}
from(A) ::= FROM sub(X). {A = X;}
%type sub {SRelationInfo*}
%destructor sub {destroyRelationInfo($$);}
sub(A) ::= LP union(Y) RP. {A = addSubqueryElem(NULL, Y, NULL);}
sub(A) ::= LP union(Y) RP ids(Z). {A = addSubqueryElem(NULL, Y, &Z);}
sub(A) ::= sub(X) COMMA LP union(Y) RP ids(Z).{A = addSubqueryElem(X, Y, &Z);}
%type tablelist {SRelationInfo*}
%destructor tablelist {destroyRelationInfo($$);}
...
...
src/query/src/qSqlParser.c
浏览文件 @
8880e515
...
...
@@ -535,11 +535,11 @@ SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int
SRelationInfo
*
setTableNameList
(
SRelationInfo
*
pRelationInfo
,
SStrToken
*
pName
,
SStrToken
*
pAlias
)
{
if
(
pRelationInfo
==
NULL
)
{
pRelationInfo
=
calloc
(
1
,
sizeof
(
SRelationInfo
));
pRelationInfo
->
list
=
taosArrayInit
(
4
,
sizeof
(
S
TableName
Pair
));
pRelationInfo
->
list
=
taosArrayInit
(
4
,
sizeof
(
S
RelElement
Pair
));
}
pRelationInfo
->
type
=
SQL_NODE_FROM_TABLELIST
;
S
TableNamePair
p
=
{.
n
ame
=
*
pName
};
S
RelElementPair
p
=
{.
tableN
ame
=
*
pName
};
if
(
pAlias
!=
NULL
)
{
p
.
aliasName
=
*
pAlias
;
}
else
{
...
...
@@ -550,17 +550,41 @@ SRelationInfo *setTableNameList(SRelationInfo* pRelationInfo, SStrToken *pName,
return
pRelationInfo
;
}
SRelationInfo
*
setSubquery
(
SRelationInfo
*
pRelationInfo
,
SArray
*
pList
)
{
if
(
pRelationInfo
==
NULL
)
{
pRelationInfo
=
calloc
(
1
,
sizeof
(
SRelationInfo
));
pRelationInfo
->
list
=
taosArrayInit
(
4
,
POINTER_BYTES
);
}
pRelationInfo
->
type
=
SQL_NODE_FROM_SUBQUERY
;
taosArrayPush
(
pRelationInfo
->
list
,
&
pList
);
return
pRelationInfo
;
}
//SRelationInfo* setSubquery(SRelationInfo* pRelationInfo, SArray* pList, SStrToken* pAlias) {
// if (pRelationInfo == NULL) {
// pRelationInfo = calloc(1, sizeof(SRelationInfo));
// pRelationInfo->list = taosArrayInit(4, POINTER_BYTES);
// }
//
// pRelationInfo->type = SQL_NODE_FROM_SUBQUERY;
// SRelElementPair p = {.pSubquery = pList};
// if (pAlias != NULL) {
// p.aliasName = *pAlias;
// } else {
// TPARSER_SET_NONE_TOKEN(p.aliasName);
// }
//
// taosArrayPush(pRelationInfo->list, &p);
// return pRelationInfo;
//}
//SRelationInfo* setSubquery(SRelationInfo* pRelationInfo, SRelElementPair* p) {
// if (pRelationInfo == NULL) {
// pRelationInfo = calloc(1, sizeof(SRelationInfo));
// pRelationInfo->list = taosArrayInit(4, POINTER_BYTES);
// }
//
// pRelationInfo->type = SQL_NODE_FROM_SUBQUERY;
// SRelElementPair elem = *p;
//// if (pAlias != NULL) {
//// p.aliasName = *pAlias;
//// } else {
//// TPARSER_SET_NONE_TOKEN(p.aliasName);
//// }
//
// taosArrayPush(pRelationInfo->list, &p);
// return pRelationInfo;
//}
void
*
destroyRelationInfo
(
SRelationInfo
*
pRelationInfo
)
{
if
(
pRelationInfo
==
NULL
)
{
...
...
@@ -582,6 +606,25 @@ void* destroyRelationInfo(SRelationInfo* pRelationInfo) {
return
NULL
;
}
SRelationInfo
*
addSubqueryElem
(
SRelationInfo
*
pRelationInfo
,
SArray
*
pSub
,
SStrToken
*
pAlias
)
{
if
(
pRelationInfo
==
NULL
)
{
pRelationInfo
=
calloc
(
1
,
sizeof
(
SRelationInfo
));
pRelationInfo
->
list
=
taosArrayInit
(
4
,
sizeof
(
SRelElementPair
));
}
pRelationInfo
->
type
=
SQL_NODE_FROM_SUBQUERY
;
SRelElementPair
p
=
{.
pSubquery
=
pSub
};
if
(
pAlias
!=
NULL
)
{
p
.
aliasName
=
*
pAlias
;
}
else
{
TPARSER_SET_NONE_TOKEN
(
p
.
aliasName
);
}
taosArrayPush
(
pRelationInfo
->
list
,
&
p
);
return
pRelationInfo
;
}
void
tSetDbName
(
SStrToken
*
pCpxName
,
SStrToken
*
pDb
)
{
pCpxName
->
type
=
pDb
->
type
;
...
...
src/query/src/sql.c
浏览文件 @
8880e515
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录