Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7391afdb
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
7391afdb
编写于
1月 12, 2022
作者:
H
Haojun Liao
提交者:
GitHub
1月 12, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9754 from taosdata/feature/3.0_liaohj
Feature/3.0 liaohj
上级
6c9ad20b
57281f6e
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
78 addition
and
72 deletion
+78
-72
include/libs/parser/parsenodes.h
include/libs/parser/parsenodes.h
+0
-9
include/libs/parser/parser.h
include/libs/parser/parser.h
+7
-1
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+0
-1
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+11
-7
source/client/src/clientMain.c
source/client/src/clientMain.c
+7
-1
source/libs/parser/inc/astToMsg.h
source/libs/parser/inc/astToMsg.h
+4
-4
source/libs/parser/inc/parserInt.h
source/libs/parser/inc/parserInt.h
+4
-4
source/libs/parser/inc/parserUtil.h
source/libs/parser/inc/parserUtil.h
+1
-1
source/libs/parser/src/astToMsg.c
source/libs/parser/src/astToMsg.c
+4
-4
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+2
-2
source/libs/parser/src/dCDAstProcess.c
source/libs/parser/src/dCDAstProcess.c
+5
-5
source/libs/parser/src/insertParser.c
source/libs/parser/src/insertParser.c
+4
-4
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+7
-7
source/libs/parser/src/parserUtil.c
source/libs/parser/src/parserUtil.c
+1
-1
source/libs/parser/test/insertParserTest.cpp
source/libs/parser/test/insertParserTest.cpp
+2
-2
source/libs/parser/test/parserTests.cpp
source/libs/parser/test/parserTests.cpp
+13
-13
source/libs/parser/test/plannerTest.cpp
source/libs/parser/test/plannerTest.cpp
+2
-2
source/libs/parser/test/tokenizerTest.cpp
source/libs/parser/test/tokenizerTest.cpp
+1
-1
source/libs/planner/test/phyPlanTests.cpp
source/libs/planner/test/phyPlanTests.cpp
+3
-3
未找到文件。
include/libs/parser/parsenodes.h
浏览文件 @
7391afdb
...
...
@@ -43,15 +43,6 @@ typedef struct SField {
int32_t
bytes
;
}
SField
;
typedef
struct
SParseBasicCtx
{
uint64_t
requestId
;
int32_t
acctId
;
const
char
*
db
;
void
*
pTransporter
;
SEpSet
mgmtEpSet
;
struct
SCatalog
*
pCatalog
;
}
SParseBasicCtx
;
typedef
struct
SFieldInfo
{
int16_t
numOfOutput
;
// number of column in result
SField
*
final
;
...
...
include/libs/parser/parser.h
浏览文件 @
7391afdb
...
...
@@ -23,11 +23,17 @@ extern "C" {
#include "parsenodes.h"
typedef
struct
SParseContext
{
SParseBasicCtx
ctx
;
uint64_t
requestId
;
int32_t
acctId
;
const
char
*
db
;
void
*
pTransporter
;
SEpSet
mgmtEpSet
;
const
char
*
pSql
;
// sql string
size_t
sqlLen
;
// length of the sql string
char
*
pMsg
;
// extended error message if exists to help identifying the problem in sql statement.
int32_t
msgLen
;
// max length of the msg
struct
SCatalog
*
pCatalog
;
}
SParseContext
;
/**
...
...
source/client/inc/clientInt.h
浏览文件 @
7391afdb
...
...
@@ -129,7 +129,6 @@ typedef struct SRequestObj {
char
*
msgBuf
;
void
*
pInfo
;
// sql parse info, generated by parser module
int32_t
code
;
uint64_t
affectedRows
;
// todo remove it
SQueryExecMetric
metric
;
SRequestSendRecvBody
body
;
}
SRequestObj
;
...
...
source/client/src/clientImpl.c
浏览文件 @
7391afdb
...
...
@@ -151,23 +151,26 @@ int32_t parseSql(SRequestObj* pRequest, SQueryNode** pQuery) {
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
SParseContext
cxt
=
{
.
ctx
=
{.
requestId
=
pRequest
->
requestId
,
.
acctId
=
pTscObj
->
acctId
,
.
db
=
getConnectionDB
(
pTscObj
),
.
pTransporter
=
pTscObj
->
pTransporter
},
.
requestId
=
pRequest
->
requestId
,
.
acctId
=
pTscObj
->
acctId
,
.
db
=
getConnectionDB
(
pTscObj
),
.
pTransporter
=
pTscObj
->
pTransporter
,
.
pSql
=
pRequest
->
sqlstr
,
.
sqlLen
=
pRequest
->
sqlLen
,
.
pMsg
=
pRequest
->
msgBuf
,
.
msgLen
=
ERROR_MSG_BUF_DEFAULT_SIZE
};
cxt
.
ctx
.
mgmtEpSet
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
);
int32_t
code
=
catalogGetHandle
(
pTscObj
->
pAppInfo
->
clusterId
,
&
cxt
.
ctx
.
pCatalog
);
cxt
.
mgmtEpSet
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
);
int32_t
code
=
catalogGetHandle
(
pTscObj
->
pAppInfo
->
clusterId
,
&
cxt
.
pCatalog
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
cxt
.
ctx
.
db
);
tfree
(
cxt
.
db
);
return
code
;
}
code
=
qParseQuerySql
(
&
cxt
,
pQuery
);
tfree
(
cxt
.
ctx
.
db
);
tfree
(
cxt
.
db
);
return
code
;
}
...
...
@@ -247,8 +250,9 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryDag* pDag) {
}
}
pRequest
->
affectedRows
=
res
.
numOfRows
;
return
res
.
code
;
pRequest
->
body
.
resInfo
.
numOfRows
=
res
.
numOfRows
;
pRequest
->
code
=
res
.
code
;
return
pRequest
->
code
;
}
return
scheduleAsyncExecJob
(
pRequest
->
pTscObj
->
pTransporter
,
NULL
,
pDag
,
&
pRequest
->
body
.
pQueryJob
);
...
...
source/client/src/clientMain.c
浏览文件 @
7391afdb
...
...
@@ -265,7 +265,13 @@ const char *taos_data_type(int type) {
const
char
*
taos_get_client_info
()
{
return
version
;
}
int
taos_affected_rows
(
TAOS_RES
*
res
)
{
return
((
SRequestObj
*
)
res
)
->
affectedRows
;
if
(
res
==
NULL
)
{
return
0
;
}
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
res
;
SReqResultInfo
*
pResInfo
=
&
pRequest
->
body
.
resInfo
;
return
pResInfo
->
numOfRows
;
}
int
taos_result_precision
(
TAOS_RES
*
res
)
{
return
TSDB_TIME_PRECISION_MILLI
;
}
source/libs/parser/inc/astToMsg.h
浏览文件 @
7391afdb
...
...
@@ -8,10 +8,10 @@
SCreateUserReq
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SCreateAcctReq
*
buildAcctManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SDropUserReq
*
buildDropUserMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SShowReq
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParse
BasicCtx
*
pParseCtx
,
char
*
msgBuf
,
int32_t
msgLen
);
SCreateDbReq
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
SParse
BasicCtx
*
pCtx
,
SMsgBuf
*
pMsgBuf
);
SMCreateStbReq
*
buildCreateStbMsg
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParse
BasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SMDropStbReq
*
buildDropStableMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SParse
BasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SShowReq
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParse
Context
*
pParseCtx
,
char
*
msgBuf
,
int32_t
msgLen
);
SCreateDbReq
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
SParse
Context
*
pCtx
,
SMsgBuf
*
pMsgBuf
);
SMCreateStbReq
*
buildCreateStbMsg
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParse
Context
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SMDropStbReq
*
buildDropStableMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SParse
Context
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SCreateDnodeReq
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
SDropDnodeReq
*
buildDropDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
);
...
...
source/libs/parser/inc/parserInt.h
浏览文件 @
7391afdb
...
...
@@ -51,7 +51,7 @@ void clearAllTableMetaInfo(SQueryStmtInfo* pQueryInfo, bool removeMeta, uint64_t
* @param msgBufLen
* @return
*/
int32_t
qParserValidateSqlNode
(
SParse
BasicCtx
*
pCtx
,
SSqlInfo
*
pInfo
,
SQueryStmtInfo
*
pQueryInfo
,
char
*
msgBuf
,
int32_t
msgBufLen
);
int32_t
qParserValidateSqlNode
(
SParse
Context
*
pCtx
,
SSqlInfo
*
pInfo
,
SQueryStmtInfo
*
pQueryInfo
,
char
*
msgBuf
,
int32_t
msgBufLen
);
/**
* validate the ddl ast, and convert the ast to the corresponding message format
...
...
@@ -60,7 +60,7 @@ int32_t qParserValidateSqlNode(SParseBasicCtx *pCtx, SSqlInfo* pInfo, SQueryStmt
* @param type
* @return
*/
SDclStmtInfo
*
qParserValidateDclSqlNode
(
SSqlInfo
*
pInfo
,
SParse
BasicCtx
*
pCtx
,
char
*
msgBuf
,
int32_t
msgBufLen
);
SDclStmtInfo
*
qParserValidateDclSqlNode
(
SSqlInfo
*
pInfo
,
SParse
Context
*
pCtx
,
char
*
msgBuf
,
int32_t
msgBufLen
);
/**
*
...
...
@@ -70,7 +70,7 @@ SDclStmtInfo* qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, c
* @param msgBufLen
* @return
*/
SVnodeModifOpStmtInfo
*
qParserValidateCreateTbSqlNode
(
SSqlInfo
*
pInfo
,
SParse
BasicCtx
*
pCtx
,
char
*
msgBuf
,
int32_t
msgBufLen
);
SVnodeModifOpStmtInfo
*
qParserValidateCreateTbSqlNode
(
SSqlInfo
*
pInfo
,
SParse
Context
*
pCtx
,
char
*
msgBuf
,
int32_t
msgBufLen
);
/**
* Evaluate the numeric and timestamp arithmetic expression in the WHERE clause.
...
...
@@ -98,7 +98,7 @@ int32_t checkForInvalidExpr(SQueryStmtInfo* pQueryInfo, SMsgBuf* pMsgBuf);
* @param msgBufLen
* @return
*/
int32_t
qParserExtractRequestedMetaInfo
(
const
SSqlInfo
*
pSqlInfo
,
SCatalogReq
*
pMetaInfo
,
SParse
BasicCtx
*
pCtx
,
char
*
msg
,
int32_t
msgBufLen
);
int32_t
qParserExtractRequestedMetaInfo
(
const
SSqlInfo
*
pSqlInfo
,
SCatalogReq
*
pMetaInfo
,
SParse
Context
*
pCtx
,
char
*
msg
,
int32_t
msgBufLen
);
/**
* Destroy the meta data request structure.
...
...
source/libs/parser/inc/parserUtil.h
浏览文件 @
7391afdb
...
...
@@ -81,7 +81,7 @@ int32_t KvRowAppend(const void *value, int32_t len, void *param);
typedef
int32_t
(
*
_row_append_fn_t
)(
const
void
*
value
,
int32_t
len
,
void
*
param
);
int32_t
parseValueToken
(
char
**
end
,
SToken
*
pToken
,
SSchema
*
pSchema
,
int16_t
timePrec
,
char
*
tmpTokenBuf
,
_row_append_fn_t
func
,
void
*
param
,
SMsgBuf
*
pMsgBuf
);
int32_t
createSName
(
SName
*
pName
,
SToken
*
pTableName
,
SParse
BasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
int32_t
createSName
(
SName
*
pName
,
SToken
*
pTableName
,
SParse
Context
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
#ifdef __cplusplus
}
...
...
source/libs/parser/src/astToMsg.c
浏览文件 @
7391afdb
...
...
@@ -85,7 +85,7 @@ SDropUserReq* buildDropUserMsg(SSqlInfo* pInfo, int32_t *msgLen, int64_t id, cha
return
pMsg
;
}
SShowReq
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParse
BasicCtx
*
pCtx
,
char
*
msgBuf
,
int32_t
msgLen
)
{
SShowReq
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParse
Context
*
pCtx
,
char
*
msgBuf
,
int32_t
msgLen
)
{
SShowReq
*
pShowMsg
=
calloc
(
1
,
sizeof
(
SShowReq
));
pShowMsg
->
type
=
pShowInfo
->
showType
;
...
...
@@ -210,7 +210,7 @@ int32_t setDbOptions(SCreateDbReq* pCreateDbMsg, const SCreateDbInfo* pCreateDbS
return
TSDB_CODE_SUCCESS
;
}
SCreateDbReq
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
SParse
BasicCtx
*
pCtx
,
SMsgBuf
*
pMsgBuf
)
{
SCreateDbReq
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
SParse
Context
*
pCtx
,
SMsgBuf
*
pMsgBuf
)
{
SCreateDbReq
*
pCreateMsg
=
calloc
(
1
,
sizeof
(
SCreateDbReq
));
if
(
setDbOptions
(
pCreateMsg
,
pCreateDbInfo
,
pMsgBuf
)
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
pCreateMsg
);
...
...
@@ -230,7 +230,7 @@ SCreateDbReq* buildCreateDbMsg(SCreateDbInfo* pCreateDbInfo, SParseBasicCtx *pCt
return
pCreateMsg
;
}
SMCreateStbReq
*
buildCreateStbMsg
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParse
BasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
SMCreateStbReq
*
buildCreateStbMsg
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParse
Context
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
SSchema
*
pSchema
;
int32_t
numOfTags
=
0
;
...
...
@@ -315,7 +315,7 @@ SMCreateStbReq* buildCreateStbMsg(SCreateTableSql* pCreateTableSql, int32_t* len
return
pCreateStbMsg
;
}
SMDropStbReq
*
buildDropStableMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SParse
BasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
SMDropStbReq
*
buildDropStableMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SParse
Context
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
SToken
*
tableName
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
SName
name
=
{
0
};
...
...
source/libs/parser/src/astValidate.c
浏览文件 @
7391afdb
...
...
@@ -3628,7 +3628,7 @@ int32_t evaluateSqlNode(SSqlNode* pNode, int32_t tsPrecision, SMsgBuf* pMsgBuf)
return
TSDB_CODE_SUCCESS
;
}
int32_t
setTableVgroupList
(
SParse
BasicCtx
*
pCtx
,
SName
*
name
,
SVgroupsInfo
**
pVgList
)
{
int32_t
setTableVgroupList
(
SParse
Context
*
pCtx
,
SName
*
name
,
SVgroupsInfo
**
pVgList
)
{
SArray
*
vgroupList
=
NULL
;
int32_t
code
=
catalogGetTableDistVgroup
(
pCtx
->
pCatalog
,
pCtx
->
pTransporter
,
&
pCtx
->
mgmtEpSet
,
name
,
&
vgroupList
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -3655,7 +3655,7 @@ int32_t setTableVgroupList(SParseBasicCtx *pCtx, SName* name, SVgroupsInfo **pVg
return
TSDB_CODE_SUCCESS
;
}
int32_t
qParserValidateSqlNode
(
SParse
BasicCtx
*
pCtx
,
SSqlInfo
*
pInfo
,
SQueryStmtInfo
*
pQueryInfo
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
int32_t
qParserValidateSqlNode
(
SParse
Context
*
pCtx
,
SSqlInfo
*
pInfo
,
SQueryStmtInfo
*
pQueryInfo
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
assert
(
pCtx
!=
NULL
&&
pInfo
!=
NULL
);
int32_t
code
=
0
;
...
...
source/libs/parser/src/dCDAstProcess.c
浏览文件 @
7391afdb
...
...
@@ -18,7 +18,7 @@ static bool has(SArray* pFieldList, int32_t startIndex, const char* name) {
return
false
;
}
static
int32_t
setShowInfo
(
SShowInfo
*
pShowInfo
,
SParse
BasicCtx
*
pCtx
,
void
**
output
,
int32_t
*
outputLen
,
static
int32_t
setShowInfo
(
SShowInfo
*
pShowInfo
,
SParse
Context
*
pCtx
,
void
**
output
,
int32_t
*
outputLen
,
SEpSet
*
pEpSet
,
void
**
pExtension
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
msg1
=
"invalid name"
;
const
char
*
msg2
=
"wildcard string should be less than %d characters"
;
...
...
@@ -396,7 +396,7 @@ static void destroyCreateTbReqBatch(SVgroupTablesBatch* pTbBatch) {
taosArrayDestroy
(
pTbBatch
->
req
.
pArray
);
}
static
int32_t
doCheckAndBuildCreateCTableReq
(
SCreateTableSql
*
pCreateTable
,
SParse
BasicCtx
*
pCtx
,
SMsgBuf
*
pMsgBuf
,
SArray
**
pBufArray
)
{
static
int32_t
doCheckAndBuildCreateCTableReq
(
SCreateTableSql
*
pCreateTable
,
SParse
Context
*
pCtx
,
SMsgBuf
*
pMsgBuf
,
SArray
**
pBufArray
)
{
const
char
*
msg1
=
"invalid table name"
;
const
char
*
msg2
=
"tags number not matched"
;
const
char
*
msg3
=
"tag value too long"
;
...
...
@@ -634,7 +634,7 @@ static int32_t doBuildSingleTableBatchReq(SName* pTableName, SArray* pColumns, S
return
TSDB_CODE_SUCCESS
;
}
int32_t
doCheckAndBuildCreateTableReq
(
SCreateTableSql
*
pCreateTable
,
SParse
BasicCtx
*
pCtx
,
SMsgBuf
*
pMsgBuf
,
char
**
pOutput
,
int32_t
*
len
)
{
int32_t
doCheckAndBuildCreateTableReq
(
SCreateTableSql
*
pCreateTable
,
SParse
Context
*
pCtx
,
SMsgBuf
*
pMsgBuf
,
char
**
pOutput
,
int32_t
*
len
)
{
SArray
*
pBufArray
=
NULL
;
int32_t
code
=
0
;
...
...
@@ -703,7 +703,7 @@ SArray* doSerializeVgroupCreateTableInfo(SHashObj* pVgroupHashmap) {
return
pBufArray
;
}
SDclStmtInfo
*
qParserValidateDclSqlNode
(
SSqlInfo
*
pInfo
,
SParse
BasicCtx
*
pCtx
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
SDclStmtInfo
*
qParserValidateDclSqlNode
(
SSqlInfo
*
pInfo
,
SParse
Context
*
pCtx
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
int32_t
code
=
0
;
SDclStmtInfo
*
pDcl
=
calloc
(
1
,
sizeof
(
SDclStmtInfo
));
...
...
@@ -961,7 +961,7 @@ SDclStmtInfo* qParserValidateDclSqlNode(SSqlInfo* pInfo, SParseBasicCtx* pCtx, c
return
NULL
;
}
SVnodeModifOpStmtInfo
*
qParserValidateCreateTbSqlNode
(
SSqlInfo
*
pInfo
,
SParse
BasicCtx
*
pCtx
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
SVnodeModifOpStmtInfo
*
qParserValidateCreateTbSqlNode
(
SSqlInfo
*
pInfo
,
SParse
Context
*
pCtx
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
SCreateTableSql
*
pCreateTable
=
pInfo
->
pCreateTableInfo
;
assert
(
pCreateTable
->
type
==
TSDB_SQL_CREATE_TABLE
);
...
...
source/libs/parser/src/insertParser.c
浏览文件 @
7391afdb
...
...
@@ -84,11 +84,11 @@ static int32_t buildName(SInsertParseContext* pCxt, SToken* pStname, char* fullD
char
*
p
=
strnchr
(
pStname
->
z
,
TS_PATH_DELIMITER
[
0
],
pStname
->
n
,
false
);
if
(
NULL
!=
p
)
{
// db.table
int32_t
n
=
sprintf
(
fullDbName
,
"%d."
,
pCxt
->
pComCxt
->
ctx
.
acctId
);
int32_t
n
=
sprintf
(
fullDbName
,
"%d."
,
pCxt
->
pComCxt
->
acctId
);
strncpy
(
fullDbName
+
n
,
pStname
->
z
,
p
-
pStname
->
z
);
strncpy
(
tableName
,
p
+
1
,
pStname
->
n
-
(
p
-
pStname
->
z
)
-
1
);
}
else
{
snprintf
(
fullDbName
,
TSDB_DB_FNAME_LEN
,
"%d.%s"
,
pCxt
->
pComCxt
->
ctx
.
acctId
,
pCxt
->
pComCxt
->
ctx
.
db
);
snprintf
(
fullDbName
,
TSDB_DB_FNAME_LEN
,
"%d.%s"
,
pCxt
->
pComCxt
->
acctId
,
pCxt
->
pComCxt
->
db
);
strncpy
(
tableName
,
pStname
->
z
,
pStname
->
n
);
}
...
...
@@ -97,11 +97,11 @@ static int32_t buildName(SInsertParseContext* pCxt, SToken* pStname, char* fullD
static
int32_t
getTableMeta
(
SInsertParseContext
*
pCxt
,
SToken
*
pTname
)
{
SName
name
=
{
0
};
createSName
(
&
name
,
pTname
,
&
pCxt
->
pComCxt
->
ctx
,
&
pCxt
->
msg
);
createSName
(
&
name
,
pTname
,
pCxt
->
pComCxt
,
&
pCxt
->
msg
);
char
tableName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
tNameExtractFullName
(
&
name
,
tableName
);
SParse
BasicCtx
*
pBasicCtx
=
&
pCxt
->
pComCxt
->
ctx
;
SParse
Context
*
pBasicCtx
=
pCxt
->
pComCxt
;
CHECK_CODE
(
catalogGetTableMeta
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
pCxt
->
pTableMeta
));
SVgroupInfo
vg
;
CHECK_CODE
(
catalogGetTableHashVgroup
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
vg
));
...
...
source/libs/parser/src/parser.c
浏览文件 @
7391afdb
...
...
@@ -45,14 +45,14 @@ int32_t parseQuerySql(SParseContext* pCxt, SQueryNode** pQuery) {
if
(
!
isDqlSqlStatement
(
&
info
))
{
if
(
info
.
type
==
TSDB_SQL_CREATE_TABLE
)
{
SVnodeModifOpStmtInfo
*
pModifStmtInfo
=
qParserValidateCreateTbSqlNode
(
&
info
,
&
pCxt
->
ctx
,
pCxt
->
pMsg
,
pCxt
->
msgLen
);
SVnodeModifOpStmtInfo
*
pModifStmtInfo
=
qParserValidateCreateTbSqlNode
(
&
info
,
pCxt
,
pCxt
->
pMsg
,
pCxt
->
msgLen
);
if
(
pModifStmtInfo
==
NULL
)
{
return
terrno
;
}
*
pQuery
=
(
SQueryNode
*
)
pModifStmtInfo
;
}
else
{
SDclStmtInfo
*
pDcl
=
qParserValidateDclSqlNode
(
&
info
,
&
pCxt
->
ctx
,
pCxt
->
pMsg
,
pCxt
->
msgLen
);
SDclStmtInfo
*
pDcl
=
qParserValidateDclSqlNode
(
&
info
,
pCxt
,
pCxt
->
pMsg
,
pCxt
->
msgLen
);
if
(
pDcl
==
NULL
)
{
return
terrno
;
}
...
...
@@ -67,7 +67,7 @@ int32_t parseQuerySql(SParseContext* pCxt, SQueryNode** pQuery) {
return
terrno
;
}
int32_t
code
=
qParserValidateSqlNode
(
&
pCxt
->
ctx
,
&
info
,
pQueryInfo
,
pCxt
->
pMsg
,
pCxt
->
msgLen
);
int32_t
code
=
qParserValidateSqlNode
(
pCxt
,
&
info
,
pQueryInfo
,
pCxt
->
pMsg
,
pCxt
->
msgLen
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
*
pQuery
=
(
SQueryNode
*
)
pQueryInfo
;
}
else
{
...
...
@@ -92,7 +92,7 @@ int32_t qParserConvertSql(const char* pStr, size_t length, char** pConvertSql) {
return
0
;
}
static
int32_t
getTableNameFromSqlNode
(
SSqlNode
*
pSqlNode
,
SArray
*
tableNameList
,
SParse
BasicCtx
*
pCtx
,
SMsgBuf
*
pMsgBuf
);
static
int32_t
getTableNameFromSqlNode
(
SSqlNode
*
pSqlNode
,
SArray
*
tableNameList
,
SParse
Context
*
pCtx
,
SMsgBuf
*
pMsgBuf
);
static
int32_t
tnameComparFn
(
const
void
*
p1
,
const
void
*
p2
)
{
SName
*
pn1
=
(
SName
*
)
p1
;
...
...
@@ -116,7 +116,7 @@ static int32_t tnameComparFn(const void* p1, const void* p2) {
}
}
static
int32_t
getTableNameFromSubquery
(
SSqlNode
*
pSqlNode
,
SArray
*
tableNameList
,
SParse
BasicCtx
*
pCtx
,
SMsgBuf
*
pMsgBuf
)
{
static
int32_t
getTableNameFromSubquery
(
SSqlNode
*
pSqlNode
,
SArray
*
tableNameList
,
SParse
Context
*
pCtx
,
SMsgBuf
*
pMsgBuf
)
{
int32_t
numOfSub
=
(
int32_t
)
taosArrayGetSize
(
pSqlNode
->
from
->
list
);
for
(
int32_t
j
=
0
;
j
<
numOfSub
;
++
j
)
{
...
...
@@ -139,7 +139,7 @@ static int32_t getTableNameFromSubquery(SSqlNode* pSqlNode, SArray* tableNameLis
return
TSDB_CODE_SUCCESS
;
}
int32_t
getTableNameFromSqlNode
(
SSqlNode
*
pSqlNode
,
SArray
*
tableNameList
,
SParse
BasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
int32_t
getTableNameFromSqlNode
(
SSqlNode
*
pSqlNode
,
SArray
*
tableNameList
,
SParse
Context
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
msg1
=
"invalid table name"
;
int32_t
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
pSqlNode
->
from
->
list
);
...
...
@@ -173,7 +173,7 @@ static void freePtrElem(void* p) {
tfree
(
*
(
char
**
)
p
);
}
int32_t
qParserExtractRequestedMetaInfo
(
const
SSqlInfo
*
pSqlInfo
,
SCatalogReq
*
pMetaInfo
,
SParse
BasicCtx
*
pCtx
,
char
*
msg
,
int32_t
msgBufLen
)
{
int32_t
qParserExtractRequestedMetaInfo
(
const
SSqlInfo
*
pSqlInfo
,
SCatalogReq
*
pMetaInfo
,
SParse
Context
*
pCtx
,
char
*
msg
,
int32_t
msgBufLen
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SMsgBuf
msgBuf
=
{.
buf
=
msg
,
.
len
=
msgBufLen
};
...
...
source/libs/parser/src/parserUtil.c
浏览文件 @
7391afdb
...
...
@@ -1943,7 +1943,7 @@ int32_t KvRowAppend(const void *value, int32_t len, void *param) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
createSName
(
SName
*
pName
,
SToken
*
pTableName
,
SParse
BasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
int32_t
createSName
(
SName
*
pName
,
SToken
*
pTableName
,
SParse
Context
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
msg1
=
"name too long"
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
source/libs/parser/test/insertParserTest.cpp
浏览文件 @
7391afdb
...
...
@@ -43,8 +43,8 @@ protected:
void
bind
(
const
char
*
sql
)
{
reset
();
cxt_
.
ctx
.
acctId
=
atoi
(
acctId_
.
c_str
());
cxt_
.
ctx
.
db
=
(
char
*
)
db_
.
c_str
();
cxt_
.
acctId
=
atoi
(
acctId_
.
c_str
());
cxt_
.
db
=
(
char
*
)
db_
.
c_str
();
strcpy
(
sqlBuf_
,
sql
);
cxt_
.
sqlLen
=
strlen
(
sql
);
sqlBuf_
[
cxt_
.
sqlLen
]
=
'\0'
;
...
...
source/libs/parser/test/parserTests.cpp
浏览文件 @
7391afdb
...
...
@@ -77,7 +77,7 @@ void sqlCheck(const char* sql, bool valid) {
buf
.
len
=
128
;
buf
.
buf
=
msg
;
SParse
BasicCtx
ctx
=
{
0
};
SParse
Context
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
SSqlNode
*
pNode
=
(
SSqlNode
*
)
taosArrayGetP
(((
SArray
*
)
info1
.
sub
.
node
),
0
);
...
...
@@ -122,7 +122,7 @@ TEST(testCase, validateAST_test) {
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SParse
BasicCtx
ctx
=
{
0
};
SParse
Context
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
...
...
@@ -184,7 +184,7 @@ TEST(testCase, function_Test) {
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SParse
BasicCtx
ctx
=
{
0
};
SParse
Context
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
...
...
@@ -234,7 +234,7 @@ TEST(testCase, function_Test2) {
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SParse
BasicCtx
ctx
=
{
0
};
SParse
Context
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
...
...
@@ -284,7 +284,7 @@ TEST(testCase, function_Test3) {
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SParse
BasicCtx
ctx
=
{
0
};
SParse
Context
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
...
...
@@ -333,7 +333,7 @@ TEST(testCase, function_Test4) {
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SParse
BasicCtx
ctx
=
{
0
};
SParse
Context
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
...
...
@@ -385,7 +385,7 @@ TEST(testCase, function_Test5) {
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SParse
BasicCtx
ctx
=
{
0
};
SParse
Context
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
...
...
@@ -474,7 +474,7 @@ TEST(testCase, function_Test6) {
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SParse
BasicCtx
ctx
=
{
0
};
SParse
Context
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
...
...
@@ -556,7 +556,7 @@ TEST(testCase, function_Test6) {
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SParse
BasicCtx
ctx
=
{
0
};
SParse
Context
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
...
...
@@ -622,7 +622,7 @@ TEST(testCase, function_Test6) {
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SParse
BasicCtx
ctx
=
{
0
};
SParse
Context
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
...
...
@@ -705,7 +705,7 @@ TEST(testCase, function_Test6) {
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SParse
BasicCtx
ctx
=
{
0
};
SParse
Context
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
...
...
@@ -756,7 +756,7 @@ TEST(testCase, show_user_Test) {
SSqlInfo
info1
=
doGenerateAST
(
sql1
);
ASSERT_EQ
(
info1
.
valid
,
true
);
SParse
BasicCtx
ct
=
{.
requestId
=
1
,
.
acctId
=
1
,
.
db
=
"abc"
,
.
pTransporter
=
NULL
};
SParse
Context
ct
=
{.
requestId
=
1
,
.
acctId
=
1
,
.
db
=
"abc"
,
.
pTransporter
=
NULL
};
SDclStmtInfo
*
output
=
qParserValidateDclSqlNode
(
&
info1
,
&
ct
,
msg
,
buf
.
len
);
ASSERT_NE
(
output
,
nullptr
);
...
...
@@ -776,7 +776,7 @@ TEST(testCase, create_user_Test) {
ASSERT_EQ
(
info1
.
valid
,
true
);
ASSERT_EQ
(
isDclSqlStatement
(
&
info1
),
true
);
SParse
BasicCtx
ct
=
{.
requestId
=
1
,
.
acctId
=
1
,
.
db
=
"abc"
};
SParse
Context
ct
=
{.
requestId
=
1
,
.
acctId
=
1
,
.
db
=
"abc"
};
SDclStmtInfo
*
output
=
qParserValidateDclSqlNode
(
&
info1
,
&
ct
,
msg
,
buf
.
len
);
ASSERT_NE
(
output
,
nullptr
);
...
...
source/libs/parser/test/plannerTest.cpp
浏览文件 @
7391afdb
...
...
@@ -81,7 +81,7 @@ void generateLogicplan(const char* sql) {
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SParse
BasicCtx
ctx
=
{
0
};
SParse
Context
ctx
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
...
...
@@ -122,7 +122,7 @@ TEST(testCase, planner_test) {
ASSERT_EQ
(
code
,
0
);
SCatalogReq
req
=
{
0
};
SParse
BasicCtx
ctx
=
{
0
};
SParse
Context
ctx
=
{
0
};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
ASSERT_EQ
(
ret
,
0
);
...
...
source/libs/parser/test/tokenizerTest.cpp
浏览文件 @
7391afdb
...
...
@@ -711,7 +711,7 @@ TEST(testCase, extractMeta_test) {
char
msg
[
128
]
=
{
0
};
SCatalogReq
req
=
{
0
};
SParse
BasicCtx
ctx
=
{
0
};
SParse
Context
ctx
=
{
0
};
ctx
.
db
=
"db1"
;
ctx
.
acctId
=
1
;
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
&
ctx
,
msg
,
128
);
...
...
source/libs/planner/test/phyPlanTests.cpp
浏览文件 @
7391afdb
...
...
@@ -135,9 +135,9 @@ private:
_sql
=
sql
;
memset
(
_msg
,
0
,
_msgMaxLen
);
pCxt
->
ctx
.
acctId
=
1
;
pCxt
->
ctx
.
db
=
_db
.
c_str
();
pCxt
->
ctx
.
requestId
=
1
;
pCxt
->
acctId
=
1
;
pCxt
->
db
=
_db
.
c_str
();
pCxt
->
requestId
=
1
;
pCxt
->
pSql
=
_sql
.
c_str
();
pCxt
->
sqlLen
=
_sql
.
length
();
pCxt
->
pMsg
=
_msg
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录