Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
adminstrot
TDengine
提交
c1252c2d
TDengine
项目概览
adminstrot
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c1252c2d
编写于
7月 01, 2020
作者:
B
Bomin Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-803: use KV to transfer tags
上级
f65bb570
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
52 deletion
+38
-52
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+17
-26
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+18
-7
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+3
-19
未找到文件。
src/client/src/tscParseInsert.c
浏览文件 @
c1252c2d
...
@@ -891,11 +891,15 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -891,11 +891,15 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"keyword TAGS expected"
,
sToken
.
z
);
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
"keyword TAGS expected"
,
sToken
.
z
);
}
}
SKVRowBuilder
kvRowBuilder
=
{
0
};
if
(
tdInitKVRowBuilder
(
&
kvRowBuilder
)
<
0
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
uint32_t
ignoreTokenTypes
=
TK_LP
;
uint32_t
ignoreTokenTypes
=
TK_LP
;
uint32_t
numOfIgnoreToken
=
1
;
uint32_t
numOfIgnoreToken
=
1
;
for
(
int
i
=
0
;
i
<
spd
.
numOfAssignedCols
;
++
i
)
{
for
(
int
i
=
0
;
i
<
spd
.
numOfAssignedCols
;
++
i
)
{
char
*
tagVal
=
pTag
->
data
+
spd
.
elems
[
i
].
offset
;
SSchema
*
pSchema
=
pTagSchema
+
spd
.
elems
[
i
].
colIndex
;
int16_t
colIndex
=
spd
.
elems
[
i
].
colIndex
;
index
=
0
;
index
=
0
;
sToken
=
tStrGetToken
(
sql
,
&
index
,
true
,
numOfIgnoreToken
,
&
ignoreTokenTypes
);
sToken
=
tStrGetToken
(
sql
,
&
index
,
true
,
numOfIgnoreToken
,
&
ignoreTokenTypes
);
...
@@ -911,12 +915,21 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -911,12 +915,21 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
sToken
.
n
-=
2
;
sToken
.
n
-=
2
;
}
}
code
=
tsParseOneColumnData
(
&
pTagSchema
[
colIndex
],
&
sToken
,
tagVal
,
pCmd
->
payload
,
&
sql
,
false
,
tinfo
.
precision
);
char
tagVal
[
TSDB_MAX_TAGS_LEN
];
code
=
tsParseOneColumnData
(
pSchema
,
&
sToken
,
tagVal
,
pCmd
->
payload
,
&
sql
,
false
,
tinfo
.
precision
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
tdAddColToKVRow
(
&
kvRowBuilder
,
pSchema
->
colId
,
pSchema
->
type
,
tagVal
);
}
}
SKVRow
row
=
tdGetKVRowFromBuilder
(
&
kvRowBuilder
);
pTag
->
dataLen
=
kvRowLen
(
row
);
memcpy
(
pTag
->
data
,
row
,
pTag
->
dataLen
);
free
(
row
);
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
index
=
0
;
index
=
0
;
sToken
=
tStrGetToken
(
sql
,
&
index
,
false
,
0
,
NULL
);
sToken
=
tStrGetToken
(
sql
,
&
index
,
false
,
0
,
NULL
);
sql
+=
index
;
sql
+=
index
;
...
@@ -924,29 +937,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
...
@@ -924,29 +937,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql) {
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
") expected"
,
sToken
.
z
);
return
tscInvalidSQLErrMsg
(
pCmd
->
payload
,
") expected"
,
sToken
.
z
);
}
}
// 2. set the null value for the columns that do not assign values
pCmd
->
payloadLen
=
sizeof
(
pTag
->
name
)
+
sizeof
(
pTag
->
dataLen
)
+
pTag
->
dataLen
;
if
(
spd
.
numOfAssignedCols
<
spd
.
numOfCols
)
{
char
*
ptr
=
pTag
->
data
;
for
(
int32_t
i
=
0
;
i
<
spd
.
numOfCols
;
++
i
)
{
if
(
!
spd
.
hasVal
[
i
])
{
// current tag column do not have any value to insert, set it to null
if
(
pTagSchema
[
i
].
type
==
TSDB_DATA_TYPE_BINARY
||
pTagSchema
[
i
].
type
==
TSDB_DATA_TYPE_NCHAR
)
{
setVardataNull
(
ptr
,
pTagSchema
[
i
].
type
);
}
else
{
setNull
(
ptr
,
pTagSchema
[
i
].
type
,
pTagSchema
[
i
].
bytes
);
}
}
ptr
+=
pTagSchema
[
i
].
bytes
;
}
}
// 3. calculate the actual data size of STagData
pCmd
->
payloadLen
=
sizeof
(
pTag
->
name
)
+
sizeof
(
pTag
->
dataLen
);
for
(
int32_t
t
=
0
;
t
<
numOfTags
;
++
t
)
{
pTag
->
dataLen
+=
pTagSchema
[
t
].
bytes
;
pCmd
->
payloadLen
+=
pTagSchema
[
t
].
bytes
;
}
pTag
->
dataLen
=
htonl
(
pTag
->
dataLen
);
pTag
->
dataLen
=
htonl
(
pTag
->
dataLen
);
if
(
tscValidateName
(
&
tableToken
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscValidateName
(
&
tableToken
)
!=
TSDB_CODE_SUCCESS
)
{
...
...
src/client/src/tscSQLParser.c
浏览文件 @
c1252c2d
...
@@ -5623,25 +5623,36 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
...
@@ -5623,25 +5623,36 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
SSchema
*
pTagSchema
=
tscGetTableTagSchema
(
pStableMeterMetaInfo
->
pTableMeta
);
SSchema
*
pTagSchema
=
tscGetTableTagSchema
(
pStableMeterMetaInfo
->
pTableMeta
);
STagData
*
pTag
=
&
pCreateTable
->
usingInfo
.
tagdata
;
STagData
*
pTag
=
&
pCreateTable
->
usingInfo
.
tagdata
;
char
*
tagVal
=
pTag
->
data
;
SKVRowBuilder
kvRowBuilder
=
{
0
};
if
(
tdInitKVRowBuilder
(
&
kvRowBuilder
)
<
0
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
int32_t
ret
=
TSDB_CODE_SUCCESS
;
int32_t
ret
=
TSDB_CODE_SUCCESS
;
for
(
int32_t
i
=
0
;
i
<
pList
->
nExpr
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pList
->
nExpr
;
++
i
)
{
if
(
pTagSchema
[
i
].
type
==
TSDB_DATA_TYPE_BINARY
||
pTagSchema
[
i
].
type
==
TSDB_DATA_TYPE_NCHAR
)
{
SSchema
*
pSchema
=
pTagSchema
+
i
;
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_BINARY
||
pSchema
->
type
==
TSDB_DATA_TYPE_NCHAR
)
{
// validate the length of binary
// validate the length of binary
if
(
pList
->
a
[
i
].
pVar
.
nLen
+
VARSTR_HEADER_SIZE
>
p
TagSchema
[
i
].
bytes
)
{
if
(
pList
->
a
[
i
].
pVar
.
nLen
+
VARSTR_HEADER_SIZE
>
p
Schema
->
bytes
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
}
}
}
ret
=
tVariantDump
(
&
(
pList
->
a
[
i
].
pVar
),
tagVal
,
pTagSchema
[
i
].
type
,
true
);
char
tagVal
[
TSDB_MAX_TAGS_LEN
];
ret
=
tVariantDump
(
&
(
pList
->
a
[
i
].
pVar
),
tagVal
,
pSchema
->
type
,
true
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg4
);
}
}
t
agVal
+=
pTagSchema
[
i
].
bytes
;
t
dAddColToKVRow
(
&
kvRowBuilder
,
pSchema
->
colId
,
pSchema
->
type
,
tagVal
)
;
}
}
SKVRow
row
=
tdGetKVRowFromBuilder
(
&
kvRowBuilder
);
pTag
->
dataLen
=
kvRowLen
(
row
);
memcpy
(
pTag
->
data
,
row
,
pTag
->
dataLen
);
free
(
row
);
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
// table name
// table name
if
(
tscValidateName
(
&
pInfo
->
pCreateTableInfo
->
name
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tscValidateName
(
&
pInfo
->
pCreateTableInfo
->
name
)
!=
TSDB_CODE_SUCCESS
)
{
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
return
invalidSqlErrMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg1
);
...
@@ -5653,7 +5664,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
...
@@ -5653,7 +5664,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
return
ret
;
return
ret
;
}
}
pTag
->
dataLen
=
tagVal
-
pTag
->
data
;
//
pTag->dataLen = tagVal - pTag->data;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
c1252c2d
...
@@ -233,26 +233,10 @@ STableCfg *tsdbCreateTableCfgFromMsg(SMDCreateTableMsg *pMsg) {
...
@@ -233,26 +233,10 @@ STableCfg *tsdbCreateTableCfgFromMsg(SMDCreateTableMsg *pMsg) {
if
(
tsdbTableSetSName
(
pCfg
,
pMsg
->
superTableId
,
true
)
<
0
)
goto
_err
;
if
(
tsdbTableSetSName
(
pCfg
,
pMsg
->
superTableId
,
true
)
<
0
)
goto
_err
;
if
(
tsdbTableSetSuperUid
(
pCfg
,
htobe64
(
pMsg
->
superTableUid
))
<
0
)
goto
_err
;
if
(
tsdbTableSetSuperUid
(
pCfg
,
htobe64
(
pMsg
->
superTableUid
))
<
0
)
goto
_err
;
// Decode tag values
int32_t
tagDataLen
=
htonl
(
pMsg
->
tagDataLen
);
if
(
pMsg
->
tagDataLen
)
{
if
(
tagDataLen
)
{
int
accBytes
=
0
;
char
*
pTagData
=
pMsg
->
data
+
(
numOfCols
+
numOfTags
)
*
sizeof
(
SSchema
);
char
*
pTagData
=
pMsg
->
data
+
(
numOfCols
+
numOfTags
)
*
sizeof
(
SSchema
);
tsdbTableSetTagValue
(
pCfg
,
pTagData
,
true
);
SKVRowBuilder
kvRowBuilder
=
{
0
};
if
(
tdInitKVRowBuilder
(
&
kvRowBuilder
)
<
0
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
_err
;
}
for
(
int
i
=
numOfCols
;
i
<
numOfCols
+
numOfTags
;
i
++
)
{
if
(
tdAddColToKVRow
(
&
kvRowBuilder
,
htons
(
pSchema
[
i
].
colId
),
pSchema
[
i
].
type
,
pTagData
+
accBytes
)
<
0
)
{
terrno
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
_err
;
}
accBytes
+=
htons
(
pSchema
[
i
].
bytes
);
}
tsdbTableSetTagValue
(
pCfg
,
tdGetKVRowFromBuilder
(
&
kvRowBuilder
),
false
);
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录