Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f15ab9d1
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看板
未验证
提交
f15ab9d1
编写于
3月 25, 2022
作者:
M
Minglei Jin
提交者:
GitHub
3月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10994 from taosdata/TD-13918-dev
[TD-13918]<fix>: Strings are compared without comparing lengths
上级
97d728d1
9cf658c3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
26 addition
and
6 deletion
+26
-6
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+1
-1
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+2
-2
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+2
-2
tests/develop-test/0-others/json_tag.py
tests/develop-test/0-others/json_tag.py
+20
-0
未找到文件。
src/client/inc/tscUtil.h
浏览文件 @
f15ab9d1
...
...
@@ -400,7 +400,7 @@ void tscRemoveCachedTableMeta(STableMetaInfo* pTableMetaInfo, uint64_t id);
char
*
cloneCurrentDBName
(
SSqlObj
*
pSql
);
int
parseJsontoTagData
(
char
*
json
,
SKVRowBuilder
*
kvRowBuilder
,
char
*
errMsg
,
int16_t
startColId
);
int
parseJsontoTagData
(
char
*
json
,
uint32_t
jsonLength
,
SKVRowBuilder
*
kvRowBuilder
,
char
*
errMsg
,
int16_t
startColId
);
int8_t
jsonType2DbType
(
double
data
,
int
jsonType
);
void
getJsonKey
(
SStrToken
*
t0
);
...
...
src/client/src/tscParseInsert.c
浏览文件 @
f15ab9d1
...
...
@@ -1068,7 +1068,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
tfree
(
tmp
);
return
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"json tag too long"
,
NULL
);
}
code
=
parseJsontoTagData
(
sToken
.
z
,
&
kvRowBuilder
,
pInsertParam
->
msg
,
pTagSchema
[
spd
.
boundedColumns
[
0
]].
colId
);
code
=
parseJsontoTagData
(
sToken
.
z
,
sToken
.
n
,
&
kvRowBuilder
,
pInsertParam
->
msg
,
pTagSchema
[
spd
.
boundedColumns
[
0
]].
colId
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
tscDestroyBoundColumnInfo
(
&
spd
);
...
...
src/client/src/tscSQLParser.c
浏览文件 @
f15ab9d1
...
...
@@ -7364,7 +7364,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
int8_t
tagVal
=
TSDB_DATA_JSON_PLACEHOLDER
;
tdAddColToKVRow
(
&
kvRowBuilder
,
pTagsSchema
->
colId
,
pTagsSchema
->
type
,
&
tagVal
,
false
);
code
=
parseJsontoTagData
(
pItem
->
pVar
.
pz
,
&
kvRowBuilder
,
pMsg
,
pTagsSchema
->
colId
);
code
=
parseJsontoTagData
(
pItem
->
pVar
.
pz
,
pItem
->
pVar
.
nLen
,
&
kvRowBuilder
,
pMsg
,
pTagsSchema
->
colId
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
return
code
;
...
...
@@ -9170,7 +9170,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
ret
=
parseJsontoTagData
(
pItem
->
pVar
.
pz
,
&
kvRowBuilder
,
tscGetErrorMsgPayload
(
pCmd
),
pTagSchema
[
0
].
colId
);
ret
=
parseJsontoTagData
(
pItem
->
pVar
.
pz
,
pItem
->
pVar
.
nLen
,
&
kvRowBuilder
,
tscGetErrorMsgPayload
(
pCmd
),
pTagSchema
[
0
].
colId
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
return
ret
;
...
...
src/client/src/tscUtil.c
浏览文件 @
f15ab9d1
...
...
@@ -5393,7 +5393,7 @@ char* cloneCurrentDBName(SSqlObj* pSql) {
return
p
;
}
int
parseJsontoTagData
(
char
*
json
,
SKVRowBuilder
*
kvRowBuilder
,
char
*
errMsg
,
int16_t
startColId
){
int
parseJsontoTagData
(
char
*
json
,
uint32_t
jsonLength
,
SKVRowBuilder
*
kvRowBuilder
,
char
*
errMsg
,
int16_t
startColId
){
// set json NULL data
uint8_t
nullTypeVal
[
CHAR_BYTES
+
VARSTR_HEADER_SIZE
+
INT_BYTES
]
=
{
0
};
uint32_t
jsonNULL
=
TSDB_DATA_JSON_NULL
;
...
...
@@ -5404,7 +5404,7 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
varDataSetLen
(
nullTypeVal
+
CHAR_BYTES
,
INT_BYTES
);
*
(
uint32_t
*
)(
varDataVal
(
nullTypeKey
))
=
jsonNULL
;
tdAddColToKVRow
(
kvRowBuilder
,
jsonIndex
++
,
TSDB_DATA_TYPE_NCHAR
,
nullTypeKey
,
false
);
// add json null type
if
(
!
json
||
strtrim
(
json
)
==
0
||
strncasecmp
(
json
,
"null"
,
4
)
==
0
){
if
(
!
json
||
strtrim
(
json
)
==
0
||
(
jsonLength
==
strlen
(
"null"
)
&&
strncasecmp
(
json
,
"null"
,
4
)
==
0
)
){
*
(
uint32_t
*
)(
varDataVal
(
nullTypeVal
+
CHAR_BYTES
))
=
jsonNULL
;
tdAddColToKVRow
(
kvRowBuilder
,
jsonIndex
++
,
TSDB_DATA_TYPE_NCHAR
,
nullTypeVal
,
true
);
// add json null value
return
TSDB_CODE_SUCCESS
;
...
...
tests/develop-test/0-others/json_tag.py
浏览文件 @
f15ab9d1
...
...
@@ -530,6 +530,26 @@ class TDTestCase:
tdSql
.
checkData
(
5
,
2
,
4096
)
tdSql
.
query
(
"describe jsons1_1"
)
tdSql
.
checkData
(
5
,
2
,
4096
)
#test TD-13918
tdSql
.
execute
(
"drop table if exists jsons_13918_1"
)
tdSql
.
execute
(
"drop table if exists jsons_13918_2"
)
tdSql
.
execute
(
"drop table if exists jsons_13918_3"
)
tdSql
.
execute
(
"drop table if exists jsons_13918_4"
)
tdSql
.
execute
(
"drop table if exists jsons_stb"
)
tdSql
.
execute
(
"create table jsons_stb (ts timestamp, dataInt int) tags (jtag json)"
)
tdSql
.
error
(
"create table jsons_13918_1 using jsons_stb tags ('nullx')"
)
tdSql
.
error
(
"create table jsons_13918_2 using jsons_stb tags (nullx)"
)
tdSql
.
error
(
"insert into jsons_13918_3 using jsons_stb tags('NULLx') values(1591061628001, 11)"
)
tdSql
.
error
(
"insert into jsons_13918_4 using jsons_stb tags(NULLx) values(1591061628002, 11)"
)
tdSql
.
execute
(
"create table jsons_13918_1 using jsons_stb tags ('null')"
)
tdSql
.
execute
(
"create table jsons_13918_2 using jsons_stb tags (null)"
)
tdSql
.
execute
(
"insert into jsons_13918_1 values(1591061628003, 11)"
)
tdSql
.
execute
(
"insert into jsons_13918_2 values(1591061628004, 11)"
)
tdSql
.
execute
(
"insert into jsons_13918_3 using jsons_stb tags('NULL') values(1591061628005, 11)"
)
tdSql
.
execute
(
"insert into jsons_13918_4 using jsons_stb tags(
\"
NULL
\"
) values(1591061628006, 11)"
)
tdSql
.
query
(
"select * from jsons_stb"
)
tdSql
.
checkRows
(
4
)
def
stop
(
self
):
tdSql
.
close
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录