Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
77ff634d
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
77ff634d
编写于
12月 14, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-10564] enable parser create user.
上级
c8ffc27e
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
100 addition
and
24 deletion
+100
-24
include/libs/parser/parser.h
include/libs/parser/parser.h
+1
-1
source/client/CMakeLists.txt
source/client/CMakeLists.txt
+1
-1
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+5
-2
source/client/inc/clientLog.h
source/client/inc/clientLog.h
+2
-2
source/client/src/client.c
source/client/src/client.c
+2
-2
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+58
-2
source/client/src/clientMain.c
source/client/src/clientMain.c
+11
-3
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+2
-2
source/client/src/tscEnv.c
source/client/src/tscEnv.c
+4
-3
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+1
-0
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+13
-6
未找到文件。
include/libs/parser/parser.h
浏览文件 @
77ff634d
...
@@ -151,7 +151,7 @@ typedef struct SParseContext {
...
@@ -151,7 +151,7 @@ typedef struct SParseContext {
* @param msg extended error message if exists.
* @param msg extended error message if exists.
* @return error code
* @return error code
*/
*/
int32_t
qParseQuerySql
(
const
char
*
pStr
,
size_t
length
,
struct
SQueryStmtInfo
**
pQueryInfo
,
int64_t
id
,
char
*
msg
,
int32_t
msgLen
);
struct
SQueryStmtInfo
*
qParseQuerySql
(
const
char
*
pStr
,
size_t
length
,
int64_t
id
,
char
*
msg
,
int32_t
msgLen
);
typedef
enum
{
typedef
enum
{
PAYLOAD_TYPE_KV
=
0
,
PAYLOAD_TYPE_KV
=
0
,
...
...
source/client/CMakeLists.txt
浏览文件 @
77ff634d
...
@@ -8,7 +8,7 @@ target_include_directories(
...
@@ -8,7 +8,7 @@ target_include_directories(
target_link_libraries
(
target_link_libraries
(
taos
taos
INTERFACE api
INTERFACE api
PRIVATE os util common transport parser
PRIVATE os util common transport parser
catalog function
)
)
ADD_SUBDIRECTORY
(
test
)
ADD_SUBDIRECTORY
(
test
)
\ No newline at end of file
source/client/inc/clientInt.h
浏览文件 @
77ff634d
...
@@ -92,6 +92,8 @@ typedef struct SReqBody {
...
@@ -92,6 +92,8 @@ typedef struct SReqBody {
void
*
param
;
void
*
param
;
}
SRequestBody
;
}
SRequestBody
;
#define ERROR_MSG_BUF_DEFAULT_SIZE 512
typedef
struct
SRequestObj
{
typedef
struct
SRequestObj
{
uint64_t
requestId
;
uint64_t
requestId
;
int32_t
type
;
// request type
int32_t
type
;
// request type
...
@@ -129,8 +131,6 @@ void destroyTscObj(void*pObj);
...
@@ -129,8 +131,6 @@ void destroyTscObj(void*pObj);
void
*
createRequest
(
STscObj
*
pObj
,
__taos_async_fn_t
fp
,
void
*
param
,
int32_t
type
);
void
*
createRequest
(
STscObj
*
pObj
,
__taos_async_fn_t
fp
,
void
*
param
,
int32_t
type
);
void
destroyRequest
(
SRequestObj
*
pRequest
);
void
destroyRequest
(
SRequestObj
*
pRequest
);
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
);
void
taos_init_imp
(
void
);
void
taos_init_imp
(
void
);
int
taos_options_imp
(
TSDB_OPTION
option
,
const
char
*
str
);
int
taos_options_imp
(
TSDB_OPTION
option
,
const
char
*
str
);
...
@@ -139,6 +139,9 @@ void* openTransporter(const char *user, const char *auth);
...
@@ -139,6 +139,9 @@ void* openTransporter(const char *user, const char *auth);
void
processMsgFromServer
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
void
processMsgFromServer
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
void
initMsgHandleFp
();
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
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/client/inc/
tsc
Log.h
→
source/client/inc/
client
Log.h
浏览文件 @
77ff634d
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef TDENGINE_
TSC
LOG_H
#ifndef TDENGINE_
CLIENT
LOG_H
#define TDENGINE_
TSC
LOG_H
#define TDENGINE_
CLIENT
LOG_H
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
...
source/client/src/client.c
浏览文件 @
77ff634d
...
@@ -16,9 +16,9 @@
...
@@ -16,9 +16,9 @@
#include "os.h"
#include "os.h"
#include "tdef.h"
#include "tdef.h"
#include "tglobal.h"
#include "clientInt.h"
#include "clientInt.h"
#include "tscLog.h"
#include "clientLog.h"
#include "tglobal.h"
TAOS
*
taos_connect
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
db
,
uint16_t
port
)
{
TAOS
*
taos_connect
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
db
,
uint16_t
port
)
{
int32_t
p
=
(
port
!=
0
)
?
port
:
tsServerPort
;
int32_t
p
=
(
port
!=
0
)
?
port
:
tsServerPort
;
...
...
source/client/src/clientImpl.c
浏览文件 @
77ff634d
#include <tpagedfile.h>
#include <parser.h>
#include "clientInt.h"
#include "clientInt.h"
#include "clientLog.h"
#include "tdef.h"
#include "tdef.h"
#include "tep.h"
#include "tep.h"
#include "tglobal.h"
#include "tglobal.h"
#include "tmsgtype.h"
#include "tmsgtype.h"
#include "tnote.h"
#include "tpagedfile.h"
#include "tref.h"
#include "tref.h"
#include "tscLog.h"
static
int32_t
initEpSetFromCfg
(
const
char
*
firstEp
,
const
char
*
secondEp
,
SCorEpSet
*
pEpSet
);
static
int32_t
initEpSetFromCfg
(
const
char
*
firstEp
,
const
char
*
secondEp
,
SCorEpSet
*
pEpSet
);
static
int32_t
buildConnectMsg
(
SRequestObj
*
pRequest
,
SRequestMsgBody
*
pMsgBody
);
static
int32_t
buildConnectMsg
(
SRequestObj
*
pRequest
,
SRequestMsgBody
*
pMsgBody
);
...
@@ -109,6 +112,59 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
...
@@ -109,6 +112,59 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass,
return
taosConnectImpl
(
ip
,
user
,
&
secretEncrypt
[
0
],
db
,
port
,
NULL
,
NULL
,
pInst
);
return
taosConnectImpl
(
ip
,
user
,
&
secretEncrypt
[
0
],
db
,
port
,
NULL
,
NULL
,
pInst
);
}
}
TAOS_RES
*
taos_query_l
(
TAOS
*
taos
,
const
char
*
sql
,
size_t
sqlLen
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
if
(
sqlLen
>
(
size_t
)
tsMaxSQLStringLen
)
{
tscError
(
"sql string exceeds max length:%d"
,
tsMaxSQLStringLen
);
terrno
=
TSDB_CODE_TSC_EXCEED_SQL_LIMIT
;
return
NULL
;
}
nPrintTsc
(
"%s"
,
sql
)
SRequestObj
*
pRequest
=
createRequest
(
pObj
,
NULL
,
NULL
,
TSDB_SQL_SELECT
);
if
(
pRequest
==
NULL
)
{
tscError
(
"failed to malloc sqlObj"
);
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
NULL
;
}
pRequest
->
sqlstr
=
malloc
(
sqlLen
+
1
);
if
(
pRequest
->
sqlstr
==
NULL
)
{
tscError
(
"0x%"
PRIx64
" failed to prepare sql string buffer"
,
pRequest
->
self
);
pRequest
->
msgBuf
=
strdup
(
"failed to prepare sql string buffer"
);
terrno
=
pRequest
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
pRequest
;
}
strntolower
(
pRequest
->
sqlstr
,
sql
,
(
int32_t
)
sqlLen
);
pRequest
->
sqlstr
[
sqlLen
]
=
0
;
tscDebugL
(
"0x%"
PRIx64
" SQL: %s"
,
pRequest
->
requestId
,
pRequest
->
sqlstr
);
int32_t
code
=
0
;
//tsParseSql(pSql, true);
if
(
qIsInsertSql
(
pRequest
->
sqlstr
,
sqlLen
))
{
// qParseInsertSql();
}
else
{
SQueryStmtInfo
*
pQueryInfo
=
qParseQuerySql
(
pRequest
->
sqlstr
,
sqlLen
,
pRequest
->
requestId
,
pRequest
->
msgBuf
,
ERROR_MSG_BUF_DEFAULT_SIZE
);
assert
(
pQueryInfo
!=
NULL
);
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pRequest
->
code
=
code
;
// tscAsyncResultOnError(pSql);
// taosReleaseRef(tscReqRef, p->self);
return
NULL
;
}
// executeQuery(pSql, pQueryInfo);
// doAsyncQuery(pObj, pSql, waitForQueryRsp, taos, sqlstr, sqlLen);
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
return
pRequest
;
}
int
initEpSetFromCfg
(
const
char
*
firstEp
,
const
char
*
secondEp
,
SCorEpSet
*
pEpSet
)
{
int
initEpSetFromCfg
(
const
char
*
firstEp
,
const
char
*
secondEp
,
SCorEpSet
*
pEpSet
)
{
pEpSet
->
version
=
0
;
pEpSet
->
version
=
0
;
...
...
source/client/src/client
m
ain.c
→
source/client/src/client
M
ain.c
浏览文件 @
77ff634d
#include "clientInt.h"
#include "clientInt.h"
#include "
trpc
.h"
#include "
clientLog
.h"
#include "os.h"
#include "os.h"
#include "taosmsg.h"
#include "taosmsg.h"
#include "tcache.h"
#include "tcache.h"
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include "tglobal.h"
#include "tglobal.h"
#include "tnote.h"
#include "tnote.h"
#include "tref.h"
#include "tref.h"
#include "t
scLog
.h"
#include "t
rpc
.h"
#include "tsched.h"
#include "tsched.h"
#include "ttime.h"
#include "ttime.h"
#include "ttimezone.h"
#include "ttimezone.h"
...
@@ -82,4 +82,12 @@ const char *taos_errstr(TAOS_RES *res) {
...
@@ -82,4 +82,12 @@ const char *taos_errstr(TAOS_RES *res) {
void
taos_free_result
(
TAOS_RES
*
res
)
{
void
taos_free_result
(
TAOS_RES
*
res
)
{
}
}
\ No newline at end of file
TAOS_RES
*
taos_query
(
TAOS
*
taos
,
const
char
*
sql
)
{
if
(
taos
==
NULL
||
sql
==
NULL
)
{
return
NULL
;
}
return
taos_query_l
(
taos
,
sql
,
strlen
(
sql
));
}
source/client/src/clientMsgHandler.c
浏览文件 @
77ff634d
...
@@ -13,11 +13,11 @@
...
@@ -13,11 +13,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "os.h"
#include "clientInt.h"
#include "clientInt.h"
#include "clientLog.h"
#include "os.h"
#include "tmsgtype.h"
#include "tmsgtype.h"
#include "trpc.h"
#include "trpc.h"
#include "tscLog.h"
int
(
*
buildRequestMsgFp
[
TSDB_SQL_MAX
])(
SRequestObj
*
pRequest
,
SRequestMsgBody
*
pMsgBody
)
=
{
0
};
int
(
*
buildRequestMsgFp
[
TSDB_SQL_MAX
])(
SRequestObj
*
pRequest
,
SRequestMsgBody
*
pMsgBody
)
=
{
0
};
int
(
*
handleRequestRspFp
[
TSDB_SQL_MAX
])(
SRequestObj
*
pRequest
,
const
char
*
pMsg
,
int32_t
msgLen
);
int
(
*
handleRequestRspFp
[
TSDB_SQL_MAX
])(
SRequestObj
*
pRequest
,
const
char
*
pMsg
,
int32_t
msgLen
);
...
...
source/client/src/tscEnv.c
浏览文件 @
77ff634d
...
@@ -13,6 +13,8 @@
...
@@ -13,6 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "clientInt.h"
#include "clientLog.h"
#include "os.h"
#include "os.h"
#include "taosmsg.h"
#include "taosmsg.h"
#include "tcache.h"
#include "tcache.h"
...
@@ -20,12 +22,10 @@
...
@@ -20,12 +22,10 @@
#include "tglobal.h"
#include "tglobal.h"
#include "tnote.h"
#include "tnote.h"
#include "tref.h"
#include "tref.h"
#include "t
scLog
.h"
#include "t
rpc
.h"
#include "tsched.h"
#include "tsched.h"
#include "ttime.h"
#include "ttime.h"
#include "trpc.h"
#include "ttimezone.h"
#include "ttimezone.h"
#include "clientInt.h"
#define TSC_VAR_NOT_RELEASE 1
#define TSC_VAR_NOT_RELEASE 1
#define TSC_VAR_RELEASED 0
#define TSC_VAR_RELEASED 0
...
@@ -172,6 +172,7 @@ void* createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t ty
...
@@ -172,6 +172,7 @@ void* createRequest(STscObj* pObj, __taos_async_fn_t fp, void* param, int32_t ty
pRequest
->
pTscObj
=
pObj
;
pRequest
->
pTscObj
=
pObj
;
pRequest
->
body
.
fp
=
fp
;
pRequest
->
body
.
fp
=
fp
;
pRequest
->
body
.
param
=
param
;
pRequest
->
body
.
param
=
param
;
pRequest
->
msgBuf
=
calloc
(
1
,
ERROR_MSG_BUF_DEFAULT_SIZE
);
tsem_init
(
&
pRequest
->
body
.
rspSem
,
0
,
0
);
tsem_init
(
&
pRequest
->
body
.
rspSem
,
0
,
0
);
registerRequest
(
pRequest
);
registerRequest
(
pRequest
);
...
...
source/client/test/clientTests.cpp
浏览文件 @
77ff634d
...
@@ -36,5 +36,6 @@ TEST(testCase, driverInit_Test) {
...
@@ -36,5 +36,6 @@ TEST(testCase, driverInit_Test) {
TAOS
*
pConn
=
taos_connect
(
"ubuntu"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS
*
pConn
=
taos_connect
(
"ubuntu"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
assert
(
pConn
!=
NULL
);
taos_query
(
pConn
,
"create user abc pass 'abc'"
);
taos_close
(
pConn
);
taos_close
(
pConn
);
}
}
\ No newline at end of file
source/libs/parser/src/parser.c
浏览文件 @
77ff634d
...
@@ -31,20 +31,27 @@ bool qIsInsertSql(const char* pStr, size_t length) {
...
@@ -31,20 +31,27 @@ bool qIsInsertSql(const char* pStr, size_t length) {
}
while
(
1
);
}
while
(
1
);
}
}
int32_t
qParseQuerySql
(
const
char
*
pStr
,
size_t
length
,
struct
SQueryStmtInfo
**
pQueryInfo
,
int64_t
id
,
char
*
msg
,
int32_t
msgLen
)
{
SQueryStmtInfo
*
qParseQuerySql
(
const
char
*
pStr
,
size_t
length
,
int64_t
id
,
char
*
msg
,
int32_t
msgLen
)
{
*
pQueryInfo
=
calloc
(
1
,
sizeof
(
SQueryStmtInfo
));
SQueryStmtInfo
*
pQueryInfo
=
calloc
(
1
,
sizeof
(
SQueryStmtInfo
));
if
(
*
pQueryInfo
==
NULL
)
{
if
(
pQueryInfo
==
NULL
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
// set correct error code.
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
// set correct error code.
return
NULL
;
}
}
SSqlInfo
info
=
doGenerateAST
(
pStr
);
SSqlInfo
info
=
doGenerateAST
(
pStr
);
if
(
!
info
.
valid
)
{
if
(
!
info
.
valid
)
{
strncpy
(
msg
,
info
.
msg
,
msgLen
);
strncpy
(
msg
,
info
.
msg
,
msgLen
);
return
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
terrno
=
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
return
NULL
;
}
}
struct
SCatalog
*
pCatalog
=
getCatalogHandle
(
NULL
);
struct
SCatalog
*
pCatalog
=
getCatalogHandle
(
NULL
);
return
qParserValidateSqlNode
(
pCatalog
,
&
info
,
*
pQueryInfo
,
id
,
msg
,
msgLen
);
int32_t
code
=
qParserValidateSqlNode
(
pCatalog
,
&
info
,
pQueryInfo
,
id
,
msg
,
msgLen
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
return
pQueryInfo
;
}
return
NULL
;
}
}
int32_t
qParseInsertSql
(
SParseContext
*
pContext
,
SInsertStmtInfo
**
pInfo
)
{
int32_t
qParseInsertSql
(
SParseContext
*
pContext
,
SInsertStmtInfo
**
pInfo
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录