Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cfce1340
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
cfce1340
编写于
12月 16, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-11818] implementate the taos_fetch_row .
上级
63869172
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
243 addition
and
38 deletion
+243
-38
include/common/taosmsg.h
include/common/taosmsg.h
+1
-1
include/libs/parser/parser.h
include/libs/parser/parser.h
+1
-1
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+14
-3
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+20
-2
source/client/src/clientMain.c
source/client/src/clientMain.c
+14
-0
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+71
-1
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+10
-8
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+1
-1
source/libs/parser/inc/parserInt.h
source/libs/parser/inc/parserInt.h
+1
-1
source/libs/parser/inc/parserUtil.h
source/libs/parser/inc/parserUtil.h
+1
-1
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+93
-2
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+3
-3
source/libs/parser/src/parserUtil.c
source/libs/parser/src/parserUtil.c
+4
-3
source/libs/parser/test/parserTests.cpp
source/libs/parser/test/parserTests.cpp
+9
-11
未找到文件。
include/common/taosmsg.h
浏览文件 @
cfce1340
...
...
@@ -804,7 +804,7 @@ typedef struct {
}
SVgroupsMsg
,
SVgroupsInfo
;
typedef
struct
{
char
tbFname
[
TSDB_TABLE_FNAME_LEN
];
// table
id
char
tbFname
[
TSDB_TABLE_FNAME_LEN
];
// table
full name
char
stbFname
[
TSDB_TABLE_FNAME_LEN
];
int32_t
numOfTags
;
int32_t
numOfColumns
;
...
...
include/libs/parser/parser.h
浏览文件 @
cfce1340
...
...
@@ -151,7 +151,7 @@ typedef struct SParseContext {
* @param msg extended error message if exists.
* @return error code
*/
int32_t
qParseQuerySql
(
const
char
*
pStr
,
size_t
length
,
int64_t
id
,
int32_t
*
type
,
void
**
pOutput
,
char
*
msg
,
int32_t
msgLen
);
int32_t
qParseQuerySql
(
const
char
*
pStr
,
size_t
length
,
int64_t
id
,
int32_t
*
type
,
void
**
pOutput
,
int32_t
*
outputLen
,
char
*
msg
,
int32_t
msgLen
);
typedef
enum
{
PAYLOAD_TYPE_KV
=
0
,
...
...
source/client/inc/clientInt.h
浏览文件 @
cfce1340
...
...
@@ -20,14 +20,15 @@
extern
"C"
{
#endif
#include <common.h>
#include "taos.h"
#include "taosmsg.h"
#include "tdef.h"
#include "tep.h"
#include "thash.h"
#include "tlist.h"
#include "trpc.h"
#include "tdef.h"
#include "tmsgtype.h"
#include "t
ep
.h"
#include "t
rpc
.h"
typedef
struct
SQueryExecMetric
{
int64_t
start
;
// start timestamp
...
...
@@ -86,10 +87,18 @@ typedef struct STscObj {
SAppInstInfo
*
pAppInfo
;
}
STscObj
;
typedef
struct
SClientResultInfo
{
SSDataBlock
*
pData
;
TAOS_FIELD
*
resultFields
;
int32_t
current
;
}
SClientResultInfo
;
typedef
struct
SReqBody
{
tsem_t
rspSem
;
// not used now
void
*
fp
;
void
*
param
;
int32_t
paramLen
;
SClientResultInfo
*
pResInfo
;
}
SRequestBody
;
#define ERROR_MSG_BUF_DEFAULT_SIZE 512
...
...
@@ -142,6 +151,8 @@ void initMsgHandleFp();
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
);
TAOS_RES
*
taos_query_l
(
TAOS
*
taos
,
const
char
*
sql
,
size_t
sqlLen
);
void
*
doFetchRow
(
SRequestObj
*
pRequest
);
#ifdef __cplusplus
}
#endif
...
...
source/client/src/clientImpl.c
浏览文件 @
cfce1340
...
...
@@ -149,11 +149,12 @@ TAOS_RES *taos_query_l(TAOS *taos, const char *sql, size_t sqlLen) {
}
else
{
int32_t
type
=
0
;
void
*
output
=
NULL
;
code
=
qParseQuerySql
(
pRequest
->
sqlstr
,
sqlLen
,
pRequest
->
requestId
,
&
type
,
&
output
,
pRequest
->
msgBuf
,
ERROR_MSG_BUF_DEFAULT_SIZE
);
int32_t
outputLen
=
0
;
code
=
qParseQuerySql
(
pRequest
->
sqlstr
,
sqlLen
,
pRequest
->
requestId
,
&
type
,
&
output
,
&
outputLen
,
pRequest
->
msgBuf
,
ERROR_MSG_BUF_DEFAULT_SIZE
);
if
(
type
==
TSDB_SQL_CREATE_USER
||
type
==
TSDB_SQL_SHOW
)
{
pRequest
->
type
=
type
;
pRequest
->
body
.
param
=
output
;
pRequest
->
body
.
paramLen
=
outputLen
;
SRequestMsgBody
body
=
{
0
};
buildRequestMsgFp
[
type
](
pRequest
,
&
body
);
...
...
@@ -374,4 +375,21 @@ TAOS *taos_connect_l(const char *ip, int ipLen, const char *user, int userLen, c
strncpy
(
passStr
,
pass
,
MIN
(
TSDB_PASSWORD_LEN
-
1
,
passLen
));
strncpy
(
dbStr
,
db
,
MIN
(
TSDB_DB_NAME_LEN
-
1
,
dbLen
));
return
taos_connect
(
ipStr
,
userStr
,
passStr
,
dbStr
,
port
);
}
void
*
doFetchRow
(
SRequestObj
*
pRequest
)
{
assert
(
pRequest
!=
NULL
);
SClientResultInfo
*
pResultInfo
=
pRequest
->
body
.
pResInfo
;
if
(
pResultInfo
==
NULL
||
pResultInfo
->
current
>=
pResultInfo
->
pData
->
info
.
rows
)
{
if
(
pResultInfo
==
NULL
)
{
pRequest
->
body
.
pResInfo
=
calloc
(
1
,
sizeof
(
SClientResultInfo
));
// pRequest->body.pResInfo.
}
// current data set are exhausted, fetch more result from node
// if (pRes->row >= pRes->numOfRows && needToFetchNewBlock(pSql)) {
// taos_fetch_rows_a(res, waitForRetrieveRsp, pSql->pTscObj);
// tsem_wait(&pSql->rspSem);
// }
}
}
\ No newline at end of file
source/client/src/clientMain.c
浏览文件 @
cfce1340
...
...
@@ -117,3 +117,17 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) {
return
taos_query_l
(
taos
,
sql
,
strlen
(
sql
));
}
TAOS_ROW
taos_fetch_row
(
TAOS_RES
*
pRes
)
{
if
(
pRes
==
NULL
)
{
return
NULL
;
}
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
pRes
;
if
(
pRequest
->
type
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
||
pRequest
->
type
==
TSDB_SQL_INSERT
)
{
return
NULL
;
}
return
doFetchRow
(
pRequest
);
}
source/client/src/clientMsgHandler.c
浏览文件 @
cfce1340
...
...
@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <catalog.h>
#include "clientInt.h"
#include "clientLog.h"
#include "os.h"
...
...
@@ -3165,7 +3166,74 @@ int32_t buildCreateUserMsg(SRequestObj *pRequest, SRequestMsgBody* pMsgBody) {
pMsgBody
->
msgType
=
TSDB_MSG_TYPE_CREATE_USER
;
pMsgBody
->
msgLen
=
sizeof
(
SCreateUserMsg
);
pMsgBody
->
requestObjRefId
=
pRequest
->
self
;
pMsgBody
->
pData
=
pRequest
->
body
.
param
;
pMsgBody
->
pData
=
pRequest
->
body
.
param
;
return
0
;
}
int32_t
buildShowMsg
(
SRequestObj
*
pRequest
,
SRequestMsgBody
*
pMsgBody
)
{
pMsgBody
->
msgType
=
TSDB_MSG_TYPE_SHOW
;
pMsgBody
->
msgLen
=
pRequest
->
body
.
paramLen
;
pMsgBody
->
requestObjRefId
=
pRequest
->
self
;
pMsgBody
->
pData
=
pRequest
->
body
.
param
;
}
STableMeta
*
createTableMetaFromMsg
(
STableMetaMsg
*
pTableMetaMsg
)
{
assert
(
pTableMetaMsg
!=
NULL
&&
pTableMetaMsg
->
numOfColumns
>=
2
);
size_t
schemaSize
=
(
pTableMetaMsg
->
numOfColumns
+
pTableMetaMsg
->
numOfTags
)
*
sizeof
(
SSchema
);
STableMeta
*
pTableMeta
=
calloc
(
1
,
sizeof
(
STableMeta
)
+
schemaSize
);
pTableMeta
->
tableType
=
pTableMetaMsg
->
tableType
;
pTableMeta
->
vgId
=
pTableMetaMsg
->
vgroup
.
vgId
;
pTableMeta
->
suid
=
pTableMetaMsg
->
suid
;
pTableMeta
->
uid
=
pTableMetaMsg
->
tuid
;
pTableMeta
->
tableInfo
=
(
STableComInfo
)
{
.
numOfTags
=
pTableMetaMsg
->
numOfTags
,
.
precision
=
pTableMetaMsg
->
precision
,
.
numOfColumns
=
pTableMetaMsg
->
numOfColumns
,
};
pTableMeta
->
sversion
=
pTableMetaMsg
->
sversion
;
pTableMeta
->
tversion
=
pTableMetaMsg
->
tversion
;
memcpy
(
pTableMeta
->
schema
,
pTableMetaMsg
->
pSchema
,
schemaSize
);
int32_t
numOfTotalCols
=
pTableMeta
->
tableInfo
.
numOfColumns
;
for
(
int32_t
i
=
0
;
i
<
numOfTotalCols
;
++
i
)
{
pTableMeta
->
tableInfo
.
rowSize
+=
pTableMeta
->
schema
[
i
].
bytes
;
}
return
pTableMeta
;
}
int32_t
processShowRsp
(
SRequestObj
*
pRequest
,
const
char
*
pMsg
,
int32_t
msgLen
)
{
SShowRsp
*
pShow
=
(
SShowRsp
*
)
pMsg
;
pShow
->
showId
=
htonl
(
pShow
->
showId
);
STableMetaMsg
*
pMetaMsg
=
&
(
pShow
->
tableMeta
);
pMetaMsg
->
numOfColumns
=
htonl
(
pMetaMsg
->
numOfColumns
);
SSchema
*
pSchema
=
pMetaMsg
->
pSchema
;
pMetaMsg
->
tuid
=
htobe64
(
pMetaMsg
->
tuid
);
for
(
int
i
=
0
;
i
<
pMetaMsg
->
numOfColumns
;
++
i
)
{
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
pSchema
++
;
}
STableMeta
*
pTableMeta
=
createTableMetaFromMsg
(
pMetaMsg
);
SSchema
*
pTableSchema
=
pTableMeta
->
schema
;
TAOS_FIELD
*
pFields
=
calloc
(
1
,
pTableMeta
->
tableInfo
.
numOfColumns
);
for
(
int16_t
i
=
0
;
i
<
pTableMeta
->
tableInfo
.
numOfColumns
;
++
i
,
++
pSchema
)
{
tstrncpy
(
pFields
[
i
].
name
,
pTableSchema
[
i
].
name
,
tListLen
(
pFields
[
i
].
name
));
pFields
[
i
].
type
=
pTableSchema
[
i
].
type
;
pFields
[
i
].
bytes
=
pTableSchema
[
i
].
bytes
;
}
// pRequest->body.resultFields = pFields;
// pRequest->body.numOfFields = pTableMeta->tableInfo.numOfColumns;
return
0
;
}
...
...
@@ -3250,5 +3318,7 @@ void initMsgHandleFp() {
buildRequestMsgFp
[
TSDB_SQL_CREATE_USER
]
=
buildCreateUserMsg
;
buildRequestMsgFp
[
TSDB_SQL_SHOW
]
=
buildShowMsg
;
handleRequestRspFp
[
TSDB_SQL_SHOW
]
=
processShowRsp
;
}
\ No newline at end of file
source/client/test/clientTests.cpp
浏览文件 @
cfce1340
...
...
@@ -37,14 +37,16 @@ TEST(testCase, driverInit_Test) {
TAOS
*
pConn
=
taos_connect
(
"ubuntu"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"create user abc pass 'abc'"
);
if
(
taos_errno
(
pRes
)
!=
TSDB_CODE_SUCCESS
)
{
printf
(
"failed to create user, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"show users"
);
// TAOS_RES* pRes = taos_query(pConn, "create user abc pass 'abc'");
// if (taos_errno(pRes) != TSDB_CODE_SUCCESS) {
// printf("failed to create user, reason:%s\n", taos_errstr(pRes));
// }
//
// taos_free_result(pRes);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"show users"
);
TAOS_ROW
pRow
=
taos_fetch_row
(
pRes
);
assert
(
pRow
!=
NULL
);
taos_close
(
pConn
);
}
\ No newline at end of file
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
cfce1340
...
...
@@ -471,7 +471,7 @@ static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pMeta
->
numOfColumns
=
hton
s
(
cols
);
pMeta
->
numOfColumns
=
hton
l
(
cols
);
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
...
...
source/libs/parser/inc/parserInt.h
浏览文件 @
cfce1340
...
...
@@ -60,7 +60,7 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pSqlInfo, SQ
* @param type
* @return
*/
int32_t
qParserValidateD
dlSqlNode
(
SSqlInfo
*
pInfo
,
int64_t
id
,
void
**
output
,
int32_t
*
type
,
char
*
msgBuf
,
int32_t
msgBufLen
);
int32_t
qParserValidateD
clSqlNode
(
SSqlInfo
*
pInfo
,
int64_t
id
,
void
**
output
,
int32_t
*
outputLen
,
int32_t
*
type
,
char
*
msgBuf
,
int32_t
msgBufLen
);
/**
* Evaluate the numeric and timestamp arithmetic expression in the WHERE clause.
...
...
source/libs/parser/inc/parserUtil.h
浏览文件 @
cfce1340
...
...
@@ -65,7 +65,7 @@ int32_t getExprFunctionId(SExprInfo *pExprInfo);
STableMeta
*
tableMetaDup
(
const
STableMeta
*
pTableMeta
);
bool
isD
dlSql
(
SSqlInfo
*
pSqlInfo
);
bool
isD
clSqlStatement
(
SSqlInfo
*
pSqlInfo
);
#ifdef __cplusplus
}
...
...
source/libs/parser/src/astValidate.c
浏览文件 @
cfce1340
...
...
@@ -4069,7 +4069,93 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
return
code
;
}
int32_t
qParserValidateDdlSqlNode
(
SSqlInfo
*
pInfo
,
int64_t
id
,
void
**
output
,
int32_t
*
type
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
// todo remove it
static
int32_t
setShowInfo
(
struct
SSqlInfo
*
pInfo
,
void
**
output
,
int32_t
*
msgLen
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
msg1
=
"invalid name"
;
const
char
*
msg2
=
"wildcard string should be less than %d characters"
;
const
char
*
msg3
=
"database name too long"
;
const
char
*
msg4
=
"pattern is invalid"
;
const
char
*
msg5
=
"database name is empty"
;
const
char
*
msg6
=
"pattern string is empty"
;
/*
* database prefix in pInfo->pMiscInfo->a[0]
* wildcard in like clause in pInfo->pMiscInfo->a[1]
*/
SShowInfo
*
pShowInfo
=
&
pInfo
->
pMiscInfo
->
showOpt
;
int16_t
showType
=
pShowInfo
->
showType
;
if
(
showType
==
TSDB_MGMT_TABLE_TABLE
||
showType
==
TSDB_MGMT_TABLE_VGROUP
)
{
SToken
*
pDbPrefixToken
=
&
pShowInfo
->
prefix
;
if
(
pDbPrefixToken
->
type
!=
0
)
{
if
(
pDbPrefixToken
->
n
>=
TSDB_DB_NAME_LEN
)
{
// db name is too long
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg3
);
}
if
(
pDbPrefixToken
->
n
<=
0
)
{
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg5
);
}
if
(
parserValidateIdToken
(
pDbPrefixToken
)
!=
TSDB_CODE_SUCCESS
)
{
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
}
// int32_t ret = tNameSetDbName(&pTableMetaInfo->name, getAccountId(pRequest->pTsc), pDbPrefixToken);
// if (ret != TSDB_CODE_SUCCESS) {
// return buildInvalidOperationMsg(pMsgBuf, msg1);
// }
}
// show table/stable like 'xxxx', set the like pattern for show tables
SToken
*
pPattern
=
&
pShowInfo
->
pattern
;
if
(
pPattern
->
type
!=
0
)
{
if
(
pPattern
->
type
==
TK_ID
&&
pPattern
->
z
[
0
]
==
TS_ESCAPE_CHAR
)
{
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg4
);
}
pPattern
->
n
=
strdequote
(
pPattern
->
z
);
if
(
pPattern
->
n
<=
0
)
{
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg6
);
}
if
(
pPattern
->
n
>
tsMaxWildCardsLen
)
{
char
tmp
[
64
]
=
{
0
};
sprintf
(
tmp
,
msg2
,
tsMaxWildCardsLen
);
return
buildInvalidOperationMsg
(
pMsgBuf
,
tmp
);
}
}
}
else
if
(
showType
==
TSDB_MGMT_TABLE_VNODES
)
{
if
(
pShowInfo
->
prefix
.
type
==
0
)
{
return
buildInvalidOperationMsg
(
pMsgBuf
,
"No specified dnode ep"
);
}
if
(
pShowInfo
->
prefix
.
type
==
TK_STRING
)
{
pShowInfo
->
prefix
.
n
=
strdequote
(
pShowInfo
->
prefix
.
z
);
}
}
SShowMsg
*
pShowMsg
=
calloc
(
1
,
sizeof
(
SShowMsg
));
pShowMsg
->
type
=
pShowInfo
->
showType
;
if
(
pShowInfo
->
showType
!=
TSDB_MGMT_TABLE_VNODES
)
{
SToken
*
pPattern
=
&
pShowInfo
->
pattern
;
if
(
pPattern
->
type
>
0
)
{
// only show tables support wildcard query
strncpy
(
pShowMsg
->
payload
,
pPattern
->
z
,
pPattern
->
n
);
pShowMsg
->
payloadLen
=
htons
(
pPattern
->
n
);
}
}
else
{
SToken
*
pEpAddr
=
&
pShowInfo
->
prefix
;
assert
(
pEpAddr
->
n
>
0
&&
pEpAddr
->
type
>
0
);
strncpy
(
pShowMsg
->
payload
,
pEpAddr
->
z
,
pEpAddr
->
n
);
pShowMsg
->
payloadLen
=
htons
(
pEpAddr
->
n
);
}
*
output
=
pShowMsg
;
*
msgLen
=
sizeof
(
SShowMsg
)
+
htons
(
pShowMsg
->
payloadLen
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
qParserValidateDclSqlNode
(
SSqlInfo
*
pInfo
,
int64_t
id
,
void
**
output
,
int32_t
*
outputLen
,
int32_t
*
type
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
int32_t
code
=
0
;
SMsgBuf
m
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
...
...
@@ -4125,9 +4211,14 @@ int32_t qParserValidateDdlSqlNode(SSqlInfo* pInfo, int64_t id, void** output, in
*
output
=
buildUserManipulationMsg
(
pInfo
,
id
,
msgBuf
,
msgBufLen
);
break
;
}
case
TSDB_SQL_SHOW
:
{
code
=
setShowInfo
(
pInfo
,
output
,
outputLen
,
pMsgBuf
);
break
;
}
default:
break
;
}
return
0
;
return
code
;
}
source/libs/parser/src/parser.c
浏览文件 @
cfce1340
...
...
@@ -31,7 +31,7 @@ bool qIsInsertSql(const char* pStr, size_t length) {
}
while
(
1
);
}
int32_t
qParseQuerySql
(
const
char
*
pStr
,
size_t
length
,
int64_t
id
,
int32_t
*
type
,
void
**
pOutput
,
char
*
msg
,
int32_t
msgLen
)
{
int32_t
qParseQuerySql
(
const
char
*
pStr
,
size_t
length
,
int64_t
id
,
int32_t
*
type
,
void
**
pOutput
,
int32_t
*
outputLen
,
char
*
msg
,
int32_t
msgLen
)
{
SQueryStmtInfo
*
pQueryInfo
=
calloc
(
1
,
sizeof
(
SQueryStmtInfo
));
if
(
pQueryInfo
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
// set correct error code.
...
...
@@ -45,8 +45,8 @@ int32_t qParseQuerySql(const char* pStr, size_t length, int64_t id, int32_t *typ
return
terrno
;
}
if
(
isD
dlSql
(
&
info
))
{
int32_t
code
=
qParserValidateD
dlSqlNode
(
&
info
,
id
,
pOutput
,
type
,
msg
,
msgLen
);
if
(
isD
clSqlStatement
(
&
info
))
{
int32_t
code
=
qParserValidateD
clSqlNode
(
&
info
,
id
,
pOutput
,
outputLen
,
type
,
msg
,
msgLen
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
// do nothing
}
...
...
source/libs/parser/src/parserUtil.c
浏览文件 @
cfce1340
...
...
@@ -12,8 +12,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "parserUtil.h"
#include <tmsgtype.h>
#include "taosmsg.h"
#include "parser.h"
...
...
@@ -23,6 +22,8 @@
#include "thash.h"
#include "tbuffer.h"
#include "parserInt.h"
#include "parserUtil.h"
#include "tmsgtype.h"
#include "queryInfoUtil.h"
#include "function.h"
...
...
@@ -1632,7 +1633,7 @@ uint32_t convertRelationalOperator(SToken *pToken) {
}
}
bool
isD
dlSql
(
SSqlInfo
*
pSqlInfo
)
{
bool
isD
clSqlStatement
(
SSqlInfo
*
pSqlInfo
)
{
return
(
pSqlInfo
->
type
!=
TSDB_SQL_SELECT
);
}
...
...
source/libs/parser/test/parserTests.cpp
浏览文件 @
cfce1340
...
...
@@ -714,16 +714,14 @@ TEST(testCase, show_user_Test) {
SSqlInfo
info1
=
doGenerateAST
(
sql1
);
ASSERT_EQ
(
info1
.
valid
,
true
);
void
*
output
=
NULL
;
int32_t
type
=
0
;
int32_t
len
=
0
;
int32_t
code
=
qParserValidateDclSqlNode
(
&
info1
,
1
,
&
output
,
&
len
,
&
type
,
msg
,
buf
.
len
);
ASSERT_EQ
(
code
,
0
);
// convert the show command to be the select query
// select name, privilege, create_time, account from information_schema.users;
SQueryStmtInfo
*
pQueryInfo
=
createQueryInfo
();
// setTableMetaInfo(pQueryInfo, &req);
// SSqlNode* pSqlNode = (SSqlNode*)taosArrayGetP(info1.sub.node, 0);
// ret = validateSqlNode(pSqlNode, pQueryInfo, &buf);
// ASSERT_NE(ret, 0);
}
TEST
(
testCase
,
create_user_Test
)
{
...
...
@@ -737,12 +735,12 @@ TEST(testCase, create_user_Test) {
SSqlInfo
info1
=
doGenerateAST
(
sql
);
ASSERT_EQ
(
info1
.
valid
,
true
);
ASSERT_EQ
(
isD
dlSql
(
&
info1
),
true
);
ASSERT_EQ
(
isD
clSqlStatement
(
&
info1
),
true
);
void
*
output
=
NULL
;
int32_t
type
=
0
;
int32_t
code
=
qParserValidateD
dlSqlNode
(
&
info1
,
1
,
&
output
,
&
type
,
msg
,
buf
.
len
);
int32_t
len
=
0
;
int32_t
code
=
qParserValidateD
clSqlNode
(
&
info1
,
1
,
&
output
,
&
len
,
&
type
,
msg
,
buf
.
len
);
ASSERT_EQ
(
code
,
0
);
destroySqlInfo
(
&
info1
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录