Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bd3ecabd
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看板
未验证
提交
bd3ecabd
编写于
9月 09, 2021
作者:
D
dapan1121
提交者:
GitHub
9月 09, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7834 from taosdata/hotfix/portfromdev
port from dev
上级
dc86d5d7
b75fd612
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
21 deletion
+49
-21
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+47
-21
src/query/inc/qTableMeta.h
src/query/inc/qTableMeta.h
+2
-0
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
bd3ecabd
...
...
@@ -4074,8 +4074,9 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS
index
.
columnIndex
=
index
.
columnIndex
-
tscGetNumOfColumns
(
pTableMetaInfo
->
pTableMeta
);
if
(
tscColumnExists
(
pTableMetaInfo
->
tagColList
,
pTagSchema1
->
colId
,
pTableMetaInfo
->
pTableMeta
->
id
.
uid
)
<
0
)
{
tscColumnListInsert
(
pTableMetaInfo
->
tagColList
,
index
.
columnIndex
,
pTableMeta
->
id
.
uid
,
pTagSchema1
);
atomic_add_fetch_32
(
&
pTableMetaInfo
->
joinTagNum
,
1
);
if
(
taosArrayGetSize
(
pTableMetaInfo
->
tagColList
)
>
1
)
{
if
(
pTableMetaInfo
->
joinTagNum
>
1
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
}
...
...
@@ -4107,7 +4108,9 @@ static int32_t checkAndSetJoinCondInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tS
if
(
tscColumnExists
(
pTableMetaInfo
->
tagColList
,
pTagSchema2
->
colId
,
pTableMeta
->
id
.
uid
)
<
0
)
{
tscColumnListInsert
(
pTableMetaInfo
->
tagColList
,
index
.
columnIndex
,
pTableMeta
->
id
.
uid
,
pTagSchema2
);
if
(
taosArrayGetSize
(
pTableMetaInfo
->
tagColList
)
>
1
)
{
atomic_add_fetch_32
(
&
pTableMetaInfo
->
joinTagNum
,
1
);
if
(
pTableMetaInfo
->
joinTagNum
>
1
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
}
}
...
...
@@ -8904,6 +8907,7 @@ int32_t validateSqlNode(SSqlObj* pSql, SSqlNode* pSqlNode, SQueryInfo* pQueryInf
int32_t
exprTreeFromSqlExpr
(
SSqlCmd
*
pCmd
,
tExprNode
**
pExpr
,
const
tSqlExpr
*
pSqlExpr
,
SQueryInfo
*
pQueryInfo
,
SArray
*
pCols
,
uint64_t
*
uid
)
{
tExprNode
*
pLeft
=
NULL
;
tExprNode
*
pRight
=
NULL
;
SColumnIndex
index
=
COLUMN_INDEX_INITIALIZER
;
if
(
pSqlExpr
->
pLeft
!=
NULL
)
{
int32_t
ret
=
exprTreeFromSqlExpr
(
pCmd
,
&
pLeft
,
pSqlExpr
->
pLeft
,
pQueryInfo
,
pCols
,
uid
);
...
...
@@ -8935,13 +8939,17 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
(
*
pExpr
)
->
pVal
=
calloc
(
1
,
sizeof
(
tVariant
));
tVariantAssign
((
*
pExpr
)
->
pVal
,
&
pSqlExpr
->
value
);
STableMeta
*
pTableMeta
=
tscGetMetaInfo
(
pQueryInfo
,
0
)
->
pTableMeta
;
if
(
pCols
!=
NULL
&&
taosArrayGetSize
(
pCols
)
>
0
)
{
SColIndex
*
idx
=
taosArrayGet
(
pCols
,
0
);
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMeta
,
idx
->
colIndex
);
// convert time by precision
if
(
pSchema
!=
NULL
&&
TSDB_DATA_TYPE_TIMESTAMP
==
pSchema
->
type
&&
TSDB_DATA_TYPE_BINARY
==
(
*
pExpr
)
->
pVal
->
nType
)
{
ret
=
setColumnFilterInfoForTimestamp
(
pCmd
,
pQueryInfo
,
(
*
pExpr
)
->
pVal
);
STableMeta
*
pTableMeta
=
tscGetMetaInfo
(
pQueryInfo
,
pQueryInfo
->
curTableIdx
)
->
pTableMeta
;
if
(
pCols
!=
NULL
)
{
size_t
colSize
=
taosArrayGetSize
(
pCols
);
if
(
colSize
>
0
)
{
SColIndex
*
idx
=
taosArrayGet
(
pCols
,
colSize
-
1
);
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMeta
,
idx
->
colIndex
);
// convert time by precision
if
(
pSchema
!=
NULL
&&
TSDB_DATA_TYPE_TIMESTAMP
==
pSchema
->
type
&&
TSDB_DATA_TYPE_BINARY
==
(
*
pExpr
)
->
pVal
->
nType
)
{
ret
=
setColumnFilterInfoForTimestamp
(
pCmd
,
pQueryInfo
,
(
*
pExpr
)
->
pVal
);
}
}
}
return
ret
;
...
...
@@ -8971,21 +8979,31 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
}
}
}
else
if
(
pSqlExpr
->
type
==
SQL_NODE_TABLE_COLUMN
)
{
// column name, normal column arithmetic expression
SColumnIndex
index
=
COLUMN_INDEX_INITIALIZER
;
int32_t
ret
=
getColumnIndexByName
(
&
pSqlExpr
->
columnName
,
pQueryInfo
,
&
index
,
tscGetErrorMsgPayload
(
pCmd
));
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
STableMeta
*
pTableMeta
=
tscGetMetaInfo
(
pQueryInfo
,
0
)
->
pTableMeta
;
pQueryInfo
->
curTableIdx
=
index
.
tableIndex
;
STableMeta
*
pTableMeta
=
tscGetMetaInfo
(
pQueryInfo
,
index
.
tableIndex
)
->
pTableMeta
;
int32_t
numOfColumns
=
tscGetNumOfColumns
(
pTableMeta
);
*
pExpr
=
calloc
(
1
,
sizeof
(
tExprNode
));
(
*
pExpr
)
->
nodeType
=
TSQL_NODE_COL
;
(
*
pExpr
)
->
pSchema
=
calloc
(
1
,
sizeof
(
SSchema
));
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMeta
,
index
.
columnIndex
);
*
(
*
pExpr
)
->
pSchema
=
*
pSchema
;
SSchema
*
pSchema
=
NULL
;
if
(
index
.
columnIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
pSchema
=
(
*
pExpr
)
->
pSchema
;
strcpy
(
pSchema
->
name
,
TSQL_TBNAME_L
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
pSchema
->
colId
=
TSDB_TBNAME_COLUMN_INDEX
;
pSchema
->
bytes
=
-
1
;
}
else
{
pSchema
=
tscGetTableColumnSchema
(
pTableMeta
,
index
.
columnIndex
);
*
(
*
pExpr
)
->
pSchema
=
*
pSchema
;
}
if
(
pCols
!=
NULL
)
{
// record the involved columns
SColIndex
colIndex
=
{
0
};
...
...
@@ -9000,12 +9018,20 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
return
TSDB_CODE_SUCCESS
;
}
else
if
(
pSqlExpr
->
tokenId
==
TK_SET
)
{
int32_t
colType
=
-
1
;
STableMeta
*
pTableMeta
=
tscGetMetaInfo
(
pQueryInfo
,
0
)
->
pTableMeta
;
if
(
pCols
!=
NULL
&&
taosArrayGetSize
(
pCols
)
>
0
)
{
SColIndex
*
idx
=
taosArrayGet
(
pCols
,
taosArrayGetSize
(
pCols
)
-
1
);
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMeta
,
idx
->
colIndex
);
if
(
pSchema
!=
NULL
)
{
colType
=
pSchema
->
type
;
STableMeta
*
pTableMeta
=
tscGetMetaInfo
(
pQueryInfo
,
pQueryInfo
->
curTableIdx
)
->
pTableMeta
;
if
(
pCols
!=
NULL
)
{
size_t
colSize
=
taosArrayGetSize
(
pCols
);
if
(
colSize
>
0
)
{
SColIndex
*
idx
=
taosArrayGet
(
pCols
,
colSize
-
1
);
if
(
idx
->
colIndex
==
TSDB_TBNAME_COLUMN_INDEX
)
{
colType
=
TSDB_DATA_TYPE_BINARY
;
}
else
{
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMeta
,
idx
->
colIndex
);
if
(
pSchema
!=
NULL
)
{
colType
=
pSchema
->
type
;
}
}
}
}
tVariant
*
pVal
;
...
...
@@ -9014,7 +9040,7 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
}
else
if
(
colType
==
TSDB_DATA_TYPE_FLOAT
||
colType
==
TSDB_DATA_TYPE_DOUBLE
)
{
colType
=
TSDB_DATA_TYPE_DOUBLE
;
}
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
pQueryInfo
->
curTableIdx
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
if
(
serializeExprListToVariant
(
pSqlExpr
->
Expr
.
paramList
,
&
pVal
,
colType
,
tinfo
.
precision
)
==
false
)
{
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"not support filter expression"
);
...
...
@@ -9053,7 +9079,7 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS
// NOTE: binary|nchar data allows the >|< type filter
if
((
*
pExpr
)
->
_node
.
optr
!=
TSDB_RELATION_EQUAL
&&
(
*
pExpr
)
->
_node
.
optr
!=
TSDB_RELATION_NOT_EQUAL
)
{
if
(
pRight
!=
NULL
&&
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
if
(
pRight
->
pVal
->
nType
==
TSDB_DATA_TYPE_BOOL
)
{
if
(
pRight
->
pVal
->
nType
==
TSDB_DATA_TYPE_BOOL
&&
pLeft
->
pSchema
->
type
==
TSDB_DATA_TYPE_BOOL
)
{
return
TSDB_CODE_TSC_INVALID_OPERATION
;
}
}
...
...
src/query/inc/qTableMeta.h
浏览文件 @
bd3ecabd
...
...
@@ -84,6 +84,7 @@ typedef struct STableMetaInfo {
SName
name
;
char
aliasName
[
TSDB_TABLE_NAME_LEN
];
// alias name of table specified in query sql
SArray
*
tagColList
;
// SArray<SColumn*>, involved tag columns
int32_t
joinTagNum
;
}
STableMetaInfo
;
struct
SQInfo
;
// global merge operator
...
...
@@ -108,6 +109,7 @@ typedef struct SQueryInfo {
SOrderVal
order
;
int16_t
numOfTables
;
int16_t
curTableIdx
;
STableMetaInfo
**
pTableMetaInfo
;
struct
STSBuf
*
tsBuf
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录