Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7e4c7e7c
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7e4c7e7c
编写于
6月 02, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-90] add protocol to update the tags value of tables.
上级
152c8267
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
77 addition
and
26 deletion
+77
-26
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-0
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+32
-7
src/client/src/tscSchemaUtil.c
src/client/src/tscSchemaUtil.c
+2
-0
src/client/src/tscServer.c
src/client/src/tscServer.c
+22
-14
src/common/inc/qsqltype.h
src/common/inc/qsqltype.h
+2
-1
src/dnode/src/dnodeShell.c
src/dnode/src/dnodeShell.c
+2
-1
src/inc/taosmsg.h
src/inc/taosmsg.h
+13
-1
tests/examples/c/demo.c
tests/examples/c/demo.c
+3
-2
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
7e4c7e7c
...
...
@@ -56,6 +56,7 @@ typedef struct STableMeta {
STableComInfo
tableInfo
;
uint8_t
tableType
;
int16_t
sversion
;
int16_t
tversion
;
SCMVgroupInfo
vgroupInfo
;
int32_t
sid
;
// the index of one table in a virtual node
uint64_t
uid
;
// unique id of a table
...
...
src/client/src/tscSQLParser.c
浏览文件 @
7e4c7e7c
...
...
@@ -4402,7 +4402,9 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
}
else
if
(
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
)
{
// Note: update can only be applied to table not super table.
// the following is handle display tags value for meters created according to super table
// the following is used to handle tags value for table created according to super table
pCmd
->
command
=
TSDB_SQL_UPDATE_TAGS_VAL
;
tVariantList
*
pVarList
=
pAlterSQL
->
varList
;
tVariant
*
pTagName
=
&
pVarList
->
a
[
0
].
pVar
;
...
...
@@ -4425,15 +4427,38 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
// validate the length of binary
if
((
pTagsSchema
->
type
==
TSDB_DATA_TYPE_BINARY
||
pTagsSchema
->
type
==
TSDB_DATA_TYPE_NCHAR
)
&&
pVarList
->
a
[
1
].
pVar
.
nLen
>
pTagsSchema
->
bytes
)
{
(
pVarList
->
a
[
1
].
pVar
.
nLen
+
VARSTR_HEADER_SIZE
)
>
pTagsSchema
->
bytes
)
{
return
invalidSqlErrMsg
(
pQueryInfo
->
msg
,
msg14
);
}
char
name1
[
128
]
=
{
0
};
strncpy
(
name1
,
pTagName
->
pz
,
pTagName
->
nLen
);
TAOS_FIELD
f
=
tscCreateField
(
TSDB_DATA_TYPE_INT
,
name1
,
tDataTypeDesc
[
TSDB_DATA_TYPE_INT
].
nSize
);
tscFieldInfoAppend
(
&
pQueryInfo
->
fieldsInfo
,
&
f
);
int32_t
size
=
sizeof
(
SUpdateTableTagValMsg
)
+
pTagsSchema
->
bytes
+
TSDB_EXTRA_PAYLOAD_SIZE
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
tscError
(
"%p failed to malloc for alter table msg"
,
pSql
);
return
TSDB_CODE_CLI_OUT_OF_MEMORY
;
}
SUpdateTableTagValMsg
*
pUpdateMsg
=
(
SUpdateTableTagValMsg
*
)
(
pCmd
->
payload
+
tsRpcHeadSize
);
pUpdateMsg
->
head
.
vgId
=
htonl
(
pTableMeta
->
vgroupInfo
.
vgId
);
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
);
int32_t
len
=
0
;
if
(
pTagsSchema
->
type
!=
TSDB_DATA_TYPE_BINARY
&&
pTagsSchema
->
type
!=
TSDB_DATA_TYPE_NCHAR
)
{
len
=
tDataTypeDesc
[
pTagsSchema
->
type
].
nSize
;
}
else
{
len
=
varDataLen
(
pUpdateMsg
->
data
);
}
pUpdateMsg
->
tagValLen
=
htonl
(
len
);
// length may be changed after dump data
int32_t
total
=
sizeof
(
SUpdateTableTagValMsg
)
+
len
;
pUpdateMsg
->
head
.
contLen
=
htonl
(
total
);
}
else
if
(
pAlterSQL
->
type
==
TSDB_ALTER_TABLE_ADD_COLUMN
)
{
tFieldList
*
pFieldList
=
pAlterSQL
->
pAddColumns
;
...
...
src/client/src/tscSchemaUtil.c
浏览文件 @
7e4c7e7c
...
...
@@ -168,6 +168,8 @@ STableMeta* tscCreateTableMetaFromMsg(STableMetaMsg* pTableMetaMsg, size_t* size
pTableMeta
->
sid
=
pTableMetaMsg
->
sid
;
pTableMeta
->
uid
=
pTableMetaMsg
->
uid
;
pTableMeta
->
vgroupInfo
=
pTableMetaMsg
->
vgroup
;
pTableMeta
->
sversion
=
pTableMetaMsg
->
sversion
;
pTableMeta
->
tversion
=
pTableMetaMsg
->
tversion
;
memcpy
(
pTableMeta
->
schema
,
pTableMetaMsg
->
schema
,
schemaSize
);
...
...
src/client/src/tscServer.c
浏览文件 @
7e4c7e7c
...
...
@@ -1260,28 +1260,24 @@ int tscEstimateAlterTableMsgLength(SSqlCmd *pCmd) {
}
int
tscBuildAlterTableMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SCMAlterTableMsg
*
pAlterTableMsg
;
char
*
pMsg
;
int
msgLen
=
0
;
int
size
=
0
;
char
*
pMsg
;
int
msgLen
=
0
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
size
=
tscEstimateAlterTableMsgLength
(
pCmd
);
SAlterTableSQL
*
pAlterInfo
=
pInfo
->
pAlterInfo
;
int
size
=
tscEstimateAlterTableMsgLength
(
pCmd
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
size
))
{
tscError
(
"%p failed to malloc for alter table msg"
,
pSql
);
return
-
1
;
}
pAlterTableMsg
=
(
SCMAlterTableMsg
*
)
pCmd
->
payload
;
SCMAlterTableMsg
*
pAlterTableMsg
=
(
SCMAlterTableMsg
*
)
pCmd
->
payload
;
tscGetDBInfoFromMeterId
(
pTableMetaInfo
->
name
,
pAlterTableMsg
->
db
);
SAlterTableSQL
*
pAlterInfo
=
pInfo
->
pAlterInfo
;
strcpy
(
pAlterTableMsg
->
tableId
,
pTableMetaInfo
->
name
);
pAlterTableMsg
->
type
=
htons
(
pAlterInfo
->
type
);
...
...
@@ -1289,7 +1285,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SSchema
*
pSchema
=
pAlterTableMsg
->
schema
;
for
(
int
i
=
0
;
i
<
tscNumOfFields
(
pQueryInfo
);
++
i
)
{
TAOS_FIELD
*
pField
=
tscFieldInfoGetField
(
&
pQueryInfo
->
fieldsInfo
,
i
);
pSchema
->
type
=
pField
->
type
;
strcpy
(
pSchema
->
name
,
pField
->
name
);
pSchema
->
bytes
=
htons
(
pField
->
bytes
);
...
...
@@ -1302,6 +1298,7 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg
+=
pAlterInfo
->
tagData
.
dataLen
;
msgLen
=
pMsg
-
(
char
*
)
pAlterTableMsg
;
pCmd
->
payloadLen
=
msgLen
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_ALTER_TABLE
;
...
...
@@ -1310,6 +1307,16 @@ int tscBuildAlterTableMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
return
TSDB_CODE_SUCCESS
;
}
int
tscBuildUpdateTagMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_UPDATE_TAG_VAL
;
SUpdateTableTagValMsg
*
pUpdateMsg
=
(
SUpdateTableTagValMsg
*
)
(
pCmd
->
payload
+
tsRpcHeadSize
);
pCmd
->
payloadLen
=
htonl
(
pUpdateMsg
->
head
.
contLen
);
return
TSDB_CODE_SUCCESS
;
}
int
tscAlterDbMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
payloadLen
=
sizeof
(
SCMAlterDbMsg
);
...
...
@@ -1804,7 +1811,7 @@ int tscProcessTableMetaRsp(SSqlObj *pSql) {
pMetaMsg
->
sid
=
htonl
(
pMetaMsg
->
sid
);
pMetaMsg
->
sversion
=
htons
(
pMetaMsg
->
sversion
);
pMetaMsg
->
tversion
=
htons
(
pMetaMsg
->
tversion
);
pMetaMsg
->
vgroup
.
vgId
=
htonl
(
pMetaMsg
->
vgroup
.
vgId
);
pMetaMsg
->
uid
=
htobe64
(
pMetaMsg
->
uid
);
...
...
@@ -2552,6 +2559,7 @@ void tscInitMsgsFp() {
tscBuildMsg
[
TSDB_SQL_DROP_DNODE
]
=
tscBuildDropDnodeMsg
;
tscBuildMsg
[
TSDB_SQL_CFG_DNODE
]
=
tscBuildCfgDnodeMsg
;
tscBuildMsg
[
TSDB_SQL_ALTER_TABLE
]
=
tscBuildAlterTableMsg
;
tscBuildMsg
[
TSDB_SQL_UPDATE_TAGS_VAL
]
=
tscBuildUpdateTagMsg
;
tscBuildMsg
[
TSDB_SQL_ALTER_DB
]
=
tscAlterDbMsg
;
tscBuildMsg
[
TSDB_SQL_CONNECT
]
=
tscBuildConnectMsg
;
...
...
src/common/inc/qsqltype.h
浏览文件 @
7e4c7e7c
...
...
@@ -35,7 +35,8 @@ enum {
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_SELECT
,
"select"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_FETCH
,
"fetch"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_INSERT
,
"insert"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_UPDATE_TAGS_VAL
,
"update-tag-val"
)
// the SQL below is for mgmt node
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_MGMT
,
"mgmt"
)
TSDB_DEFINE_SQL_TYPE
(
TSDB_SQL_CREATE_DB
,
"create-db"
)
...
...
src/dnode/src/dnodeShell.c
浏览文件 @
7e4c7e7c
...
...
@@ -40,7 +40,8 @@ int32_t dnodeInitShell() {
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_SUBMIT
]
=
dnodeDispatchToVnodeWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_QUERY
]
=
dnodeDispatchToVnodeReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_FETCH
]
=
dnodeDispatchToVnodeReadQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_UPDATE_TAG_VAL
]
=
dnodeDispatchToVnodeWriteQueue
;
// the following message shall be treated as mnode write
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_CREATE_ACCT
]
=
dnodeDispatchToMnodeWriteQueue
;
dnodeProcessShellMsgFp
[
TSDB_MSG_TYPE_CM_ALTER_ACCT
]
=
dnodeDispatchToMnodeWriteQueue
;
...
...
src/inc/taosmsg.h
浏览文件 @
7e4c7e7c
...
...
@@ -43,7 +43,7 @@ enum {
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_SUBMIT
,
"submit"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_QUERY
,
"query"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_FETCH
,
"fetch"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_
DUMMY0
,
"dummy0
"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_
UPDATE_TAG_VAL
,
"update-tag-val
"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_DUMMY1
,
"dummy1"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_DUMMY2
,
"dummy2"
)
TAOS_DEFINE_MESSAGE_TYPE
(
TSDB_MSG_TYPE_DUMMY3
,
"dummy3"
)
...
...
@@ -276,6 +276,18 @@ typedef struct {
// char tagVal[];
}
SCMAlterTableMsg
;
typedef
struct
{
SMsgHead
head
;
int64_t
uid
;
int32_t
tid
;
int16_t
tversion
;
int16_t
colId
;
int16_t
type
;
int16_t
bytes
;
int32_t
tagValLen
;
char
data
[];
}
SUpdateTableTagValMsg
;
typedef
struct
{
char
clientVersion
[
TSDB_VERSION_LEN
];
char
msgVersion
[
TSDB_VERSION_LEN
];
...
...
tests/examples/c/demo.c
浏览文件 @
7e4c7e7c
...
...
@@ -95,7 +95,7 @@ int main(int argc, char *argv[]) {
return
0
;
}
taos_options
(
TSDB_OPTION_CONFIGDIR
,
"
/home/lisa/Documents/workspace/TDinternal/community/sim/tsim
/cfg"
);
taos_options
(
TSDB_OPTION_CONFIGDIR
,
"
~/sec
/cfg"
);
// init TAOS
taos_init
();
...
...
@@ -108,7 +108,8 @@ int main(int argc, char *argv[]) {
printf
(
"success to connect to server
\n
"
);
// multiThreadTest(1, taos);
doQuery
(
taos
,
"select max(c1), min(c2), sum(c3), avg(c4), first(c7), last(c8), first(c9) from lm2_db0.lm2_stb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(value, -1, -2) group by t1 limit 2 offset 10;"
);
doQuery
(
taos
,
"use test"
);
doQuery
(
taos
,
"alter table tm99 set tag a=99"
);
// for(int32_t i = 0; i < 100000; ++i) {
// doQuery(taos, "insert into t1 values(now, 2)");
// }
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录