Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
973ebce2
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看板
提交
973ebce2
编写于
1月 04, 2023
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update add/drop index msg
上级
5bb20a9a
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
152 addition
and
4 deletion
+152
-4
include/common/tmsg.h
include/common/tmsg.h
+7
-2
source/common/src/tmsg.c
source/common/src/tmsg.c
+32
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+90
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+23
-2
未找到文件。
include/common/tmsg.h
浏览文件 @
973ebce2
...
...
@@ -2786,10 +2786,15 @@ int32_t tDeserializeSCreateTagIdxReq(void* buf, int32_t bufLen, SCreateTagIndexR
typedef
struct
{
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
stb
[
TSDB_TABLE_FNAME_LEN
];
int8_t
indexType
;
char
stbName
[
TSDB_TABLE_FNAME_LEN
];
char
colName
[
TSDB_COL_NAME_LEN
];
char
idxName
[
TSDB_COL_NAME_LEN
];
int8_t
idxType
;
}
SDropTagIndexReq
;
int32_t
tSerializeSDropTagIdxReq
(
void
*
buf
,
int32_t
bufLen
,
SDropTagIndexReq
*
pReq
);
int32_t
tDeserializeSDropTagIdxReq
(
void
*
buf
,
int32_t
bufLen
,
SDropTagIndexReq
*
pReq
);
typedef
struct
{
int8_t
version
;
// for compatibility(default 0)
int8_t
intervalUnit
;
// MACRO: TIME_UNIT_XXX
...
...
source/common/src/tmsg.c
浏览文件 @
973ebce2
...
...
@@ -951,6 +951,38 @@ int32_t tDeserializeSCreateTagIdxReq(void *buf, int32_t bufLen, SCreateTagIndexR
tDecoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSDropTagIdxReq
(
void
*
buf
,
int32_t
bufLen
,
SDropTagIndexReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
dbFName
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
stbName
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
colName
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
idxName
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
idxType
)
<
0
)
return
-
1
;
int32_t
tlen
=
encoder
.
pos
;
tEncoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSDropTagIdxReq
(
void
*
buf
,
int32_t
bufLen
,
SDropTagIndexReq
*
pReq
)
{
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
dbFName
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
stbName
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
colName
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
idxName
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
idxType
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSMCreateFullTextReq
(
void
*
buf
,
int32_t
bufLen
,
SMCreateFullTextReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
973ebce2
...
...
@@ -49,6 +49,9 @@ static int32_t mndAlterStbImp(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SStbO
void
*
alterOriData
,
int32_t
alterOriDataLen
);
static
int32_t
mndCheckColAndTagModifiable
(
SMnode
*
pMnode
,
const
char
*
stbname
,
int64_t
suid
,
col_id_t
colId
);
static
int32_t
mndProcessCreateIndexReq
(
SRpcMsg
*
pReq
);
static
int32_t
mndProcessDropIndexReq
(
SRpcMsg
*
pReq
);
int32_t
mndInitStb
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{
.
sdbType
=
SDB_STB
,
...
...
@@ -70,6 +73,9 @@ int32_t mndInitStb(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TTL_TIMER
,
mndProcessTtlTimer
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_TABLE_CFG
,
mndProcessTableCfgReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_CREATE_INDEX
,
mndProcessCreateIndexReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_INDEX
,
mndProcessDropIndexReq
);
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_STB
,
mndRetrieveStb
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_STB
,
mndCancelGetNextStb
);
...
...
@@ -2614,3 +2620,87 @@ const char *mndGetStbStr(const char *src) {
if
(
posStb
==
NULL
)
return
posDb
;
return
posStb
;
}
static
int32_t
mndCheckIndexReq
(
SCreateTagIndexReq
*
pReq
)
{
// impl
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mndAddIndex
(
SMnode
*
pMnode
,
SRpcMsg
*
pReq
,
SCreateTagIndexReq
*
tagIdxReq
,
SDbObj
*
pDb
,
SStbObj
*
pOld
)
{
bool
needRsp
=
true
;
int32_t
code
=
-
1
;
SField
*
pField0
=
NULL
;
SStbObj
stbObj
=
{
0
};
taosRLockLatch
(
&
pOld
->
lock
);
memcpy
(
&
stbObj
,
pOld
,
sizeof
(
SStbObj
));
taosRUnLockLatch
(
&
pOld
->
lock
);
stbObj
.
pColumns
=
NULL
;
stbObj
.
pTags
=
NULL
;
stbObj
.
updateTime
=
taosGetTimestampMs
();
stbObj
.
lock
=
0
;
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mndProcessCreateIndexReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SDbObj
*
pDb
=
NULL
;
SStbObj
*
pStb
=
NULL
;
SCreateTagIndexReq
tagIdxReq
=
{
0
};
if
(
tDeserializeSCreateTagIdxReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
tagIdxReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
_OVER
;
}
mInfo
(
"stb:%s, start to alter"
,
tagIdxReq
.
stbName
);
if
(
mndCheckIndexReq
(
&
tagIdxReq
)
!=
TSDB_CODE_SUCCESS
)
{
goto
_OVER
;
}
pDb
=
mndAcquireDbByStb
(
pMnode
,
tagIdxReq
.
dbFName
);
if
(
pDb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_INVALID_DB
;
goto
_OVER
;
}
pStb
=
mndAcquireStb
(
pMnode
,
tagIdxReq
.
stbName
);
if
(
pStb
==
NULL
)
{
terrno
=
TSDB_CODE_MND_STB_NOT_EXIST
;
goto
_OVER
;
}
if
(
mndCheckDbPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndAddIndex
(
pMnode
,
pReq
,
&
tagIdxReq
,
pDb
,
pStb
);
if
(
code
!=
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
return
TSDB_CODE_SUCCESS
;
_OVER:
if
(
code
!=
0
&&
code
!=
TSDB_CODE_ACTION_IN_PROGRESS
)
{
mError
(
"stb:%s, failed to create index since %s"
,
tagIdxReq
.
stbName
,
terrstr
());
}
mndReleaseStb
(
pMnode
,
pStb
);
mndReleaseDb
(
pMnode
,
pDb
);
return
code
;
}
static
int32_t
mndProcessDropIndexReq
(
SRpcMsg
*
pReq
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
int32_t
code
=
-
1
;
SDbObj
*
pDb
=
NULL
;
SStbObj
*
pStb
=
NULL
;
SDropTagIndexReq
dropReq
=
{
0
};
if
(
tDeserializeSDropTagIdxReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
dropReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
goto
_OVER
;
}
//
return
TSDB_CODE_SUCCESS
;
_OVER:
return
code
;
}
source/libs/parser/src/parTranslater.c
浏览文件 @
973ebce2
...
...
@@ -5333,6 +5333,16 @@ static int32_t buildCreateFullTextReq(STranslateContext* pCxt, SCreateIndexStmt*
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
buildCreateTagIndexReq
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
,
SCreateTagIndexReq
*
pReq
)
{
SName
name
;
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
indexDbName
,
pStmt
->
indexName
,
&
name
),
pReq
->
dbFName
);
memset
(
&
name
,
0
,
sizeof
(
SName
));
tNameExtractFullName
(
toName
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
name
),
pReq
->
stbName
);
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateCreateFullTextIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
SMCreateFullTextReq
createFTReq
=
{
0
};
int32_t
code
=
buildCreateFullTextReq
(
pCxt
,
pStmt
,
&
createFTReq
);
...
...
@@ -5343,9 +5353,20 @@ static int32_t translateCreateFullTextIndex(STranslateContext* pCxt, SCreateInde
return
code
;
}
static
int32_t
translateCreateNormalIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
SCreateTagIndexReq
createTagIdxReq
=
{
0
};
int32_t
code
=
buildCreateTagIndexReq
(
pCxt
,
pStmt
,
&
createTagIdxReq
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
buildCmdMsg
(
pCxt
,
TDMT_MND_CREATE_INDEX
,
(
FSerializeFunc
)
tSerializeSCreateTagIdxReq
,
&
createTagIdxReq
);
}
return
code
;
}
static
int32_t
translateCreateIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
if
(
INDEX_TYPE_FULLTEXT
==
pStmt
->
indexType
)
{
return
translateCreateFullTextIndex
(
pCxt
,
pStmt
);
}
else
if
(
INDEX_TYPE_NORMAL
==
pStmt
->
indexType
)
{
return
translateCreateNormalIndex
(
pCxt
,
pStmt
);
}
return
translateCreateSmaIndex
(
pCxt
,
pStmt
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录