Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e2794d17
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看板
提交
e2794d17
编写于
5月 24, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:add modify schema for schemaless
上级
cc9e8aba
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
19 addition
and
8 deletion
+19
-8
source/client/src/clientSml.c
source/client/src/clientSml.c
+19
-8
未找到文件。
source/client/src/clientSml.c
浏览文件 @
e2794d17
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
#define EQUAL '='
#define EQUAL '='
#define QUOTE '"'
#define QUOTE '"'
#define SLASH '\\'
#define SLASH '\\'
#define tsMaxSQLStringLen (1024*1024)
#define JUMP_SPACE(sql) while (*sql != '\0'){if(*sql == SPACE) sql++;else break;}
#define JUMP_SPACE(sql) while (*sql != '\0'){if(*sql == SPACE) sql++;else break;}
// comma ,
// comma ,
...
@@ -63,12 +62,11 @@ for (int i = 1; i < keyLen; ++i) { \
...
@@ -63,12 +62,11 @@ for (int i = 1; i < keyLen; ++i) { \
#define TS "_ts"
#define TS "_ts"
#define TS_LEN 3
#define TS_LEN 3
#define VALUE "value"
#define VALUE "
_
value"
#define VALUE_LEN
5
#define VALUE_LEN
6
#define BINARY_ADD_LEN 2 // "binary" 2 means " "
#define BINARY_ADD_LEN 2 // "binary" 2 means " "
#define NCHAR_ADD_LEN 3 // L"nchar" 3 means L" "
#define NCHAR_ADD_LEN 3 // L"nchar" 3 means L" "
#define CHAR_SAVE_LENGTH 8
//=================================================================================================
//=================================================================================================
typedef
TSDB_SML_PROTOCOL_TYPE
SMLProtocolType
;
typedef
TSDB_SML_PROTOCOL_TYPE
SMLProtocolType
;
...
@@ -253,12 +251,20 @@ static int32_t smlGenerateSchemaAction(SSchema* colField, SHashObj* colHash, SSm
...
@@ -253,12 +251,20 @@ static int32_t smlGenerateSchemaAction(SSchema* colField, SHashObj* colHash, SSm
return
0
;
return
0
;
}
}
static
int32_t
smlFindNearestPowerOf2
(
int32_t
length
){
int32_t
result
=
1
;
while
(
result
<=
length
){
result
*=
2
;
}
return
result
;
}
static
int32_t
smlBuildColumnDescription
(
SSmlKv
*
field
,
char
*
buf
,
int32_t
bufSize
,
int32_t
*
outBytes
)
{
static
int32_t
smlBuildColumnDescription
(
SSmlKv
*
field
,
char
*
buf
,
int32_t
bufSize
,
int32_t
*
outBytes
)
{
uint8_t
type
=
field
->
type
;
uint8_t
type
=
field
->
type
;
char
tname
[
TSDB_TABLE_NAME_LEN
]
=
{
0
};
char
tname
[
TSDB_TABLE_NAME_LEN
]
=
{
0
};
memcpy
(
tname
,
field
->
key
,
field
->
keyLen
);
memcpy
(
tname
,
field
->
key
,
field
->
keyLen
);
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
)
{
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
;
int32_t
bytes
=
smlFindNearestPowerOf2
(
field
->
length
)
;
int
out
=
snprintf
(
buf
,
bufSize
,
"`%s` %s(%d)"
,
int
out
=
snprintf
(
buf
,
bufSize
,
"`%s` %s(%d)"
,
tname
,
tDataTypes
[
field
->
type
].
name
,
bytes
);
tname
,
tDataTypes
[
field
->
type
].
name
,
bytes
);
*
outBytes
=
out
;
*
outBytes
=
out
;
...
@@ -273,8 +279,8 @@ static int32_t smlBuildColumnDescription(SSmlKv* field, char* buf, int32_t bufSi
...
@@ -273,8 +279,8 @@ static int32_t smlBuildColumnDescription(SSmlKv* field, char* buf, int32_t bufSi
static
int32_t
smlApplySchemaAction
(
SSmlHandle
*
info
,
SSchemaAction
*
action
)
{
static
int32_t
smlApplySchemaAction
(
SSmlHandle
*
info
,
SSchemaAction
*
action
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
int32_t
outBytes
=
0
;
int32_t
outBytes
=
0
;
char
*
result
=
(
char
*
)
taosMemoryCalloc
(
1
,
tsMaxSQLStringLen
+
1
);
char
*
result
=
(
char
*
)
taosMemoryCalloc
(
1
,
TSDB_MAX_ALLOWED_SQL_LEN
);
int32_t
capacity
=
tsMaxSQLStringLen
+
1
;
int32_t
capacity
=
TSDB_MAX_ALLOWED_SQL_LEN
;
uDebug
(
"SML:0x%"
PRIx64
" apply schema action. action: %d"
,
info
->
id
,
action
->
action
);
uDebug
(
"SML:0x%"
PRIx64
" apply schema action. action: %d"
,
info
->
id
,
action
->
action
);
switch
(
action
->
action
)
{
switch
(
action
->
action
)
{
...
@@ -398,7 +404,7 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) {
...
@@ -398,7 +404,7 @@ static int32_t smlApplySchemaAction(SSmlHandle* info, SSchemaAction* action) {
}
}
if
(
taosArrayGetSize
(
cols
)
==
0
){
if
(
taosArrayGetSize
(
cols
)
==
0
){
outBytes
=
snprintf
(
pos
,
freeBytes
,
"`%s` %s(%d)"
,
outBytes
=
snprintf
(
pos
,
freeBytes
,
"`%s` %s(%d)"
,
tsSmlTagName
,
tDataTypes
[
TSDB_DATA_TYPE_NCHAR
].
name
,
CHAR_SAVE_LENGTH
);
tsSmlTagName
,
tDataTypes
[
TSDB_DATA_TYPE_NCHAR
].
name
,
1
);
pos
+=
outBytes
;
freeBytes
-=
outBytes
;
pos
+=
outBytes
;
freeBytes
-=
outBytes
;
*
pos
=
','
;
++
pos
;
--
freeBytes
;
*
pos
=
','
;
++
pos
;
--
freeBytes
;
}
}
...
@@ -508,6 +514,11 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) {
...
@@ -508,6 +514,11 @@ static int32_t smlModifyDBSchemas(SSmlHandle* info) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
code
=
catalogRefreshTableMeta
(
info
->
pCatalog
,
info
->
taos
->
pAppInfo
->
pTransporter
,
&
ep
,
&
pName
,
-
1
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
else
{
}
else
{
uError
(
"SML:0x%"
PRIx64
" load table meta error: %s"
,
info
->
id
,
tstrerror
(
code
));
uError
(
"SML:0x%"
PRIx64
" load table meta error: %s"
,
info
->
id
,
tstrerror
(
code
));
return
code
;
return
code
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录