Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5ac1c1bb
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
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,发现更多精彩内容 >>
提交
5ac1c1bb
编写于
7月 02, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225] update the updateTagVal msg
上级
a9ef9ff9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
10 deletion
+29
-10
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+24
-7
src/inc/taosmsg.h
src/inc/taosmsg.h
+2
-2
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+3
-1
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
5ac1c1bb
...
...
@@ -4452,6 +4452,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tVariantList
*
pVarList
=
pAlterSQL
->
varList
;
tVariant
*
pTagName
=
&
pVarList
->
a
[
0
].
pVar
;
int16_t
numOfTags
=
tscGetNumOfTags
(
pTableMeta
);
SColumnIndex
columnIndex
=
COLUMN_INDEX_INITIALIZER
;
SSQLToken
name
=
{.
type
=
TK_STRING
,
.
z
=
pTagName
->
pz
,
.
n
=
pTagName
->
nLen
};
...
...
@@ -4475,8 +4476,10 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
(
pVarList
->
a
[
1
].
pVar
.
nLen
+
VARSTR_HEADER_SIZE
)
>
pTagsSchema
->
bytes
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg14
);
}
int32_t
size
=
sizeof
(
SUpdateTableTagValMsg
)
+
pTagsSchema
->
bytes
+
TSDB_EXTRA_PAYLOAD_SIZE
;
int32_t
schemaLen
=
sizeof
(
STColumn
)
*
numOfTags
;
int32_t
size
=
sizeof
(
SUpdateTableTagValMsg
)
+
pTagsSchema
->
bytes
+
schemaLen
+
TSDB_EXTRA_PAYLOAD_SIZE
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
tscError
(
"%p failed to malloc for alter table msg"
,
pSql
);
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
...
...
@@ -4487,11 +4490,25 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pUpdateMsg
->
tid
=
htonl
(
pTableMeta
->
sid
);
pUpdateMsg
->
uid
=
htobe64
(
pTableMeta
->
uid
);
pUpdateMsg
->
colId
=
htons
(
pTagsSchema
->
colId
);
pUpdateMsg
->
type
=
htons
(
pTagsSchema
->
type
);
pUpdateMsg
->
bytes
=
htons
(
pTagsSchema
->
bytes
);
pUpdateMsg
->
tversion
=
htons
(
pTableMeta
->
tversion
);
tVariantDump
(
&
pVarList
->
a
[
1
].
pVar
,
pUpdateMsg
->
data
,
pTagsSchema
->
type
,
true
);
pUpdateMsg
->
numOfTags
=
htons
(
numOfTags
);
pUpdateMsg
->
schemaLen
=
htonl
(
schemaLen
);
// the schema is located after the msg body, then followed by true tag value
char
*
d
=
pUpdateMsg
->
data
;
SSchema
*
pTagCols
=
tscGetTableTagSchema
(
pTableMeta
);
for
(
int
i
=
0
;
i
<
numOfTags
;
++
i
)
{
STColumn
*
pCol
=
(
STColumn
*
)
d
;
pCol
->
colId
=
htons
(
pTagCols
[
i
].
colId
);
pCol
->
bytes
=
htons
(
pTagCols
[
i
].
bytes
);
pCol
->
type
=
pTagCols
[
i
].
type
;
pCol
->
offset
=
0
;
d
+=
sizeof
(
STColumn
);
}
// copy the tag value to msg body
tVariantDump
(
&
pVarList
->
a
[
1
].
pVar
,
pUpdateMsg
->
data
+
schemaLen
,
pTagsSchema
->
type
,
true
);
int32_t
len
=
0
;
if
(
pTagsSchema
->
type
!=
TSDB_DATA_TYPE_BINARY
&&
pTagsSchema
->
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
...
...
@@ -4502,7 +4519,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
pUpdateMsg
->
tagValLen
=
htonl
(
len
);
// length may be changed after dump data
int32_t
total
=
sizeof
(
SUpdateTableTagValMsg
)
+
len
;
int32_t
total
=
sizeof
(
SUpdateTableTagValMsg
)
+
len
+
schemaLen
;
pUpdateMsg
->
head
.
contLen
=
htonl
(
total
);
}
else
if
(
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
)
{
...
...
src/inc/taosmsg.h
浏览文件 @
5ac1c1bb
...
...
@@ -285,9 +285,9 @@ typedef struct {
int32_t
tid
;
int16_t
tversion
;
int16_t
colId
;
int16_t
type
;
int16_t
bytes
;
int32_t
tagValLen
;
int16_t
numOfTags
;
int32_t
schemaLen
;
char
data
[];
}
SUpdateTableTagValMsg
;
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
5ac1c1bb
...
...
@@ -310,7 +310,9 @@ int tsdbUpdateTagValue(TSDB_REPO_T *repo, SUpdateTableTagValMsg *pMsg) {
tsdbRemoveTableFromIndex
(
pMeta
,
pTable
);
}
// TODO: remove table from index if it is the first column of tag
tdSetKVRowDataOfCol
(
&
pTable
->
tagVal
,
htons
(
pMsg
->
colId
),
htons
(
pMsg
->
type
),
pMsg
->
data
);
// TODO: convert the tag schema from client, and then extract the type and bytes from schema according to colId
// tdSetKVRowDataOfCol(&pTable->tagVal, htons(pMsg->colId), htons(pMsg->type), pMsg->data);
if
(
schemaColAt
(
pTagSchema
,
DEFAULT_TAG_INDEX_COLUMN
)
->
colId
==
htons
(
pMsg
->
colId
))
{
tsdbAddTableIntoIndex
(
pMeta
,
pTable
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录