Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
18da95ad
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看板
提交
18da95ad
编写于
4月 02, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of
https://github.com/taosdata/TDengine
into develop
上级
c06fb4d9
d099fa7a
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
629 addition
and
304 deletion
+629
-304
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+0
-1
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+3
-4
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+9
-16
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/client/src/tscSql.c
src/client/src/tscSql.c
+3
-11
src/inc/taoserror.h
src/inc/taoserror.h
+2
-2
src/mnode/src/mgmtShell.c
src/mnode/src/mgmtShell.c
+20
-1
src/query/inc/qast.h
src/query/inc/qast.h
+17
-23
src/query/inc/qsqlparser.h
src/query/inc/qsqlparser.h
+16
-32
src/query/src/qast.c
src/query/src/qast.c
+90
-102
src/query/src/qparserImpl.c
src/query/src/qparserImpl.c
+173
-2
src/query/src/queryExecutor.c
src/query/src/queryExecutor.c
+4
-4
src/query/src/queryUtil.c
src/query/src/queryUtil.c
+0
-1
src/vnode/tsdb/src/tsdbRead.c
src/vnode/tsdb/src/tsdbRead.c
+291
-104
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
18da95ad
...
...
@@ -132,7 +132,6 @@ void tscFieldInfoSetExpr(SFieldInfo* pFieldInfo, int32_t index, SSqlExpr* pExpr)
void
tscFieldInfoSetBinExpr
(
SFieldInfo
*
pFieldInfo
,
int32_t
index
,
SSqlFunctionExpr
*
pExpr
);
void
tscFieldInfoCalOffset
(
SQueryInfo
*
pQueryInfo
);
void
tscFieldInfoUpdateOffsetForInterResult
(
SQueryInfo
*
pQueryInfo
);
void
tscFieldInfoCopy
(
SFieldInfo
*
src
,
SFieldInfo
*
dst
,
const
int32_t
*
indexList
,
int32_t
size
);
void
tscFieldInfoCopyAll
(
SFieldInfo
*
dst
,
SFieldInfo
*
src
);
...
...
src/client/src/tscAsync.c
浏览文件 @
18da95ad
...
...
@@ -369,7 +369,7 @@ void tscQueueAsyncRes(SSqlObj *pSql) {
tscTrace
(
"%p SqlObj is freed, not add into queue async res"
,
pSql
);
return
;
}
else
{
tscError
(
"%p add into queued async res, code:%
d"
,
pSql
,
pSql
->
res
.
code
);
tscError
(
"%p add into queued async res, code:%
s"
,
pSql
,
tstrerror
(
pSql
->
res
.
code
)
);
}
SSchedMsg
schedMsg
;
...
...
@@ -410,7 +410,6 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
pSql
->
fp
=
NULL
;
if
(
code
!=
0
)
{
code
=
abs
(
code
);
pRes
->
code
=
code
;
tscTrace
(
"%p failed to renew tableMeta"
,
pSql
);
tsem_post
(
&
pSql
->
rspSem
);
...
...
@@ -432,8 +431,8 @@ void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) {
return
;
}
if
(
code
!=
0
)
{
pRes
->
code
=
(
uint8_t
)
abs
(
code
)
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pRes
->
code
=
code
;
tscQueueAsyncRes
(
pSql
);
return
;
}
...
...
src/client/src/tscSQLParser.c
浏览文件 @
18da95ad
...
...
@@ -1213,11 +1213,11 @@ int32_t parseSelectClause(SSqlCmd* pCmd, int32_t clauseIndex, tSQLExprList* pSel
int32_t
ret
=
tSQLBinaryExprCreateFromSqlExpr
(
&
pNode
,
pItem
->
pNode
,
&
pBinExprInfo
->
numOfCols
,
&
pColIndex
,
&
pQueryInfo
->
exprsInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tSQLBinaryExprDestroy
(
&
pNode
->
pExpr
,
NULL
);
tSQLBinaryExprDestroy
(
&
pNode
,
NULL
);
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
"invalid expression in select clause"
);
}
pBinExprInfo
->
pBinExpr
=
pNode
->
pExpr
;
pBinExprInfo
->
pBinExpr
=
pNode
;
pBinExprInfo
->
pReqColumns
=
pColIndex
;
for
(
int32_t
k
=
0
;
k
<
pBinExprInfo
->
numOfCols
;
++
k
)
{
...
...
@@ -5850,28 +5850,21 @@ static int32_t tSQLBinaryExprCreateFromSqlExpr(tSQLSyntaxNode **pExpr, tSQLExpr*
return
TSDB_CODE_SUCCESS
;
}
(
*
pExpr
)
->
colId
=
-
1
;
*
pColIndex
=
realloc
(
*
pColIndex
,
(
++
(
*
num
))
*
sizeof
(
SColIndexEx
));
memset
(
&
(
*
pColIndex
)[(
*
num
)
-
1
],
0
,
sizeof
(
SColIndexEx
));
strncpy
((
*
pColIndex
)[(
*
num
)
-
1
].
name
,
pAst
->
operand
.
z
,
pAst
->
operand
.
n
);
}
else
{
tSQLBinaryExpr
*
pBinExpr
=
(
tSQLBinaryExpr
*
)
calloc
(
1
,
sizeof
(
tSQLBinaryExpr
));
pBinExpr
->
filterOnPrimaryKey
=
false
;
pBinExpr
->
pLeft
=
pLeft
;
pBinExpr
->
pRight
=
pRight
;
*
pExpr
=
(
tSQLSyntaxNode
*
)
calloc
(
1
,
sizeof
(
tSQLSyntaxNode
));
(
*
pExpr
)
->
_node
.
hasPK
=
false
;
(
*
pExpr
)
->
_node
.
pLeft
=
pLeft
;
(
*
pExpr
)
->
_node
.
pRight
=
pRight
;
SSQLToken
t
=
{.
type
=
pAst
->
nSQLOptr
};
pBinExpr
->
nSQLBinaryO
ptr
=
getBinaryExprOptr
(
&
t
);
(
*
pExpr
)
->
_node
.
o
ptr
=
getBinaryExprOptr
(
&
t
);
assert
(
pBinExpr
->
nSQLBinaryO
ptr
!=
0
);
assert
(
(
*
pExpr
)
->
_node
.
o
ptr
!=
0
);
(
*
pExpr
)
=
malloc
(
sizeof
(
tSQLSyntaxNode
));
(
*
pExpr
)
->
nodeType
=
TSQL_NODE_EXPR
;
(
*
pExpr
)
->
pExpr
=
pBinExpr
;
(
*
pExpr
)
->
colId
=
-
1
;
if
(
pBinExpr
->
nSQLBinaryOptr
==
TSDB_BINARY_OP_DIVIDE
)
{
if
((
*
pExpr
)
->
_node
.
optr
==
TSDB_BINARY_OP_DIVIDE
)
{
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
if
(
pRight
->
pVal
->
nType
==
TSDB_DATA_TYPE_INT
&&
pRight
->
pVal
->
i64Key
==
0
)
{
return
TSDB_CODE_INVALID_SQL
;
...
...
src/client/src/tscServer.c
浏览文件 @
18da95ad
...
...
@@ -325,7 +325,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg) {
if
(
rpcMsg
->
code
!=
TSDB_CODE_ACTION_IN_PROGRESS
)
{
void
*
taosres
=
tscKeepConn
[
pCmd
->
command
]
?
pSql
:
NULL
;
rpcMsg
->
code
=
pRes
->
code
?
-
pRes
->
code
:
pRes
->
numOfRows
;
rpcMsg
->
code
=
pRes
->
code
?
pRes
->
code
:
pRes
->
numOfRows
;
tscTrace
(
"%p Async SQL result:%s res:%p"
,
pSql
,
tstrerror
(
pRes
->
code
),
taosres
);
...
...
src/client/src/tscSql.c
浏览文件 @
18da95ad
...
...
@@ -867,7 +867,7 @@ int taos_errno(TAOS *taos) {
return
code
;
}
static
bool
validErrorCode
(
int32_t
code
)
{
return
code
>=
TSDB_CODE_SUCCESS
&&
code
<
TSDB_CODE_MAX_ERROR_CODE
;
}
//
static bool validErrorCode(int32_t code) { return code >= TSDB_CODE_SUCCESS && code < TSDB_CODE_MAX_ERROR_CODE; }
/*
* In case of invalid sql error, additional information is attached to explain
...
...
@@ -890,23 +890,15 @@ static bool hasAdditionalErrorInfo(int32_t code, SSqlCmd *pCmd) {
char
*
taos_errstr
(
TAOS
*
taos
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
uint8_t
code
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
return
(
char
*
)
tstrerror
(
globalCode
);
SSqlObj
*
pSql
=
pObj
->
pSql
;
if
(
validErrorCode
(
pSql
->
res
.
code
))
{
code
=
pSql
->
res
.
code
;
}
else
{
code
=
TSDB_CODE_OTHERS
;
// unknown error
}
if
(
hasAdditionalErrorInfo
(
code
,
&
pSql
->
cmd
))
{
if
(
hasAdditionalErrorInfo
(
pSql
->
res
.
code
,
&
pSql
->
cmd
))
{
return
pSql
->
cmd
.
payload
;
}
else
{
return
(
char
*
)
tstrerror
(
code
);
return
(
char
*
)
tstrerror
(
pSql
->
res
.
code
);
}
}
...
...
src/inc/taoserror.h
浏览文件 @
18da95ad
...
...
@@ -80,7 +80,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TABLE_ALREADY_EXIST, 0, 34, "table already ex
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_USER
,
0
,
35
,
"invalid user"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_ACCT
,
0
,
36
,
"invalid account"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_PASS
,
0
,
37
,
"invalid password"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DB_NOT_SELECTED
,
0
,
38
,
"d
o
not selected"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DB_NOT_SELECTED
,
0
,
38
,
"d
b
not selected"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MEMORY_CORRUPTED
,
0
,
39
,
"memory corrupted"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_USER_ALREADY_EXIST
,
0
,
40
,
"user already exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_RIGHTS
,
0
,
41
,
"no rights"
)
...
...
@@ -118,7 +118,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MONITOR_DB_FORBIDDEN, 0, 72, "monitor db forbi
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_DISK_PERMISSIONS
,
0
,
73
,
"no disk permissions"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VG_INIT_FAILED
,
0
,
74
,
"vg init failed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DATA_ALREADY_IMPORTED
,
0
,
75
,
"data already imported"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_OPS_NOT_SUPPORT
,
0
,
76
,
"ops not support"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_OPS_NOT_SUPPORT
,
0
,
76
,
"op
eration
s not support"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_QUERY_ID
,
0
,
77
,
"invalid query id"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_STREAM_ID
,
0
,
78
,
"invalid stream id"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_CONNECTION
,
0
,
79
,
"invalid connection"
)
...
...
src/mnode/src/mgmtShell.c
浏览文件 @
18da95ad
...
...
@@ -50,6 +50,7 @@ static void mgmtProcessShowMsg(SQueuedMsg *queuedMsg);
static
void
mgmtProcessRetrieveMsg
(
SQueuedMsg
*
queuedMsg
);
static
void
mgmtProcessHeartBeatMsg
(
SQueuedMsg
*
queuedMsg
);
static
void
mgmtProcessConnectMsg
(
SQueuedMsg
*
queuedMsg
);
static
void
mgmtProcessUseMsg
(
SQueuedMsg
*
queuedMsg
);
static
void
*
tsMgmtShellRpc
=
NULL
;
static
void
*
tsMgmtTranQhandle
=
NULL
;
...
...
@@ -62,7 +63,8 @@ int32_t mgmtInitShell() {
mgmtAddShellMsgHandle
(
TSDB_MSG_TYPE_RETRIEVE
,
mgmtProcessRetrieveMsg
);
mgmtAddShellMsgHandle
(
TSDB_MSG_TYPE_CM_HEARTBEAT
,
mgmtProcessHeartBeatMsg
);
mgmtAddShellMsgHandle
(
TSDB_MSG_TYPE_CM_CONNECT
,
mgmtProcessConnectMsg
);
mgmtAddShellMsgHandle
(
TSDB_MSG_TYPE_CM_USE_DB
,
mgmtProcessUseMsg
);
tsMgmtTranQhandle
=
taosInitScheduler
(
tsMaxShellConns
,
1
,
"mnodeT"
);
int32_t
numOfThreads
=
tsNumOfCores
*
tsNumOfThreadsPerCore
/
4
.
0
;
...
...
@@ -435,6 +437,23 @@ connect_over:
rpcSendResponse
(
&
rpcRsp
);
}
static
void
mgmtProcessUseMsg
(
SQueuedMsg
*
pMsg
)
{
SRpcMsg
rpcRsp
=
{.
handle
=
pMsg
->
thandle
,
.
pCont
=
NULL
,
.
contLen
=
0
,
.
code
=
0
,
.
msgType
=
0
};
SCMUseDbMsg
*
pUseDbMsg
=
pMsg
->
pCont
;
// todo check for priority of current user
SDbObj
*
pDbObj
=
mgmtGetDb
(
pUseDbMsg
->
db
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
pDbObj
==
NULL
)
{
code
=
TSDB_CODE_INVALID_DB
;
}
rpcRsp
.
code
=
code
;
rpcSendResponse
(
&
rpcRsp
);
}
/**
* check if we need to add mgmtProcessTableMetaMsg into tranQueue, which will be executed one-by-one.
*/
...
...
src/query/inc/qast.h
浏览文件 @
18da95ad
...
...
@@ -27,7 +27,7 @@ extern "C" {
#include "taosdef.h"
#include "tvariant.h"
struct
tSQL
BinaryExpr
;
struct
tSQL
SyntaxNode
;
struct
SSchema
;
struct
tSkipList
;
struct
tSkipListNode
;
...
...
@@ -62,44 +62,38 @@ typedef struct SBinaryFilterSupp {
typedef
struct
tSQLSyntaxNode
{
uint8_t
nodeType
;
int16_t
colId
;
// for schema, the id of column
union
{
struct
tSQLBinaryExpr
*
pExpr
;
struct
SSchema
*
pSchema
;
tVariant
*
pVal
;
struct
{
uint8_t
optr
;
// filter operator
uint8_t
hasPK
;
// 0: do not contain primary filter, 1: contain
void
*
info
;
// support filter operation on this expression only available for leaf node
struct
tSQLSyntaxNode
*
pLeft
;
// left child pointer
struct
tSQLSyntaxNode
*
pRight
;
// right child pointer
}
_node
;
struct
SSchema
*
pSchema
;
tVariant
*
pVal
;
};
}
tSQLSyntaxNode
;
typedef
struct
tSQLBinaryExpr
{
uint8_t
nSQLBinaryOptr
;
// filter operator
uint8_t
filterOnPrimaryKey
;
// 0: do not contain primary filter, 1: contain
/*
* provide the information to support filter operation on this expression
* only available for leaf node
*/
void
*
info
;
tSQLSyntaxNode
*
pLeft
;
// left child pointer
tSQLSyntaxNode
*
pRight
;
// right child pointer
}
tSQLBinaryExpr
;
typedef
struct
tQueryResultset
{
void
**
pRes
;
int64_t
num
;
}
tQueryResultset
;
void
tSQLBinaryExprFromString
(
tSQL
BinaryExpr
**
pExpr
,
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
src
,
int32_t
len
);
void
tSQLBinaryExprFromString
(
tSQL
SyntaxNode
**
pExpr
,
SSchema
*
pSchema
,
int32_t
numOfCols
,
char
*
src
,
int32_t
len
);
void
tSQLBinaryExprToString
(
tSQL
BinaryExpr
*
pExpr
,
char
*
dst
,
int32_t
*
len
);
void
tSQLBinaryExprToString
(
tSQL
SyntaxNode
*
pExpr
,
char
*
dst
,
int32_t
*
len
);
void
tSQLBinaryExprDestroy
(
tSQL
BinaryExpr
**
pExprs
,
void
(
*
fp
)(
void
*
));
void
tSQLBinaryExprDestroy
(
tSQL
SyntaxNode
**
pExprs
,
void
(
*
fp
)(
void
*
));
void
tSQLBinaryExprTraverse
(
tSQL
BinaryExpr
*
pExpr
,
SSkipList
*
pSkipList
,
SArray
*
result
,
SBinaryFilterSupp
*
param
);
void
tSQLBinaryExprTraverse
(
tSQL
SyntaxNode
*
pExpr
,
SSkipList
*
pSkipList
,
SArray
*
result
,
SBinaryFilterSupp
*
param
);
void
tSQLBinaryExprCalcTraverse
(
tSQL
BinaryExpr
*
pExprs
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
void
tSQLBinaryExprCalcTraverse
(
tSQL
SyntaxNode
*
pExprs
,
int32_t
numOfRows
,
char
*
pOutput
,
void
*
param
,
int32_t
order
,
char
*
(
*
cb
)(
void
*
,
char
*
,
int32_t
));
void
tSQLBinaryExprTrv
(
tSQL
BinaryExpr
*
pExprs
,
int32_t
*
val
,
int16_t
*
ids
);
void
tSQLBinaryExprTrv
(
tSQL
SyntaxNode
*
pExprs
,
int32_t
*
val
,
int16_t
*
ids
);
void
tQueryResultClean
(
tQueryResultset
*
pRes
);
uint8_t
getBinaryExprOptr
(
SSQLToken
*
pToken
);
...
...
src/query/inc/qsqlparser.h
浏览文件 @
18da95ad
...
...
@@ -20,6 +20,7 @@
extern
"C"
{
#endif
#include <tstrbuild.h>
#include "taos.h"
#include "taosmsg.h"
#include "tstoken.h"
...
...
@@ -187,38 +188,19 @@ typedef struct SSqlInfo {
}
SSqlInfo
;
typedef
struct
tSQLExpr
{
/*
* for single operand:
* TK_ALL
* TK_ID
* TK_SUM
* TK_AVG
* TK_MIN
* TK_MAX
* TK_FIRST
* TK_LAST
* TK_BOTTOM
* TK_TOP
* TK_STDDEV
* TK_PERCENTILE
*
* for binary operand:
* TK_LESS
* TK_LARGE
* TK_EQUAL etc...
*/
uint32_t
nSQLOptr
;
// TK_FUNCTION: sql function, TK_LE: less than(binary expr)
// TK_FUNCTION: sql function, TK_LE: less than(binary expr)
uint32_t
nSQLOptr
;
// the full sql string of function(col, param), which is actually the raw
// field name, since the function name is kept in nSQLOptr already
SSQLToken
operand
;
struct
tSQLExprList
*
pParam
;
// function parameters
SSQLToken
operand
;
SSQLToken
colInfo
;
// field id
tVariant
val
;
// value only for string, float, int
SSQLToken
colInfo
;
// field i
d
tVariant
val
;
// value only for string, float, int
struct
tSQLExpr
*
pLeft
;
// left chil
d
struct
tSQLExpr
*
pRight
;
// right child
struct
tSQLExpr
*
pLeft
;
// left child
struct
tSQLExpr
*
pRight
;
// right child
struct
tSQLExprList
*
pParam
;
// function parameters
}
tSQLExpr
;
// used in select clause. select <tSQLExprList> from xxx
...
...
@@ -326,18 +308,20 @@ void tSQLSetColumnInfo(TAOS_FIELD *pField, SSQLToken *pName, TAOS_FIELD *pType);
void
tSQLSetColumnType
(
TAOS_FIELD
*
pField
,
SSQLToken
*
pToken
);
void
*
ParseAlloc
(
void
*
(
*
mallocProc
)(
size_t
));
// convert the sql filter expression into binary data
int32_t
tSQLExprToBinary
(
tSQLExpr
*
pExpr
,
SStringBuilder
*
sb
);
enum
{
TSQL_NODE_TYPE_EXPR
=
0x1
,
TSQL_NODE_TYPE_ID
=
0x2
,
TSQL_NODE_TYPE_EXPR
=
0x1
,
TSQL_NODE_TYPE_ID
=
0x2
,
TSQL_NODE_TYPE_VALUE
=
0x4
,
};
#define NON_ARITHMEIC_EXPR 0
#define NORMAL_ARITHMETIC 1
#define AGG_ARIGHTMEIC 2
#define NORMAL_ARITHMETIC
1
#define AGG_ARIGHTMEIC
2
int32_t
tSQLParse
(
SSqlInfo
*
pSQLInfo
,
const
char
*
pSql
);
...
...
src/query/src/qast.c
浏览文件 @
18da95ad
此差异已折叠。
点击以展开。
src/query/src/qparserImpl.c
浏览文件 @
18da95ad
...
...
@@ -13,17 +13,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <qsqltype.h>
#include "os.h"
#include "qsqlparser.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "tglobalcfg.h"
#include "tlog.h"
#include "tstoken.h"
#include "ttime.h"
#include "ttokendef.h"
#include "taosdef.h"
#include "tutil.h"
#include "qsqltype.h"
#include "tstrbuild.h"
int32_t
tSQLParse
(
SSqlInfo
*
pSQLInfo
,
const
char
*
pStr
)
{
void
*
pParser
=
ParseAlloc
(
malloc
);
...
...
@@ -900,3 +901,173 @@ void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo) {
memset
(
&
pDBInfo
->
precision
,
0
,
sizeof
(
SSQLToken
));
}
static
bool
isExprLeafNode
(
tSQLExpr
*
pExpr
)
{
return
(
pExpr
->
pRight
==
NULL
&&
pExpr
->
pLeft
==
NULL
)
&&
(
pExpr
->
nSQLOptr
==
TK_ID
||
(
pExpr
->
nSQLOptr
>=
TK_BOOL
&&
pExpr
->
nSQLOptr
<=
TK_NCHAR
)
||
pExpr
->
nSQLOptr
==
TK_SET
);
}
static
bool
isExprParentOfLeafNode
(
tSQLExpr
*
pExpr
)
{
return
(
pExpr
->
pLeft
!=
NULL
&&
pExpr
->
pRight
!=
NULL
)
&&
(
isExprLeafNode
(
pExpr
->
pLeft
)
&&
isExprLeafNode
(
pExpr
->
pRight
));
}
static
int32_t
tSQLExprNodeToString
(
tSQLExpr
*
pExpr
,
SStringBuilder
*
pBuilder
)
{
if
(
pExpr
->
nSQLOptr
==
TK_ID
)
{
// column name
// strncpy(*str, pExpr->colInfo.z, pExpr->colInfo.n);
// *str += pExpr->colInfo.n;
}
else
if
(
pExpr
->
nSQLOptr
>=
TK_BOOL
&&
pExpr
->
nSQLOptr
<=
TK_STRING
)
{
// value
// *str += tVariantToString(&pExpr->val, *str);
// taosStringBuilderAppendStringLen()
}
else
if
(
pExpr
->
nSQLOptr
>=
TK_COUNT
&&
pExpr
->
nSQLOptr
<=
TK_AVG_IRATE
)
{
taosStringBuilderAppendStringLen
(
pBuilder
,
pExpr
->
operand
.
z
,
pExpr
->
operand
.
n
);
}
else
{
// not supported operation
assert
(
false
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
optrToString
(
tSQLExpr
*
pExpr
,
char
**
exprString
)
{
const
char
*
le
=
"<="
;
const
char
*
ge
=
">="
;
const
char
*
ne
=
"<>"
;
const
char
*
likeOptr
=
"LIKE"
;
switch
(
pExpr
->
nSQLOptr
)
{
case
TK_LE
:
{
*
(
int16_t
*
)(
*
exprString
)
=
*
(
int16_t
*
)
le
;
*
exprString
+=
1
;
break
;
}
case
TK_GE
:
{
*
(
int16_t
*
)(
*
exprString
)
=
*
(
int16_t
*
)
ge
;
*
exprString
+=
1
;
break
;
}
case
TK_NE
:
{
*
(
int16_t
*
)(
*
exprString
)
=
*
(
int16_t
*
)
ne
;
*
exprString
+=
1
;
break
;
}
case
TK_LT
:
*
(
*
exprString
)
=
'<'
;
break
;
case
TK_GT
:
*
(
*
exprString
)
=
'>'
;
break
;
case
TK_EQ
:
*
(
*
exprString
)
=
'='
;
break
;
case
TK_PLUS
:
*
(
*
exprString
)
=
'+'
;
break
;
case
TK_MINUS
:
*
(
*
exprString
)
=
'-'
;
break
;
case
TK_STAR
:
*
(
*
exprString
)
=
'*'
;
break
;
case
TK_DIVIDE
:
*
(
*
exprString
)
=
'/'
;
break
;
case
TK_REM
:
*
(
*
exprString
)
=
'%'
;
break
;
case
TK_LIKE
:
{
int32_t
len
=
sprintf
(
*
exprString
,
" %s "
,
likeOptr
);
*
exprString
+=
(
len
-
1
);
break
;
}
default:
return
TSDB_CODE_INVALID_SQL
;
}
*
exprString
+=
1
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
tSQLExprLeafToBinary
(
tSQLExpr
*
pExpr
,
SStringBuilder
*
pBuilder
)
{
if
(
!
isExprParentOfLeafNode
(
pExpr
))
{
return
TSDB_CODE_INVALID_SQL
;
}
tSQLExpr
*
pLeft
=
pExpr
->
pLeft
;
tSQLExpr
*
pRight
=
pExpr
->
pRight
;
// if (addParentheses) {
// *(*output) = '(';
// *output += 1;
// }
tSQLExprNodeToString
(
pLeft
,
pBuilder
);
tSQLExprNodeToString
(
pRight
,
pBuilder
);
if
(
optrToString
(
pExpr
,
pBuilder
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_INVALID_SQL
;
}
// if (addParentheses) {
// *(*output) = ')';
// *output += 1;
// }
return
TSDB_CODE_SUCCESS
;
}
static
void
relToString
(
tSQLExpr
*
pExpr
,
SStringBuilder
*
pBuilder
)
{
assert
(
pExpr
->
nSQLOptr
==
TK_AND
||
pExpr
->
nSQLOptr
==
TK_OR
);
const
char
*
or
=
"OR"
;
const
char
*
and
=
"AND"
;
// if (pQueryInfo->tagCond.relType == TSQL_STABLE_QTYPE_COND) {
// if (pExpr->nSQLOptr == TK_AND) {
// strcpy(*str, and);
// *str += strlen(and);
// } else {
// strcpy(*str, or);
// *str += strlen(or);
// }
}
static
int32_t
doSQLExprToBinary
(
tSQLExpr
*
pExpr
,
SStringBuilder
*
pBuilder
)
{
if
(
pExpr
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
}
if
(
!
isExprParentOfLeafNode
(
pExpr
))
{
// *(*str) = '(';
// *str += 1;
int32_t
ret
=
doSQLExprToBinary
(
pExpr
->
pLeft
,
pBuilder
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
ret
=
doSQLExprToBinary
(
pExpr
->
pRight
,
pBuilder
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
ret
;
}
relToString
(
pExpr
,
pBuilder
);
// *(*str) = ')';
// *str += 1;
return
ret
;
}
return
tSQLExprLeafToBinary
(
pExpr
,
pBuilder
);
}
// post order seralize to binary data
int32_t
tSQLExprToBinary
(
tSQLExpr
*
pExpr
,
SStringBuilder
*
pBuilder
)
{
assert
(
pExpr
!=
NULL
&&
pBuilder
!=
NULL
);
}
\ No newline at end of file
src/query/src/queryExecutor.c
浏览文件 @
18da95ad
...
...
@@ -2603,8 +2603,8 @@ int32_t binarySearchForKey(char *pValue, int num, TSKEY key, int order) {
static
int64_t
doScanAllDataBlocks
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
int64_t
cnt
=
0
;
dTrace
(
"QInfo:%p query start, qrange:%"
PRId64
"-%"
PRId64
", lastkey:%"
PRId64
", order:%d"
,
GET_QINFO_ADDR
(
pRuntimeEnv
),
pQuery
->
window
.
skey
,
pQuery
->
window
.
ekey
,
pQuery
->
lastKey
,
pQuery
->
order
.
order
);
...
...
@@ -3595,8 +3595,8 @@ void scanAllDataBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
pQuery
->
window
.
ekey
=
ekey
;
STimeWindow
win
=
{.
skey
=
pQuery
->
window
.
skey
,
.
ekey
=
pQuery
->
window
.
ekey
};
tsdbResetQuery
(
pRuntimeEnv
->
pQueryHandle
,
&
win
,
current
,
pQuery
->
order
.
order
);
tsdbNextDataBlock
(
pRuntimeEnv
->
pQueryHandle
);
//
tsdbResetQuery(pRuntimeEnv->pQueryHandle, &win, current, pQuery->order.order);
//
tsdbNextDataBlock(pRuntimeEnv->pQueryHandle);
}
void
doFinalizeResult
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
...
...
@@ -5461,7 +5461,7 @@ static int32_t buildAirthmeticExprFromMsg(SSqlFunctionExpr *pExpr, SQueryTableMs
SSqlBinaryExprInfo
*
pBinaryExprInfo
=
&
pExpr
->
binExprInfo
;
SColumnInfo
*
pColMsg
=
pQueryMsg
->
colList
;
#if 0
tSQL
BinaryExpr
* pBinExpr = NULL;
tSQL
SyntaxNode
* pBinExpr = NULL;
SSchema* pSchema = toSchema(pQueryMsg, pColMsg, pQueryMsg->numOfCols);
dTrace("qmsg:%p create binary expr from string:%s", pQueryMsg, pExpr->pBase.arg[0].argValue.pz);
...
...
src/query/src/queryUtil.c
浏览文件 @
18da95ad
...
...
@@ -21,7 +21,6 @@
#include "ttime.h"
#include "qinterpolation.h"
//#include "tscJoinProcess.h"
#include "ttime.h"
#include "queryExecutor.h"
...
...
src/vnode/tsdb/src/tsdbRead.c
浏览文件 @
18da95ad
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录