Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3de234a2
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
3de234a2
编写于
9月 21, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-6129<feature> add json type check
上级
12a2c0b5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
25 addition
and
4 deletion
+25
-4
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+5
-0
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+11
-0
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+1
-2
tests/pytest/stable/json_tag.py
tests/pytest/stable/json_tag.py
+8
-2
未找到文件。
src/client/src/tscParseInsert.c
浏览文件 @
3de234a2
...
...
@@ -1084,6 +1084,11 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
if
(
spd
.
numOfBound
==
1
&&
pTagSchema
[
spd
.
boundedColumns
[
0
]].
type
==
TSDB_DATA_TYPE_JSON
){
char
tmp
=
sToken
.
z
[
sToken
.
n
];
sToken
.
z
[
sToken
.
n
]
=
0
;
if
(
sToken
.
type
!=
TK_STRING
)
{
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
tscDestroyBoundColumnInfo
(
&
spd
);
return
tscSQLSyntaxErrMsg
(
pInsertParam
->
msg
,
"json type error, should be string"
,
NULL
);
}
code
=
parseJsontoTagData
(
sToken
.
z
,
&
kvRowBuilder
,
pInsertParam
->
msg
,
pTagSchema
[
spd
.
boundedColumns
[
0
]].
colId
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
...
...
src/client/src/tscSQLParser.c
浏览文件 @
3de234a2
...
...
@@ -5867,6 +5867,8 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
const
char
*
msg23
=
"only column length coulbe be modified"
;
const
char
*
msg24
=
"invalid binary/nchar column length"
;
const
char
*
msg25
=
"json type error, should be string"
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
...
...
@@ -6070,6 +6072,10 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
if
(
tdInitKVRowBuilder
(
&
kvRowBuilder
)
<
0
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
if
(
pItem
->
pVar
.
nType
!=
TSDB_DATA_TYPE_BINARY
){
tscError
(
"json type error, should be string"
);
return
invalidOperationMsg
(
pMsg
,
"json type error, should be string"
);
}
code
=
parseJsontoTagData
(
pItem
->
pVar
.
pz
,
&
kvRowBuilder
,
pMsg
,
pTagsSchema
->
colId
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
...
...
@@ -7492,6 +7498,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
const
char
*
msg3
=
"tag value too long"
;
const
char
*
msg4
=
"illegal value or data overflow"
;
const
char
*
msg5
=
"tags number not matched"
;
const
char
*
msg6
=
"json type error, should be string"
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
...
...
@@ -7689,6 +7696,10 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg5
);
}
tVariantListItem
*
pItem
=
taosArrayGet
(
pValList
,
0
);
if
(
pItem
->
pVar
.
nType
!=
TSDB_DATA_TYPE_BINARY
){
tscError
(
"json type error, should be string"
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
"json type error, should be string"
);
}
ret
=
parseJsontoTagData
(
pItem
->
pVar
.
pz
,
&
kvRowBuilder
,
tscGetErrorMsgPayload
(
pCmd
),
pTagSchema
[
0
].
colId
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
...
...
src/client/src/tscUtil.c
浏览文件 @
3de234a2
...
...
@@ -5234,11 +5234,10 @@ end:
}
int
parseJsontoTagData
(
char
*
json
,
SKVRowBuilder
*
kvRowBuilder
,
char
*
errMsg
,
int16_t
startColId
){
cJSON
*
root
=
cJSON_Parse
(
json
);
cJSON
*
root
=
cJSON_Parse
(
json
->
pz
);
if
(
root
==
NULL
){
tscError
(
"json parse error"
);
return
tscSQLSyntaxErrMsg
(
errMsg
,
"json parse error"
,
NULL
);
}
int
retCode
=
0
;
...
...
tests/pytest/stable/json_tag.py
浏览文件 @
3de234a2
...
...
@@ -49,10 +49,16 @@ class TDTestCase:
print
(
"==============step3"
)
tdLog
.
info
(
"alter stable add tag"
)
tdSql
.
execute
(
"ALTER STABLE db_json_tag_test.jsons1 add
COLUMN
tag2 nchar(20)"
)
"ALTER STABLE db_json_tag_test.jsons1 add
tag
tag2 nchar(20)"
)
tdSql
.
execute
(
"ALTER STABLE db_json_tag_test.jsons1 drop COLUMN jtag"
)
"ALTER STABLE db_json_tag_test.jsons1 drop tag jtag"
)
tdSql
.
execute
(
"ALTER TABLE db_json_tag_test.jsons1_1 SET TAG jtag=4"
)
tdSql
.
execute
(
"ALTER TABLE db_json_tag_test.jsons1_1 SET TAG jtag='{
\"
sex
\"
:
\"
femail
\"
,
\"
age
\"
:35}'"
)
def
stop
(
self
):
tdSql
.
close
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录