Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1676bfe5
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
1676bfe5
编写于
6月 14, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: some problems of parser
上级
63e78e3e
变更
18
展开全部
隐藏空白更改
内联
并排
Showing
18 changed file
with
804 addition
and
697 deletion
+804
-697
include/libs/parser/parser.h
include/libs/parser/parser.h
+1
-0
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/client/src/clientMain.c
source/client/src/clientMain.c
+4
-0
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+1
-1
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+8
-4
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+113
-46
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+2
-0
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+2
-0
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+605
-604
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+15
-15
source/libs/parser/test/parInitialATest.cpp
source/libs/parser/test/parInitialATest.cpp
+12
-6
source/libs/parser/test/parInitialCTest.cpp
source/libs/parser/test/parInitialCTest.cpp
+3
-1
source/libs/parser/test/parInsertTest.cpp
source/libs/parser/test/parInsertTest.cpp
+4
-4
source/libs/parser/test/parSelectTest.cpp
source/libs/parser/test/parSelectTest.cpp
+12
-2
source/libs/parser/test/parTestUtil.cpp
source/libs/parser/test/parTestUtil.cpp
+4
-2
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+3
-0
source/libs/planner/test/planGroupByTest.cpp
source/libs/planner/test/planGroupByTest.cpp
+2
-0
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+12
-12
未找到文件。
include/libs/parser/parser.h
浏览文件 @
1676bfe5
...
@@ -65,6 +65,7 @@ void qDestroyQuery(SQuery* pQueryNode);
...
@@ -65,6 +65,7 @@ void qDestroyQuery(SQuery* pQueryNode);
int32_t
qExtractResultSchema
(
const
SNode
*
pRoot
,
int32_t
*
numOfCols
,
SSchema
**
pSchema
);
int32_t
qExtractResultSchema
(
const
SNode
*
pRoot
,
int32_t
*
numOfCols
,
SSchema
**
pSchema
);
int32_t
qSetSTableIdForRsma
(
SNode
*
pStmt
,
int64_t
uid
);
int32_t
qSetSTableIdForRsma
(
SNode
*
pStmt
,
int64_t
uid
);
void
qCleanupKeywordsTable
();
int32_t
qBuildStmtOutput
(
SQuery
*
pQuery
,
SHashObj
*
pVgHash
,
SHashObj
*
pBlockHash
);
int32_t
qBuildStmtOutput
(
SQuery
*
pQuery
,
SHashObj
*
pVgHash
,
SHashObj
*
pBlockHash
);
int32_t
qResetStmtDataBlock
(
void
*
block
,
bool
keepBuf
);
int32_t
qResetStmtDataBlock
(
void
*
block
,
bool
keepBuf
);
...
...
include/util/taoserror.h
浏览文件 @
1676bfe5
...
@@ -653,6 +653,7 @@ int32_t* taosGetErrno();
...
@@ -653,6 +653,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INVALID_DELETE_WHERE TAOS_DEF_ERROR_CODE(0, 0x2655)
#define TSDB_CODE_PAR_INVALID_DELETE_WHERE TAOS_DEF_ERROR_CODE(0, 0x2655)
#define TSDB_CODE_PAR_INVALID_REDISTRIBUTE_VG TAOS_DEF_ERROR_CODE(0, 0x2656)
#define TSDB_CODE_PAR_INVALID_REDISTRIBUTE_VG TAOS_DEF_ERROR_CODE(0, 0x2656)
#define TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2657)
#define TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x2657)
#define TSDB_CODE_PAR_INVALID_WINDOW_PC TAOS_DEF_ERROR_CODE(0, 0x2658)
//planner
//planner
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
...
...
source/client/src/clientMain.c
浏览文件 @
1676bfe5
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include "tref.h"
#include "tref.h"
#include "trpc.h"
#include "trpc.h"
#include "version.h"
#include "version.h"
#include "functionMgt.h"
#define TSC_VAR_NOT_RELEASE 1
#define TSC_VAR_NOT_RELEASE 1
#define TSC_VAR_RELEASED 0
#define TSC_VAR_RELEASED 0
...
@@ -61,6 +62,9 @@ void taos_cleanup(void) {
...
@@ -61,6 +62,9 @@ void taos_cleanup(void) {
cleanupTaskQueue
();
cleanupTaskQueue
();
fmFuncMgtDestroy
();
qCleanupKeywordsTable
();
id
=
clientConnRefPool
;
id
=
clientConnRefPool
;
clientConnRefPool
=
-
1
;
clientConnRefPool
=
-
1
;
taosCloseRef
(
id
);
taosCloseRef
(
id
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
1676bfe5
...
@@ -255,7 +255,7 @@ multi_create_clause(A) ::= multi_create_clause(B) create_subtable_clause(C).
...
@@ -255,7 +255,7 @@ multi_create_clause(A) ::= multi_create_clause(B) create_subtable_clause(C).
create_subtable_clause(A) ::=
create_subtable_clause(A) ::=
not_exists_opt(B) full_table_name(C) USING full_table_name(D)
not_exists_opt(B) full_table_name(C) USING full_table_name(D)
specific_tags_opt(E) TAGS NK_LP
literal_list(F) NK_RP table_options(G).
{ A = createCreateSubTableClause(pCxt, B, C, D, E, F, G); }
specific_tags_opt(E) TAGS NK_LP
expression_list(F) NK_RP table_options(G).
{ A = createCreateSubTableClause(pCxt, B, C, D, E, F, G); }
%type multi_drop_clause { SNodeList* }
%type multi_drop_clause { SNodeList* }
%destructor multi_drop_clause { nodesDestroyList($$); }
%destructor multi_drop_clause { nodesDestroyList($$); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
1676bfe5
...
@@ -230,9 +230,13 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) {
...
@@ -230,9 +230,13 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) {
SRawExprNode
*
pRawExpr
=
(
SRawExprNode
*
)
pNode
;
SRawExprNode
*
pRawExpr
=
(
SRawExprNode
*
)
pNode
;
SNode
*
pExpr
=
pRawExpr
->
pNode
;
SNode
*
pExpr
=
pRawExpr
->
pNode
;
if
(
nodesIsExprNode
(
pExpr
))
{
if
(
nodesIsExprNode
(
pExpr
))
{
int32_t
len
=
TMIN
(
sizeof
(((
SExprNode
*
)
pExpr
)
->
aliasName
)
-
1
,
pRawExpr
->
n
);
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pExpr
))
{
strncpy
(((
SExprNode
*
)
pExpr
)
->
aliasName
,
pRawExpr
->
p
,
len
);
strcpy
(((
SExprNode
*
)
pExpr
)
->
aliasName
,
((
SColumnNode
*
)
pExpr
)
->
colName
);
((
SExprNode
*
)
pExpr
)
->
aliasName
[
len
]
=
'\0'
;
}
else
{
int32_t
len
=
TMIN
(
sizeof
(((
SExprNode
*
)
pExpr
)
->
aliasName
)
-
1
,
pRawExpr
->
n
);
strncpy
(((
SExprNode
*
)
pExpr
)
->
aliasName
,
pRawExpr
->
p
,
len
);
((
SExprNode
*
)
pExpr
)
->
aliasName
[
len
]
=
'\0'
;
}
}
}
taosMemoryFreeClear
(
pNode
);
taosMemoryFreeClear
(
pNode
);
return
pExpr
;
return
pExpr
;
...
@@ -801,7 +805,7 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti
...
@@ -801,7 +805,7 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti
((
SDatabaseOptions
*
)
pOptions
)
->
pRetentions
=
pVal
;
((
SDatabaseOptions
*
)
pOptions
)
->
pRetentions
=
pVal
;
break
;
break
;
case
DB_OPTION_SCHEMALESS
:
case
DB_OPTION_SCHEMALESS
:
// ((SDatabaseOptions*)pOptions)->schemaless = taosStr2Int8(((SToken*)pVal)->z, NULL, 10);
// ((SDatabaseOptions*)pOptions)->schemaless = taosStr2Int8(((SToken*)pVal)->z, NULL, 10);
((
SDatabaseOptions
*
)
pOptions
)
->
schemaless
=
1
;
((
SDatabaseOptions
*
)
pOptions
)
->
schemaless
=
1
;
break
;
break
;
default:
default:
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
1676bfe5
...
@@ -537,13 +537,15 @@ static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef,
...
@@ -537,13 +537,15 @@ static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef,
SNode
*
pNode
;
SNode
*
pNode
;
FOREACH
(
pNode
,
pProjectList
)
{
FOREACH
(
pNode
,
pProjectList
)
{
SExprNode
*
pExpr
=
(
SExprNode
*
)
pNode
;
SExprNode
*
pExpr
=
(
SExprNode
*
)
pNode
;
if
(
0
==
strcmp
(
pCol
->
colName
,
pExpr
->
aliasName
)
||
if
(
0
==
strcmp
(
pCol
->
colName
,
pExpr
->
aliasName
))
{
(
isPrimaryKey
((
STempTableNode
*
)
pTable
,
pNode
)
&&
isInternalPrimaryKey
(
pCol
)))
{
if
(
*
pFound
)
{
if
(
*
pFound
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_AMBIGUOUS_COLUMN
,
pCol
->
colName
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_AMBIGUOUS_COLUMN
,
pCol
->
colName
);
}
}
setColumnInfoByExpr
(
pTable
,
pExpr
,
pColRef
);
setColumnInfoByExpr
(
pTable
,
pExpr
,
pColRef
);
*
pFound
=
true
;
*
pFound
=
true
;
}
else
if
(
isPrimaryKey
((
STempTableNode
*
)
pTable
,
pNode
)
&&
isInternalPrimaryKey
(
pCol
))
{
setColumnInfoByExpr
(
pTable
,
pExpr
,
pColRef
);
*
pFound
=
true
;
}
}
}
}
}
}
...
@@ -662,9 +664,24 @@ static int32_t parseTimeFromValueNode(STranslateContext* pCxt, SValueNode* pVal)
...
@@ -662,9 +664,24 @@ static int32_t parseTimeFromValueNode(STranslateContext* pCxt, SValueNode* pVal)
}
}
char
*
pEnd
=
NULL
;
char
*
pEnd
=
NULL
;
pVal
->
datum
.
i
=
taosStr2Int64
(
pVal
->
literal
,
&
pEnd
,
10
);
pVal
->
datum
.
i
=
taosStr2Int64
(
pVal
->
literal
,
&
pEnd
,
10
);
return
(
NULL
!=
pEnd
&&
'\0'
==
*
pEnd
)
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_
FAILED
;
return
(
NULL
!=
pEnd
&&
'\0'
==
*
pEnd
)
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_
PAR_WRONG_VALUE_TYPE
;
}
else
{
}
else
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_PAR_WRONG_VALUE_TYPE
;
}
}
static
int32_t
parseBoolFromValueNode
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
if
(
IS_VAR_DATA_TYPE
(
pVal
->
node
.
resType
.
type
)
||
TSDB_DATA_TYPE_BOOL
==
pVal
->
node
.
resType
.
type
)
{
pVal
->
datum
.
b
=
(
0
==
strcasecmp
(
pVal
->
literal
,
"true"
));
return
TSDB_CODE_SUCCESS
;
}
else
if
(
IS_INTEGER_TYPE
(
pVal
->
node
.
resType
.
type
))
{
pVal
->
datum
.
b
=
(
0
!=
taosStr2Int64
(
pVal
->
literal
,
NULL
,
10
));
return
TSDB_CODE_SUCCESS
;
}
else
if
(
IS_FLOAT_TYPE
(
pVal
->
node
.
resType
.
type
))
{
pVal
->
datum
.
b
=
(
0
!=
taosStr2Double
(
pVal
->
literal
,
NULL
));
return
TSDB_CODE_SUCCESS
;
}
else
{
return
TSDB_CODE_PAR_WRONG_VALUE_TYPE
;
}
}
}
}
...
@@ -685,7 +702,9 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
...
@@ -685,7 +702,9 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
case
TSDB_DATA_TYPE_NULL
:
case
TSDB_DATA_TYPE_NULL
:
break
;
break
;
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BOOL
:
pVal
->
datum
.
b
=
(
0
==
strcasecmp
(
pVal
->
literal
,
"true"
));
if
(
TSDB_CODE_SUCCESS
!=
parseBoolFromValueNode
(
pCxt
,
pVal
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
*
(
bool
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
b
;
*
(
bool
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
b
;
break
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
{
case
TSDB_DATA_TYPE_TINYINT
:
{
...
@@ -1068,6 +1087,16 @@ static int32_t translateForbidFillFunc(STranslateContext* pCxt, SFunctionNode* p
...
@@ -1068,6 +1087,16 @@ static int32_t translateForbidFillFunc(STranslateContext* pCxt, SFunctionNode* p
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
translateWindowPseudoColumnFunc
(
STranslateContext
*
pCxt
,
SFunctionNode
*
pFunc
)
{
if
(
!
fmIsWindowPseudoColumnFunc
(
pFunc
->
funcId
))
{
return
TSDB_CODE_SUCCESS
;
}
if
(
NULL
==
pCxt
->
pCurrSelectStmt
->
pWindow
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_WINDOW_PC
);
}
return
TSDB_CODE_SUCCESS
;
}
static
void
setFuncClassification
(
SSelectStmt
*
pSelect
,
SFunctionNode
*
pFunc
)
{
static
void
setFuncClassification
(
SSelectStmt
*
pSelect
,
SFunctionNode
*
pFunc
)
{
if
(
NULL
!=
pSelect
)
{
if
(
NULL
!=
pSelect
)
{
pSelect
->
hasAggFuncs
=
pSelect
->
hasAggFuncs
?
true
:
fmIsAggFunc
(
pFunc
->
funcId
);
pSelect
->
hasAggFuncs
=
pSelect
->
hasAggFuncs
?
true
:
fmIsAggFunc
(
pFunc
->
funcId
);
...
@@ -1097,6 +1126,9 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc)
...
@@ -1097,6 +1126,9 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc)
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
pCxt
->
errCode
=
translateForbidFillFunc
(
pCxt
,
pFunc
);
pCxt
->
errCode
=
translateForbidFillFunc
(
pCxt
,
pFunc
);
}
}
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
pCxt
->
errCode
=
translateWindowPseudoColumnFunc
(
pCxt
,
pFunc
);
}
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
if
(
TSDB_CODE_SUCCESS
==
pCxt
->
errCode
)
{
setFuncClassification
(
pCxt
->
pCurrSelectStmt
,
pFunc
);
setFuncClassification
(
pCxt
->
pCurrSelectStmt
,
pFunc
);
}
}
...
@@ -3106,7 +3138,11 @@ static int32_t translateDropSuperTable(STranslateContext* pCxt, SDropSuperTableS
...
@@ -3106,7 +3138,11 @@ static int32_t translateDropSuperTable(STranslateContext* pCxt, SDropSuperTableS
pStmt
->
ignoreNotExists
);
pStmt
->
ignoreNotExists
);
}
}
static
int32_t
setAlterTableField
(
SAlterTableStmt
*
pStmt
,
SMAlterStbReq
*
pAlterReq
)
{
static
int32_t
buildAlterSuperTableReq
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
,
SMAlterStbReq
*
pAlterReq
)
{
SName
tableName
;
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
tableName
),
pAlterReq
->
name
);
pAlterReq
->
alterType
=
pStmt
->
alterType
;
if
(
TSDB_ALTER_TABLE_UPDATE_OPTIONS
==
pStmt
->
alterType
)
{
if
(
TSDB_ALTER_TABLE_UPDATE_OPTIONS
==
pStmt
->
alterType
)
{
pAlterReq
->
ttl
=
pStmt
->
pOptions
->
ttl
;
pAlterReq
->
ttl
=
pStmt
->
pOptions
->
ttl
;
if
(
'\0'
!=
pStmt
->
pOptions
->
comment
[
0
])
{
if
(
'\0'
!=
pStmt
->
pOptions
->
comment
[
0
])
{
...
@@ -3154,15 +3190,45 @@ static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAlterStbReq* pAlterR
...
@@ -3154,15 +3190,45 @@ static int32_t setAlterTableField(SAlterTableStmt* pStmt, SMAlterStbReq* pAlterR
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
translateAlterTable
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
static
SSchema
*
getColSchema
(
STableMeta
*
pTableMeta
,
const
char
*
pTagName
)
{
SMAlterStbReq
alterReq
=
{
0
};
int32_t
numOfFields
=
getNumOfTags
(
pTableMeta
)
+
getNumOfColumns
(
pTableMeta
);
SName
tableName
;
for
(
int32_t
i
=
0
;
i
<
numOfFields
;
++
i
)
{
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
tableName
),
alterReq
.
name
);
SSchema
*
pTagSchema
=
pTableMeta
->
schema
+
i
;
alterReq
.
alterType
=
pStmt
->
alterType
;
if
(
0
==
strcmp
(
pTagName
,
pTagSchema
->
name
))
{
return
pTagSchema
;
}
}
return
NULL
;
}
static
int32_t
checkAlterSuperTable
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
if
(
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
==
pStmt
->
alterType
||
TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
==
pStmt
->
alterType
)
{
if
(
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
==
pStmt
->
alterType
||
TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME
==
pStmt
->
alterType
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ALTER_TABLE
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ALTER_TABLE
);
}
}
int32_t
code
=
setAlterTableField
(
pStmt
,
&
alterReq
);
if
(
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
==
pStmt
->
alterType
||
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
==
pStmt
->
alterType
)
{
STableMeta
*
pTableMeta
=
NULL
;
int32_t
code
=
getTableMeta
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
pTableMeta
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
SSchema
*
pSchema
=
getColSchema
(
pTableMeta
,
pStmt
->
colName
);
if
(
NULL
==
pSchema
)
{
code
=
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_COLUMN
,
pStmt
->
colName
);
}
else
if
(
!
IS_VAR_DATA_TYPE
(
pSchema
->
type
)
||
pSchema
->
type
!=
pStmt
->
dataType
.
type
||
pSchema
->
bytes
>=
pStmt
->
dataType
.
bytes
)
{
code
=
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_MODIFY_COL
);
}
}
return
code
;
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateAlterSuperTable
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
)
{
SMAlterStbReq
alterReq
=
{
0
};
int32_t
code
=
checkAlterSuperTable
(
pCxt
,
pStmt
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
buildAlterSuperTableReq
(
pCxt
,
pStmt
,
&
alterReq
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
buildCmdMsg
(
pCxt
,
TDMT_MND_ALTER_STB
,
(
FSerializeFunc
)
tSerializeSMAlterStbReq
,
&
alterReq
);
code
=
buildCmdMsg
(
pCxt
,
TDMT_MND_ALTER_STB
,
(
FSerializeFunc
)
tSerializeSMAlterStbReq
,
&
alterReq
);
}
}
...
@@ -3835,7 +3901,7 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
...
@@ -3835,7 +3901,7 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
code
=
translateDropSuperTable
(
pCxt
,
(
SDropSuperTableStmt
*
)
pNode
);
code
=
translateDropSuperTable
(
pCxt
,
(
SDropSuperTableStmt
*
)
pNode
);
break
;
break
;
case
QUERY_NODE_ALTER_TABLE_STMT
:
case
QUERY_NODE_ALTER_TABLE_STMT
:
code
=
translateAlterTable
(
pCxt
,
(
SAlterTableStmt
*
)
pNode
);
code
=
translateAlter
Super
Table
(
pCxt
,
(
SAlterTableStmt
*
)
pNode
);
break
;
break
;
case
QUERY_NODE_CREATE_USER_STMT
:
case
QUERY_NODE_CREATE_USER_STMT
:
code
=
translateCreateUser
(
pCxt
,
(
SCreateUserStmt
*
)
pNode
);
code
=
translateCreateUser
(
pCxt
,
(
SCreateUserStmt
*
)
pNode
);
...
@@ -4445,8 +4511,32 @@ static int32_t translateTagVal(STranslateContext* pCxt, uint8_t precision, SSche
...
@@ -4445,8 +4511,32 @@ static int32_t translateTagVal(STranslateContext* pCxt, uint8_t precision, SSche
?
pCxt
->
errCode
?
pCxt
->
errCode
:
TSDB_CODE_SUCCESS
);
:
TSDB_CODE_SUCCESS
);
}
else
{
}
else
{
return
TSDB_CODE_FAILED
;
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
((
SExprNode
*
)
pNode
)
->
aliasName
);
}
}
static
int32_t
buildJsonTagVal
(
STranslateContext
*
pCxt
,
SSchema
*
pTagSchema
,
SValueNode
*
pVal
,
SArray
*
pTagArray
,
STag
**
ppTag
)
{
if
(
pVal
->
literal
&&
strlen
(
pVal
->
literal
)
>
(
TSDB_MAX_JSON_TAG_LEN
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
)
{
return
buildSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
"json string too long than 4095"
,
pVal
->
literal
);
}
}
return
parseJsontoTagData
(
pVal
->
literal
,
pTagArray
,
ppTag
,
&
pCxt
->
msgBuf
);
}
static
int32_t
buildNormalTagVal
(
STranslateContext
*
pCxt
,
SSchema
*
pTagSchema
,
SValueNode
*
pVal
,
SArray
*
pTagArray
)
{
if
(
pVal
->
node
.
resType
.
type
!=
TSDB_DATA_TYPE_NULL
)
{
void
*
nodeVal
=
nodesGetValueFromNode
(
pVal
);
STagVal
val
=
{.
cid
=
pTagSchema
->
colId
,
.
type
=
pTagSchema
->
type
};
if
(
IS_VAR_DATA_TYPE
(
pTagSchema
->
type
))
{
val
.
pData
=
varDataVal
(
nodeVal
);
val
.
nData
=
varDataLen
(
nodeVal
);
}
else
{
memcpy
(
&
val
.
i64
,
nodeVal
,
pTagSchema
->
bytes
);
}
taosArrayPush
(
pTagArray
,
&
val
);
}
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
buildKVRowForBindTags
(
STranslateContext
*
pCxt
,
SCreateSubTableClause
*
pStmt
,
STableMeta
*
pSuperTableMeta
,
static
int32_t
buildKVRowForBindTags
(
STranslateContext
*
pCxt
,
SCreateSubTableClause
*
pStmt
,
STableMeta
*
pSuperTableMeta
,
...
@@ -4458,11 +4548,10 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
...
@@ -4458,11 +4548,10 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
}
}
SArray
*
pTagArray
=
taosArrayInit
(
LIST_LENGTH
(
pStmt
->
pValsOfTags
),
sizeof
(
STagVal
));
SArray
*
pTagArray
=
taosArrayInit
(
LIST_LENGTH
(
pStmt
->
pValsOfTags
),
sizeof
(
STagVal
));
if
(
!
pTagArray
)
{
if
(
NULL
==
pTagArray
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_TSC_OUT_OF_MEMORY
)
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int16_t
nTags
=
0
,
nBufPos
=
0
;
SSchema
*
pTagSchema
=
getTableTagSchema
(
pSuperTableMeta
);
SSchema
*
pTagSchema
=
getTableTagSchema
(
pSuperTableMeta
);
SNode
*
pTag
=
NULL
,
*
pNode
=
NULL
;
SNode
*
pTag
=
NULL
,
*
pNode
=
NULL
;
bool
isJson
=
false
;
bool
isJson
=
false
;
...
@@ -4490,27 +4579,12 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
...
@@ -4490,27 +4579,12 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
}
else
{
}
else
{
REPLACE_LIST2_NODE
(
pVal
);
REPLACE_LIST2_NODE
(
pVal
);
}
}
if
(
pTagSchema
->
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
pVal
->
literal
&&
strlen
(
pVal
->
literal
)
>
(
TSDB_MAX_JSON_TAG_LEN
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
)
{
code
=
buildSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
"json string too long than 4095"
,
pVal
->
literal
);
goto
end
;
}
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_JSON
)
{
isJson
=
true
;
isJson
=
true
;
code
=
parseJsontoTagData
(
pVal
->
literal
,
pTagArray
,
ppTag
,
&
pCxt
->
msgBuf
);
code
=
buildJsonTagVal
(
pCxt
,
pSchema
,
pVal
,
pTagArray
,
ppTag
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
end
;
}
}
else
if
(
pVal
->
node
.
resType
.
type
!=
TSDB_DATA_TYPE_NULL
)
{
}
else
if
(
pVal
->
node
.
resType
.
type
!=
TSDB_DATA_TYPE_NULL
)
{
void
*
nodeVal
=
nodesGetValueFromNode
(
pVal
);
code
=
buildNormalTagVal
(
pCxt
,
pSchema
,
pVal
,
pTagArray
);
STagVal
val
=
{.
cid
=
pTagSchema
->
colId
,
.
type
=
pTagSchema
->
type
};
if
(
IS_VAR_DATA_TYPE
(
pTagSchema
->
type
))
{
val
.
pData
=
varDataVal
(
nodeVal
);
val
.
nData
=
varDataLen
(
nodeVal
);
}
else
{
memcpy
(
&
val
.
i64
,
nodeVal
,
pTagSchema
->
bytes
);
}
taosArrayPush
(
pTagArray
,
&
val
);
}
}
}
}
...
@@ -4825,17 +4899,6 @@ static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) {
...
@@ -4825,17 +4899,6 @@ static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) {
return
rewriteToVnodeModifyOpStmt
(
pQuery
,
pBufArray
);
return
rewriteToVnodeModifyOpStmt
(
pQuery
,
pBufArray
);
}
}
static
SSchema
*
getColSchema
(
STableMeta
*
pTableMeta
,
const
char
*
pTagName
)
{
int32_t
numOfFields
=
getNumOfTags
(
pTableMeta
)
+
getNumOfColumns
(
pTableMeta
);
for
(
int32_t
i
=
0
;
i
<
numOfFields
;
++
i
)
{
SSchema
*
pTagSchema
=
pTableMeta
->
schema
+
i
;
if
(
0
==
strcmp
(
pTagName
,
pTagSchema
->
name
))
{
return
pTagSchema
;
}
}
return
NULL
;
}
static
int32_t
buildUpdateTagValReq
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
,
STableMeta
*
pTableMeta
,
static
int32_t
buildUpdateTagValReq
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
,
STableMeta
*
pTableMeta
,
SVAlterTbReq
*
pReq
)
{
SVAlterTbReq
*
pReq
)
{
SSchema
*
pSchema
=
getColSchema
(
pTableMeta
,
pStmt
->
colName
);
SSchema
*
pSchema
=
getColSchema
(
pTableMeta
,
pStmt
->
colName
);
...
@@ -4853,6 +4916,10 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
...
@@ -4853,6 +4916,10 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
return
pCxt
->
errCode
;
return
pCxt
->
errCode
;
}
}
if
(
IS_VAR_DATA_TYPE
(
pSchema
->
type
)
&&
strlen
(
pStmt
->
pVal
->
literal
)
>
pSchema
->
bytes
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pStmt
->
pVal
->
literal
);
}
pReq
->
isNull
=
(
TSDB_DATA_TYPE_NULL
==
pStmt
->
pVal
->
node
.
resType
.
type
);
pReq
->
isNull
=
(
TSDB_DATA_TYPE_NULL
==
pStmt
->
pVal
->
node
.
resType
.
type
);
if
(
pStmt
->
pVal
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
pStmt
->
pVal
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
pStmt
->
pVal
->
literal
&&
if
(
pStmt
->
pVal
->
literal
&&
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
1676bfe5
...
@@ -186,6 +186,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
...
@@ -186,6 +186,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
return
"The REDISTRIBUTE VGROUP statement only support 1 to 3 dnodes"
;
return
"The REDISTRIBUTE VGROUP statement only support 1 to 3 dnodes"
;
case
TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC
:
case
TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC
:
return
"%s function not allowed in fill query"
;
return
"%s function not allowed in fill query"
;
case
TSDB_CODE_PAR_INVALID_WINDOW_PC
:
return
"_WSTARTTS, _WENDTS and _WDURATION can only be used in window queries"
;
case
TSDB_CODE_OUT_OF_MEMORY
:
case
TSDB_CODE_OUT_OF_MEMORY
:
return
"Out of memory"
;
return
"Out of memory"
;
default:
default:
...
...
source/libs/parser/src/parser.c
浏览文件 @
1676bfe5
...
@@ -207,6 +207,8 @@ int32_t qSetSTableIdForRsma(SNode* pStmt, int64_t uid) {
...
@@ -207,6 +207,8 @@ int32_t qSetSTableIdForRsma(SNode* pStmt, int64_t uid) {
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
void
qCleanupKeywordsTable
()
{
taosCleanupKeywordsTable
();
}
int32_t
qStmtBindParams
(
SQuery
*
pQuery
,
TAOS_MULTI_BIND
*
pParams
,
int32_t
colIdx
)
{
int32_t
qStmtBindParams
(
SQuery
*
pQuery
,
TAOS_MULTI_BIND
*
pParams
,
int32_t
colIdx
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
source/libs/parser/src/sql.c
浏览文件 @
1676bfe5
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
1676bfe5
...
@@ -141,16 +141,18 @@ void generateTestT1(MockCatalogService* mcs) {
...
@@ -141,16 +141,18 @@ void generateTestT1(MockCatalogService* mcs) {
* c2 | column | VARCHAR | 20 |
* c2 | column | VARCHAR | 20 |
* tag1 | tag | INT | 4 |
* tag1 | tag | INT | 4 |
* tag2 | tag | VARCHAR | 20 |
* tag2 | tag | VARCHAR | 20 |
* tag3 | tag | TIMESTAMP | 8 |
* Child Table: st1s1, st1s2
* Child Table: st1s1, st1s2
*/
*/
void
generateTestST1
(
MockCatalogService
*
mcs
)
{
void
generateTestST1
(
MockCatalogService
*
mcs
)
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"test"
,
"st1"
,
TSDB_SUPER_TABLE
,
3
,
2
)
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"test"
,
"st1"
,
TSDB_SUPER_TABLE
,
3
,
3
)
.
setPrecision
(
TSDB_TIME_PRECISION_MILLI
)
.
setPrecision
(
TSDB_TIME_PRECISION_MILLI
)
.
addColumn
(
"ts"
,
TSDB_DATA_TYPE_TIMESTAMP
)
.
addColumn
(
"ts"
,
TSDB_DATA_TYPE_TIMESTAMP
)
.
addColumn
(
"c1"
,
TSDB_DATA_TYPE_INT
)
.
addColumn
(
"c1"
,
TSDB_DATA_TYPE_INT
)
.
addColumn
(
"c2"
,
TSDB_DATA_TYPE_BINARY
,
20
)
.
addColumn
(
"c2"
,
TSDB_DATA_TYPE_BINARY
,
20
)
.
addTag
(
"tag1"
,
TSDB_DATA_TYPE_INT
)
.
addTag
(
"tag1"
,
TSDB_DATA_TYPE_INT
)
.
addTag
(
"tag2"
,
TSDB_DATA_TYPE_BINARY
,
20
);
.
addTag
(
"tag2"
,
TSDB_DATA_TYPE_BINARY
,
20
)
.
addTag
(
"tag3"
,
TSDB_DATA_TYPE_TIMESTAMP
);
builder
.
done
();
builder
.
done
();
mcs
->
createSubTable
(
"test"
,
"st1"
,
"st1s1"
,
1
);
mcs
->
createSubTable
(
"test"
,
"st1"
,
"st1s1"
,
1
);
mcs
->
createSubTable
(
"test"
,
"st1"
,
"st1s2"
,
2
);
mcs
->
createSubTable
(
"test"
,
"st1"
,
"st1s2"
,
2
);
...
@@ -189,17 +191,17 @@ void generateFunctions(MockCatalogService* mcs) {
...
@@ -189,17 +191,17 @@ void generateFunctions(MockCatalogService* mcs) {
int32_t
__catalogGetHandle
(
const
char
*
clusterId
,
struct
SCatalog
**
catalogHandle
)
{
return
0
;
}
int32_t
__catalogGetHandle
(
const
char
*
clusterId
,
struct
SCatalog
**
catalogHandle
)
{
return
0
;
}
int32_t
__catalogGetTableMeta
(
struct
SCatalog
*
pCatalog
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
int32_t
__catalogGetTableMeta
(
struct
SCatalog
*
pCatalog
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
STableMeta
**
pTableMeta
)
{
return
g_mockCatalogService
->
catalogGetTableMeta
(
pTableName
,
pTableMeta
);
return
g_mockCatalogService
->
catalogGetTableMeta
(
pTableName
,
pTableMeta
);
}
}
int32_t
__catalogGetTableHashVgroup
(
struct
SCatalog
*
pCatalog
,
SRequestConnInfo
*
pConn
,
int32_t
__catalogGetTableHashVgroup
(
struct
SCatalog
*
pCatalog
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
const
SName
*
pTableName
,
SVgroupInfo
*
vgInfo
)
{
SVgroupInfo
*
vgInfo
)
{
return
g_mockCatalogService
->
catalogGetTableHashVgroup
(
pTableName
,
vgInfo
);
return
g_mockCatalogService
->
catalogGetTableHashVgroup
(
pTableName
,
vgInfo
);
}
}
int32_t
__catalogGetTableDistVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
int32_t
__catalogGetTableDistVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SArray
**
pVgList
)
{
SArray
**
pVgList
)
{
return
g_mockCatalogService
->
catalogGetTableDistVgInfo
(
pTableName
,
pVgList
);
return
g_mockCatalogService
->
catalogGetTableDistVgInfo
(
pTableName
,
pVgList
);
}
}
...
@@ -209,28 +211,26 @@ int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* ve
...
@@ -209,28 +211,26 @@ int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* ve
return
0
;
return
0
;
}
}
int32_t
__catalogGetDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
int32_t
__catalogGetDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SArray
**
pVgList
)
{
SArray
**
pVgList
)
{
return
g_mockCatalogService
->
catalogGetDBVgInfo
(
dbFName
,
pVgList
);
return
g_mockCatalogService
->
catalogGetDBVgInfo
(
dbFName
,
pVgList
);
}
}
int32_t
__catalogGetDBCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SDbCfgInfo
*
pDbCfg
)
{
int32_t
__catalogGetDBCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SDbCfgInfo
*
pDbCfg
)
{
return
0
;
return
0
;
}
}
int32_t
__catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFNam
e
,
int32_t
__catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
typ
e
,
AUTH_TYPE
type
,
bool
*
pass
)
{
bool
*
pass
)
{
*
pass
=
true
;
*
pass
=
true
;
return
0
;
return
0
;
}
}
int32_t
__catalogGetUdfInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
int32_t
__catalogGetUdfInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
funcName
,
SFuncInfo
*
pInfo
)
{
SFuncInfo
*
pInfo
)
{
return
g_mockCatalogService
->
catalogGetUdfInfo
(
funcName
,
pInfo
);
return
g_mockCatalogService
->
catalogGetUdfInfo
(
funcName
,
pInfo
);
}
}
int32_t
__catalogRefreshGetTableMeta
(
SCatalog
*
pCatalog
,
SRequestConnInfo
*
pConn
,
int32_t
__catalogRefreshGetTableMeta
(
SCatalog
*
pCatalog
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
isSTable
)
{
STableMeta
**
pTableMeta
,
int32_t
isSTable
)
{
return
g_mockCatalogService
->
catalogGetTableMeta
(
pTableName
,
pTableMeta
);
return
g_mockCatalogService
->
catalogGetTableMeta
(
pTableName
,
pTableMeta
);
}
}
...
...
source/libs/parser/test/parInitialATest.cpp
浏览文件 @
1676bfe5
...
@@ -163,9 +163,9 @@ TEST_F(ParserInitialATest, alterSTable) {
...
@@ -163,9 +163,9 @@ TEST_F(ParserInitialATest, alterSTable) {
run
(
"ALTER TABLE st1 DROP COLUMN c1"
);
run
(
"ALTER TABLE st1 DROP COLUMN c1"
);
clearAlterStbReq
();
clearAlterStbReq
();
setAlterStbReqFunc
(
"st1"
,
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
,
1
,
"c
1
"
,
TSDB_DATA_TYPE_VARCHAR
,
setAlterStbReqFunc
(
"st1"
,
TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES
,
1
,
"c
2
"
,
TSDB_DATA_TYPE_VARCHAR
,
2
0
+
VARSTR_HEADER_SIZE
);
3
0
+
VARSTR_HEADER_SIZE
);
run
(
"ALTER TABLE st1 MODIFY COLUMN c
1 VARCHAR(2
0)"
);
run
(
"ALTER TABLE st1 MODIFY COLUMN c
2 VARCHAR(3
0)"
);
clearAlterStbReq
();
clearAlterStbReq
();
// setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, 2, "c1", 0, 0, "cc1");
// setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, 2, "c1", 0, 0, "cc1");
...
@@ -179,9 +179,9 @@ TEST_F(ParserInitialATest, alterSTable) {
...
@@ -179,9 +179,9 @@ TEST_F(ParserInitialATest, alterSTable) {
run
(
"ALTER TABLE st1 DROP TAG tag1"
);
run
(
"ALTER TABLE st1 DROP TAG tag1"
);
clearAlterStbReq
();
clearAlterStbReq
();
setAlterStbReqFunc
(
"st1"
,
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
,
1
,
"tag
1
"
,
TSDB_DATA_TYPE_VARCHAR
,
setAlterStbReqFunc
(
"st1"
,
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
,
1
,
"tag
2
"
,
TSDB_DATA_TYPE_VARCHAR
,
2
0
+
VARSTR_HEADER_SIZE
);
3
0
+
VARSTR_HEADER_SIZE
);
run
(
"ALTER TABLE st1 MODIFY TAG tag
1 VARCHAR(2
0)"
);
run
(
"ALTER TABLE st1 MODIFY TAG tag
2 VARCHAR(3
0)"
);
clearAlterStbReq
();
clearAlterStbReq
();
setAlterStbReqFunc
(
"st1"
,
TSDB_ALTER_TABLE_UPDATE_TAG_NAME
,
2
,
"tag1"
,
0
,
0
,
"tag11"
);
setAlterStbReqFunc
(
"st1"
,
TSDB_ALTER_TABLE_UPDATE_TAG_NAME
,
2
,
"tag1"
,
0
,
0
,
"tag11"
);
...
@@ -196,6 +196,10 @@ TEST_F(ParserInitialATest, alterSTableSemanticCheck) {
...
@@ -196,6 +196,10 @@ TEST_F(ParserInitialATest, alterSTableSemanticCheck) {
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"ALTER TABLE st1 RENAME COLUMN c1 cc1"
,
TSDB_CODE_PAR_INVALID_ALTER_TABLE
);
run
(
"ALTER TABLE st1 RENAME COLUMN c1 cc1"
,
TSDB_CODE_PAR_INVALID_ALTER_TABLE
);
run
(
"ALTER TABLE st1 MODIFY COLUMN c2 NCHAR(10)"
,
TSDB_CODE_PAR_INVALID_MODIFY_COL
);
run
(
"ALTER TABLE st1 MODIFY TAG tag2 NCHAR(10)"
,
TSDB_CODE_PAR_INVALID_MODIFY_COL
);
}
}
TEST_F
(
ParserInitialATest
,
alterTable
)
{
TEST_F
(
ParserInitialATest
,
alterTable
)
{
...
@@ -336,6 +340,8 @@ TEST_F(ParserInitialATest, alterTableSemanticCheck) {
...
@@ -336,6 +340,8 @@ TEST_F(ParserInitialATest, alterTableSemanticCheck) {
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"ALTER TABLE st1s1 RENAME COLUMN c1 cc1"
,
TSDB_CODE_PAR_INVALID_ALTER_TABLE
);
run
(
"ALTER TABLE st1s1 RENAME COLUMN c1 cc1"
,
TSDB_CODE_PAR_INVALID_ALTER_TABLE
);
run
(
"ALTER TABLE st1s1 SET TAG tag2 = '123456789012345678901'"
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
);
}
}
TEST_F
(
ParserInitialATest
,
alterUser
)
{
TEST_F
(
ParserInitialATest
,
alterUser
)
{
...
...
source/libs/parser/test/parInitialCTest.cpp
浏览文件 @
1676bfe5
...
@@ -548,12 +548,14 @@ TEST_F(ParserInitialCTest, createTable) {
...
@@ -548,12 +548,14 @@ TEST_F(ParserInitialCTest, createTable) {
"a14 NCHAR(30), a15 VARCHAR(50)) "
"a14 NCHAR(30), a15 VARCHAR(50)) "
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) FILE_FACTOR 0.1"
);
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3) ROLLUP (MIN) FILE_FACTOR 0.1"
);
run
(
"CREATE TABLE IF NOT EXISTS t1 USING st1 TAGS(1, 'wxy')"
);
run
(
"CREATE TABLE IF NOT EXISTS t1 USING st1 TAGS(1, 'wxy'
, NOW
)"
);
run
(
"CREATE TABLE "
run
(
"CREATE TABLE "
"IF NOT EXISTS test.t1 USING test.st1 (tag1, tag2) TAGS(1, 'abc') "
"IF NOT EXISTS test.t1 USING test.st1 (tag1, tag2) TAGS(1, 'abc') "
"IF NOT EXISTS test.t2 USING test.st1 (tag1, tag2) TAGS(2, 'abc') "
"IF NOT EXISTS test.t2 USING test.st1 (tag1, tag2) TAGS(2, 'abc') "
"IF NOT EXISTS test.t3 USING test.st1 (tag1, tag2) TAGS(3, 'abc') "
);
"IF NOT EXISTS test.t3 USING test.st1 (tag1, tag2) TAGS(3, 'abc') "
);
// run("CREATE TABLE IF NOT EXISTS t1 USING st1 TAGS(1, 'wxy', NOW + 1S)");
}
}
TEST_F
(
ParserInitialCTest
,
createTopic
)
{
TEST_F
(
ParserInitialCTest
,
createTopic
)
{
...
...
source/libs/parser/test/parInsertTest.cpp
浏览文件 @
1676bfe5
...
@@ -245,8 +245,8 @@ TEST_F(InsertTest, autoCreateTableTest) {
...
@@ -245,8 +245,8 @@ TEST_F(InsertTest, autoCreateTableTest) {
setDatabase
(
"root"
,
"test"
);
setDatabase
(
"root"
,
"test"
);
bind
(
bind
(
"insert into st1s1 using st1 tags(1, 'wxy'
) values (now, 1,
\"
beijing
\"
)(now+1s, 2,
\"
shanghai
\"
)(now+2s, 3,
"
"insert into st1s1 using st1 tags(1, 'wxy'
, now)
"
"
\"
guangzhou
\"
)"
);
"
values (now, 1,
\"
beijing
\"
)(now+1s, 2,
\"
shanghai
\"
)(now+2s, 3,
\"
guangzhou
\"
)"
);
ASSERT_EQ
(
run
(),
TSDB_CODE_SUCCESS
);
ASSERT_EQ
(
run
(),
TSDB_CODE_SUCCESS
);
dumpReslut
();
dumpReslut
();
checkReslut
(
1
,
3
);
checkReslut
(
1
,
3
);
...
@@ -257,8 +257,8 @@ TEST_F(InsertTest, autoCreateTableTest) {
...
@@ -257,8 +257,8 @@ TEST_F(InsertTest, autoCreateTableTest) {
ASSERT_EQ
(
run
(),
TSDB_CODE_SUCCESS
);
ASSERT_EQ
(
run
(),
TSDB_CODE_SUCCESS
);
bind
(
bind
(
"insert into st1s1 using st1 tags(1, 'wxy'
) values (now, 1,
\"
beijing
\"
)(now+1s, 2,
\"
shanghai
\"
)(now+2s, 3,
"
"insert into st1s1 using st1 tags(1, 'wxy'
, now)
"
"
\"
guangzhou
\"
)"
);
"
values (now, 1,
\"
beijing
\"
)(now+1s, 2,
\"
shanghai
\"
)(now+2s, 3,
\"
guangzhou
\"
)"
);
ASSERT_EQ
(
runAsync
(),
TSDB_CODE_SUCCESS
);
ASSERT_EQ
(
runAsync
(),
TSDB_CODE_SUCCESS
);
bind
(
bind
(
...
...
source/libs/parser/test/parSelectTest.cpp
浏览文件 @
1676bfe5
...
@@ -219,6 +219,7 @@ TEST_F(ParserSelectTest, intervalSemanticCheck) {
...
@@ -219,6 +219,7 @@ TEST_F(ParserSelectTest, intervalSemanticCheck) {
run
(
"SELECT HISTOGRAM(c1, 'log_bin', '{
\"
start
\"
: -33,
\"
factor
\"
: 55,
\"
count
\"
: 5,
\"
infinity
\"
: false}', 1) FROM t1 "
run
(
"SELECT HISTOGRAM(c1, 'log_bin', '{
\"
start
\"
: -33,
\"
factor
\"
: 55,
\"
count
\"
: 5,
\"
infinity
\"
: false}', 1) FROM t1 "
"WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59' INTERVAL(10s) FILL(NULL)"
,
"WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59' INTERVAL(10s) FILL(NULL)"
,
TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC
);
TSDB_CODE_PAR_FILL_NOT_ALLOWED_FUNC
);
run
(
"SELECT _WSTARTTS, _WENDTS, _WDURATION, sum(c1) FROM t1"
,
TSDB_CODE_PAR_INVALID_WINDOW_PC
);
}
}
TEST_F
(
ParserSelectTest
,
subquery
)
{
TEST_F
(
ParserSelectTest
,
subquery
)
{
...
@@ -231,13 +232,22 @@ TEST_F(ParserSelectTest, subquery) {
...
@@ -231,13 +232,22 @@ TEST_F(ParserSelectTest, subquery) {
run
(
"SELECT SUM(a) FROM (SELECT MAX(c1) a, ts FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)"
);
run
(
"SELECT SUM(a) FROM (SELECT MAX(c1) a, ts FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)"
);
run
(
"SELECT SUM(a) FROM (SELECT MAX(c1) a, _wstartts FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)"
);
run
(
"SELECT SUM(a) FROM (SELECT MAX(c1) a, _wstartts FROM st1s1 PARTITION BY TBNAME INTERVAL(1m)) INTERVAL(1n)"
);
run
(
"SELECT _C0 FROM (SELECT _ROWTS, ts FROM st1s1)"
);
run
(
"SELECT ts FROM (SELECT t1.ts FROM st1s1 t1)"
);
}
}
TEST_F
(
ParserSelectTest
,
subquerySemanticCheck
)
{
TEST_F
(
ParserSelectTest
,
subquerySemanticCheck
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"SELECT SUM(a) FROM (SELECT MAX(c1) a FROM st1s1 INTERVAL(1m)) INTERVAL(1n)"
,
TSDB_CODE_PAR_NOT_ALLOWED_WIN_QUERY
,
run
(
"SELECT SUM(a) FROM (SELECT MAX(c1) a FROM st1s1 INTERVAL(1m)) INTERVAL(1n)"
,
PARSER_STAGE_TRANSLATE
);
TSDB_CODE_PAR_NOT_ALLOWED_WIN_QUERY
);
run
(
"SELECT ts FROM (SELECT t1.ts AS ts, t2.ts FROM st1s1 t1, st1s2 t2 WHERE t1.ts = t2.ts)"
,
TSDB_CODE_PAR_AMBIGUOUS_COLUMN
);
run
(
"SELECT ts FROM (SELECT ts AS c1 FROM st1s1 t1)"
,
TSDB_CODE_PAR_INVALID_COLUMN
);
}
}
TEST_F
(
ParserSelectTest
,
semanticCheck
)
{
TEST_F
(
ParserSelectTest
,
semanticCheck
)
{
...
...
source/libs/parser/test/parTestUtil.cpp
浏览文件 @
1676bfe5
...
@@ -62,7 +62,7 @@ int32_t getLogLevel() { return g_logLevel; }
...
@@ -62,7 +62,7 @@ int32_t getLogLevel() { return g_logLevel; }
class
ParserTestBaseImpl
{
class
ParserTestBaseImpl
{
public:
public:
ParserTestBaseImpl
(
ParserTestBase
*
pBase
)
:
pBase_
(
pBase
)
{}
ParserTestBaseImpl
(
ParserTestBase
*
pBase
)
:
pBase_
(
pBase
)
,
sqlNo_
(
0
)
{}
void
login
(
const
std
::
string
&
user
)
{
caseEnv_
.
user_
=
user
;
}
void
login
(
const
std
::
string
&
user
)
{
caseEnv_
.
user_
=
user
;
}
...
@@ -73,6 +73,7 @@ class ParserTestBaseImpl {
...
@@ -73,6 +73,7 @@ class ParserTestBaseImpl {
}
}
void
run
(
const
string
&
sql
,
int32_t
expect
,
ParserStage
checkStage
)
{
void
run
(
const
string
&
sql
,
int32_t
expect
,
ParserStage
checkStage
)
{
++
sqlNo_
;
if
(
caseEnv_
.
nsql_
>
0
)
{
if
(
caseEnv_
.
nsql_
>
0
)
{
--
(
caseEnv_
.
nsql_
);
--
(
caseEnv_
.
nsql_
);
return
;
return
;
...
@@ -174,7 +175,7 @@ class ParserTestBaseImpl {
...
@@ -174,7 +175,7 @@ class ParserTestBaseImpl {
}
}
void
dump
()
{
void
dump
()
{
cout
<<
"==========================================sql : ["
<<
stmtEnv_
.
sql_
<<
"]"
<<
endl
;
cout
<<
"==========================================
"
<<
sqlNo_
<<
"
sql : ["
<<
stmtEnv_
.
sql_
<<
"]"
<<
endl
;
if
(
!
res_
.
parsedAst_
.
empty
())
{
if
(
!
res_
.
parsedAst_
.
empty
())
{
cout
<<
"raw syntax tree : "
<<
endl
;
cout
<<
"raw syntax tree : "
<<
endl
;
cout
<<
res_
.
parsedAst_
<<
endl
;
cout
<<
res_
.
parsedAst_
<<
endl
;
...
@@ -425,6 +426,7 @@ class ParserTestBaseImpl {
...
@@ -425,6 +426,7 @@ class ParserTestBaseImpl {
stmtEnv
stmtEnv_
;
stmtEnv
stmtEnv_
;
stmtRes
res_
;
stmtRes
res_
;
ParserTestBase
*
pBase_
;
ParserTestBase
*
pBase_
;
int32_t
sqlNo_
;
};
};
ParserTestBase
::
ParserTestBase
()
:
impl_
(
new
ParserTestBaseImpl
(
this
))
{}
ParserTestBase
::
ParserTestBase
()
:
impl_
(
new
ParserTestBaseImpl
(
this
))
{}
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
1676bfe5
...
@@ -416,6 +416,8 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO
...
@@ -416,6 +416,8 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO
pMergeAgg
->
node
.
pTargets
=
NULL
;
pMergeAgg
->
node
.
pTargets
=
NULL
;
SNodeList
*
pChildren
=
pMergeAgg
->
node
.
pChildren
;
SNodeList
*
pChildren
=
pMergeAgg
->
node
.
pChildren
;
pMergeAgg
->
node
.
pChildren
=
NULL
;
pMergeAgg
->
node
.
pChildren
=
NULL
;
SNode
*
pConditions
=
pMergeAgg
->
node
.
pConditions
;
pMergeAgg
->
node
.
pConditions
=
NULL
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SAggLogicNode
*
pPartAgg
=
(
SAggLogicNode
*
)
nodesCloneNode
((
SNode
*
)
pMergeAgg
);
SAggLogicNode
*
pPartAgg
=
(
SAggLogicNode
*
)
nodesCloneNode
((
SNode
*
)
pMergeAgg
);
...
@@ -434,6 +436,7 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO
...
@@ -434,6 +436,7 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO
}
}
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pMergeAgg
->
node
.
pConditions
=
pConditions
;
pMergeAgg
->
node
.
pTargets
=
pTargets
;
pMergeAgg
->
node
.
pTargets
=
pTargets
;
pPartAgg
->
node
.
pChildren
=
pChildren
;
pPartAgg
->
node
.
pChildren
=
pChildren
;
...
...
source/libs/planner/test/planGroupByTest.cpp
浏览文件 @
1676bfe5
...
@@ -82,4 +82,6 @@ TEST_F(PlanGroupByTest, stable) {
...
@@ -82,4 +82,6 @@ TEST_F(PlanGroupByTest, stable) {
run
(
"SELECT COUNT(*) FROM st1"
);
run
(
"SELECT COUNT(*) FROM st1"
);
run
(
"SELECT COUNT(*) FROM st1 GROUP BY c1"
);
run
(
"SELECT COUNT(*) FROM st1 GROUP BY c1"
);
run
(
"SELECT SUM(c1) FROM st1 GROUP BY c2 HAVING SUM(c1) IS NOT NULL"
);
}
}
tests/script/jenkins/basic.txt
浏览文件 @
1676bfe5
...
@@ -2,20 +2,20 @@
...
@@ -2,20 +2,20 @@
#======================b1-start===============
#======================b1-start===============
# ---- user
# ---- user
#
./test.sh -f tsim/user/basic1.sim
./test.sh -f tsim/user/basic1.sim
#
./test.sh -f tsim/user/pass_alter.sim
./test.sh -f tsim/user/pass_alter.sim
#
./test.sh -f tsim/user/pass_len.sim
./test.sh -f tsim/user/pass_len.sim
#
./test.sh -f tsim/user/user_len.sim
./test.sh -f tsim/user/user_len.sim
#
./test.sh -f tsim/user/privilege1.sim
./test.sh -f tsim/user/privilege1.sim
#./test.sh -f tsim/user/privilege2.sim#
./test.sh -f tsim/user/privilege2.sim
## ---- db
## ---- db
#
./test.sh -f tsim/db/create_all_options.sim
./test.sh -f tsim/db/create_all_options.sim
#
./test.sh -f tsim/db/alter_option.sim
./test.sh -f tsim/db/alter_option.sim
#
./test.sh -f tsim/db/basic1.sim
./test.sh -f tsim/db/basic1.sim
#
./test.sh -f tsim/db/basic2.sim
./test.sh -f tsim/db/basic2.sim
#
./test.sh -f tsim/db/basic3.sim
./test.sh -f tsim/db/basic3.sim
#
./test.sh -f tsim/db/basic6.sim
./test.sh -f tsim/db/basic6.sim
./test.sh -f tsim/db/basic7.sim
./test.sh -f tsim/db/basic7.sim
./test.sh -f tsim/db/error1.sim
./test.sh -f tsim/db/error1.sim
./test.sh -f tsim/db/taosdlog.sim
./test.sh -f tsim/db/taosdlog.sim
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录