Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
74148ee3
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
74148ee3
编写于
3月 23, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-3036]<feature>: support the db sync operator.
上级
bfe554a0
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
1060 addition
and
1009 deletion
+1060
-1009
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+11
-0
src/client/src/tscServer.c
src/client/src/tscServer.c
+18
-0
src/common/inc/tcmdtype.h
src/common/inc/tcmdtype.h
+6
-5
src/dnode/src/dnodeShell.c
src/dnode/src/dnodeShell.c
+1
-0
src/inc/taosmsg.h
src/inc/taosmsg.h
+2
-1
src/inc/ttokendef.h
src/inc/ttokendef.h
+51
-50
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+6
-0
src/query/inc/sql.y
src/query/inc/sql.y
+3
-0
src/query/src/qSqlParser.c
src/query/src/qSqlParser.c
+1
-0
src/query/src/qTokenizer.c
src/query/src/qTokenizer.c
+1
-0
src/query/src/sql.c
src/query/src/sql.c
+960
-953
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
74148ee3
...
...
@@ -670,7 +670,18 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if
((
code
=
setKillInfo
(
pSql
,
pInfo
,
pInfo
->
type
))
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
break
;
}
case
TSDB_SQL_SYNC_DB_REPLICA
:
{
const
char
*
msg1
=
"invalid db name"
;
SStrToken
*
pzName
=
taosArrayGet
(
pInfo
->
pMiscInfo
->
a
,
0
);
assert
(
taosArrayGetSize
(
pInfo
->
pMiscInfo
->
a
)
==
1
);
code
=
tNameSetDbName
(
&
pTableMetaInfo
->
name
,
getAccountId
(
pSql
),
pzName
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
}
break
;
}
...
...
src/client/src/tscServer.c
浏览文件 @
74148ee3
...
...
@@ -1284,6 +1284,23 @@ int32_t tscBuildUseDbMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
tscBuildSyncDbReplicaMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
SSyncDbMsg
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
tscError
(
"%p failed to malloc for query msg"
,
pSql
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
SSyncDbMsg
*
pSyncMsg
=
(
SSyncDbMsg
*
)
pCmd
->
payload
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
tNameExtractFullName
(
&
pTableMetaInfo
->
name
,
pSyncMsg
->
db
);
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_SYNC_DB
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
tscBuildShowMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
STscObj
*
pObj
=
pSql
->
pTscObj
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
...
...
@@ -2559,6 +2576,7 @@ void tscInitMsgsFp() {
tscBuildMsg
[
TSDB_SQL_DROP_USER
]
=
tscBuildDropUserAcctMsg
;
tscBuildMsg
[
TSDB_SQL_DROP_ACCT
]
=
tscBuildDropUserAcctMsg
;
tscBuildMsg
[
TSDB_SQL_DROP_DB
]
=
tscBuildDropDbMsg
;
tscBuildMsg
[
TSDB_SQL_SYNC_DB_REPLICA
]
=
tscBuildSyncDbReplicaMsg
;
tscBuildMsg
[
TSDB_SQL_DROP_TABLE
]
=
tscBuildDropTableMsg
;
tscBuildMsg
[
TSDB_SQL_ALTER_USER
]
=
tscBuildUserMsg
;
tscBuildMsg
[
TSDB_SQL_CREATE_DNODE
]
=
tscBuildCreateDnodeMsg
;
...
...
src/common/inc/tcmdtype.h
浏览文件 @
74148ee3
...
...
@@ -51,6 +51,7 @@ enum {
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_ALTER_ACCT
,
"alter-acct"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_ALTER_TABLE
,
"alter-table"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_ALTER_DB
,
"alter-db"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_SYNC_DB_REPLICA
,
"sync db-replica"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CREATE_MNODE
,
"create-mnode"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_DROP_MNODE
,
"drop-mnode"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CREATE_DNODE
,
"create-dnode"
)
...
...
@@ -87,13 +88,13 @@ enum {
*/
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_RETRIEVE_EMPTY_RESULT
,
"retrieve-empty-result"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_RESET_CACHE
,
"reset-cache"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_SERV_STATUS
,
"serv-status"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CURRENT_DB
,
"current-db"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_RESET_CACHE
,
"reset-cache"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_SERV_STATUS
,
"serv-status"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CURRENT_DB
,
"current-db"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_SERV_VERSION
,
"serv-version"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CLI_VERSION
,
"cli-version"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CLI_VERSION
,
"cli-version"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CURRENT_USER
,
"current-user "
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CFG_LOCAL
,
"cfg-local"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CFG_LOCAL
,
"cfg-local"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_MAX
,
"max"
)
};
...
...
src/dnode/src/dnodeShell.c
浏览文件 @
74148ee3
...
...
@@ -49,6 +49,7 @@ int32_t dnodeInitShell() {
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_DB
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_TP
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_DB
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_SYNC_DB
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_DROP_TP
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_DB
]
=
dnodeDispatchToMWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_TP
]
=
dnodeDispatchToMWriteQueue
;
...
...
src/inc/taosmsg.h
浏览文件 @
74148ee3
...
...
@@ -77,6 +77,7 @@ TAOS_DEFINE_MESSAGE_TYPE( TSDB_MSG_TYPE_CM_CREATE_DB, "create-db" )
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_CM_DROP_DB
,
"drop-db"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_CM_USE_DB
,
"use-db"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_CM_ALTER_DB
,
"alter-db"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_CM_SYNC_DB
,
"sync-db-replica"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_CM_CREATE_TABLE
,
"create-table"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_CM_DROP_TABLE
,
"drop-table"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_CM_ALTER_TABLE
,
"alter-table"
)
...
...
@@ -574,7 +575,7 @@ typedef struct {
typedef
struct
{
char
db
[
TSDB_TABLE_FNAME_LEN
];
uint8_t
ignoreNotExists
;
}
SDropDbMsg
,
SUseDbMsg
;
}
SDropDbMsg
,
SUseDbMsg
,
SSyncDbMsg
;
// IMPORTANT: sizeof(SVnodeStatisticInfo) should not exceed
// TSDB_FILE_HEADER_LEN/4 - TSDB_FILE_HEADER_VERSION_SIZE
...
...
src/inc/ttokendef.h
浏览文件 @
74148ee3
...
...
@@ -152,56 +152,57 @@
#define TK_NOW 133
#define TK_RESET 134
#define TK_QUERY 135
#define TK_ADD 136
#define TK_COLUMN 137
#define TK_TAG 138
#define TK_CHANGE 139
#define TK_SET 140
#define TK_KILL 141
#define TK_CONNECTION 142
#define TK_STREAM 143
#define TK_COLON 144
#define TK_ABORT 145
#define TK_AFTER 146
#define TK_ATTACH 147
#define TK_BEFORE 148
#define TK_BEGIN 149
#define TK_CASCADE 150
#define TK_CLUSTER 151
#define TK_CONFLICT 152
#define TK_COPY 153
#define TK_DEFERRED 154
#define TK_DELIMITERS 155
#define TK_DETACH 156
#define TK_EACH 157
#define TK_END 158
#define TK_EXPLAIN 159
#define TK_FAIL 160
#define TK_FOR 161
#define TK_IGNORE 162
#define TK_IMMEDIATE 163
#define TK_INITIALLY 164
#define TK_INSTEAD 165
#define TK_MATCH 166
#define TK_KEY 167
#define TK_OF 168
#define TK_RAISE 169
#define TK_REPLACE 170
#define TK_RESTRICT 171
#define TK_ROW 172
#define TK_STATEMENT 173
#define TK_TRIGGER 174
#define TK_VIEW 175
#define TK_SEMI 176
#define TK_NONE 177
#define TK_PREV 178
#define TK_LINEAR 179
#define TK_IMPORT 180
#define TK_TBNAME 181
#define TK_JOIN 182
#define TK_INSERT 183
#define TK_INTO 184
#define TK_VALUES 185
#define TK_SYNCDB 136
#define TK_ADD 137
#define TK_COLUMN 138
#define TK_TAG 139
#define TK_CHANGE 140
#define TK_SET 141
#define TK_KILL 142
#define TK_CONNECTION 143
#define TK_STREAM 144
#define TK_COLON 145
#define TK_ABORT 146
#define TK_AFTER 147
#define TK_ATTACH 148
#define TK_BEFORE 149
#define TK_BEGIN 150
#define TK_CASCADE 151
#define TK_CLUSTER 152
#define TK_CONFLICT 153
#define TK_COPY 154
#define TK_DEFERRED 155
#define TK_DELIMITERS 156
#define TK_DETACH 157
#define TK_EACH 158
#define TK_END 159
#define TK_EXPLAIN 160
#define TK_FAIL 161
#define TK_FOR 162
#define TK_IGNORE 163
#define TK_IMMEDIATE 164
#define TK_INITIALLY 165
#define TK_INSTEAD 166
#define TK_MATCH 167
#define TK_KEY 168
#define TK_OF 169
#define TK_RAISE 170
#define TK_REPLACE 171
#define TK_RESTRICT 172
#define TK_ROW 173
#define TK_STATEMENT 174
#define TK_TRIGGER 175
#define TK_VIEW 176
#define TK_SEMI 177
#define TK_NONE 178
#define TK_PREV 179
#define TK_LINEAR 180
#define TK_IMPORT 181
#define TK_TBNAME 182
#define TK_JOIN 183
#define TK_INSERT 184
#define TK_INTO 185
#define TK_VALUES 186
#define TK_SPACE 300
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
74148ee3
...
...
@@ -50,6 +50,7 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn
static
int32_t
mnodeRetrieveDbs
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeProcessCreateDbMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessDropDbMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessSyncDbMsg
(
SMnodeMsg
*
pMsg
);
int32_t
mnodeProcessAlterDbMsg
(
SMnodeMsg
*
pMsg
);
#ifndef _TOPIC
...
...
@@ -178,6 +179,7 @@ int32_t mnodeInitDbs() {
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_CREATE_DB
,
mnodeProcessCreateDbMsg
);
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_ALTER_DB
,
mnodeProcessAlterDbMsg
);
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_DROP_DB
,
mnodeProcessDropDbMsg
);
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_SYNC_DB
,
mnodeProcessSyncDbMsg
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeGetDbMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeRetrieveDbs
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeCancelGetNextDb
);
...
...
@@ -1184,6 +1186,10 @@ static int32_t mnodeProcessDropDbMsg(SMnodeMsg *pMsg) {
return
mnodeDropDb
(
pMsg
);
}
static
int32_t
mnodeProcessSyncDbMsg
(
SMnodeMsg
*
pMsg
)
{
return
0
;
}
void
mnodeDropAllDbs
(
SAcctObj
*
pAcct
)
{
int32_t
numOfDbs
=
0
;
SDbObj
*
pDb
=
NULL
;
...
...
src/query/inc/sql.y
浏览文件 @
74148ee3
...
...
@@ -726,6 +726,9 @@ expritem(A) ::= . {A = 0;}
///////////////////////////////////reset query cache//////////////////////////////////////
cmd ::= RESET QUERY CACHE. { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);}
///////////////////////////////////sync replica database//////////////////////////////////
cmd ::= SYNCDB ids(X) REPLICA.{ setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &X);}
///////////////////////////////////ALTER TABLE statement//////////////////////////////////
cmd ::= ALTER TABLE ids(X) cpxName(F) ADD COLUMN columnlist(A). {
X.n += F.n;
...
...
src/query/src/qSqlParser.c
浏览文件 @
74148ee3
...
...
@@ -911,6 +911,7 @@ void setDCLSqlElems(SSqlInfo *pInfo, int32_t type, int32_t nParam, ...) {
SStrToken
*
pToken
=
va_arg
(
va
,
SStrToken
*
);
taosArrayPush
(
pInfo
->
pMiscInfo
->
a
,
pToken
);
}
va_end
(
va
);
}
...
...
src/query/src/qTokenizer.c
浏览文件 @
74148ee3
...
...
@@ -100,6 +100,7 @@ static SKeyword keywordTable[] = {
{
"ACCOUNT"
,
TK_ACCOUNT
},
{
"USE"
,
TK_USE
},
{
"DESCRIBE"
,
TK_DESCRIBE
},
{
"SYNCDB"
,
TK_SYNCDB
},
{
"ALTER"
,
TK_ALTER
},
{
"PASS"
,
TK_PASS
},
{
"PRIVILEGE"
,
TK_PRIVILEGE
},
...
...
src/query/src/sql.c
浏览文件 @
74148ee3
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录