Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
55ee57ec
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看板
提交
55ee57ec
编写于
12月 28, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-11818] refactor create dnode. async send message to server.
上级
4ebabfcf
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
1635 addition
and
1548 deletion
+1635
-1548
include/common/tmsg.h
include/common/tmsg.h
+2
-1
include/libs/qcom/query.h
include/libs/qcom/query.h
+9
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+0
-24
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+19
-2
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+12
-3
source/libs/parser/inc/ttokendef.h
source/libs/parser/inc/ttokendef.h
+109
-108
source/libs/parser/src/astToMsg.c
source/libs/parser/src/astToMsg.c
+25
-2
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+0
-2
source/libs/parser/src/dCDAstProcess.c
source/libs/parser/src/dCDAstProcess.c
+38
-44
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+1388
-1361
source/libs/parser/src/ttokenizer.c
source/libs/parser/src/ttokenizer.c
+2
-1
source/libs/qcom/src/queryUtil.c
source/libs/qcom/src/queryUtil.c
+25
-0
src/query/inc/sql.y
src/query/inc/sql.y
+6
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
55ee57ec
...
@@ -826,7 +826,8 @@ typedef struct SShowRsp {
...
@@ -826,7 +826,8 @@ typedef struct SShowRsp {
}
SShowRsp
;
}
SShowRsp
;
typedef
struct
{
typedef
struct
{
char
ep
[
TSDB_EP_LEN
];
// end point, hostname:port
char
ep
[
TSDB_FQDN_LEN
];
// end point, hostname:port
int32_t
port
;
}
SCreateDnodeMsg
;
}
SCreateDnodeMsg
;
typedef
struct
{
typedef
struct
{
...
...
include/libs/qcom/query.h
浏览文件 @
55ee57ec
...
@@ -124,6 +124,15 @@ int32_t cleanupTaskQueue();
...
@@ -124,6 +124,15 @@ int32_t cleanupTaskQueue();
*/
*/
int32_t
taosAsyncExec
(
__async_exec_fn_t
execFn
,
void
*
execParam
,
int32_t
*
code
);
int32_t
taosAsyncExec
(
__async_exec_fn_t
execFn
,
void
*
execParam
,
int32_t
*
code
);
/**
* Asynchronously send message to server, after the response received, the callback will be incured.
*
* @param pTransporter
* @param epSet
* @param pTransporterId
* @param pInfo
* @return
*/
int32_t
asyncSendMsgToServer
(
void
*
pTransporter
,
SEpSet
*
epSet
,
int64_t
*
pTransporterId
,
const
SMsgSendInfo
*
pInfo
);
int32_t
asyncSendMsgToServer
(
void
*
pTransporter
,
SEpSet
*
epSet
,
int64_t
*
pTransporterId
,
const
SMsgSendInfo
*
pInfo
);
const
SSchema
*
tGetTbnameColumnSchema
();
const
SSchema
*
tGetTbnameColumnSchema
();
...
...
source/client/src/clientImpl.c
浏览文件 @
55ee57ec
...
@@ -362,30 +362,6 @@ static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
...
@@ -362,30 +362,6 @@ static void destroySendMsgInfo(SMsgSendInfo* pMsgBody) {
tfree
(
pMsgBody
);
tfree
(
pMsgBody
);
}
}
int32_t
asyncSendMsgToServer
(
void
*
pTransporter
,
SEpSet
*
epSet
,
int64_t
*
pTransporterId
,
const
SMsgSendInfo
*
pInfo
)
{
char
*
pMsg
=
rpcMallocCont
(
pInfo
->
msgInfo
.
len
);
if
(
NULL
==
pMsg
)
{
tscError
(
"0x%"
PRIx64
" msg:%s malloc failed"
,
pInfo
->
requestId
,
TMSG_INFO
(
pInfo
->
msgType
));
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
-
1
;
}
memcpy
(
pMsg
,
pInfo
->
msgInfo
.
pData
,
pInfo
->
msgInfo
.
len
);
SRpcMsg
rpcMsg
=
{
.
msgType
=
pInfo
->
msgType
,
.
pCont
=
pMsg
,
.
contLen
=
pInfo
->
msgInfo
.
len
,
.
ahandle
=
(
void
*
)
pInfo
,
.
handle
=
NULL
,
.
code
=
0
};
assert
(
pInfo
->
fp
!=
NULL
);
rpcSendRequest
(
pTransporter
,
epSet
,
&
rpcMsg
,
pTransporterId
);
return
TSDB_CODE_SUCCESS
;
}
void
processMsgFromServer
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
void
processMsgFromServer
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SMsgSendInfo
*
pSendInfo
=
(
SMsgSendInfo
*
)
pMsg
->
ahandle
;
SMsgSendInfo
*
pSendInfo
=
(
SMsgSendInfo
*
)
pMsg
->
ahandle
;
assert
(
pMsg
->
ahandle
!=
NULL
);
assert
(
pMsg
->
ahandle
!=
NULL
);
...
...
source/client/test/clientTests.cpp
浏览文件 @
55ee57ec
...
@@ -173,7 +173,7 @@ TEST(testCase, create_dnode_Test) {
...
@@ -173,7 +173,7 @@ TEST(testCase, create_dnode_Test) {
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"create dnode abc1"
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"create dnode abc1
port 7000
"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in create dnode, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"error in create dnode, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
}
...
@@ -291,7 +291,24 @@ TEST(testCase, create_table_Test) {
...
@@ -291,7 +291,24 @@ TEST(testCase, create_table_Test) {
// taos_close(pConn);
// taos_close(pConn);
}
}
TEST
(
testCase
,
create_ctable_Test
)
{}
TEST
(
testCase
,
create_ctable_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to use db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table tm0 using st1 tags(1)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create child table tm0, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
TEST
(
testCase
,
show_stable_Test
)
{
TEST
(
testCase
,
show_stable_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
55ee57ec
...
@@ -200,7 +200,7 @@ ifnotexists(X) ::= . { X.n = 0;}
...
@@ -200,7 +200,7 @@ ifnotexists(X) ::= . { X.n = 0;}
/////////////////////////////////THE CREATE STATEMENT///////////////////////////////////////
/////////////////////////////////THE CREATE STATEMENT///////////////////////////////////////
//create option for dnode/db/user/account
//create option for dnode/db/user/account
cmd ::= CREATE DNODE ids(X)
. { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &X
);}
cmd ::= CREATE DNODE ids(X)
PORT ids(Y). { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 2, &X, &Y
);}
cmd ::= CREATE ACCOUNT ids(X) PASS ids(Y) acct_optr(Z).
cmd ::= CREATE ACCOUNT ids(X) PASS ids(Y) acct_optr(Z).
{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &X, &Y, &Z);}
{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &X, &Y, &Z);}
cmd ::= CREATE DATABASE ifnotexists(Z) ids(X) db_optr(Y). { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &X, &Y, &Z);}
cmd ::= CREATE DATABASE ifnotexists(Z) ids(X) db_optr(Y). { setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &X, &Y, &Z);}
...
@@ -398,13 +398,13 @@ create_stable_args(A) ::= ifnotexists(U) ids(V) cpxName(Z) LP columnlist(X) RP T
...
@@ -398,13 +398,13 @@ create_stable_args(A) ::= ifnotexists(U) ids(V) cpxName(Z) LP columnlist(X) RP T
// create table by using super table
// create table by using super table
// create table table_name using super_table_name tags(tag_values1, tag_values2)
// create table table_name using super_table_name tags(tag_values1, tag_values2)
%type create_from_stable{SCreatedTableInfo}
%type create_from_stable{SCreatedTableInfo}
create_from_stable(A) ::= ifnotexists(U) ids(V) cpxName(Z) USING ids(X) cpxName(F) TAGS LP tagitemlist(Y) RP. {
create_from_stable(A) ::= ifnotexists(U) ids(V) cpxName(Z) USING ids(X) cpxName(F) TAGS LP tagitemlist
1
(Y) RP. {
X.n += F.n;
X.n += F.n;
V.n += Z.n;
V.n += Z.n;
A = createNewChildTableInfo(&X, NULL, Y, &V, &U);
A = createNewChildTableInfo(&X, NULL, Y, &V, &U);
}
}
create_from_stable(A) ::= ifnotexists(U) ids(V) cpxName(Z) USING ids(X) cpxName(F) LP tagNamelist(P) RP TAGS LP tagitemlist(Y) RP. {
create_from_stable(A) ::= ifnotexists(U) ids(V) cpxName(Z) USING ids(X) cpxName(F) LP tagNamelist(P) RP TAGS LP tagitemlist
1
(Y) RP. {
X.n += F.n;
X.n += F.n;
V.n += Z.n;
V.n += Z.n;
A = createNewChildTableInfo(&X, P, Y, &V, &U);
A = createNewChildTableInfo(&X, P, Y, &V, &U);
...
@@ -437,6 +437,15 @@ column(A) ::= ids(X) typename(Y). {
...
@@ -437,6 +437,15 @@ column(A) ::= ids(X) typename(Y). {
tSetColumnInfo(&A, &X, &Y);
tSetColumnInfo(&A, &X, &Y);
}
}
%type tagitemlist1 {SArray*}
%destructor tagitemlist1 {taosArrayDestroy($$);}
tagitemlist1(A) ::= tagitemlist1(X) COMMA tagitem1(Y). { taosArrayPush(X, &Y); A = X;}
tagitemlist1(A) ::= tagitem1(Y). { A = taosArrayInit(4, sizeof(SToken)); taosArrayPush(A, &Y); }
%type tagitem1 {SToken}
tagitem1(A) ::= MINUS(X) INTEGER(Y). { A.n = X.n + Y.n; A.type = Y.type; }
%type tagitemlist {SArray*}
%type tagitemlist {SArray*}
%destructor tagitemlist {taosArrayDestroy($$);}
%destructor tagitemlist {taosArrayDestroy($$);}
...
...
source/libs/parser/inc/ttokendef.h
浏览文件 @
55ee57ec
...
@@ -103,114 +103,115 @@
...
@@ -103,114 +103,115 @@
#define TK_RP 85
#define TK_RP 85
#define TK_IF 86
#define TK_IF 86
#define TK_EXISTS 87
#define TK_EXISTS 87
#define TK_AS 88
#define TK_PORT 88
#define TK_OUTPUTTYPE 89
#define TK_AS 89
#define TK_AGGREGATE 90
#define TK_OUTPUTTYPE 90
#define TK_BUFSIZE 91
#define TK_AGGREGATE 91
#define TK_PPS 92
#define TK_BUFSIZE 92
#define TK_TSERIES 93
#define TK_PPS 93
#define TK_DBS 94
#define TK_TSERIES 94
#define TK_STORAGE 95
#define TK_DBS 95
#define TK_QTIME 96
#define TK_STORAGE 96
#define TK_CONNS 97
#define TK_QTIME 97
#define TK_STATE 98
#define TK_CONNS 98
#define TK_COMMA 99
#define TK_STATE 99
#define TK_KEEP 100
#define TK_COMMA 100
#define TK_CACHE 101
#define TK_KEEP 101
#define TK_REPLICA 102
#define TK_CACHE 102
#define TK_QUORUM 103
#define TK_REPLICA 103
#define TK_DAYS 104
#define TK_QUORUM 104
#define TK_MINROWS 105
#define TK_DAYS 105
#define TK_MAXROWS 106
#define TK_MINROWS 106
#define TK_BLOCKS 107
#define TK_MAXROWS 107
#define TK_CTIME 108
#define TK_BLOCKS 108
#define TK_WAL 109
#define TK_CTIME 109
#define TK_FSYNC 110
#define TK_WAL 110
#define TK_COMP 111
#define TK_FSYNC 111
#define TK_PRECISION 112
#define TK_COMP 112
#define TK_UPDATE 113
#define TK_PRECISION 113
#define TK_CACHELAST 114
#define TK_UPDATE 114
#define TK_UNSIGNED 115
#define TK_CACHELAST 115
#define TK_TAGS 116
#define TK_UNSIGNED 116
#define TK_USING 117
#define TK_TAGS 117
#define TK_NULL 118
#define TK_USING 118
#define TK_NOW 119
#define TK_NULL 119
#define TK_SELECT 120
#define TK_NOW 120
#define TK_UNION 121
#define TK_SELECT 121
#define TK_ALL 122
#define TK_UNION 122
#define TK_DISTINCT 123
#define TK_ALL 123
#define TK_FROM 124
#define TK_DISTINCT 124
#define TK_VARIABLE 125
#define TK_FROM 125
#define TK_INTERVAL 126
#define TK_VARIABLE 126
#define TK_EVERY 127
#define TK_INTERVAL 127
#define TK_SESSION 128
#define TK_EVERY 128
#define TK_STATE_WINDOW 129
#define TK_SESSION 129
#define TK_FILL 130
#define TK_STATE_WINDOW 130
#define TK_SLIDING 131
#define TK_FILL 131
#define TK_ORDER 132
#define TK_SLIDING 132
#define TK_BY 133
#define TK_ORDER 133
#define TK_ASC 134
#define TK_BY 134
#define TK_GROUP 135
#define TK_ASC 135
#define TK_HAVING 136
#define TK_GROUP 136
#define TK_LIMIT 137
#define TK_HAVING 137
#define TK_OFFSET 138
#define TK_LIMIT 138
#define TK_SLIMIT 139
#define TK_OFFSET 139
#define TK_SOFFSET 140
#define TK_SLIMIT 140
#define TK_WHERE 141
#define TK_SOFFSET 141
#define TK_RESET 142
#define TK_WHERE 142
#define TK_QUERY 143
#define TK_RESET 143
#define TK_SYNCDB 144
#define TK_QUERY 144
#define TK_ADD 145
#define TK_SYNCDB 145
#define TK_COLUMN 146
#define TK_ADD 146
#define TK_MODIFY 147
#define TK_COLUMN 147
#define TK_TAG 148
#define TK_MODIFY 148
#define TK_CHANGE 149
#define TK_TAG 149
#define TK_SET 150
#define TK_CHANGE 150
#define TK_KILL 151
#define TK_SET 151
#define TK_CONNECTION 152
#define TK_KILL 152
#define TK_STREAM 153
#define TK_CONNECTION 153
#define TK_COLON 154
#define TK_STREAM 154
#define TK_ABORT 155
#define TK_COLON 155
#define TK_AFTER 156
#define TK_ABORT 156
#define TK_ATTACH 157
#define TK_AFTER 157
#define TK_BEFORE 158
#define TK_ATTACH 158
#define TK_BEGIN 159
#define TK_BEFORE 159
#define TK_CASCADE 160
#define TK_BEGIN 160
#define TK_CLUSTER 161
#define TK_CASCADE 161
#define TK_CONFLICT 162
#define TK_CLUSTER 162
#define TK_COPY 163
#define TK_CONFLICT 163
#define TK_DEFERRED 164
#define TK_COPY 164
#define TK_DELIMITERS 165
#define TK_DEFERRED 165
#define TK_DETACH 166
#define TK_DELIMITERS 166
#define TK_EACH 167
#define TK_DETACH 167
#define TK_END 168
#define TK_EACH 168
#define TK_EXPLAIN 169
#define TK_END 169
#define TK_FAIL 170
#define TK_EXPLAIN 170
#define TK_FOR 171
#define TK_FAIL 171
#define TK_IGNORE 172
#define TK_FOR 172
#define TK_IMMEDIATE 173
#define TK_IGNORE 173
#define TK_INITIALLY 174
#define TK_IMMEDIATE 174
#define TK_INSTEAD 175
#define TK_INITIALLY 175
#define TK_KEY 176
#define TK_INSTEAD 176
#define TK_OF 177
#define TK_KEY 177
#define TK_RAISE 178
#define TK_OF 178
#define TK_REPLACE 179
#define TK_RAISE 179
#define TK_RESTRICT 180
#define TK_REPLACE 180
#define TK_ROW 181
#define TK_RESTRICT 181
#define TK_STATEMENT 182
#define TK_ROW 182
#define TK_TRIGGER 183
#define TK_STATEMENT 183
#define TK_VIEW 184
#define TK_TRIGGER 184
#define TK_IPTOKEN 185
#define TK_VIEW 185
#define TK_SEMI 186
#define TK_IPTOKEN 186
#define TK_NONE 187
#define TK_SEMI 187
#define TK_PREV 188
#define TK_NONE 188
#define TK_LINEAR 189
#define TK_PREV 189
#define TK_IMPORT 190
#define TK_LINEAR 190
#define TK_TBNAME 191
#define TK_IMPORT 191
#define TK_JOIN 192
#define TK_TBNAME 192
#define TK_INSERT 193
#define TK_JOIN 193
#define TK_INTO 194
#define TK_INSERT 194
#define TK_VALUES 195
#define TK_INTO 195
#define TK_VALUES 196
...
...
source/libs/parser/src/astToMsg.c
浏览文件 @
55ee57ec
...
@@ -379,8 +379,10 @@ SDropStbMsg* buildDropStableMsg(SSqlInfo* pInfo, int32_t* len, SParseBasicCtx* p
...
@@ -379,8 +379,10 @@ SDropStbMsg* buildDropStableMsg(SSqlInfo* pInfo, int32_t* len, SParseBasicCtx* p
SCreateDnodeMsg
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
)
{
SCreateDnodeMsg
*
buildCreateDnodeMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SMsgBuf
*
pMsgBuf
)
{
const
char
*
msg1
=
"invalid host name (name too long, maximum length 128)"
;
const
char
*
msg1
=
"invalid host name (name too long, maximum length 128)"
;
const
char
*
msg2
=
"dnode name can not be string"
;
const
char
*
msg2
=
"dnode name can not be string"
;
const
char
*
msg3
=
"port should be an integer that is less than 65535"
;
const
char
*
msg4
=
"failed prepare create dnode message"
;
if
(
taosArrayGetSize
(
pInfo
->
pMiscInfo
->
a
)
>
1
)
{
if
(
taosArrayGetSize
(
pInfo
->
pMiscInfo
->
a
)
!=
2
)
{
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
buildInvalidOperationMsg
(
pMsgBuf
,
msg1
);
return
NULL
;
return
NULL
;
}
}
...
@@ -391,10 +393,31 @@ SCreateDnodeMsg *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs
...
@@ -391,10 +393,31 @@ SCreateDnodeMsg *buildCreateDnodeMsg(SSqlInfo* pInfo, int32_t* len, SMsgBuf* pMs
return
NULL
;
return
NULL
;
}
}
SToken
*
port
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
1
);
if
(
port
->
type
!=
TK_INTEGER
)
{
buildInvalidOperationMsg
(
pMsgBuf
,
msg3
);
return
NULL
;
}
bool
isSign
=
false
;
int64_t
val
=
0
;
toInteger
(
port
->
z
,
port
->
n
,
10
,
&
val
,
&
isSign
);
if
(
val
>=
UINT16_MAX
)
{
buildInvalidOperationMsg
(
pMsgBuf
,
msg3
);
return
NULL
;
}
SCreateDnodeMsg
*
pCreate
=
(
SCreateDnodeMsg
*
)
calloc
(
1
,
sizeof
(
SCreateDnodeMsg
));
SCreateDnodeMsg
*
pCreate
=
(
SCreateDnodeMsg
*
)
calloc
(
1
,
sizeof
(
SCreateDnodeMsg
));
if
(
pCreate
==
NULL
)
{
buildInvalidOperationMsg
(
pMsgBuf
,
msg4
);
return
NULL
;
}
strncpy
(
pCreate
->
ep
,
id
->
z
,
id
->
n
);
strncpy
(
pCreate
->
ep
,
id
->
z
,
id
->
n
);
*
len
=
sizeof
(
SCreateDnodeMsg
)
;
pCreate
->
port
=
val
;
*
len
=
sizeof
(
SCreateDnodeMsg
);
return
pCreate
;
return
pCreate
;
}
}
...
...
source/libs/parser/src/astValidate.c
浏览文件 @
55ee57ec
...
@@ -3986,7 +3986,6 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
...
@@ -3986,7 +3986,6 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
return
buildInvalidOperationMsg
(
pMsgBuf
,
"not support sql expression"
);
return
buildInvalidOperationMsg
(
pMsgBuf
,
"not support sql expression"
);
}
}
SCatalogReq
req
=
{
0
};
SCatalogReq
req
=
{
0
};
SMetaData
data
=
{
0
};
SMetaData
data
=
{
0
};
...
@@ -4023,6 +4022,5 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
...
@@ -4023,6 +4022,5 @@ int32_t qParserValidateSqlNode(struct SCatalog* pCatalog, SSqlInfo* pInfo, SQuer
validateSqlNode
(
p
,
pQueryInfo
,
&
buf
);
validateSqlNode
(
p
,
pQueryInfo
,
&
buf
);
}
}
return
code
;
return
code
;
}
}
source/libs/parser/src/dCDAstProcess.c
浏览文件 @
55ee57ec
#include "tglobal.h"
#include <ttime.h>
#include "parserInt.h"
#include "astToMsg.h"
#include "astToMsg.h"
#include "parserInt.h"
#include "parserUtil.h"
#include "parserUtil.h"
#include "queryInfoUtil.h"
#include "queryInfoUtil.h"
#include "tglobal.h"
/* is contained in pFieldList or not */
/* is contained in pFieldList or not */
static
bool
has
(
SArray
*
pFieldList
,
int32_t
startIndex
,
const
char
*
name
)
{
static
bool
has
(
SArray
*
pFieldList
,
int32_t
startIndex
,
const
char
*
name
)
{
...
@@ -293,7 +294,6 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
...
@@ -293,7 +294,6 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
// super table name, create table by using dst
// super table name, create table by using dst
int32_t
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
pCreateTable
->
childTableInfo
);
int32_t
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
pCreateTable
->
childTableInfo
);
for
(
int32_t
j
=
0
;
j
<
numOfTables
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
numOfTables
;
++
j
)
{
#if 0
SCreatedTableInfo
*
pCreateTableInfo
=
taosArrayGet
(
pCreateTable
->
childTableInfo
,
j
);
SCreatedTableInfo
*
pCreateTableInfo
=
taosArrayGet
(
pCreateTable
->
childTableInfo
,
j
);
SToken
*
pSTableNameToken
=
&
pCreateTableInfo
->
stbName
;
SToken
*
pSTableNameToken
=
&
pCreateTableInfo
->
stbName
;
...
@@ -341,12 +341,7 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
...
@@ -341,12 +341,7 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
pNameList
=
pCreateTableInfo
->
pTagNames
;
pNameList
=
pCreateTableInfo
->
pTagNames
;
nameSize
=
taosArrayGetSize
(
pNameList
);
nameSize
=
taosArrayGetSize
(
pNameList
);
if (valSize != nameSize) {
if
(
valSize
!=
nameSize
||
schemaSize
<
valSize
)
{
tdDestroyKVRowBuilder(&kvRowBuilder);
return buildInvalidOperationMsg(pMsgBuf, msg2);
}
if (schemaSize < valSize) {
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg2
);
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg2
);
}
}
...
@@ -359,15 +354,15 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
...
@@ -359,15 +354,15 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
strncpy
(
tmpTokenBuf
,
sToken
->
z
,
sToken
->
n
);
strncpy
(
tmpTokenBuf
,
sToken
->
z
,
sToken
->
n
);
sToken
->
z
=
tmpTokenBuf
;
sToken
->
z
=
tmpTokenBuf
;
if (TK_STRING == sToken->type) {
//
if (TK_STRING == sToken->type) {
tscDequoteAndTrimToken(sToken);
//
tscDequoteAndTrimToken(sToken);
}
//
}
if (TK_ID == sToken->type) {
//
if (TK_ID == sToken->type) {
tscRmEscapeAndTrimToken(sToken);
//
tscRmEscapeAndTrimToken(sToken);
}
//
}
tVariant
ListItem* pItem = taosArrayGet(pValList, i);
S
ListItem
*
pItem
=
taosArrayGet
(
pValList
,
i
);
findColumnIndex
=
false
;
findColumnIndex
=
false
;
...
@@ -384,16 +379,16 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
...
@@ -384,16 +379,16 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
}
}
}
else
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
}
else
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
if
(
pItem
->
pVar
.
nType
==
TSDB_DATA_TYPE_BINARY
)
{
if
(
pItem
->
pVar
.
nType
==
TSDB_DATA_TYPE_BINARY
)
{
ret
= convertTimestampStrToInt64(&(pItem->pVar), tinfo.precision);
// code
= convertTimestampStrToInt64(&(pItem->pVar), tinfo.precision);
if (ret
!= TSDB_CODE_SUCCESS) {
// if (code
!= TSDB_CODE_SUCCESS) {
return buildInvalidOperationMsg(pMsgBuf, msg4);
//
return buildInvalidOperationMsg(pMsgBuf, msg4);
}
//
}
}
else
if
(
pItem
->
pVar
.
nType
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
}
else
if
(
pItem
->
pVar
.
nType
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
pItem->pVar.i
64 = convertTimePrecision(pItem->pVar.i64
, TSDB_TIME_PRECISION_NANO, tinfo.precision);
pItem
->
pVar
.
i
=
convertTimePrecision
(
pItem
->
pVar
.
i
,
TSDB_TIME_PRECISION_NANO
,
tinfo
.
precision
);
}
}
}
}
code = tVariantDump(&(pItem->pVar), tagVal, pSchema->type, true);
code
=
t
aos
VariantDump
(
&
(
pItem
->
pVar
),
tagVal
,
pSchema
->
type
,
true
);
// check again after the convert since it may be converted from binary to nchar.
// check again after the convert since it may be converted from binary to nchar.
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_BINARY
||
pSchema
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_BINARY
||
pSchema
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
...
@@ -428,8 +423,8 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
...
@@ -428,8 +423,8 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
}
}
for
(
int32_t
i
=
0
;
i
<
valSize
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
valSize
;
++
i
)
{
SSchema
*
pSchema = &pTagSchema[i];
SSchema
*
pSchema
=
&
pTagSchema
[
i
];
tVariantListItem*
pItem = taosArrayGet(pValList, i);
SListItem
*
pItem
=
taosArrayGet
(
pValList
,
i
);
char
tagVal
[
TSDB_MAX_TAGS_LEN
];
char
tagVal
[
TSDB_MAX_TAGS_LEN
];
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_BINARY
||
pSchema
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_BINARY
||
pSchema
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
...
@@ -439,16 +434,16 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
...
@@ -439,16 +434,16 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
}
}
}
else
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
}
else
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
if
(
pItem
->
pVar
.
nType
==
TSDB_DATA_TYPE_BINARY
)
{
if
(
pItem
->
pVar
.
nType
==
TSDB_DATA_TYPE_BINARY
)
{
ret
= convertTimestampStrToInt64(&(pItem->pVar), tinfo.precision);
// code
= convertTimestampStrToInt64(&(pItem->pVar), tinfo.precision);
if (
ret
!= TSDB_CODE_SUCCESS) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg4
);
return
buildInvalidOperationMsg
(
pMsgBuf
,
msg4
);
}
}
}
else
if
(
pItem
->
pVar
.
nType
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
}
else
if
(
pItem
->
pVar
.
nType
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
pItem->pVar.i
64 = convertTimePrecision(pItem->pVar.i64
, TSDB_TIME_PRECISION_NANO, tinfo.precision);
pItem
->
pVar
.
i
=
convertTimePrecision
(
pItem
->
pVar
.
i
,
TSDB_TIME_PRECISION_NANO
,
tinfo
.
precision
);
}
}
}
}
code = tVariantDump(&(pItem->pVar), tagVal, pSchema->type, true);
code
=
t
aos
VariantDump
(
&
(
pItem
->
pVar
),
tagVal
,
pSchema
->
type
,
true
);
// check again after the convert since it may be converted from binary to nchar.
// check again after the convert since it may be converted from binary to nchar.
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_BINARY
||
pSchema
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_BINARY
||
pSchema
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
...
@@ -485,22 +480,21 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
...
@@ -485,22 +480,21 @@ int32_t doCheckForCreateCTable(SSqlInfo* pInfo, SParseBasicCtx *pCtx, SMsgBuf* p
bool
dbIncluded2
=
false
;
bool
dbIncluded2
=
false
;
// table name
// table name
if (tscValidateName(&(pCreateTableInfo->name), true, &dbIncluded2) != TSDB_CODE_SUCCESS) {
// if (tscValidateName(&(pCreateTableInfo->name), true, &dbIncluded2) != TSDB_CODE_SUCCESS) {
return buildInvalidOperationMsg(pMsgBuf, msg1);
// return buildInvalidOperationMsg(pMsgBuf, msg1);
}
// }
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, TABLE_INDEX);
// STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, TABLE_INDEX);
code = tscSetTableFullName(&pTableMetaInfo->name, &pCreateTableInfo->name, pSql, dbIncluded2);
// code = tscSetTableFullName(&pTableMetaInfo->name, &pCreateTableInfo->name, pSql, dbIncluded2);
if (code != TSDB_CODE_SUCCESS) {
// if (code != TSDB_CODE_SUCCESS) {
return code;
// return code;
}
// }
pCreateTableInfo->fullname = calloc(1, tNameLen(&pTableMetaInfo->name) + 1);
// pCreateTableInfo->fullname = calloc(1, tNameLen(&pTableMetaInfo->name) + 1);
code = tNameExtractFullName(&pTableMetaInfo->name, pCreateTableInfo->fullname);
// code = tNameExtractFullName(&pTableMetaInfo->name, pCreateTableInfo->fullname);
if (code != TSDB_CODE_SUCCESS) {
// if (code != TSDB_CODE_SUCCESS) {
return buildInvalidOperationMsg(pMsgBuf, msg1);
// return buildInvalidOperationMsg(pMsgBuf, msg1);
}
// }
#endif
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/parser/src/sql.c
浏览文件 @
55ee57ec
此差异已折叠。
点击以展开。
source/libs/parser/src/ttokenizer.c
浏览文件 @
55ee57ec
...
@@ -70,7 +70,7 @@ static SKeyword keywordTable[] = {
...
@@ -70,7 +70,7 @@ static SKeyword keywordTable[] = {
{
"STAR"
,
TK_STAR
},
{
"STAR"
,
TK_STAR
},
{
"SLASH"
,
TK_SLASH
},
{
"SLASH"
,
TK_SLASH
},
{
"REM "
,
TK_REM
},
{
"REM "
,
TK_REM
},
{
"||"
,
TK_CONCAT
},
{
"||"
,
TK_CONCAT
},
{
"UMINUS"
,
TK_UMINUS
},
{
"UMINUS"
,
TK_UMINUS
},
{
"UPLUS"
,
TK_UPLUS
},
{
"UPLUS"
,
TK_UPLUS
},
{
"BITNOT"
,
TK_BITNOT
},
{
"BITNOT"
,
TK_BITNOT
},
...
@@ -227,6 +227,7 @@ static SKeyword keywordTable[] = {
...
@@ -227,6 +227,7 @@ static SKeyword keywordTable[] = {
{
"OUTPUTTYPE"
,
TK_OUTPUTTYPE
},
{
"OUTPUTTYPE"
,
TK_OUTPUTTYPE
},
{
"AGGREGATE"
,
TK_AGGREGATE
},
{
"AGGREGATE"
,
TK_AGGREGATE
},
{
"BUFSIZE"
,
TK_BUFSIZE
},
{
"BUFSIZE"
,
TK_BUFSIZE
},
{
"PORT"
,
TK_PORT
},
};
};
static
const
char
isIdChar
[]
=
{
static
const
char
isIdChar
[]
=
{
...
...
source/libs/qcom/src/queryUtil.c
浏览文件 @
55ee57ec
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include "query.h"
#include "query.h"
#include "tglobal.h"
#include "tglobal.h"
#include "tsched.h"
#include "tsched.h"
#include "trpc.h"
#define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS)
#define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS)
#define VALIDNUMOFTAGS(x) ((x) >= 0 && (x) <= TSDB_MAX_TAGS)
#define VALIDNUMOFTAGS(x) ((x) >= 0 && (x) <= TSDB_MAX_TAGS)
...
@@ -121,3 +122,27 @@ int32_t taosAsyncExec(__async_exec_fn_t execFn, void* execParam, int32_t* code)
...
@@ -121,3 +122,27 @@ int32_t taosAsyncExec(__async_exec_fn_t execFn, void* execParam, int32_t* code)
taosScheduleTask
(
pTaskQueue
,
&
schedMsg
);
taosScheduleTask
(
pTaskQueue
,
&
schedMsg
);
}
}
int32_t
asyncSendMsgToServer
(
void
*
pTransporter
,
SEpSet
*
epSet
,
int64_t
*
pTransporterId
,
const
SMsgSendInfo
*
pInfo
)
{
char
*
pMsg
=
rpcMallocCont
(
pInfo
->
msgInfo
.
len
);
if
(
NULL
==
pMsg
)
{
qError
(
"0x%"
PRIx64
" msg:%s malloc failed"
,
pInfo
->
requestId
,
TMSG_INFO
(
pInfo
->
msgType
));
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
-
1
;
}
memcpy
(
pMsg
,
pInfo
->
msgInfo
.
pData
,
pInfo
->
msgInfo
.
len
);
SRpcMsg
rpcMsg
=
{
.
msgType
=
pInfo
->
msgType
,
.
pCont
=
pMsg
,
.
contLen
=
pInfo
->
msgInfo
.
len
,
.
ahandle
=
(
void
*
)
pInfo
,
.
handle
=
NULL
,
.
code
=
0
};
assert
(
pInfo
->
fp
!=
NULL
);
rpcSendRequest
(
pTransporter
,
epSet
,
&
rpcMsg
,
pTransporterId
);
return
TSDB_CODE_SUCCESS
;
}
\ No newline at end of file
src/query/inc/sql.y
浏览文件 @
55ee57ec
...
@@ -438,6 +438,12 @@ column(A) ::= ids(X) typename(Y). {
...
@@ -438,6 +438,12 @@ column(A) ::= ids(X) typename(Y). {
tSetColumnInfo(&A, &X, &Y);
tSetColumnInfo(&A, &X, &Y);
}
}
%type tagitemlist1 {SArray*}
%destructor tagitemlist1 {taosArrayDestroy($$);}
%type tagitem1 {SToken}
%type tagitemlist {SArray*}
%type tagitemlist {SArray*}
%destructor tagitemlist {taosArrayDestroy($$);}
%destructor tagitemlist {taosArrayDestroy($$);}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录