Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
62e3cb16
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看板
未验证
提交
62e3cb16
编写于
5月 21, 2022
作者:
wmmhello
提交者:
GitHub
5月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12803 from taosdata/feature/TD-14761
fea: add null tag support in schemaless
上级
55fd6ade
8fdaa1c1
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
24 addition
and
35 deletion
+24
-35
include/common/tglobal.h
include/common/tglobal.h
+1
-0
source/client/src/clientSml.c
source/client/src/clientSml.c
+7
-13
source/client/test/smlTest.cpp
source/client/test/smlTest.cpp
+3
-11
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+5
-3
source/common/src/tglobal.c
source/common/src/tglobal.c
+3
-0
source/common/src/tname.c
source/common/src/tname.c
+2
-5
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+3
-3
未找到文件。
include/common/tglobal.h
浏览文件 @
62e3cb16
...
...
@@ -128,6 +128,7 @@ extern bool tsStartUdfd;
// schemaless
extern
char
tsSmlChildTableName
[];
extern
char
tsSmlTagName
[];
extern
bool
tsSmlDataFormat
;
// internal
...
...
source/client/src/clientSml.c
浏览文件 @
62e3cb16
...
...
@@ -63,10 +63,6 @@ for (int i = 1; i < keyLen; ++i) { \
#define TS "_ts"
#define TS_LEN 3
#define TAG "_tag"
#define TAG_LEN 4
#define TAG_VALUE "NULL"
#define TAG_VALUE_LEN 4
#define VALUE "value"
#define VALUE_LEN 5
...
...
@@ -263,7 +259,7 @@ static int32_t smlBuildColumnDescription(SSmlKv* field, char* buf, int32_t bufSi
memcpy
(
tname
,
field
->
key
,
field
->
keyLen
);
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
)
{
int32_t
bytes
=
field
->
length
>
CHAR_SAVE_LENGTH
?
(
2
*
field
->
length
)
:
CHAR_SAVE_LENGTH
;
int
out
=
snprintf
(
buf
,
bufSize
,
"`%s` %s(%d)"
,
int
out
=
snprintf
(
buf
,
bufSize
,
"`%s` %s(%d)"
,
tname
,
tDataTypes
[
field
->
type
].
name
,
bytes
);
*
outBytes
=
out
;
}
else
{
...
...
@@ -400,6 +396,12 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) {
pos
+=
outBytes
;
freeBytes
-=
outBytes
;
*
pos
=
','
;
++
pos
;
--
freeBytes
;
}
if
(
taosArrayGetSize
(
cols
)
==
0
){
outBytes
=
snprintf
(
pos
,
freeBytes
,
"`%s` %s(%d)"
,
tsSmlTagName
,
tDataTypes
[
TSDB_DATA_TYPE_NCHAR
].
name
,
CHAR_SAVE_LENGTH
);
pos
+=
outBytes
;
freeBytes
-=
outBytes
;
*
pos
=
','
;
++
pos
;
--
freeBytes
;
}
pos
--
;
++
freeBytes
;
outBytes
=
snprintf
(
pos
,
freeBytes
,
")"
);
TAOS_RES
*
res
=
taos_query
(
info
->
taos
,
result
);
...
...
@@ -1112,14 +1114,6 @@ static int32_t smlParseTelnetString(SSmlHandle *info, const char* sql, SSmlTable
static
int32_t
smlParseCols
(
const
char
*
data
,
int32_t
len
,
SArray
*
cols
,
char
*
childTableName
,
bool
isTag
,
SHashObj
*
dumplicateKey
,
SSmlMsgBuf
*
msg
){
if
(
isTag
&&
len
==
0
){
SSmlKv
*
kv
=
(
SSmlKv
*
)
taosMemoryCalloc
(
sizeof
(
SSmlKv
),
1
);
if
(
!
kv
)
return
TSDB_CODE_OUT_OF_MEMORY
;
kv
->
key
=
TAG
;
kv
->
keyLen
=
TAG_LEN
;
kv
->
value
=
TAG_VALUE
;
kv
->
length
=
TAG_VALUE_LEN
;
kv
->
type
=
TSDB_DATA_TYPE_NCHAR
;
if
(
cols
)
taosArrayPush
(
cols
,
&
kv
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/client/test/smlTest.cpp
浏览文件 @
62e3cb16
...
...
@@ -269,16 +269,7 @@ TEST(testCase, smlParseCols_tag_Test) {
ret
=
smlParseCols
(
data
,
len
,
cols
,
NULL
,
true
,
dumplicateKey
,
&
msgBuf
);
ASSERT_EQ
(
ret
,
TSDB_CODE_SUCCESS
);
size
=
taosArrayGetSize
(
cols
);
ASSERT_EQ
(
size
,
1
);
// nchar
kv
=
(
SSmlKv
*
)
taosArrayGetP
(
cols
,
0
);
ASSERT_EQ
(
strncasecmp
(
kv
->
key
,
TAG
,
TAG_LEN
),
0
);
ASSERT_EQ
(
kv
->
keyLen
,
TAG_LEN
);
ASSERT_EQ
(
kv
->
type
,
TSDB_DATA_TYPE_NCHAR
);
ASSERT_EQ
(
kv
->
length
,
TAG_LEN
);
ASSERT_EQ
(
strncasecmp
(
kv
->
value
,
TAG_VALUE
,
TAG_VALUE_LEN
),
0
);
taosMemoryFree
(
kv
);
ASSERT_EQ
(
size
,
0
);
taosArrayDestroy
(
cols
);
taosHashCleanup
(
dumplicateKey
);
...
...
@@ -1207,7 +1198,8 @@ TEST(testCase, sml_TD15662_Test) {
ASSERT_NE
(
info
,
nullptr
);
const
char
*
sql
[]
=
{
"hetrey,id=sub_table_0123456,t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=
\"
binaryTagValue
\"
,t8=L
\"
ncharTagValue
\"
c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=
\"
binaryColValue
\"
,c8=L
\"
ncharColValue
\"
,c9=7u64"
,
"hetrey c0=f,c1=127i8 1626006833639"
,
"hetrey,t1=r c0=f,c1=127i8 1626006833640"
,
};
int
ret
=
smlProcess
(
info
,
(
char
**
)
sql
,
sizeof
(
sql
)
/
sizeof
(
sql
[
0
]));
ASSERT_EQ
(
ret
,
0
);
...
...
source/common/src/tdataformat.c
浏览文件 @
62e3cb16
...
...
@@ -1077,7 +1077,7 @@ void tdResetKVRowBuilder(SKVRowBuilder *pBuilder) {
SKVRow
tdGetKVRowFromBuilder
(
SKVRowBuilder
*
pBuilder
)
{
int
tlen
=
sizeof
(
SColIdx
)
*
pBuilder
->
nCols
+
pBuilder
->
size
;
if
(
tlen
==
0
)
return
NULL
;
// if (tlen == 0) return NULL; // nCols == 0 means no tags
tlen
+=
TD_KV_ROW_HEAD_SIZE
;
...
...
@@ -1087,8 +1087,10 @@ SKVRow tdGetKVRowFromBuilder(SKVRowBuilder *pBuilder) {
kvRowSetNCols
(
row
,
pBuilder
->
nCols
);
kvRowSetLen
(
row
,
tlen
);
if
(
pBuilder
->
nCols
>
0
){
memcpy
(
kvRowColIdx
(
row
),
pBuilder
->
pColIdx
,
sizeof
(
SColIdx
)
*
pBuilder
->
nCols
);
memcpy
(
kvRowValues
(
row
),
pBuilder
->
buf
,
pBuilder
->
size
);
}
return
row
;
}
...
...
source/common/src/tglobal.c
浏览文件 @
62e3cb16
...
...
@@ -78,6 +78,7 @@ char tsTelemServer[TSDB_FQDN_LEN] = "telemetry.taosdata.com";
uint16_t
tsTelemPort
=
80
;
// schemaless
char
tsSmlTagName
[
TSDB_COL_NAME_LEN
]
=
"__tag"
;
char
tsSmlChildTableName
[
TSDB_TABLE_NAME_LEN
]
=
""
;
//user defined child table name can be specified in tag value.
//If set to empty system will generate table name using MD5 hash.
bool
tsSmlDataFormat
=
true
;
// true means that the name and order of cols in each line are the same(only for influx protocol)
...
...
@@ -326,6 +327,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
if
(
cfgAddBool
(
pCfg
,
"keepColumnName"
,
tsKeepOriginalColumnName
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"queryPolicy"
,
tsQueryPolicy
,
1
,
3
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"smlChildTableName"
,
""
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"smlTagName"
,
""
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"smlDataFormat"
,
tsSmlDataFormat
,
1
)
!=
0
)
return
-
1
;
tsNumOfTaskQueueThreads
=
tsNumOfCores
/
4
;
...
...
@@ -522,6 +524,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
}
tstrncpy
(
tsSmlChildTableName
,
cfgGetItem
(
pCfg
,
"smlChildTableName"
)
->
str
,
TSDB_TABLE_NAME_LEN
);
tstrncpy
(
tsSmlTagName
,
cfgGetItem
(
pCfg
,
"smlTagName"
)
->
str
,
TSDB_COL_NAME_LEN
);
tsSmlDataFormat
=
cfgGetItem
(
pCfg
,
"smlDataFormat"
)
->
bval
;
tsShellActivityTimer
=
cfgGetItem
(
pCfg
,
"shellActivityTimer"
)
->
i32
;
...
...
source/common/src/tname.c
浏览文件 @
62e3cb16
...
...
@@ -308,13 +308,10 @@ static int compareKv(const void* p1, const void* p2) {
* use stable name and tags to grearate child table name
*/
void
buildChildTableName
(
RandTableName
*
rName
)
{
int32_t
size
=
taosArrayGetSize
(
rName
->
tags
);
ASSERT
(
size
>
0
);
taosArraySort
(
rName
->
tags
,
compareKv
);
SStringBuilder
sb
=
{
0
};
taosStringBuilderAppendStringLen
(
&
sb
,
rName
->
sTableName
,
rName
->
sTableNameLen
);
for
(
int
j
=
0
;
j
<
size
;
++
j
)
{
taosArraySort
(
rName
->
tags
,
compareKv
);
for
(
int
j
=
0
;
j
<
taosArrayGetSize
(
rName
->
tags
);
++
j
)
{
SSmlKv
*
tagKv
=
taosArrayGetP
(
rName
->
tags
,
j
);
taosStringBuilderAppendStringLen
(
&
sb
,
tagKv
->
key
,
tagKv
->
keyLen
);
if
(
IS_VAR_DATA_TYPE
(
tagKv
->
type
)){
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
62e3cb16
...
...
@@ -827,7 +827,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint
SKVRow
row
=
tdGetKVRowFromBuilder
(
&
pCxt
->
tagsBuilder
);
if
(
NULL
==
row
)
{
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"
tag value expected
"
);
return
buildInvalidOperationMsg
(
&
pCxt
->
msg
,
"
out of memory
"
);
}
tdSortKVRowByColIdx
(
row
);
...
...
@@ -1347,7 +1347,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, char* tN
SKVRow
row
=
tdGetKVRowFromBuilder
(
&
tagBuilder
);
if
(
NULL
==
row
)
{
tdDestroyKVRowBuilder
(
&
tagBuilder
);
return
buildInvalidOperationMsg
(
&
pBuf
,
"
tag value expected
"
);
return
buildInvalidOperationMsg
(
&
pBuf
,
"
out of memory
"
);
}
tdSortKVRowByColIdx
(
row
);
...
...
@@ -1696,7 +1696,7 @@ static int32_t smlBuildTagRow(SArray* cols, SKVRowBuilder* tagsBuilder, SParsedD
*
row
=
tdGetKVRowFromBuilder
(
tagsBuilder
);
if
(
*
row
==
NULL
)
{
return
TSDB_CODE_
SML_INVALID_DATA
;
return
TSDB_CODE_
OUT_OF_MEMORY
;
}
tdSortKVRowByColIdx
(
*
row
);
return
TSDB_CODE_SUCCESS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录