Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
292d5799
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看板
提交
292d5799
编写于
5月 28, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: adapt for interface
上级
59a6b247
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
94 addition
and
88 deletion
+94
-88
include/common/tdataformat.h
include/common/tdataformat.h
+11
-9
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+24
-4
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+8
-13
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+20
-26
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+31
-36
未找到文件。
include/common/tdataformat.h
浏览文件 @
292d5799
...
...
@@ -60,8 +60,8 @@ int32_t tTSRowBuilderPut(STSRowBuilder *pBuilder, int32_t cid, uint8_t *pData, u
int32_t
tTSRowBuilderGetRow
(
STSRowBuilder
*
pBuilder
,
const
STSRow2
**
ppRow
);
// STagVal
static
FORCE_INLINE
void
tTagVal
Set
(
STagVal
*
pTagVal
,
void
*
key
,
int8_t
type
,
uint8_t
*
pData
,
uint32_t
nData
,
bool
isJson
);
static
FORCE_INLINE
void
tTagVal
Push
(
SArray
*
pTagArray
,
void
*
key
,
int8_t
type
,
uint8_t
*
pData
,
uint32_t
nData
,
bool
isJson
);
// STag
int32_t
tTagNew
(
SArray
*
pArray
,
int32_t
version
,
int8_t
isJson
,
STag
**
ppTag
);
...
...
@@ -133,17 +133,19 @@ struct STagVal {
uint8_t
*
pData
;
};
static
FORCE_INLINE
void
tTagValSet
(
STagVal
*
pTagVal
,
void
*
key
,
int8_t
type
,
uint8_t
*
pData
,
uint32_t
nData
,
bool
isJson
)
{
static
FORCE_INLINE
void
tTagValPush
(
SArray
*
pTagArray
,
void
*
key
,
int8_t
type
,
uint8_t
*
pData
,
uint32_t
nData
,
bool
isJson
)
{
STagVal
tagVal
=
{
0
};
if
(
isJson
)
{
pTagVal
->
pKey
=
(
char
*
)
key
;
tagVal
.
pKey
=
(
char
*
)
key
;
}
else
{
pTagVal
->
cid
=
*
(
int16_t
*
)
key
;
tagVal
.
cid
=
*
(
int16_t
*
)
key
;
}
pTagVal
->
type
=
type
;
pTagVal
->
pData
=
pData
;
pTagVal
->
nData
=
nData
;
tagVal
.
type
=
type
;
tagVal
.
pData
=
pData
;
tagVal
.
nData
=
nData
;
taosArrayPush
(
pTagArray
,
&
tagVal
);
}
#pragma pack(push, 1)
...
...
source/common/src/tdatablock.c
浏览文件 @
292d5799
...
...
@@ -1631,6 +1631,11 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SArray* pDataBlocks
SSubmitReq
*
tdBlockToSubmit
(
const
SArray
*
pBlocks
,
const
STSchema
*
pTSchema
,
bool
createTb
,
int64_t
suid
,
const
char
*
stbFullName
,
int32_t
vgId
)
{
SSubmitReq
*
ret
=
NULL
;
SArray
*
tagArray
=
taosArrayInit
(
1
,
sizeof
(
STagVal
));
if
(
!
tagArray
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
// cal size
int32_t
cap
=
sizeof
(
SSubmitReq
);
...
...
@@ -1652,14 +1657,19 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
createTbReq
.
type
=
TSDB_CHILD_TABLE
;
createTbReq
.
ctb
.
suid
=
suid
;
STagVal
tagVal
=
{.
cid
=
1
,
.
type
=
TSDB_DATA_TYPE_UBIGINT
,
.
pData
=
(
uint8_t
*
)
&
pDataBlock
->
info
.
groupId
,
.
nData
=
sizeof
(
uint64_t
)};
STag
*
pTag
=
NULL
;
tTagNew
(
&
tagVal
,
1
,
1
,
false
,
&
pTag
);
taosArrayClear
(
tagArray
);
taosArrayPush
(
tagArray
,
&
tagVal
);
tTagNew
(
tagArray
,
1
,
false
,
&
pTag
);
if
(
!
pTag
)
{
tdDestroySVCreateTbReq
(
&
createTbReq
);
taosArrayDestroy
(
tagArray
);
return
NULL
;
}
createTbReq
.
ctb
.
pTag
=
(
uint8_t
*
)
pTag
;
...
...
@@ -1669,7 +1679,11 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
tdDestroySVCreateTbReq
(
&
createTbReq
);
if
(
code
<
0
)
return
NULL
;
if
(
code
<
0
)
{
tdDestroySVCreateTbReq
(
&
createTbReq
);
taosArrayDestroy
(
tagArray
);
return
NULL
;
}
}
cap
+=
sizeof
(
SSubmitBlk
)
+
schemaLen
+
rows
*
maxLen
;
...
...
@@ -1716,10 +1730,13 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
.
type
=
TSDB_DATA_TYPE_UBIGINT
,
.
pData
=
(
uint8_t
*
)
&
pDataBlock
->
info
.
groupId
,
.
nData
=
sizeof
(
uint64_t
)};
STag
*
pTag
=
NULL
;
tTagNew
(
&
tagVal
,
1
,
1
,
false
,
&
pTag
);
taosArrayClear
(
tagArray
);
taosArrayPush
(
tagArray
,
&
tagVal
);
STag
*
pTag
=
NULL
;
tTagNew
(
tagArray
,
1
,
false
,
&
pTag
);
if
(
!
pTag
)
{
tdDestroySVCreateTbReq
(
&
createTbReq
);
taosArrayDestroy
(
tagArray
);
taosMemoryFreeClear
(
ret
);
return
NULL
;
}
...
...
@@ -1729,6 +1746,7 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
tEncodeSize
(
tEncodeSVCreateTbReq
,
&
createTbReq
,
schemaLen
,
code
);
if
(
code
<
0
)
{
tdDestroySVCreateTbReq
(
&
createTbReq
);
taosArrayDestroy
(
tagArray
);
taosMemoryFreeClear
(
ret
);
return
NULL
;
}
...
...
@@ -1740,6 +1758,7 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
tdDestroySVCreateTbReq
(
&
createTbReq
);
if
(
code
<
0
)
{
taosArrayDestroy
(
tagArray
);
taosMemoryFreeClear
(
ret
);
return
NULL
;
}
...
...
@@ -1777,5 +1796,6 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo
}
ret
->
length
=
htonl
(
ret
->
length
);
taosArrayDestroy
(
tagArray
);
return
ret
;
}
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
292d5799
...
...
@@ -565,37 +565,32 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
}
else
{
const
STag
*
pOldTag
=
(
const
STag
*
)
ctbEntry
.
ctbEntry
.
pTags
;
STag
*
pNewTag
=
NULL
;
STagVal
*
pTagVals
=
taosMemoryCalloc
(
pTagSchema
->
nCols
,
sizeof
(
STagVal
));
if
(
!
pTagVals
)
{
SArray
*
pTagArray
=
taosArrayInit
(
pTagSchema
->
nCols
,
sizeof
(
STagVal
));
if
(
!
pTagArray
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
}
int16_t
nTags
=
0
;
for
(
int32_t
i
=
0
;
i
<
pTagSchema
->
nCols
;
i
++
)
{
SSchema
*
pCol
=
&
pTagSchema
->
pSchema
[
i
];
STagVal
*
pTagVal
=
pTagVals
+
nTags
;
if
(
iCol
==
i
)
{
tTagValSet
(
pTagVal
,
&
pCol
->
colId
,
pCol
->
type
,
pAlterTbReq
->
pTagVal
,
pAlterTbReq
->
nTagVal
,
false
);
++
nTags
;
tTagValPush
(
pTagArray
,
&
pCol
->
colId
,
pCol
->
type
,
pAlterTbReq
->
pTagVal
,
pAlterTbReq
->
nTagVal
,
false
);
}
else
{
STagVal
tagVal
=
{.
cid
=
pCol
->
colId
};
if
(
tTagGet
(
pOldTag
,
&
tagVal
)
&&
tagVal
.
pData
)
{
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
tTagVal
Set
(
pTagVal
,
&
pCol
->
colId
,
pCol
->
type
,
tagVal
.
pData
,
varDataTLen
(
tagVal
.
pData
),
false
);
tTagVal
Push
(
pTagArray
,
&
pCol
->
colId
,
pCol
->
type
,
tagVal
.
pData
,
varDataTLen
(
tagVal
.
pData
),
false
);
}
else
{
tTagVal
Set
(
pTagVal
,
&
pCol
->
colId
,
pCol
->
type
,
tagVal
.
pData
,
pCol
->
bytes
,
false
);
tTagVal
Push
(
pTagArray
,
&
pCol
->
colId
,
pCol
->
type
,
tagVal
.
pData
,
pCol
->
bytes
,
false
);
}
++
nTags
;
}
}
}
if
((
terrno
=
tTagNew
(
pTag
Vals
,
nTags
,
pTagSchema
->
version
,
false
,
&
pNewTag
))
<
0
)
{
taos
MemoryFreeClear
(
pTagVals
);
if
((
terrno
=
tTagNew
(
pTag
Array
,
pTagSchema
->
version
,
false
,
&
pNewTag
))
<
0
)
{
taos
ArrayDestroy
(
pTagArray
);
goto
_err
;
}
ctbEntry
.
ctbEntry
.
pTags
=
(
uint8_t
*
)
pNewTag
;
taos
MemoryFreeClear
(
pTagVals
);
taos
ArrayDestroy
(
pTagArray
);
}
// save to table.db
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
292d5799
...
...
@@ -54,7 +54,7 @@ typedef struct SInsertParseContext {
SMsgBuf
msg
;
// input
STableMeta
*
pTableMeta
;
// each table
SParsedDataColInfo
tags
;
// each table
S
TagVal
*
pTagVals
;
// each table
S
Array
*
pTagVals
;
// each table
SVCreateTbReq
createTblReq
;
// each table
SHashObj
*
pVgroupsHashObj
;
// global
SHashObj
*
pTableBlockHashObj
;
// global
...
...
@@ -72,9 +72,8 @@ static uint8_t TRUE_VALUE = (uint8_t)TSDB_TRUE;
static
uint8_t
FALSE_VALUE
=
(
uint8_t
)
TSDB_FALSE
;
typedef
struct
SKvParam
{
int16_t
nTag
;
int16_t
pos
;
S
TagVal
*
pTagVals
;
S
Array
*
pTagVals
;
SSchema
*
schema
;
char
buf
[
TSDB_MAX_TAGS_LEN
];
}
SKvParam
;
...
...
@@ -773,7 +772,7 @@ static int32_t KvRowAppend(SMsgBuf* pMsgBuf, const void* value, int32_t len, voi
if
(
TSDB_DATA_TYPE_BINARY
==
type
)
{
memcpy
(
pa
->
buf
+
pa
->
pos
,
value
,
len
);
tTagVal
Set
(
pa
->
pTagVals
+
pa
->
nTag
++
,
&
colId
,
type
,
(
uint8_t
*
)(
pa
->
buf
+
pa
->
pos
),
len
,
false
);
tTagVal
Push
(
pa
->
pTagVals
,
&
colId
,
type
,
(
uint8_t
*
)(
pa
->
buf
+
pa
->
pos
),
len
,
false
);
pa
->
pos
+=
len
;
}
else
if
(
TSDB_DATA_TYPE_NCHAR
==
type
)
{
// if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long'
...
...
@@ -789,11 +788,11 @@ static int32_t KvRowAppend(SMsgBuf* pMsgBuf, const void* value, int32_t len, voi
snprintf
(
buf
,
tListLen
(
buf
),
" taosMbsToUcs4 error:%s"
,
strerror
(
errno
));
return
buildSyntaxErrMsg
(
pMsgBuf
,
buf
,
value
);
}
tTagVal
Set
(
pa
->
pTagVals
+
pa
->
nTag
++
,
&
colId
,
type
,
(
uint8_t
*
)(
pa
->
buf
+
pa
->
pos
),
output
,
false
);
tTagVal
Push
(
pa
->
pTagVals
,
&
colId
,
type
,
(
uint8_t
*
)(
pa
->
buf
+
pa
->
pos
),
output
,
false
);
pa
->
pos
+=
output
;
}
else
{
memcpy
(
pa
->
buf
+
pa
->
pos
,
value
,
TYPE_BYTES
[
type
]);
tTagVal
Set
(
pa
->
pTagVals
+
pa
->
nTag
++
,
&
colId
,
type
,
(
uint8_t
*
)(
pa
->
buf
+
pa
->
pos
),
TYPE_BYTES
[
type
],
false
);
tTagVal
Push
(
pa
->
pTagVals
,
&
colId
,
type
,
(
uint8_t
*
)(
pa
->
buf
+
pa
->
pos
),
TYPE_BYTES
[
type
],
false
);
pa
->
pos
+
TYPE_BYTES
[
type
];
}
ASSERT
(
pa
->
pos
<=
TSDB_MAX_TAGS_LEN
);
...
...
@@ -813,11 +812,11 @@ static int32_t buildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag*
// pSql -> tag1_value, ...)
static
int32_t
parseTagsClause
(
SInsertParseContext
*
pCxt
,
SSchema
*
pSchema
,
uint8_t
precision
,
const
char
*
tName
)
{
ASSERT
(
!
pCxt
->
pTagVals
);
if
(
!
(
pCxt
->
pTagVals
=
taos
MemoryCalloc
(
pCxt
->
tags
.
numOfBound
,
sizeof
(
STagVal
))))
{
if
(
!
(
pCxt
->
pTagVals
=
taos
ArrayInit
(
pCxt
->
tags
.
numOfBound
,
sizeof
(
STagVal
))))
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
SKvParam
param
=
{.
pTagVals
=
pCxt
->
pTagVals
,
.
nTag
=
0
,
.
pos
=
0
};
SKvParam
param
=
{.
pTagVals
=
pCxt
->
pTagVals
,
.
pos
=
0
};
SToken
sToken
;
bool
isParseBindParam
=
false
;
char
tmpTokenBuf
[
TSDB_MAX_BYTES_PER_ROW
]
=
{
0
};
// used for deleting Escape character: \\, \', \"
...
...
@@ -828,7 +827,6 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint
if
(
sToken
.
type
==
TK_NK_QUESTION
)
{
isParseBindParam
=
true
;
if
(
NULL
==
pCxt
->
pStmtCb
)
{
taosMemoryFreeClear
(
pCxt
->
pTagVals
);
return
buildSyntaxErrMsg
(
&
pCxt
->
msg
,
"? only used in stmt"
,
sToken
.
z
);
}
...
...
@@ -836,7 +834,6 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint
}
if
(
isParseBindParam
)
{
taosMemoryFreeClear
(
pCxt
->
pTagVals
);
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"no mix usage for ? and tag values"
);
}
...
...
@@ -847,18 +844,15 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint
}
if
(
isParseBindParam
)
{
taosMemoryFreeClear
(
pCxt
->
pTagVals
);
return
TSDB_CODE_SUCCESS
;
}
// TODO: JSON_TAG_REFACTOR (would be JSON tag or normal tag)
STag
*
pTag
=
NULL
;
if
(
tTagNew
(
param
.
pTagVals
,
param
.
nTag
,
1
,
false
,
&
pTag
)
!=
0
)
{
taosMemoryFreeClear
(
pCxt
->
pTagVals
);
if
(
tTagNew
(
param
.
pTagVals
,
1
,
false
,
&
pTag
)
!=
0
)
{
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"out of memory"
);
}
taosMemoryFreeClear
(
pCxt
->
pTagVals
);
return
buildCreateTbReq
(
&
pCxt
->
createTblReq
,
tName
,
pTag
,
pCxt
->
pTableMeta
->
suid
);
}
...
...
@@ -1078,7 +1072,7 @@ void destroyCreateSubTbReq(SVCreateTbReq* pReq) {
static
void
destroyInsertParseContextForTable
(
SInsertParseContext
*
pCxt
)
{
taosMemoryFreeClear
(
pCxt
->
pTableMeta
);
destroyBoundColumnInfo
(
&
pCxt
->
tags
);
taos
MemoryFreeClear
(
pCxt
->
pTagVals
);
taos
ArrayDestroy
(
pCxt
->
pTagVals
);
destroyCreateSubTbReq
(
&
pCxt
->
createTblReq
);
}
...
...
@@ -1349,13 +1343,13 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tN
return
TSDB_CODE_QRY_APP_ERROR
;
}
S
TagVal
*
pTagVals
=
taosMemoryCalloc
(
tags
->
numOfBound
,
sizeof
(
STagVal
));
if
(
!
pTag
Vals
)
{
S
Array
*
pTagArray
=
taosArrayInit
(
tags
->
numOfBound
,
sizeof
(
STagVal
));
if
(
!
pTag
Array
)
{
return
buildInvalidOperationMsg
(
&
pBuf
,
"out of memory"
);
}
SSchema
*
pSchema
=
pDataBlock
->
pTableMeta
->
schema
;
SKvParam
param
=
{.
pTagVals
=
pTag
Vals
,
.
nTag
=
0
,
.
pos
=
0
};
SKvParam
param
=
{.
pTagVals
=
pTag
Array
,
.
pos
=
0
};
for
(
int
c
=
0
;
c
<
tags
->
numOfBound
;
++
c
)
{
if
(
bind
[
c
].
is_null
&&
bind
[
c
].
is_null
[
0
])
{
...
...
@@ -1377,7 +1371,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tN
STag
*
pTag
=
NULL
;
// TODO: JSON_TAG_REFACTOR (if is json or not)?
if
(
0
!=
tTagNew
(
pTag
Vals
,
param
.
nTag
,
1
,
false
,
&
pTag
))
{
if
(
0
!=
tTagNew
(
pTag
Array
,
1
,
false
,
&
pTag
))
{
return
buildInvalidOperationMsg
(
&
pBuf
,
"out of memory"
);
}
...
...
@@ -1386,7 +1380,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tN
CHECK_CODE
(
buildCreateTbMsg
(
pDataBlock
,
&
tbReq
));
destroyCreateSubTbReq
(
&
tbReq
);
taos
MemoryFreeClear
(
pTagVals
);
taos
ArrayDestroy
(
pTagArray
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1715,12 +1709,12 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS
* @return int32_t
*/
static
int32_t
smlBuildTagRow
(
SArray
*
cols
,
SParsedDataColInfo
*
tags
,
SSchema
*
pSchema
,
STag
**
ppTag
,
SMsgBuf
*
msg
)
{
S
TagVal
*
pTagVals
=
taosMemoryCalloc
(
tags
->
numOfBound
,
sizeof
(
STagVal
));
if
(
!
pTag
Vals
)
{
S
Array
*
pTagArray
=
taosArrayInit
(
tags
->
numOfBound
,
sizeof
(
STagVal
));
if
(
!
pTag
Array
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
SKvParam
param
=
{.
pTagVals
=
pTag
Vals
,
.
nTag
=
0
,
.
pos
=
0
};
SKvParam
param
=
{.
pTagVals
=
pTag
Array
,
.
pos
=
0
};
for
(
int
i
=
0
;
i
<
tags
->
numOfBound
;
++
i
)
{
SSchema
*
pTagSchema
=
&
pSchema
[
tags
->
boundColumns
[
i
]];
param
.
schema
=
pTagSchema
;
...
...
@@ -1732,12 +1726,12 @@ static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* p
}
}
if
(
tTagNew
(
pTag
Vals
,
param
.
nTag
,
1
,
false
,
ppTag
)
!=
0
)
{
taos
MemoryFree
(
pTagVals
);
if
(
tTagNew
(
pTag
Array
,
1
,
false
,
ppTag
)
!=
0
)
{
taos
ArrayDestroy
(
pTagArray
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
taos
MemoryFree
(
pTagVals
);
taos
ArrayDestroy
(
pTagArray
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
292d5799
...
...
@@ -4113,8 +4113,8 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) {
return
code
;
}
static
void
addCreateTbReqIntoVgroup
(
int32_t
acctId
,
SHashObj
*
pVgroupHashmap
,
SCreateSubTableClause
*
pStmt
,
const
STag
*
pTag
,
uint64_t
suid
,
SVgroupInfo
*
pVgInfo
)
{
static
void
addCreateTbReqIntoVgroup
(
int32_t
acctId
,
SHashObj
*
pVgroupHashmap
,
SCreateSubTableClause
*
pStmt
,
const
STag
*
pTag
,
uint64_t
suid
,
SVgroupInfo
*
pVgInfo
)
{
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
SName
name
=
{.
type
=
TSDB_DB_NAME_T
,
.
acctId
=
acctId
};
strcpy
(
name
.
dbname
,
pStmt
->
dbName
);
...
...
@@ -4147,13 +4147,13 @@ static void addCreateTbReqIntoVgroup(int32_t acctId, SHashObj* pVgroupHashmap, S
// static int32_t addValToKVRow(STranslateContext* pCxt, SValueNode* pVal, const SSchema* pSchema,
// SKVRowBuilder* pBuilder) {
#ifdef JSON_TAG_REFACTOR
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
pVal
->
literal
&&
strlen
(
pVal
->
literal
)
>
(
TSDB_MAX_JSON_TAG_LEN
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
)
{
return
buildSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
"json string too long than 4095"
,
pVal
->
literal
);
}
return
parseJsontoTagData
(
pVal
->
literal
,
pBuilder
,
&
pCxt
->
msgBuf
,
pSchema
->
colId
);
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
pVal
->
literal
&&
strlen
(
pVal
->
literal
)
>
(
TSDB_MAX_JSON_TAG_LEN
-
VARSTR_HEADER_SIZE
)
/
TSDB_NCHAR_SIZE
)
{
return
buildSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
"json string too long than 4095"
,
pVal
->
literal
);
}
return
parseJsontoTagData
(
pVal
->
literal
,
pBuilder
,
&
pCxt
->
msgBuf
,
pSchema
->
colId
);
}
#endif
// if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) {
...
...
@@ -4198,10 +4198,10 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TAGS_NOT_MATCHED
);
}
S
TagVal
*
pTagVals
=
(
STagVal
*
)
taosMemoryCalloc
(
LIST_LENGTH
(
pStmt
->
pValsOfTags
),
sizeof
(
STagVal
));
char
*
pTagBuf
=
taosMemoryCalloc
(
1
,
TSDB_MAX_TAGS_LEN
);
if
(
!
pTag
Vals
||
!
pTagBuf
)
{
taos
MemoryFreeClear
(
pTagVals
);
S
Array
*
pTagArray
=
taosArrayInit
(
LIST_LENGTH
(
pStmt
->
pValsOfTags
),
sizeof
(
STagVal
));
char
*
pTagBuf
=
taosMemoryCalloc
(
1
,
TSDB_MAX_TAGS_LEN
);
if
(
!
pTag
Array
||
!
pTagBuf
)
{
taos
ArrayDestroy
(
pTagArray
);
taosMemoryFreeClear
(
pTagBuf
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_TSC_OUT_OF_MEMORY
);
}
...
...
@@ -4212,7 +4212,6 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
FORBOTH
(
pTag
,
pStmt
->
pSpecificTags
,
pNode
,
pStmt
->
pValsOfTags
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pTag
;
SSchema
*
pSchema
=
NULL
;
STagVal
*
pTagVal
=
pTagVals
+
nTags
;
for
(
int32_t
i
=
0
;
i
<
numOfTags
;
++
i
)
{
if
(
0
==
strcmp
(
pCol
->
colName
,
pTagSchema
[
i
].
name
))
{
pSchema
=
pTagSchema
+
i
;
...
...
@@ -4220,7 +4219,7 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
}
}
if
(
NULL
==
pSchema
)
{
taos
MemoryFreeClear
(
pTagVals
);
taos
ArrayDestroy
(
pTagArray
);
taosMemoryFreeClear
(
pTagBuf
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_TAG_NAME
,
pCol
->
colName
);
}
...
...
@@ -4233,7 +4232,7 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
REPLACE_LIST2_NODE
(
pVal
);
}
}
#ifdef JSON_TAG_REFACTOR
#ifdef JSON_TAG_REFACTOR
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addValToKVRow
(
pCxt
,
pVal
,
pSchema
,
pBuilder
);
}
...
...
@@ -4244,32 +4243,32 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla
void
*
nodeVal
=
nodesGetValueFromNode
(
pVal
);
if
(
IS_VAR_DATA_TYPE
(
pSchema
->
type
))
{
memcpy
(
pTagBuf
+
nBufPos
,
varDataVal
(
nodeVal
),
varDataLen
(
nodeVal
));
tTagVal
Set
(
pTagVal
,
&
pSchema
->
colId
,
pSchema
->
type
,
(
uint8_t
*
)
pTagBuf
+
nBufPos
,
varDataLen
(
nodeVal
),
false
);
tTagVal
Push
(
pTagArray
,
&
pSchema
->
colId
,
pSchema
->
type
,
(
uint8_t
*
)
pTagBuf
+
nBufPos
,
varDataLen
(
nodeVal
),
false
);
nBufPos
+=
varDataLen
(
pVal
->
datum
.
p
);
}
else
{
memcpy
(
pTagBuf
+
nBufPos
,
varDataVal
(
nodeVal
),
TYPE_BYTES
[
pSchema
->
type
]);
tTagVal
Set
(
pTagVal
,
&
pSchema
->
colId
,
pSchema
->
type
,
(
uint8_t
*
)
pTagBuf
+
nBufPos
,
TYPE_BYTES
[
pSchema
->
type
],
false
);
tTagVal
Push
(
pTagArray
,
&
pSchema
->
colId
,
pSchema
->
type
,
(
uint8_t
*
)
pTagBuf
+
nBufPos
,
TYPE_BYTES
[
pSchema
->
type
],
false
);
nBufPos
+=
TYPE_BYTES
[
pSchema
->
type
];
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
taos
MemoryFreeClear
(
pTagVals
);
taos
ArrayDestroy
(
pTagArray
);
taosMemoryFreeClear
(
pTagBuf
);
return
code
;
}
}
// TODO: JSON_TAG_TODO: version
code
=
tTagNew
(
pTag
Vals
,
nTags
,
1
,
false
,
ppTag
);
code
=
tTagNew
(
pTag
Array
,
1
,
false
,
ppTag
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
taos
MemoryFreeClear
(
pTagVals
);
taos
ArrayDestroy
(
pTagArray
);
taosMemoryFreeClear
(
pTagBuf
);
return
code
;
}
taos
MemoryFreeClear
(
pTagVals
);
taos
ArrayDestroy
(
pTagArray
);
taosMemoryFreeClear
(
pTagBuf
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -4284,21 +4283,19 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
SNode
*
pNode
;
int32_t
code
=
0
;
int32_t
index
=
0
;
int16_t
nTag
=
0
;
STagVal
*
pTagVals
=
taosMemoryCalloc
(
LIST_LENGTH
(
pStmt
->
pValsOfTags
),
sizeof
(
STagVal
));
SArray
*
pTagArray
=
taosArrayInit
(
LIST_LENGTH
(
pStmt
->
pValsOfTags
),
sizeof
(
STagVal
));
char
*
pTagBuf
=
taosMemoryCalloc
(
1
,
TSDB_MAX_TAGS_LEN
);
const
char
*
qTagBuf
=
pTagBuf
;
if
(
!
pTag
Vals
||
!
pTagBuf
)
{
taos
MemoryFreeClear
(
pTagVals
);
if
(
!
pTag
Array
||
!
pTagBuf
)
{
taos
ArrayDestroy
(
pTagArray
);
taosMemoryFreeClear
(
qTagBuf
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_TSC_OUT_OF_MEMORY
);
}
FOREACH
(
pNode
,
pStmt
->
pValsOfTags
)
{
SValueNode
*
pVal
=
NULL
;
STagVal
*
pTagVal
=
pTagVals
+
nTag
;
SSchema
*
pTagSchema
=
pTagSchemas
+
index
;
code
=
translateTagVal
(
pCxt
,
pSuperTableMeta
->
tableInfo
.
precision
,
pTagSchema
,
pNode
,
&
pVal
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
@@ -4318,16 +4315,14 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
char
*
tmpVal
=
nodesGetValueFromNode
(
pVal
);
if
(
IS_VAR_DATA_TYPE
(
pTagSchema
->
type
))
{
memcpy
(
pTagBuf
,
varDataVal
(
tmpVal
),
varDataLen
(
tmpVal
));
tTagValSet
(
pTagVal
,
&
pTagSchema
->
colId
,
pTagSchema
->
type
,
(
uint8_t
*
)
pTagBuf
,
varDataLen
(
tmpVal
),
false
);
tTagValPush
(
pTagArray
,
&
pTagSchema
->
colId
,
pTagSchema
->
type
,
(
uint8_t
*
)
pTagBuf
,
varDataLen
(
tmpVal
),
false
);
pTagBuf
+=
varDataLen
(
tmpVal
);
}
else
{
memcpy
(
pTagBuf
,
tmpVal
,
TYPE_BYTES
[
pTagSchema
->
type
]);
tTagVal
Set
(
pTagVal
,
&
pTagSchema
->
colId
,
pTagSchema
->
type
,
(
uint8_t
*
)
pTagBuf
,
TYPE_BYTES
[
pTagSchema
->
type
],
false
);
tTagVal
Push
(
pTagArray
,
&
pTagSchema
->
colId
,
pTagSchema
->
type
,
(
uint8_t
*
)
pTagBuf
,
TYPE_BYTES
[
pTagSchema
->
type
]
,
false
);
pTagBuf
+=
TYPE_BYTES
[
pTagSchema
->
type
];
}
++
nTag
;
}
++
index
;
}
...
...
@@ -4335,20 +4330,20 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
// TODO: JSON_TAG_TODO remove below codes if code is 0 all the time.
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
taos
MemoryFreeClear
(
pTagVals
);
taos
ArrayDestroy
(
pTagArray
);
taosMemoryFreeClear
(
qTagBuf
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
code
);
}
}
// TODO: JSON_TAG_TODO: version?
// TODO: JSON_TAG_REFACTOR: json or not
if
(
TSDB_CODE_SUCCESS
!=
(
code
=
tTagNew
(
pTagVals
,
nTag
,
1
,
false
,
ppTag
)))
{
taos
MemoryFreeClear
(
pTagVals
);
if
(
0
!=
(
code
=
tTagNew
(
pTagArray
,
1
,
false
,
ppTag
)))
{
taos
ArrayDestroy
(
pTagArray
);
taosMemoryFreeClear
(
qTagBuf
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
code
);
}
taos
MemoryFreeClear
(
pTagVals
);
taos
ArrayDestroy
(
pTagArray
);
taosMemoryFreeClear
(
qTagBuf
);
return
TSDB_CODE_SUCCESS
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录