Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9dd40166
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9dd40166
编写于
7月 07, 2021
作者:
H
Haojun Liao
提交者:
GitHub
7月 07, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6756 from taosdata/feature/query
[td-255] refactor.
上级
ce0a24ca
e7cad3db
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
302 addition
and
210 deletion
+302
-210
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+216
-133
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+12
-11
src/common/inc/tname.h
src/common/inc/tname.h
+1
-1
src/common/src/tglobal.c
src/common/src/tglobal.c
+9
-9
src/inc/taosmsg.h
src/inc/taosmsg.h
+1
-1
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+18
-16
src/query/inc/qSqlparser.h
src/query/inc/qSqlparser.h
+9
-7
src/query/inc/sql.y
src/query/inc/sql.y
+1
-1
src/query/src/qPlan.c
src/query/src/qPlan.c
+2
-1
src/query/src/qSqlParser.c
src/query/src/qSqlParser.c
+27
-27
src/query/src/sql.c
src/query/src/sql.c
+1
-1
src/util/src/tlog.c
src/util/src/tlog.c
+1
-1
tests/script/general/parser/having.sim
tests/script/general/parser/having.sim
+3
-0
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
9dd40166
...
...
@@ -187,7 +187,7 @@ int32_t tscGetResRowLength(SArray* pExprList);
SExprInfo
*
tscExprInsert
(
SQueryInfo
*
pQueryInfo
,
int32_t
index
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
int16_t
size
,
int16_t
resColId
,
int16_t
interSize
,
bool
isTagCol
);
SExprInfo
*
tscExprCreate
(
S
QueryInfo
*
pQuery
Info
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
SExprInfo
*
tscExprCreate
(
S
TableMetaInfo
*
pTableMeta
Info
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
int16_t
size
,
int16_t
resColId
,
int16_t
interSize
,
int32_t
colType
);
void
tscExprAddParams
(
SSqlExpr
*
pExpr
,
char
*
argument
,
int32_t
type
,
int32_t
bytes
);
...
...
src/client/src/tscSQLParser.c
浏览文件 @
9dd40166
此差异已折叠。
点击以展开。
src/client/src/tscUtil.c
浏览文件 @
9dd40166
...
...
@@ -661,7 +661,7 @@ void tscSetResRawPtrRv(SSqlRes* pRes, SQueryInfo* pQueryInfo, SSDataBlock* pBloc
setResRawPtrImpl
(
pRes
,
pInfo
,
i
,
convertNchar
);
/*
// generated the user-defined column result
if (pInfo->pExpr->pExpr == NULL && TSDB_COL_IS_UD_COL(pInfo->pExpr->base.
colInfo
.flag)) {
if (pInfo->pExpr->pExpr == NULL && TSDB_COL_IS_UD_COL(pInfo->pExpr->base.
ColName
.flag)) {
if (pInfo->pExpr->base.param[1].nType == TSDB_DATA_TYPE_NULL) {
setNullN(pRes->urow[i], pInfo->field.type, pInfo->field.bytes, (int32_t) pRes->numOfRows);
} else {
...
...
@@ -2096,10 +2096,8 @@ void tscFieldInfoCopy(SFieldInfo* pFieldInfo, const SFieldInfo* pSrc, const SArr
}
SExprInfo
*
tscExprCreate
(
S
QueryInfo
*
pQuery
Info
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
SExprInfo
*
tscExprCreate
(
S
TableMetaInfo
*
pTableMeta
Info
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
int16_t
size
,
int16_t
resColId
,
int16_t
interSize
,
int32_t
colType
)
{
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
pColIndex
->
tableIndex
);
SExprInfo
*
pExpr
=
calloc
(
1
,
sizeof
(
SExprInfo
));
if
(
pExpr
==
NULL
)
{
return
NULL
;
...
...
@@ -2121,21 +2119,22 @@ SExprInfo* tscExprCreate(SQueryInfo* pQueryInfo, int16_t functionId, SColumnInde
}
else
if
(
functionId
==
TSDB_FUNC_BLKINFO
)
{
p
->
colInfo
.
colId
=
pColIndex
->
columnIndex
;
p
->
colBytes
=
TSDB_MAX_BINARY_LEN
;
p
->
colType
=
TSDB_DATA_TYPE_BINARY
;
p
->
colType
=
TSDB_DATA_TYPE_BINARY
;
}
else
{
int32_t
len
=
tListLen
(
p
->
colInfo
.
name
);
if
(
TSDB_COL_IS_TAG
(
colType
))
{
SSchema
*
pSchema
=
tscGetTableTagSchema
(
pTableMetaInfo
->
pTableMeta
);
p
->
colInfo
.
colId
=
pSchema
[
pColIndex
->
columnIndex
].
colId
;
p
->
colBytes
=
pSchema
[
pColIndex
->
columnIndex
].
bytes
;
p
->
colType
=
pSchema
[
pColIndex
->
columnIndex
].
type
;
tstrncpy
(
p
->
colInfo
.
name
,
pSchema
[
pColIndex
->
columnIndex
].
name
,
sizeof
(
p
->
colInfo
.
name
)
);
snprintf
(
p
->
colInfo
.
name
,
len
,
"%s.%s"
,
pTableMetaInfo
->
aliasName
,
pSchema
[
pColIndex
->
columnIndex
].
name
);
}
else
if
(
pTableMetaInfo
->
pTableMeta
!=
NULL
)
{
// in handling select database/version/server_status(), the pTableMeta is NULL
SSchema
*
pSchema
=
tscGetTableColumnSchema
(
pTableMetaInfo
->
pTableMeta
,
pColIndex
->
columnIndex
);
p
->
colInfo
.
colId
=
pSchema
->
colId
;
p
->
colBytes
=
pSchema
->
bytes
;
p
->
colType
=
pSchema
->
type
;
tstrncpy
(
p
->
colInfo
.
name
,
pSchema
->
name
,
sizeof
(
p
->
colInfo
.
name
)
);
p
->
colType
=
pSchema
->
type
;
snprintf
(
p
->
colInfo
.
name
,
len
,
"%s.%s"
,
pTableMetaInfo
->
aliasName
,
pSchema
->
name
);
}
}
...
...
@@ -2160,15 +2159,17 @@ SExprInfo* tscExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t function
if
(
index
==
num
)
{
return
tscExprAppend
(
pQueryInfo
,
functionId
,
pColIndex
,
type
,
size
,
resColId
,
interSize
,
isTagCol
);
}
SExprInfo
*
pExpr
=
tscExprCreate
(
pQueryInfo
,
functionId
,
pColIndex
,
type
,
size
,
resColId
,
interSize
,
isTagCol
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
pColIndex
->
tableIndex
);
SExprInfo
*
pExpr
=
tscExprCreate
(
pTableMetaInfo
,
functionId
,
pColIndex
,
type
,
size
,
resColId
,
interSize
,
isTagCol
);
taosArrayInsert
(
pQueryInfo
->
exprList
,
index
,
&
pExpr
);
return
pExpr
;
}
SExprInfo
*
tscExprAppend
(
SQueryInfo
*
pQueryInfo
,
int16_t
functionId
,
SColumnIndex
*
pColIndex
,
int16_t
type
,
int16_t
size
,
int16_t
resColId
,
int16_t
interSize
,
bool
isTagCol
)
{
SExprInfo
*
pExpr
=
tscExprCreate
(
pQueryInfo
,
functionId
,
pColIndex
,
type
,
size
,
resColId
,
interSize
,
isTagCol
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
pColIndex
->
tableIndex
);
SExprInfo
*
pExpr
=
tscExprCreate
(
pTableMetaInfo
,
functionId
,
pColIndex
,
type
,
size
,
resColId
,
interSize
,
isTagCol
);
taosArrayPush
(
pQueryInfo
->
exprList
,
&
pExpr
);
return
pExpr
;
}
...
...
src/common/inc/tname.h
浏览文件 @
9dd40166
...
...
@@ -46,7 +46,7 @@ typedef struct SSqlExpr {
char
aliasName
[
TSDB_COL_NAME_LEN
];
// as aliasName
char
token
[
TSDB_COL_NAME_LEN
];
// original token
SColIndex
colInfo
;
uint64_t
uid
;
// refactor use the pointer
uint64_t
uid
;
//
table uid, todo
refactor use the pointer
int16_t
functionId
;
// function id in aAgg array
...
...
src/common/src/tglobal.c
浏览文件 @
9dd40166
...
...
@@ -180,15 +180,15 @@ int8_t tsEnableStream = 1;
int8_t
tsCompactMnodeWal
=
0
;
int8_t
tsPrintAuth
=
0
;
int8_t
tscEmbedded
=
0
;
char
configDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsVnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsDnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsMnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsMnodeTmpDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsMnodeBakDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsDataDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsScriptDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsTempDir
[
TSDB_FILENAME_LEN
]
=
"/tmp/"
;
char
configDir
[
PATH_MAX
]
=
{
0
};
char
tsVnodeDir
[
PATH_MAX
]
=
{
0
};
char
tsDnodeDir
[
PATH_MAX
]
=
{
0
};
char
tsMnodeDir
[
PATH_MAX
]
=
{
0
};
char
tsMnodeTmpDir
[
PATH_MAX
]
=
{
0
};
char
tsMnodeBakDir
[
PATH_MAX
]
=
{
0
};
char
tsDataDir
[
PATH_MAX
]
=
{
0
};
char
tsScriptDir
[
PATH_MAX
]
=
{
0
};
char
tsTempDir
[
PATH_MAX
]
=
"/tmp/"
;
int32_t
tsDiskCfgNum
=
0
;
...
...
src/inc/taosmsg.h
浏览文件 @
9dd40166
...
...
@@ -402,7 +402,7 @@ typedef struct SColIndex {
int16_t
colId
;
// column id
int16_t
colIndex
;
// column index in colList if it is a normal column or index in tagColList if a tag
uint16_t
flag
;
// denote if it is a tag or a normal column
char
name
[
TSDB_COL_NAME_LEN
];
// TODO remove it
char
name
[
TSDB_COL_NAME_LEN
+
TSDB_DB_NAME_LEN
+
1
];
}
SColIndex
;
typedef
struct
SColumnFilterInfo
{
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
9dd40166
...
...
@@ -1035,6 +1035,20 @@ static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
return
code
;
}
static
uint64_t
mnodeCreateSuperTableUid
()
{
int64_t
us
=
taosGetTimestampUs
();
uint64_t
x
=
(
us
&
((((
uint64_t
)
1
)
<<
40
)
-
1
));
x
=
x
<<
24
;
return
x
+
((
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
))
<<
8
)
+
(
taosRand
()
&
((
1ul
<<
8
)
-
1ul
));
}
static
uint64_t
mnodeCreateTableUid
(
int32_t
vgId
,
int32_t
tid
)
{
uint64_t
uid
=
(((
uint64_t
)
vgId
)
<<
48
)
+
((((
uint64_t
)
tid
)
&
((
1ul
<<
24
)
-
1ul
))
<<
24
)
+
((
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
))
<<
8
)
+
(
taosRand
()
&
((
1ul
<<
8
)
-
1ul
));
return
uid
;
}
static
int32_t
mnodeProcessCreateSuperTableMsg
(
SMnodeMsg
*
pMsg
)
{
if
(
pMsg
==
NULL
)
return
TSDB_CODE_MND_APP_ERROR
;
...
...
@@ -1064,15 +1078,10 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
int64_t
us
=
taosGetTimestampUs
();
pStable
->
info
.
tableId
=
strdup
(
pCreate
->
tableName
);
pStable
->
info
.
type
=
TSDB_SUPER_TABLE
;
pStable
->
createdTime
=
taosGetTimestampMs
();
uint64_t
x
=
(
us
&
((((
uint64_t
)
1
)
<<
40
)
-
1
));
// todo refactor
x
=
x
<<
24
;
pStable
->
uid
=
x
+
((
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
))
<<
8
)
+
(
taosRand
()
&
((
1ul
<<
8
)
-
1ul
));
pStable
->
uid
=
mnodeCreateSuperTableUid
();
pStable
->
sversion
=
0
;
pStable
->
tversion
=
0
;
pStable
->
numOfColumns
=
numOfColumns
;
...
...
@@ -2075,20 +2084,13 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
}
pTable
->
suid
=
pMsg
->
pSTable
->
uid
;
pTable
->
uid
=
(((
uint64_t
)
pTable
->
vgId
)
<<
48
)
+
((((
uint64_t
)
pTable
->
tid
)
&
((
1ul
<<
24
)
-
1ul
))
<<
24
)
+
((
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
))
<<
8
)
+
(
taosRand
()
&
((
1ul
<<
8
)
-
1ul
));
pTable
->
uid
=
mnodeCreateTableUid
(
pTable
->
vgId
,
pTable
->
tid
);
pTable
->
superTable
=
pMsg
->
pSTable
;
}
else
{
if
(
pTable
->
info
.
type
==
TSDB_SUPER_TABLE
)
{
uint64_t
us
=
(
uint64_t
)
taosGetTimestampUs
();
uint64_t
x
=
(
us
&
((((
uint64_t
)
1
)
<<
40
)
-
1
));
x
=
x
<<
24
;
pTable
->
uid
=
x
+
((
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
))
<<
8
)
+
(
taosRand
()
&
((
1ul
<<
8
)
-
1ul
));
pTable
->
uid
=
mnodeCreateSuperTableUid
();
}
else
{
pTable
->
uid
=
(((
uint64_t
)
pTable
->
vgId
)
<<
48
)
+
((((
uint64_t
)
pTable
->
tid
)
&
((
1ul
<<
24
)
-
1ul
))
<<
24
)
+
((
sdbGetVersion
()
&
((
1ul
<<
16
)
-
1ul
))
<<
8
)
+
(
taosRand
()
&
((
1ul
<<
8
)
-
1ul
));
pTable
->
uid
=
mnodeCreateTableUid
(
pTable
->
vgId
,
pTable
->
tid
);
}
pTable
->
sversion
=
0
;
...
...
src/query/inc/qSqlparser.h
浏览文件 @
9dd40166
...
...
@@ -237,18 +237,20 @@ typedef struct tSqlExpr {
uint16_t
type
;
// sql node type
uint32_t
tokenId
;
// TK_LE: less than(binary expr)
// the whole string of the function(col, param), while the function name is kept in token
SStrToken
operand
;
uint32_t
functionId
;
// function id
// the whole string of the function(col, param), while the function name is kept in exprToken
struct
{
SStrToken
operand
;
struct
SArray
*
paramList
;
// function parameters list
}
Expr
;
SStrToken
colInfo
;
// table column info
uint32_t
functionId
;
// function id, todo remove it
SStrToken
columnName
;
// table column info
tVariant
value
;
// the use input value
SStrToken
token
;
// original sql expr string
uint32_t
flags
;
SStrToken
exprToken
;
// original sql expr string
uint32_t
flags
;
// todo remove it
struct
tSqlExpr
*
pLeft
;
// left child
struct
tSqlExpr
*
pRight
;
// right child
struct
SArray
*
pParam
;
// function parameters list
}
tSqlExpr
;
// used in select clause. select <SArray> from xxx
...
...
src/query/inc/sql.y
浏览文件 @
9dd40166
...
...
@@ -681,7 +681,7 @@ where_opt(A) ::= WHERE expr(X). {A = X;}
%type expr {tSqlExpr*}
%destructor expr {tSqlExprDestroy($$);}
expr(A) ::= LP(X) expr(Y) RP(Z). {A = Y; A->
token.z = X.z; A->t
oken.n = (Z.z - X.z + 1);}
expr(A) ::= LP(X) expr(Y) RP(Z). {A = Y; A->
exprToken.z = X.z; A->exprT
oken.n = (Z.z - X.z + 1);}
expr(A) ::= ID(X). { A = tSqlExprCreateIdValue(&X, TK_ID);}
expr(A) ::= ID(X) DOT ID(Y). { X.n += (1+Y.n); A = tSqlExprCreateIdValue(&X, TK_ID);}
...
...
src/query/src/qPlan.c
浏览文件 @
9dd40166
...
...
@@ -127,7 +127,8 @@ static SQueryNode* doAddTableColumnNode(SQueryInfo* pQueryInfo, STableMetaInfo*
SColumn
*
pCol
=
taosArrayGetP
(
tableCols
,
i
);
SColumnIndex
index
=
{.
tableIndex
=
0
,
.
columnIndex
=
pCol
->
columnIndex
};
SExprInfo
*
p
=
tscExprCreate
(
pQueryInfo
,
TSDB_FUNC_PRJ
,
&
index
,
pCol
->
info
.
type
,
pCol
->
info
.
bytes
,
STableMetaInfo
*
pTableMetaInfo1
=
tscGetMetaInfo
(
pQueryInfo
,
index
.
tableIndex
);
SExprInfo
*
p
=
tscExprCreate
(
pTableMetaInfo1
,
TSDB_FUNC_PRJ
,
&
index
,
pCol
->
info
.
type
,
pCol
->
info
.
bytes
,
pCol
->
info
.
colId
,
0
,
TSDB_COL_NORMAL
);
strncpy
(
p
->
base
.
aliasName
,
pSchema
[
pCol
->
columnIndex
].
name
,
tListLen
(
p
->
base
.
aliasName
));
...
...
src/query/src/qSqlParser.c
浏览文件 @
9dd40166
...
...
@@ -124,7 +124,7 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) {
tSqlExpr
*
pSqlExpr
=
calloc
(
1
,
sizeof
(
tSqlExpr
));
if
(
pToken
!=
NULL
)
{
pSqlExpr
->
t
oken
=
*
pToken
;
pSqlExpr
->
exprT
oken
=
*
pToken
;
}
if
(
optrType
==
TK_NULL
)
{
...
...
@@ -161,7 +161,7 @@ tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType) {
// Here it must be the column name (tk_id) if it is not a number or string.
assert
(
optrType
==
TK_ID
||
optrType
==
TK_ALL
);
if
(
pToken
!=
NULL
)
{
pSqlExpr
->
col
Info
=
*
pToken
;
pSqlExpr
->
col
umnName
=
*
pToken
;
}
pSqlExpr
->
tokenId
=
optrType
;
...
...
@@ -180,17 +180,17 @@ tSqlExpr *tSqlExprCreateFunction(SArray *pParam, SStrToken *pFuncToken, SStrToke
return
NULL
;
}
tSqlExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
tSqlExpr
));
pExpr
->
tokenId
=
optType
;
pExpr
->
type
=
SQL_NODE_SQLFUNCTION
;
pExpr
->
pParam
=
pParam
;
tSqlExpr
*
pExpr
=
calloc
(
1
,
sizeof
(
tSqlExpr
));
pExpr
->
tokenId
=
optType
;
pExpr
->
type
=
SQL_NODE_SQLFUNCTION
;
pExpr
->
Expr
.
paramList
=
pParam
;
int32_t
len
=
(
int32_t
)((
endToken
->
z
+
endToken
->
n
)
-
pFuncToken
->
z
);
pExpr
->
operand
=
(
*
pFuncToken
);
pExpr
->
Expr
.
operand
=
(
*
pFuncToken
);
pExpr
->
t
oken
.
n
=
len
;
pExpr
->
t
oken
.
z
=
pFuncToken
->
z
;
pExpr
->
t
oken
.
type
=
pFuncToken
->
type
;
pExpr
->
exprT
oken
.
n
=
len
;
pExpr
->
exprT
oken
.
z
=
pFuncToken
->
z
;
pExpr
->
exprT
oken
.
type
=
pFuncToken
->
type
;
return
pExpr
;
}
...
...
@@ -204,16 +204,16 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) {
pExpr
->
type
=
SQL_NODE_EXPR
;
if
(
pLeft
!=
NULL
&&
pRight
!=
NULL
&&
(
optrType
!=
TK_IN
))
{
char
*
endPos
=
pRight
->
token
.
z
+
pRight
->
t
oken
.
n
;
pExpr
->
token
.
z
=
pLeft
->
t
oken
.
z
;
pExpr
->
token
.
n
=
(
uint32_t
)(
endPos
-
pExpr
->
t
oken
.
z
);
pExpr
->
token
.
type
=
pLeft
->
t
oken
.
type
;
char
*
endPos
=
pRight
->
exprToken
.
z
+
pRight
->
exprT
oken
.
n
;
pExpr
->
exprToken
.
z
=
pLeft
->
exprT
oken
.
z
;
pExpr
->
exprToken
.
n
=
(
uint32_t
)(
endPos
-
pExpr
->
exprT
oken
.
z
);
pExpr
->
exprToken
.
type
=
pLeft
->
exprT
oken
.
type
;
}
if
((
pLeft
!=
NULL
&&
pRight
!=
NULL
)
&&
(
optrType
==
TK_PLUS
||
optrType
==
TK_MINUS
||
optrType
==
TK_STAR
||
optrType
==
TK_DIVIDE
||
optrType
==
TK_REM
))
{
/*
* if a
t
oken is noted as the TK_TIMESTAMP, the time precision is microsecond
* if a
exprT
oken is noted as the TK_TIMESTAMP, the time precision is microsecond
* Otherwise, the time precision is adaptive, determined by the time precision from databases.
*/
if
((
pLeft
->
tokenId
==
TK_INTEGER
&&
pRight
->
tokenId
==
TK_INTEGER
)
||
...
...
@@ -304,7 +304,7 @@ tSqlExpr *tSqlExprCreate(tSqlExpr *pLeft, tSqlExpr *pRight, int32_t optrType) {
tSqlExpr
*
pRSub
=
calloc
(
1
,
sizeof
(
tSqlExpr
));
pRSub
->
tokenId
=
TK_SET
;
// TODO refactor .....
pRSub
->
pParam
=
(
SArray
*
)
pRight
;
pRSub
->
Expr
.
paramList
=
(
SArray
*
)
pRight
;
pExpr
->
pRight
=
pRSub
;
}
else
{
...
...
@@ -346,8 +346,8 @@ int32_t tSqlExprCompare(tSqlExpr *left, tSqlExpr *right) {
||
(
left
->
pLeft
==
NULL
&&
right
->
pLeft
)
||
(
left
->
pRight
&&
right
->
pRight
==
NULL
)
||
(
left
->
pRight
==
NULL
&&
right
->
pRight
)
||
(
left
->
pParam
&&
right
->
pParam
==
NULL
)
||
(
left
->
pParam
==
NULL
&&
right
->
pParam
))
{
||
(
left
->
Expr
.
paramList
&&
right
->
Expr
.
paramList
==
NULL
)
||
(
left
->
Expr
.
paramList
==
NULL
&&
right
->
Expr
.
paramList
))
{
return
1
;
}
...
...
@@ -355,20 +355,20 @@ int32_t tSqlExprCompare(tSqlExpr *left, tSqlExpr *right) {
return
1
;
}
if
(
tStrTokenCompare
(
&
left
->
col
Info
,
&
right
->
colInfo
))
{
if
(
tStrTokenCompare
(
&
left
->
col
umnName
,
&
right
->
columnName
))
{
return
1
;
}
if
(
right
->
pParam
&&
left
->
pParam
)
{
size_t
size
=
taosArrayGetSize
(
right
->
pParam
);
if
(
left
->
pParam
&&
taosArrayGetSize
(
left
->
pParam
)
!=
size
)
{
if
(
right
->
Expr
.
paramList
&&
left
->
Expr
.
paramList
)
{
size_t
size
=
taosArrayGetSize
(
right
->
Expr
.
paramList
);
if
(
left
->
Expr
.
paramList
&&
taosArrayGetSize
(
left
->
Expr
.
paramList
)
!=
size
)
{
return
1
;
}
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
tSqlExprItem
*
pLeftElem
=
taosArrayGet
(
left
->
pParam
,
i
);
tSqlExprItem
*
pLeftElem
=
taosArrayGet
(
left
->
Expr
.
paramList
,
i
);
tSqlExpr
*
pSubLeft
=
pLeftElem
->
pNode
;
tSqlExprItem
*
pRightElem
=
taosArrayGet
(
right
->
pParam
,
i
);
tSqlExprItem
*
pRightElem
=
taosArrayGet
(
right
->
Expr
.
paramList
,
i
);
tSqlExpr
*
pSubRight
=
pRightElem
->
pNode
;
if
(
tSqlExprCompare
(
pSubLeft
,
pSubRight
))
{
...
...
@@ -401,8 +401,8 @@ tSqlExpr *tSqlExprClone(tSqlExpr *pSrc) {
pExpr
->
pRight
=
tSqlExprClone
(
pSrc
->
pRight
);
}
//we don't clone p
Param
now because clone is only used for between/and
assert
(
pSrc
->
pParam
==
NULL
);
//we don't clone p
aramList
now because clone is only used for between/and
assert
(
pSrc
->
Expr
.
paramList
==
NULL
);
return
pExpr
;
}
...
...
@@ -460,7 +460,7 @@ static void doDestroySqlExprNode(tSqlExpr *pExpr) {
tVariantDestroy
(
&
pExpr
->
value
);
}
tSqlExprListDestroy
(
pExpr
->
pParam
);
tSqlExprListDestroy
(
pExpr
->
Expr
.
paramList
);
free
(
pExpr
);
}
...
...
src/query/src/sql.c
浏览文件 @
9dd40166
...
...
@@ -2921,7 +2921,7 @@ static void yy_reduce(
{
yymsp
[
-
3
].
minor
.
yy414
.
limit
=
yymsp
[
0
].
minor
.
yy369
;
yymsp
[
-
3
].
minor
.
yy414
.
offset
=
yymsp
[
-
2
].
minor
.
yy369
;}
break
;
case
223
:
/* expr ::= LP expr RP */
{
yylhsminor
.
yy166
=
yymsp
[
-
1
].
minor
.
yy166
;
yylhsminor
.
yy166
->
token
.
z
=
yymsp
[
-
2
].
minor
.
yy0
.
z
;
yylhsminor
.
yy166
->
t
oken
.
n
=
(
yymsp
[
0
].
minor
.
yy0
.
z
-
yymsp
[
-
2
].
minor
.
yy0
.
z
+
1
);}
{
yylhsminor
.
yy166
=
yymsp
[
-
1
].
minor
.
yy166
;
yylhsminor
.
yy166
->
exprToken
.
z
=
yymsp
[
-
2
].
minor
.
yy0
.
z
;
yylhsminor
.
yy166
->
exprT
oken
.
n
=
(
yymsp
[
0
].
minor
.
yy0
.
z
-
yymsp
[
-
2
].
minor
.
yy0
.
z
+
1
);}
yymsp
[
-
2
].
minor
.
yy166
=
yylhsminor
.
yy166
;
break
;
case
224
:
/* expr ::= ID */
...
...
src/util/src/tlog.c
浏览文件 @
9dd40166
...
...
@@ -86,7 +86,7 @@ char tsLogDir[TSDB_FILENAME_LEN] = "/var/log/power";
#elif (_TD_TQ_ == true)
char
tsLogDir
[
TSDB_FILENAME_LEN
]
=
"/var/log/tq"
;
#else
char
tsLogDir
[
TSDB_FILENAME_LEN
]
=
"/var/log/taos"
;
char
tsLogDir
[
PATH_MAX
]
=
"/var/log/taos"
;
#endif
static
SLogObj
tsLogObj
=
{
.
fileNum
=
1
};
...
...
tests/script/general/parser/having.sim
浏览文件 @
9dd40166
...
...
@@ -1835,5 +1835,8 @@ if $data04 != 1 then
endi
sql_error select top(f1,2) from tb1 group by f1 having count(f1) > 0;
sql_error select count(*) from tb1 group by f1 having last(*) > 0;
print bug for select count(*) k from tb1 group by f1 having k > 0;
system sh/exec.sh -n dnode1 -s stop -x SIGINT
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录