Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
08b39a22
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
08b39a22
编写于
10月 27, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimize json length
上级
8d0798e2
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
17 addition
and
18 deletion
+17
-18
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+1
-1
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+7
-9
src/client/src/tscServer.c
src/client/src/tscServer.c
+2
-1
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+3
-3
src/common/src/ttypes.c
src/common/src/ttypes.c
+1
-1
src/inc/taosdef.h
src/inc/taosdef.h
+1
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+2
-2
未找到文件。
src/client/src/tscParseInsert.c
浏览文件 @
08b39a22
...
@@ -1082,7 +1082,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
...
@@ -1082,7 +1082,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_JSON
){
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_JSON
){
assert
(
spd
.
numOfBound
==
1
);
assert
(
spd
.
numOfBound
==
1
);
if
(
sToken
.
n
>
TSDB_MAX_TAGS_LEN
/
TSDB_NCHAR_SIZE
){
if
(
sToken
.
n
>
TSDB_MAX_
JSON_
TAGS_LEN
/
TSDB_NCHAR_SIZE
){
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
tscDestroyBoundColumnInfo
(
&
spd
);
tscDestroyBoundColumnInfo
(
&
spd
);
if
(
TK_STRING
==
sToken
.
type
)
free
(
sToken
.
z
);
if
(
TK_STRING
==
sToken
.
type
)
free
(
sToken
.
z
);
...
...
src/client/src/tscSQLParser.c
浏览文件 @
08b39a22
...
@@ -1528,18 +1528,21 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC
...
@@ -1528,18 +1528,21 @@ static bool validateTagParams(SArray* pTagsList, SArray* pFieldList, SSqlCmd* pC
}
}
int32_t
nLen
=
0
;
int32_t
nLen
=
0
;
bool
isJsonTag
=
false
;
for
(
int32_t
i
=
0
;
i
<
numOfTags
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTags
;
++
i
)
{
TAOS_FIELD
*
p
=
taosArrayGet
(
pTagsList
,
i
);
TAOS_FIELD
*
p
=
taosArrayGet
(
pTagsList
,
i
);
if
(
p
->
bytes
==
0
)
{
if
(
p
->
bytes
==
0
)
{
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg7
);
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg7
);
return
false
;
return
false
;
}
}
if
(
p
->
type
==
TSDB_DATA_TYPE_JSON
){
isJsonTag
=
true
;
}
nLen
+=
p
->
bytes
;
nLen
+=
p
->
bytes
;
}
}
// max tag row length must be less than TSDB_MAX_TAGS_LEN
// max tag row length must be less than TSDB_MAX_TAGS_LEN
if
(
nLen
>
TSDB_MAX_TAGS_LEN
)
{
if
(
!
isJsonTag
&&
nLen
>
TSDB_MAX_TAGS_LEN
)
{
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg2
);
return
false
;
return
false
;
}
}
...
@@ -6118,7 +6121,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
...
@@ -6118,7 +6121,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) {
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
return
invalidOperationMsg
(
pMsg
,
msg25
);
return
invalidOperationMsg
(
pMsg
,
msg25
);
}
}
if
(
pItem
->
pVar
.
nType
>
TSDB_MAX_TAGS_LEN
/
TSDB_NCHAR_SIZE
)
{
if
(
pItem
->
pVar
.
nType
>
TSDB_MAX_
JSON_
TAGS_LEN
/
TSDB_NCHAR_SIZE
)
{
tscError
(
"json tag too long"
);
tscError
(
"json tag too long"
);
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
return
invalidOperationMsg
(
pMsg
,
msg14
);
return
invalidOperationMsg
(
pMsg
,
msg14
);
...
@@ -7686,11 +7689,6 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
...
@@ -7686,11 +7689,6 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
}
else
if
(
pItem
->
pVar
.
nType
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
}
else
if
(
pItem
->
pVar
.
nType
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
pItem
->
pVar
.
i64
=
convertTimePrecision
(
pItem
->
pVar
.
i64
,
TSDB_TIME_PRECISION_NANO
,
tinfo
.
precision
);
pItem
->
pVar
.
i64
=
convertTimePrecision
(
pItem
->
pVar
.
i64
,
TSDB_TIME_PRECISION_NANO
,
tinfo
.
precision
);
}
}
}
else
if
(
pSchema
->
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
pItem
->
pVar
.
nLen
>
TSDB_MAX_TAGS_LEN
)
{
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
}
}
}
ret
=
tVariantDump
(
&
(
pItem
->
pVar
),
tagVal
,
pSchema
->
type
,
true
);
ret
=
tVariantDump
(
&
(
pItem
->
pVar
),
tagVal
,
pSchema
->
type
,
true
);
...
@@ -7778,7 +7776,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
...
@@ -7778,7 +7776,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) {
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg6
);
}
}
if
(
pItem
->
pVar
.
nLen
>
TSDB_MAX_TAGS_LEN
/
TSDB_NCHAR_SIZE
){
if
(
pItem
->
pVar
.
nLen
>
TSDB_MAX_
JSON_
TAGS_LEN
/
TSDB_NCHAR_SIZE
){
tscError
(
"json tag too long"
);
tscError
(
"json tag too long"
);
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
tdDestroyKVRowBuilder
(
&
kvRowBuilder
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
return
invalidOperationMsg
(
tscGetErrorMsgPayload
(
pCmd
),
msg3
);
...
...
src/client/src/tscServer.c
浏览文件 @
08b39a22
...
@@ -1479,7 +1479,8 @@ int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1479,7 +1479,8 @@ int tscEstimateCreateTableMsgLength(SSqlObj *pSql, SSqlInfo *pInfo) {
SCreateTableSql
*
pCreateTableInfo
=
pInfo
->
pCreateTableInfo
;
SCreateTableSql
*
pCreateTableInfo
=
pInfo
->
pCreateTableInfo
;
if
(
pCreateTableInfo
->
type
==
TSQL_CREATE_TABLE_FROM_STABLE
)
{
if
(
pCreateTableInfo
->
type
==
TSQL_CREATE_TABLE_FROM_STABLE
)
{
int32_t
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
pInfo
->
pCreateTableInfo
->
childTableInfo
);
int32_t
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
pInfo
->
pCreateTableInfo
->
childTableInfo
);
size
+=
numOfTables
*
(
sizeof
(
SCreateTableMsg
)
+
TSDB_MAX_TAGS_LEN
);
size
+=
numOfTables
*
(
sizeof
(
SCreateTableMsg
)
+
((
TSDB_MAX_TAGS_LEN
>
TSDB_MAX_JSON_TAGS_LEN
)
?
TSDB_MAX_TAGS_LEN
:
TSDB_MAX_JSON_TAGS_LEN
));
}
else
{
}
else
{
size
+=
sizeof
(
SSchema
)
*
(
pCmd
->
numOfCols
+
pCmd
->
count
);
size
+=
sizeof
(
SSchema
)
*
(
pCmd
->
numOfCols
+
pCmd
->
count
);
}
}
...
...
src/client/src/tscUtil.c
浏览文件 @
08b39a22
...
@@ -5237,7 +5237,7 @@ char* parseTagDatatoJson(void *p){
...
@@ -5237,7 +5237,7 @@ char* parseTagDatatoJson(void *p){
memset
(
tagJsonKey
,
0
,
sizeof
(
tagJsonKey
));
memset
(
tagJsonKey
,
0
,
sizeof
(
tagJsonKey
));
memcpy
(
tagJsonKey
,
varDataVal
(
val
),
varDataLen
(
val
));
memcpy
(
tagJsonKey
,
varDataVal
(
val
),
varDataLen
(
val
));
}
else
{
// json value
}
else
{
// json value
char
tagJsonValue
[
TSDB_MAX_TAGS_LEN
]
=
{
0
};
char
tagJsonValue
[
TSDB_MAX_
JSON_
TAGS_LEN
]
=
{
0
};
char
*
realData
=
POINTER_SHIFT
(
val
,
CHAR_BYTES
);
char
*
realData
=
POINTER_SHIFT
(
val
,
CHAR_BYTES
);
char
type
=
*
(
char
*
)
val
;
char
type
=
*
(
char
*
)
val
;
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
...
@@ -5365,11 +5365,11 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
...
@@ -5365,11 +5365,11 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in
char
*
jsonValue
=
item
->
valuestring
;
char
*
jsonValue
=
item
->
valuestring
;
strtrim
(
jsonValue
);
strtrim
(
jsonValue
);
outLen
=
0
;
outLen
=
0
;
char
tagVal
[
TSDB_MAX_
TAGS_LEN
+
VARSTR_HEADER_SIZE
+
CHAR_BYTES
]
=
{
0
};
char
tagVal
[
TSDB_MAX_
JSON_TAGS_LEN
+
CHAR_BYTES
]
=
{
0
};
*
tagVal
=
jsonType2DbType
(
0
,
item
->
type
);
// type
*
tagVal
=
jsonType2DbType
(
0
,
item
->
type
);
// type
char
*
tagData
=
POINTER_SHIFT
(
tagVal
,
CHAR_BYTES
);
char
*
tagData
=
POINTER_SHIFT
(
tagVal
,
CHAR_BYTES
);
if
(
!
taosMbsToUcs4
(
jsonValue
,
strlen
(
jsonValue
),
varDataVal
(
tagData
),
if
(
!
taosMbsToUcs4
(
jsonValue
,
strlen
(
jsonValue
),
varDataVal
(
tagData
),
TSDB_MAX_TAGS_LEN
,
&
outLen
))
{
TSDB_MAX_
JSON_
TAGS_LEN
,
&
outLen
))
{
tscError
(
"json string error:%s|%s"
,
strerror
(
errno
),
jsonValue
);
tscError
(
"json string error:%s|%s"
,
strerror
(
errno
),
jsonValue
);
retCode
=
tscSQLSyntaxErrMsg
(
errMsg
,
"serizelize json error"
,
NULL
);
retCode
=
tscSQLSyntaxErrMsg
(
errMsg
,
"serizelize json error"
,
NULL
);
goto
end
;
goto
end
;
...
...
src/common/src/ttypes.c
浏览文件 @
08b39a22
...
@@ -384,7 +384,7 @@ tDataTypeDescriptor tDataTypes[16] = {
...
@@ -384,7 +384,7 @@ tDataTypeDescriptor tDataTypes[16] = {
{
TSDB_DATA_TYPE_USMALLINT
,
17
,
SHORT_BYTES
,
"SMALLINT UNSIGNED"
,
0
,
UINT16_MAX
,
tsCompressSmallint
,
tsDecompressSmallint
,
getStatics_u16
},
{
TSDB_DATA_TYPE_USMALLINT
,
17
,
SHORT_BYTES
,
"SMALLINT UNSIGNED"
,
0
,
UINT16_MAX
,
tsCompressSmallint
,
tsDecompressSmallint
,
getStatics_u16
},
{
TSDB_DATA_TYPE_UINT
,
12
,
INT_BYTES
,
"INT UNSIGNED"
,
0
,
UINT32_MAX
,
tsCompressInt
,
tsDecompressInt
,
getStatics_u32
},
{
TSDB_DATA_TYPE_UINT
,
12
,
INT_BYTES
,
"INT UNSIGNED"
,
0
,
UINT32_MAX
,
tsCompressInt
,
tsDecompressInt
,
getStatics_u32
},
{
TSDB_DATA_TYPE_UBIGINT
,
15
,
LONG_BYTES
,
"BIGINT UNSIGNED"
,
0
,
UINT64_MAX
,
tsCompressBigint
,
tsDecompressBigint
,
getStatics_u64
},
{
TSDB_DATA_TYPE_UBIGINT
,
15
,
LONG_BYTES
,
"BIGINT UNSIGNED"
,
0
,
UINT64_MAX
,
tsCompressBigint
,
tsDecompressBigint
,
getStatics_u64
},
{
TSDB_DATA_TYPE_JSON
,
4
,
JSON_BYTES
,
"JSON"
,
0
,
0
,
tsCompressString
,
tsDecompressString
,
getStatics_nchr
},
{
TSDB_DATA_TYPE_JSON
,
4
,
TSDB_MAX_JSON_TAGS_LEN
,
"JSON"
,
0
,
0
,
tsCompressString
,
tsDecompressString
,
getStatics_nchr
},
};
};
char
tTokenTypeSwitcher
[
13
]
=
{
char
tTokenTypeSwitcher
[
13
]
=
{
...
...
src/inc/taosdef.h
浏览文件 @
08b39a22
...
@@ -50,7 +50,6 @@ extern const int32_t TYPE_BYTES[16];
...
@@ -50,7 +50,6 @@ extern const int32_t TYPE_BYTES[16];
#define DOUBLE_BYTES sizeof(double)
#define DOUBLE_BYTES sizeof(double)
#define POINTER_BYTES sizeof(void *) // 8 by default assert(sizeof(ptrdiff_t) == sizseof(void*)
#define POINTER_BYTES sizeof(void *) // 8 by default assert(sizeof(ptrdiff_t) == sizseof(void*)
#define JSON_BYTES (TSDB_MAX_TAGS_LEN + VARSTR_HEADER_SIZE)
#define TSDB_KEYSIZE sizeof(TSKEY)
#define TSDB_KEYSIZE sizeof(TSKEY)
#if LINUX
#if LINUX
...
@@ -222,6 +221,7 @@ do { \
...
@@ -222,6 +221,7 @@ do { \
*/
*/
#define TSDB_MAX_BYTES_PER_ROW 49151
#define TSDB_MAX_BYTES_PER_ROW 49151
#define TSDB_MAX_TAGS_LEN 16384
#define TSDB_MAX_TAGS_LEN 16384
#define TSDB_MAX_JSON_TAGS_LEN (4096*TSDB_NCHAR_SIZE + 2)
#define TSDB_MAX_TAGS 128
#define TSDB_MAX_TAGS 128
#define TSDB_MAX_TAG_CONDITIONS 1024
#define TSDB_MAX_TAG_CONDITIONS 1024
#define TSDB_MAX_JSON_KEY_LEN 256
#define TSDB_MAX_JSON_KEY_LEN 256
...
...
src/query/src/qExecutor.c
浏览文件 @
08b39a22
...
@@ -3358,8 +3358,8 @@ static void doSetTagValueInParam(void* pTable, int32_t tagColId, tVariant *tag,
...
@@ -3358,8 +3358,8 @@ static void doSetTagValueInParam(void* pTable, int32_t tagColId, tVariant *tag,
tVariantCreateFromBinary
(
tag
,
varDataVal
(
val
),
len
,
type
);
tVariantCreateFromBinary
(
tag
,
varDataVal
(
val
),
len
,
type
);
//tVariantCreateFromBinary(tag, varDataVal(val), varDataLen(val), type);
//tVariantCreateFromBinary(tag, varDataVal(val), varDataLen(val), type);
}
else
if
(
type
==
TSDB_DATA_TYPE_JSON
){
}
else
if
(
type
==
TSDB_DATA_TYPE_JSON
){
char
jsonVal
[
TSDB_MAX_TAGS_LEN
]
=
{
0
};
char
jsonVal
[
TSDB_MAX_
JSON_
TAGS_LEN
]
=
{
0
};
getJsonTagValueAll
(
val
,
jsonVal
,
TSDB_MAX_TAGS_LEN
);
getJsonTagValueAll
(
val
,
jsonVal
,
TSDB_MAX_
JSON_
TAGS_LEN
);
tVariantCreateFromBinary
(
tag
,
jsonVal
,
varDataTLen
(
jsonVal
),
type
);
tVariantCreateFromBinary
(
tag
,
jsonVal
,
varDataTLen
(
jsonVal
),
type
);
}
}
else
{
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录