Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cf9f9ab4
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,发现更多精彩内容 >>
提交
cf9f9ab4
编写于
8月 14, 2023
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rebuild index at tag0
上级
1990a891
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
191 addition
and
131 deletion
+191
-131
source/dnode/mnode/impl/src/mndIndex.c
source/dnode/mnode/impl/src/mndIndex.c
+59
-11
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+7
-7
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+5
-4
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+120
-109
未找到文件。
source/dnode/mnode/impl/src/mndIndex.c
浏览文件 @
cf9f9ab4
...
...
@@ -79,9 +79,12 @@ int32_t mndInitIdx(SMnode *pMnode) {
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
}
static
int32_t
mndFindSuperTableTagId
(
const
SStbObj
*
pStb
,
const
char
*
tagName
)
{
static
int32_t
mndFindSuperTableTagId
(
const
SStbObj
*
pStb
,
const
char
*
tagName
,
int8_t
*
hasIdx
)
{
for
(
int32_t
tag
=
0
;
tag
<
pStb
->
numOfTags
;
tag
++
)
{
if
(
strcasecmp
(
pStb
->
pTags
[
tag
].
name
,
tagName
)
==
0
)
{
if
(
IS_IDX_ON
(
&
pStb
->
pTags
[
tag
]))
{
*
hasIdx
=
1
;
}
return
tag
;
}
}
...
...
@@ -597,7 +600,8 @@ static int32_t mndSetUpdateIdxStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb
pNew
->
updateTime
=
taosGetTimestampMs
();
pNew
->
lock
=
0
;
int32_t
tag
=
mndFindSuperTableTagId
(
pOld
,
tagName
);
int8_t
hasIdx
=
0
;
int32_t
tag
=
mndFindSuperTableTagId
(
pOld
,
tagName
,
&
hasIdx
);
if
(
tag
<
0
)
{
terrno
=
TSDB_CODE_MND_TAG_NOT_EXIST
;
return
-
1
;
...
...
@@ -612,14 +616,14 @@ static int32_t mndSetUpdateIdxStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb
SSchema
*
pTag
=
pNew
->
pTags
+
tag
;
if
(
on
==
1
)
{
if
(
IS_IDX_ON
(
pTag
)
)
{
if
(
hasIdx
&&
tag
!=
0
)
{
terrno
=
TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST
;
return
-
1
;
}
else
{
SSCHMEA_SET_IDX_ON
(
pTag
);
}
}
else
{
if
(
!
IS_IDX_ON
(
pTag
)
)
{
if
(
hasIdx
==
0
)
{
terrno
=
TSDB_CODE_MND_SMA_NOT_EXIST
;
}
else
{
SSCHMEA_SET_IDX_OFF
(
pTag
);
...
...
@@ -667,7 +671,42 @@ _OVER:
mndTransDrop
(
pTrans
);
return
code
;
}
int8_t
mndCheckIndexNameByTagName
(
SMnode
*
pMnode
,
SIdxObj
*
pIdxObj
)
{
// build index on first tag, and no index name;
int8_t
exist
=
0
;
SDbObj
*
pDb
=
NULL
;
if
(
strlen
(
pIdxObj
->
db
)
>
0
)
{
pDb
=
mndAcquireDb
(
pMnode
,
pIdxObj
->
db
);
if
(
pDb
==
NULL
)
return
0
;
}
SSmaAndTagIter
*
pIter
=
NULL
;
SIdxObj
*
pIdx
=
NULL
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_IDX
,
pIter
,
(
void
**
)
&
pIdx
);
if
(
pIter
==
NULL
)
break
;
if
(
NULL
!=
pDb
&&
pIdx
->
dbUid
!=
pDb
->
uid
)
{
sdbRelease
(
pSdb
,
pIdx
);
continue
;
}
if
(
pIdxObj
->
stbUid
!=
pIdx
->
stbUid
)
{
sdbRelease
(
pSdb
,
pIdx
);
continue
;
}
if
(
strncmp
(
pIdxObj
->
colName
,
pIdx
->
colName
,
TSDB_COL_NAME_LEN
)
==
0
)
{
sdbRelease
(
pSdb
,
pIdx
);
sdbCancelFetch
(
pSdb
,
pIdx
);
exist
=
1
;
break
;
}
sdbRelease
(
pSdb
,
pIdx
);
}
mndReleaseDb
(
pMnode
,
pDb
);
return
exist
;
}
static
int32_t
mndAddIndex
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SCreateTagIndexReq
*
req
,
SDbObj
*
pDb
,
SStbObj
*
pStb
)
{
int32_t
code
=
-
1
;
SIdxObj
idxObj
=
{
0
};
...
...
@@ -681,11 +720,20 @@ static int32_t mndAddIndex(SMnode *pMnode, SRpcMsg *pReq, SCreateTagIndexReq *re
idxObj
.
stbUid
=
pStb
->
uid
;
idxObj
.
dbUid
=
pStb
->
dbUid
;
int32_t
tag
=
mndFindSuperTableTagId
(
pStb
,
req
->
colName
);
int8_t
hasIdx
=
0
;
int32_t
tag
=
mndFindSuperTableTagId
(
pStb
,
req
->
colName
,
&
hasIdx
);
if
(
tag
<
0
)
{
terrno
=
TSDB_CODE_MND_TAG_NOT_EXIST
;
return
-
1
;
}
else
if
(
tag
==
0
)
{
}
int8_t
exist
=
0
;
if
(
tag
==
0
&&
hasIdx
==
1
)
{
exist
=
mndCheckIndexNameByTagName
(
pMnode
,
&
idxObj
);
if
(
exist
)
{
terrno
=
TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST
;
return
-
1
;
}
}
else
if
(
hasIdx
==
1
)
{
terrno
=
TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST
;
return
-
1
;
}
...
...
@@ -695,11 +743,11 @@ static int32_t mndAddIndex(SMnode *pMnode, SRpcMsg *pReq, SCreateTagIndexReq *re
return
-
1
;
}
SSchema
*
pTag
=
pStb
->
pTags
+
tag
;
if
(
IS_IDX_ON
(
pTag
))
{
terrno
=
TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST
;
return
-
1
;
}
//
SSchema *pTag = pStb->pTags + tag;
//
if (IS_IDX_ON(pTag)) {
//
terrno = TSDB_CODE_MND_TAG_INDEX_ALREADY_EXIST;
//
return -1;
//
}
code
=
mndAddIndexImpl
(
pMnode
,
pReq
,
pDb
,
pStb
,
&
idxObj
);
return
code
;
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
cf9f9ab4
...
...
@@ -17,8 +17,8 @@
#include "osMemory.h"
#include "tencode.h"
void
_metaReaderInit
(
SMetaReader
*
pReader
,
void
*
pVnode
,
int32_t
flags
,
SStoreMeta
*
pAPI
)
{
SMeta
*
pMeta
=
((
SVnode
*
)
pVnode
)
->
pMeta
;
void
_metaReaderInit
(
SMetaReader
*
pReader
,
void
*
pVnode
,
int32_t
flags
,
SStoreMeta
*
pAPI
)
{
SMeta
*
pMeta
=
((
SVnode
*
)
pVnode
)
->
pMeta
;
metaReaderDoInit
(
pReader
,
pMeta
,
flags
);
pReader
->
pAPI
=
pAPI
;
}
...
...
@@ -143,7 +143,7 @@ tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name) {
int
metaGetTableNameByUid
(
void
*
pVnode
,
uint64_t
uid
,
char
*
tbName
)
{
int
code
=
0
;
SMetaReader
mr
=
{
0
};
metaReaderDoInit
(
&
mr
,
((
SVnode
*
)
pVnode
)
->
pMeta
,
0
);
metaReaderDoInit
(
&
mr
,
((
SVnode
*
)
pVnode
)
->
pMeta
,
0
);
code
=
metaReaderGetTableEntryByUid
(
&
mr
,
uid
);
if
(
code
<
0
)
{
metaReaderClear
(
&
mr
);
...
...
@@ -195,7 +195,7 @@ int metaGetTableUidByName(void *pVnode, char *tbName, uint64_t *uid) {
int
metaGetTableTypeByName
(
void
*
pVnode
,
char
*
tbName
,
ETableType
*
tbType
)
{
int
code
=
0
;
SMetaReader
mr
=
{
0
};
metaReaderDoInit
(
&
mr
,
((
SVnode
*
)
pVnode
)
->
pMeta
,
0
);
metaReaderDoInit
(
&
mr
,
((
SVnode
*
)
pVnode
)
->
pMeta
,
0
);
code
=
metaGetTableEntryByName
(
&
mr
,
tbName
);
if
(
code
==
0
)
*
tbType
=
mr
.
me
.
type
;
...
...
@@ -244,7 +244,7 @@ SMTbCursor *metaOpenTbCursor(void *pVnode) {
return
NULL
;
}
SVnode
*
pVnodeObj
=
pVnode
;
SVnode
*
pVnodeObj
=
pVnode
;
// tdbTbcMoveToFirst((TBC *)pTbCur->pDbc);
pTbCur
->
pMeta
=
pVnodeObj
->
pMeta
;
pTbCur
->
paused
=
1
;
...
...
@@ -1139,7 +1139,7 @@ int32_t metaFilterTtl(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
pCursor
->
type
=
param
->
type
;
metaRLock
(
pMeta
);
//ret = tdbTbcOpen(pMeta->pTtlIdx, &pCursor->pCur, NULL);
//
ret = tdbTbcOpen(pMeta->pTtlIdx, &pCursor->pCur, NULL);
END:
if
(
pCursor
->
pMeta
)
metaULock
(
pCursor
->
pMeta
);
...
...
@@ -1194,7 +1194,7 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
ret
=
-
1
;
for
(
int
i
=
0
;
i
<
oStbEntry
.
stbEntry
.
schemaTag
.
nCols
;
i
++
)
{
SSchema
*
schema
=
oStbEntry
.
stbEntry
.
schemaTag
.
pSchema
+
i
;
if
(
schema
->
colId
==
param
->
cid
&&
param
->
type
==
schema
->
type
&&
(
IS_IDX_ON
(
schema
)
||
i
==
0
))
{
if
(
schema
->
colId
==
param
->
cid
&&
param
->
type
==
schema
->
type
&&
(
IS_IDX_ON
(
schema
)))
{
ret
=
0
;
}
}
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
cf9f9ab4
...
...
@@ -450,12 +450,13 @@ int metaAddIndexToSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
goto
_err
;
}
if
(
IS_IDX_ON
(
pNew
)
&&
!
IS_IDX_ON
(
pOld
))
{
if
(
diffIdx
!=
-
1
)
goto
_err
;
//
if (diffIdx != -1) goto _err;
diffIdx
=
i
;
break
;
}
}
if
(
diffIdx
==
-
1
||
diffIdx
==
0
)
{
if
(
diffIdx
==
-
1
)
{
goto
_err
;
}
...
...
@@ -586,7 +587,7 @@ int metaDropIndexFromSTable(SMeta *pMeta, int64_t version, SDropIndexReq *pReq)
for
(
int
i
=
0
;
i
<
oStbEntry
.
stbEntry
.
schemaTag
.
nCols
;
i
++
)
{
SSchema
*
schema
=
oStbEntry
.
stbEntry
.
schemaTag
.
pSchema
+
i
;
if
(
0
==
strncmp
(
schema
->
name
,
pReq
->
colName
,
sizeof
(
pReq
->
colName
)))
{
if
(
i
!=
0
||
IS_IDX_ON
(
schema
))
{
if
(
IS_IDX_ON
(
schema
))
{
pCol
=
schema
;
}
break
;
...
...
@@ -2094,7 +2095,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
}
else
{
for
(
int
i
=
0
;
i
<
pTagSchema
->
nCols
;
i
++
)
{
pTagColumn
=
&
pTagSchema
->
pSchema
[
i
];
if
(
i
!=
0
&&
!
IS_IDX_ON
(
pTagColumn
))
continue
;
if
(
!
IS_IDX_ON
(
pTagColumn
))
continue
;
STagVal
tagVal
=
{.
cid
=
pTagColumn
->
colId
};
tTagGet
((
const
STag
*
)
pCtbEntry
->
ctbEntry
.
pTags
,
&
tagVal
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
cf9f9ab4
...
...
@@ -278,7 +278,8 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = {
static
int32_t
translateSubquery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
);
static
int32_t
translateQuery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
);
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
);
static
int32_t
createSimpleSelectStmtFromProjList
(
const
char
*
pDb
,
const
char
*
pTable
,
SNodeList
*
pProjectionList
,
SSelectStmt
**
pStmt
);
static
int32_t
createSimpleSelectStmtFromProjList
(
const
char
*
pDb
,
const
char
*
pTable
,
SNodeList
*
pProjectionList
,
SSelectStmt
**
pStmt
);
static
int32_t
createLastTsSelectStmt
(
char
*
pDb
,
char
*
pTable
,
STableMeta
*
pMeta
,
SNode
**
pQuery
);
static
int32_t
setQuery
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
);
static
int32_t
setRefreshMate
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
);
...
...
@@ -772,7 +773,8 @@ static SNodeList* getProjectList(const SNode* pNode) {
static
bool
isTimeLineQuery
(
SNode
*
pStmt
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pStmt
))
{
return
(
TIME_LINE_MULTI
==
((
SSelectStmt
*
)
pStmt
)
->
timeLineResMode
)
||
(
TIME_LINE_GLOBAL
==
((
SSelectStmt
*
)
pStmt
)
->
timeLineResMode
);
return
(
TIME_LINE_MULTI
==
((
SSelectStmt
*
)
pStmt
)
->
timeLineResMode
)
||
(
TIME_LINE_GLOBAL
==
((
SSelectStmt
*
)
pStmt
)
->
timeLineResMode
);
}
else
if
(
QUERY_NODE_SET_OPERATOR
==
nodeType
(
pStmt
))
{
return
TIME_LINE_GLOBAL
==
((
SSetOperator
*
)
pStmt
)
->
timeLineResMode
;
}
else
{
...
...
@@ -791,7 +793,7 @@ static bool isGlobalTimeLineQuery(SNode* pStmt) {
}
static
bool
isTimeLineAlignedQuery
(
SNode
*
pStmt
)
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pStmt
;
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pStmt
;
if
(
isGlobalTimeLineQuery
(((
STempTableNode
*
)
pSelect
->
pFromTable
)
->
pSubquery
))
{
return
true
;
}
...
...
@@ -801,7 +803,7 @@ static bool isTimeLineAlignedQuery(SNode* pStmt) {
if
(
QUERY_NODE_SELECT_STMT
!=
nodeType
(((
STempTableNode
*
)
pSelect
->
pFromTable
)
->
pSubquery
))
{
return
false
;
}
SSelectStmt
*
pSub
=
(
SSelectStmt
*
)((
STempTableNode
*
)
pSelect
->
pFromTable
)
->
pSubquery
;
SSelectStmt
*
pSub
=
(
SSelectStmt
*
)((
STempTableNode
*
)
pSelect
->
pFromTable
)
->
pSubquery
;
if
(
nodesListMatch
(
pSelect
->
pPartitionByList
,
pSub
->
pPartitionByList
))
{
return
true
;
}
...
...
@@ -860,7 +862,7 @@ static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* p
pCol
->
tableType
=
pTable
->
pMeta
->
tableType
;
pCol
->
colId
=
pColSchema
->
colId
;
pCol
->
colType
=
(
tagFlag
>=
0
?
COLUMN_TYPE_TAG
:
COLUMN_TYPE_COLUMN
);
pCol
->
hasIndex
=
(
(
0
==
tagFlag
)
||
(
pColSchema
!=
NULL
&&
IS_IDX_ON
(
pColSchema
)
));
pCol
->
hasIndex
=
(
pColSchema
!=
NULL
&&
IS_IDX_ON
(
pColSchema
));
pCol
->
node
.
resType
.
type
=
pColSchema
->
type
;
pCol
->
node
.
resType
.
bytes
=
pColSchema
->
bytes
;
if
(
TSDB_DATA_TYPE_TIMESTAMP
==
pCol
->
node
.
resType
.
type
)
{
...
...
@@ -1608,9 +1610,11 @@ static int32_t translateInterpFunc(STranslateContext* pCxt, SFunctionNode* pFunc
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
);
}
if
(
pSelect
->
hasInterpFunc
&&
(
FUNC_RETURN_ROWS_INDEFINITE
==
pSelect
->
returnRows
||
pSelect
->
returnRows
!=
fmGetFuncReturnRows
(
pFunc
)))
{
if
(
pSelect
->
hasInterpFunc
&&
(
FUNC_RETURN_ROWS_INDEFINITE
==
pSelect
->
returnRows
||
pSelect
->
returnRows
!=
fmGetFuncReturnRows
(
pFunc
)))
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
,
"%s ignoring null value options cannot be used when applying to multiple columns"
,
pFunc
->
functionName
);
"%s ignoring null value options cannot be used when applying to multiple columns"
,
pFunc
->
functionName
);
}
if
(
NULL
!=
pSelect
->
pWindow
||
NULL
!=
pSelect
->
pGroupByList
)
{
...
...
@@ -1648,7 +1652,8 @@ static int32_t translateTimelineFunc(STranslateContext* pCxt, SFunctionNode* pFu
}
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pCxt
->
pCurrStmt
;
if
(
NULL
!=
pSelect
->
pFromTable
&&
QUERY_NODE_TEMP_TABLE
==
nodeType
(
pSelect
->
pFromTable
)
&&
!
isGlobalTimeLineQuery
(((
STempTableNode
*
)
pSelect
->
pFromTable
)
->
pSubquery
)
&&
!
isTimeLineAlignedQuery
(
pCxt
->
pCurrStmt
))
{
!
isGlobalTimeLineQuery
(((
STempTableNode
*
)
pSelect
->
pFromTable
)
->
pSubquery
)
&&
!
isTimeLineAlignedQuery
(
pCxt
->
pCurrStmt
))
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_NOT_ALLOWED_FUNC
,
"%s function requires valid time series input"
,
pFunc
->
functionName
);
}
...
...
@@ -2308,7 +2313,8 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
}
}
if
(
isScanPseudoColumnFunc
(
*
pNode
)
||
QUERY_NODE_COLUMN
==
nodeType
(
*
pNode
))
{
if
(
pSelect
->
selectFuncNum
>
1
||
pSelect
->
hasOtherVectorFunc
||
!
pSelect
->
hasSelectFunc
||
(
isDistinctOrderBy
(
pCxt
)
&&
pCxt
->
currClause
==
SQL_CLAUSE_ORDER_BY
))
{
if
(
pSelect
->
selectFuncNum
>
1
||
pSelect
->
hasOtherVectorFunc
||
!
pSelect
->
hasSelectFunc
||
(
isDistinctOrderBy
(
pCxt
)
&&
pCxt
->
currClause
==
SQL_CLAUSE_ORDER_BY
))
{
return
generateDealNodeErrMsg
(
pCxt
,
getGroupByErrorCode
(
pCxt
),
((
SExprNode
*
)(
*
pNode
))
->
userAlias
);
}
else
{
return
rewriteColToSelectValFunc
(
pCxt
,
pNode
);
...
...
@@ -2403,14 +2409,14 @@ static int32_t checkHavingGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect)
if
(
NULL
!=
pSelect
->
pHaving
)
{
code
=
checkExprForGroupBy
(
pCxt
,
&
pSelect
->
pHaving
);
}
/*
/*
if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pProjectionList) {
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pProjectionList);
}
if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pOrderByList) {
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pOrderByList);
}
*/
*/
return
code
;
}
...
...
@@ -2669,9 +2675,9 @@ static int32_t setTableCacheLastMode(STranslateContext* pCxt, SSelectStmt* pSele
static
EDealRes
doTranslateTbName
(
SNode
**
pNode
,
void
*
pContext
)
{
switch
(
nodeType
(
*
pNode
))
{
case
QUERY_NODE_FUNCTION
:
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
*
pNode
;
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
*
pNode
;
if
(
FUNCTION_TYPE_TBNAME
==
pFunc
->
funcType
)
{
SRewriteTbNameContext
*
pCxt
=
(
SRewriteTbNameContext
*
)
pContext
;
SRewriteTbNameContext
*
pCxt
=
(
SRewriteTbNameContext
*
)
pContext
;
SValueNode
*
pVal
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
if
(
NULL
==
pVal
)
{
pCxt
->
errCode
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -2711,7 +2717,8 @@ static int32_t replaceTbName(STranslateContext* pCxt, SSelectStmt* pSelect) {
}
SRealTableNode
*
pTable
=
(
SRealTableNode
*
)
pSelect
->
pFromTable
;
if
(
TSDB_CHILD_TABLE
!=
pTable
->
pMeta
->
tableType
&&
TSDB_NORMAL_TABLE
!=
pTable
->
pMeta
->
tableType
&&
TSDB_SYSTEM_TABLE
!=
pTable
->
pMeta
->
tableType
)
{
if
(
TSDB_CHILD_TABLE
!=
pTable
->
pMeta
->
tableType
&&
TSDB_NORMAL_TABLE
!=
pTable
->
pMeta
->
tableType
&&
TSDB_SYSTEM_TABLE
!=
pTable
->
pMeta
->
tableType
)
{
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -3122,7 +3129,8 @@ static int32_t convertFillValue(STranslateContext* pCxt, SDataType dt, SNodeList
code
=
scalarCalculateConstants
(
pCastFunc
,
&
pCell
->
pNode
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
QUERY_NODE_VALUE
!=
nodeType
(
pCell
->
pNode
))
{
code
=
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
"Fill value can only accept constant"
);
code
=
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
"Fill value can only accept constant"
);
}
else
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
code
=
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
"Filled data type mismatch"
);
}
...
...
@@ -3588,7 +3596,6 @@ static int32_t createDefaultEveryNode(STranslateContext* pCxt, SNode** pOutput)
pEvery
->
isDuration
=
true
;
pEvery
->
literal
=
taosStrdup
(
"1s"
);
*
pOutput
=
(
SNode
*
)
pEvery
;
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -3687,8 +3694,8 @@ static int32_t translatePartitionBy(STranslateContext* pCxt, SSelectStmt* pSelec
if
(
pSelect
->
pPartitionByList
)
{
int8_t
typeType
=
getTableTypeFromTableNode
(
pSelect
->
pFromTable
);
SNode
*
pPar
=
nodesListGetNode
(
pSelect
->
pPartitionByList
,
0
);
if
(
!
((
TSDB_NORMAL_TABLE
==
typeType
||
TSDB_CHILD_TABLE
==
typeType
)
&&
1
==
pSelect
->
pPartitionByList
->
length
&&
(
QUERY_NODE_FUNCTION
==
nodeType
(
pPar
)
&&
FUNCTION_TYPE_TBNAME
==
((
SFunctionNode
*
)
pPar
)
->
funcType
)))
{
if
(
!
((
TSDB_NORMAL_TABLE
==
typeType
||
TSDB_CHILD_TABLE
==
typeType
)
&&
1
==
pSelect
->
pPartitionByList
->
length
&&
(
QUERY_NODE_FUNCTION
==
nodeType
(
pPar
)
&&
FUNCTION_TYPE_TBNAME
==
((
SFunctionNode
*
)
pPar
)
->
funcType
)))
{
pSelect
->
timeLineResMode
=
TIME_LINE_MULTI
;
}
...
...
@@ -3955,9 +3962,9 @@ static int32_t translateSetOperProject(STranslateContext* pCxt, SSetOperator* pS
}
snprintf
(
pRightExpr
->
aliasName
,
sizeof
(
pRightExpr
->
aliasName
),
"%s"
,
pLeftExpr
->
aliasName
);
SNode
*
pProj
=
createSetOperProject
(
pSetOperator
->
stmtName
,
pLeft
);
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pLeft
)
&&
QUERY_NODE_COLUMN
==
nodeType
(
pRight
)
&&
((
SColumnNode
*
)
pLeft
)
->
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
&&
((
SColumnNode
*
)
pRight
)
->
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pLeft
)
&&
QUERY_NODE_COLUMN
==
nodeType
(
pRight
)
&&
((
SColumnNode
*
)
pLeft
)
->
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
&&
((
SColumnNode
*
)
pRight
)
->
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
((
SColumnNode
*
)
pProj
)
->
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
}
if
(
TSDB_CODE_SUCCESS
!=
nodesListMakeStrictAppend
(
&
pSetOperator
->
pProjectionList
,
pProj
))
{
...
...
@@ -5737,7 +5744,6 @@ static int32_t translateRestoreDnode(STranslateContext* pCxt, SRestoreComponentN
return
buildCmdMsg
(
pCxt
,
TDMT_MND_RESTORE_DNODE
,
(
FSerializeFunc
)
tSerializeSRestoreDnodeReq
,
&
restoreReq
);
}
static
int32_t
getSmaIndexDstVgId
(
STranslateContext
*
pCxt
,
const
char
*
pDbName
,
const
char
*
pTableName
,
int32_t
*
pVgId
)
{
SVgroupInfo
vg
=
{
0
};
...
...
@@ -5879,13 +5885,15 @@ int32_t createIntervalFromCreateSmaIndexStmt(SCreateIndexStmt* pStmt, SInterval*
pInterval
->
interval
=
((
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
->
datum
.
i
;
pInterval
->
intervalUnit
=
((
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
->
unit
;
pInterval
->
offset
=
NULL
!=
pStmt
->
pOptions
->
pOffset
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pOffset
)
->
datum
.
i
:
0
;
pInterval
->
sliding
=
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
datum
.
i
:
pInterval
->
interval
;
pInterval
->
slidingUnit
=
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
unit
:
pInterval
->
intervalUnit
;
pInterval
->
sliding
=
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
datum
.
i
:
pInterval
->
interval
;
pInterval
->
slidingUnit
=
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
unit
:
pInterval
->
intervalUnit
;
pInterval
->
precision
=
pStmt
->
pOptions
->
tsPrecision
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
translatePostCreateSmaIndex
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
,
void
**
pResRow
)
{
int32_t
translatePostCreateSmaIndex
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
,
void
**
pResRow
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SCreateIndexStmt
*
pStmt
=
(
SCreateIndexStmt
*
)
pQuery
->
pRoot
;
int64_t
lastTs
=
0
;
...
...
@@ -6053,7 +6061,7 @@ static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pS
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
subDbName
,
pStmt
->
subSTbName
,
&
name
);
tNameGetFullDbName
(
&
name
,
pReq
->
subDbName
);
tNameExtractFullName
(
&
name
,
pReq
->
subStbName
);
if
(
pStmt
->
pQuery
!=
NULL
)
{
if
(
pStmt
->
pQuery
!=
NULL
)
{
code
=
nodesNodeToString
(
pStmt
->
pQuery
,
false
,
&
pReq
->
ast
,
NULL
);
}
}
else
if
(
'\0'
!=
pStmt
->
subDbName
[
0
])
{
...
...
@@ -6112,7 +6120,8 @@ static EDealRes checkColumnTagsInCond(SNode* pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
static
int32_t
checkCollectTopicTags
(
STranslateContext
*
pCxt
,
SCreateTopicStmt
*
pStmt
,
STableMeta
*
pMeta
,
SNodeList
**
ppProjection
)
{
static
int32_t
checkCollectTopicTags
(
STranslateContext
*
pCxt
,
SCreateTopicStmt
*
pStmt
,
STableMeta
*
pMeta
,
SNodeList
**
ppProjection
)
{
SBuildTopicContext
colCxt
=
{.
colExists
=
false
,
.
colNotFound
=
false
,
.
pMeta
=
pMeta
,
.
pTags
=
NULL
};
nodesWalkExprPostOrder
(
pStmt
->
pWhere
,
checkColumnTagsInCond
,
&
colCxt
);
if
(
colCxt
.
colNotFound
)
{
...
...
@@ -6123,7 +6132,7 @@ static int32_t checkCollectTopicTags(STranslateContext* pCxt, SCreateTopicStmt*
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_SYNTAX_ERROR
,
"Columns are forbidden in where clause"
);
}
if
(
NULL
==
colCxt
.
pTags
)
{
// put one column to select
// for (int32_t i = 0; i < pMeta->tableInfo.numOfColumns; ++i) {
// for (int32_t i = 0; i < pMeta->tableInfo.numOfColumns; ++i) {
SSchema
*
column
=
&
pMeta
->
schema
[
0
];
SColumnNode
*
col
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
col
)
{
...
...
@@ -6133,7 +6142,7 @@ static int32_t checkCollectTopicTags(STranslateContext* pCxt, SCreateTopicStmt*
strcpy
(
col
->
node
.
aliasName
,
col
->
colName
);
strcpy
(
col
->
node
.
userAlias
,
col
->
colName
);
addTagList
(
&
colCxt
.
pTags
,
(
SNode
*
)
col
);
// }
// }
}
*
ppProjection
=
colCxt
.
pTags
;
...
...
@@ -6554,7 +6563,8 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_STREAM_QUERY
,
"SUBTABLE expression must be of VARCHAR type"
);
}
if
(
NULL
!=
pSelect
->
pSubtable
&&
0
==
LIST_LENGTH
(
pSelect
->
pPartitionByList
)
&&
subtableExprHasColumnOrPseudoColumn
(
pSelect
->
pSubtable
))
{
if
(
NULL
!=
pSelect
->
pSubtable
&&
0
==
LIST_LENGTH
(
pSelect
->
pPartitionByList
)
&&
subtableExprHasColumnOrPseudoColumn
(
pSelect
->
pSubtable
))
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_STREAM_QUERY
,
"SUBTABLE expression must not has column when no partition by clause"
);
}
...
...
@@ -6915,13 +6925,13 @@ static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta
strcpy
(
col
->
colName
,
pMeta
->
schema
[
0
].
name
);
SNodeList
*
pParamterList
=
nodesMakeList
();
if
(
NULL
==
pParamterList
)
{
nodesDestroyNode
((
SNode
*
)
col
);
nodesDestroyNode
((
SNode
*
)
col
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
code
=
nodesListStrictAppend
(
pParamterList
,
(
SNode
*
)
col
);
int32_t
code
=
nodesListStrictAppend
(
pParamterList
,
(
SNode
*
)
col
);
if
(
code
)
{
nodesDestroyNode
((
SNode
*
)
col
);
nodesDestroyNode
((
SNode
*
)
col
);
nodesDestroyList
(
pParamterList
);
return
code
;
}
...
...
@@ -6944,7 +6954,7 @@ static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta
return
code
;
}
code
=
createSimpleSelectStmtFromProjList
(
pDb
,
pTable
,
pProjectionList
,
(
SSelectStmt
**
)
pQuery
);
code
=
createSimpleSelectStmtFromProjList
(
pDb
,
pTable
,
pProjectionList
,
(
SSelectStmt
**
)
pQuery
);
if
(
code
)
{
nodesDestroyList
(
pProjectionList
);
return
code
;
...
...
@@ -6982,14 +6992,14 @@ static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt
if
(
TSDB_CODE_SUCCESS
==
code
&&
pStmt
->
pOptions
->
fillHistory
)
{
SRealTableNode
*
pTable
=
(
SRealTableNode
*
)(((
SSelectStmt
*
)
pStmt
->
pQuery
)
->
pFromTable
);
code
=
createLastTsSelectStmt
(
pTable
->
table
.
dbName
,
pTable
->
table
.
tableName
,
pTable
->
pMeta
,
&
pStmt
->
pPrevQuery
);
/*
/*
if (TSDB_CODE_SUCCESS == code) {
STranslateContext cxt = {0};
int32_t code = initTranslateContext(pCxt->pParseCxt, pCxt->pMetaCache, &cxt);
code = translateQuery(&cxt, pStmt->pPrevQuery);
destroyTranslateContext(&cxt);
}
*/
*/
}
taosMemoryFree
(
pMeta
);
return
code
;
...
...
@@ -7136,7 +7146,6 @@ int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, void
return
code
;
}
static
int32_t
translateDropStream
(
STranslateContext
*
pCxt
,
SDropStreamStmt
*
pStmt
)
{
SMDropStreamReq
dropReq
=
{
0
};
SName
name
;
...
...
@@ -7821,7 +7830,8 @@ static SNodeList* createProjectCols(int32_t ncols, const char* const pCols[]) {
return
pProjections
;
}
static
int32_t
createSimpleSelectStmtImpl
(
const
char
*
pDb
,
const
char
*
pTable
,
SNodeList
*
pProjectionList
,
SSelectStmt
**
pStmt
)
{
static
int32_t
createSimpleSelectStmtImpl
(
const
char
*
pDb
,
const
char
*
pTable
,
SNodeList
*
pProjectionList
,
SSelectStmt
**
pStmt
)
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
nodesMakeNode
(
QUERY_NODE_SELECT_STMT
);
if
(
NULL
==
pSelect
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -7844,7 +7854,6 @@ static int32_t createSimpleSelectStmtImpl(const char* pDb, const char* pTable, S
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
createSimpleSelectStmtFromCols
(
const
char
*
pDb
,
const
char
*
pTable
,
int32_t
numOfProjs
,
const
char
*
const
pProjCol
[],
SSelectStmt
**
pStmt
)
{
SNodeList
*
pProjectionList
=
NULL
;
...
...
@@ -7858,13 +7867,15 @@ static int32_t createSimpleSelectStmtFromCols(const char* pDb, const char* pTabl
return
createSimpleSelectStmtImpl
(
pDb
,
pTable
,
pProjectionList
,
pStmt
);
}
static
int32_t
createSimpleSelectStmtFromProjList
(
const
char
*
pDb
,
const
char
*
pTable
,
SNodeList
*
pProjectionList
,
SSelectStmt
**
pStmt
)
{
static
int32_t
createSimpleSelectStmtFromProjList
(
const
char
*
pDb
,
const
char
*
pTable
,
SNodeList
*
pProjectionList
,
SSelectStmt
**
pStmt
)
{
return
createSimpleSelectStmtImpl
(
pDb
,
pTable
,
pProjectionList
,
pStmt
);
}
static
int32_t
createSelectStmtForShow
(
ENodeType
showType
,
SSelectStmt
**
pStmt
)
{
const
SSysTableShowAdapter
*
pShow
=
&
sysTableShowAdapter
[
showType
-
SYSTABLE_SHOW_TYPE_OFFSET
];
return
createSimpleSelectStmtFromCols
(
pShow
->
pDbName
,
pShow
->
pTableName
,
pShow
->
numOfShowCols
,
pShow
->
pShowCols
,
pStmt
);
return
createSimpleSelectStmtFromCols
(
pShow
->
pDbName
,
pShow
->
pTableName
,
pShow
->
numOfShowCols
,
pShow
->
pShowCols
,
pStmt
);
}
static
int32_t
createSelectStmtForShowTableDist
(
SShowTableDistributedStmt
*
pStmt
,
SSelectStmt
**
pOutput
)
{
...
...
@@ -8002,8 +8013,8 @@ static int32_t createShowTableTagsProjections(SNodeList** pProjections, SNodeLis
static
int32_t
rewriteShowStableTags
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
SShowTableTagsStmt
*
pShow
=
(
SShowTableTagsStmt
*
)
pQuery
->
pRoot
;
SSelectStmt
*
pSelect
=
NULL
;
int32_t
code
=
createSimpleSelectStmtFromCols
(((
SValueNode
*
)
pShow
->
pDbName
)
->
literal
,
((
SValueNode
*
)
pShow
->
pT
bName
)
->
literal
,
-
1
,
NULL
,
&
pSelect
);
int32_t
code
=
createSimpleSelectStmtFromCols
(((
SValueNode
*
)
pShow
->
pD
bName
)
->
literal
,
((
SValueNode
*
)
pShow
->
pTbName
)
->
literal
,
-
1
,
NULL
,
&
pSelect
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createShowTableTagsProjections
(
&
pSelect
->
pProjectionList
,
&
pShow
->
pTags
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录