Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
34c87dc4
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
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看板
提交
34c87dc4
编写于
7月 18, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:<TD-17324> ts already exist when insert with schemaless & modify the interface of tmq meta
上级
22903b3d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
47 addition
and
37 deletion
+47
-37
include/client/taos.h
include/client/taos.h
+8
-4
source/client/src/clientSml.c
source/client/src/clientSml.c
+18
-7
source/client/src/tmq.c
source/client/src/tmq.c
+18
-25
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+3
-1
未找到文件。
include/client/taos.h
浏览文件 @
34c87dc4
...
...
@@ -259,13 +259,17 @@ enum tmq_res_t {
TMQ_RES_TABLE_META
=
2
,
};
typedef
struct
{
void
*
raw_meta
;
uint32_t
raw_meta_len
;
uint16_t
raw_meta_type
;
}
tmq_raw_data
;
typedef
enum
tmq_res_t
tmq_res_t
;
typedef
struct
tmq_raw_data
tmq_raw_data
;
DLL_EXPORT
tmq_res_t
tmq_get_res_type
(
TAOS_RES
*
res
);
DLL_EXPORT
tmq_raw_data
*
tmq_get_raw_meta
(
TAOS_RES
*
res
);
DLL_EXPORT
int32_t
taos_write_raw_meta
(
TAOS
*
taos
,
tmq_raw_data
*
raw_meta
);
DLL_EXPORT
void
tmq_free_raw_meta
(
tmq_raw_data
*
rawMeta
);
DLL_EXPORT
int32_t
tmq_get_raw_meta
(
TAOS_RES
*
res
,
tmq_raw_data
*
raw_meta
);
DLL_EXPORT
int32_t
taos_write_raw_meta
(
TAOS
*
taos
,
tmq_raw_data
raw_meta
);
DLL_EXPORT
char
*
tmq_get_json_meta
(
TAOS_RES
*
res
);
// Returning null means error. Returned result need to be freed by tmq_free_json_meta
DLL_EXPORT
void
tmq_free_json_meta
(
char
*
jsonMeta
);
DLL_EXPORT
const
char
*
tmq_get_topic_name
(
TAOS_RES
*
res
);
...
...
source/client/src/clientSml.c
浏览文件 @
34c87dc4
...
...
@@ -268,7 +268,7 @@ static int32_t smlGenerateSchemaAction(SSchema *colField, SHashObj *colHash, SSm
*
actionNeeded
=
true
;
}
if
(
*
actionNeeded
)
{
uDebug
(
"SML:0x%"
PRIx64
" generate schema action.
column name: %s, action: %d"
,
info
->
id
,
colField
->
name
,
uDebug
(
"SML:0x%"
PRIx64
" generate schema action.
kv->name: %s, action: %d"
,
info
->
id
,
kv
->
key
,
action
->
action
);
}
return
0
;
...
...
@@ -436,6 +436,7 @@ static int32_t smlProcessSchemaAction(SSmlHandle *info, SSchema *schemaField, SH
SSchemaAction
*
action
,
bool
isTag
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
for
(
int
j
=
0
;
j
<
taosArrayGetSize
(
cols
);
++
j
)
{
if
(
j
==
0
&&
!
isTag
)
continue
;
SSmlKv
*
kv
=
(
SSmlKv
*
)
taosArrayGetP
(
cols
,
j
);
bool
actionNeeded
=
false
;
code
=
smlGenerateSchemaAction
(
schemaField
,
schemaHash
,
kv
,
isTag
,
action
,
&
actionNeeded
,
info
);
...
...
@@ -452,18 +453,25 @@ static int32_t smlProcessSchemaAction(SSmlHandle *info, SSchema *schemaField, SH
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
smlCheckMeta
(
SSchema
*
schema
,
int32_t
length
,
SArray
*
cols
)
{
static
int32_t
smlCheckMeta
(
SSchema
*
schema
,
int32_t
length
,
SArray
*
cols
,
bool
isTag
)
{
SHashObj
*
hashTmp
=
taosHashInit
(
length
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_NO_LOCK
);
for
(
uint16_t
i
=
0
;
i
<
length
;
i
++
)
{
int32_t
i
=
0
;
for
(
;
i
<
length
;
i
++
)
{
taosHashPut
(
hashTmp
,
schema
[
i
].
name
,
strlen
(
schema
[
i
].
name
),
&
i
,
SHORT_BYTES
);
}
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
cols
);
i
++
)
{
if
(
isTag
){
i
=
0
;
}
else
{
i
=
1
;
}
for
(;
i
<
taosArrayGetSize
(
cols
);
i
++
)
{
SSmlKv
*
kv
=
(
SSmlKv
*
)
taosArrayGetP
(
cols
,
i
);
if
(
taosHashGet
(
hashTmp
,
kv
->
key
,
kv
->
keyLen
)
==
NULL
)
{
return
-
1
;
}
}
taosHashCleanup
(
hashTmp
);
return
0
;
}
...
...
@@ -523,7 +531,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
}
taosHashClear
(
hashTmp
);
for
(
uint16_t
i
=
0
;
i
<
pTableMeta
->
tableInfo
.
numOfColumns
;
i
++
)
{
for
(
uint16_t
i
=
1
;
i
<
pTableMeta
->
tableInfo
.
numOfColumns
;
i
++
)
{
taosHashPut
(
hashTmp
,
pTableMeta
->
schema
[
i
].
name
,
strlen
(
pTableMeta
->
schema
[
i
].
name
),
&
i
,
SHORT_BYTES
);
}
code
=
smlProcessSchemaAction
(
info
,
pTableMeta
->
schema
,
hashTmp
,
sTableData
->
cols
,
&
schemaAction
,
false
);
...
...
@@ -551,12 +559,12 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
if
(
needCheckMeta
)
{
code
=
smlCheckMeta
(
&
(
pTableMeta
->
schema
[
pTableMeta
->
tableInfo
.
numOfColumns
]),
pTableMeta
->
tableInfo
.
numOfTags
,
sTableData
->
tags
);
sTableData
->
tags
,
true
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" check tag failed. super table name %s"
,
info
->
id
,
(
char
*
)
superTable
);
goto
end
;
}
code
=
smlCheckMeta
(
&
(
pTableMeta
->
schema
[
0
]),
pTableMeta
->
tableInfo
.
numOfColumns
,
sTableData
->
cols
);
code
=
smlCheckMeta
(
&
(
pTableMeta
->
schema
[
0
]),
pTableMeta
->
tableInfo
.
numOfColumns
,
sTableData
->
cols
,
false
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" check cols failed. super table name %s"
,
info
->
id
,
(
char
*
)
superTable
);
goto
end
;
...
...
@@ -832,6 +840,7 @@ static int64_t smlParseOpenTsdbTime(SSmlHandle *info, const char *data, int32_t
static
int32_t
smlParseTS
(
SSmlHandle
*
info
,
const
char
*
data
,
int32_t
len
,
SArray
*
cols
)
{
int64_t
ts
=
0
;
if
(
info
->
protocol
==
TSDB_SML_LINE_PROTOCOL
)
{
// uError("SML:data:%s,len:%d", data, len);
ts
=
smlParseInfluxTime
(
info
,
data
,
len
);
}
else
if
(
info
->
protocol
==
TSDB_SML_TELNET_PROTOCOL
)
{
ts
=
smlParseOpenTsdbTime
(
info
,
data
,
len
);
...
...
@@ -2031,6 +2040,8 @@ static int32_t smlParseJSONString(SSmlHandle *info, cJSON *root, SSmlTableInfo *
static
int32_t
smlParseInfluxLine
(
SSmlHandle
*
info
,
const
char
*
sql
)
{
SSmlLineInfo
elements
=
{
0
};
uError
(
"SML:0x%"
PRIx64
" smlParseInfluxLine sql:%s, hello"
,
info
->
id
,
sql
);
int
ret
=
smlParseInfluxString
(
sql
,
&
elements
,
&
info
->
msgBuf
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
uError
(
"SML:0x%"
PRIx64
" smlParseInfluxLine failed"
,
info
->
id
);
...
...
source/client/src/tmq.c
浏览文件 @
34c87dc4
...
...
@@ -106,12 +106,6 @@ struct tmq_t {
tsem_t
rspSem
;
};
struct
tmq_raw_data
{
void
*
raw_meta
;
int32_t
raw_meta_len
;
int16_t
raw_meta_type
;
};
enum
{
TMQ_VG_STATUS__IDLE
=
0
,
TMQ_VG_STATUS__WAIT
,
...
...
@@ -1858,16 +1852,15 @@ const char* tmq_get_table_name(TAOS_RES* res) {
return
NULL
;
}
tmq_raw_data
*
tmq_get_raw_meta
(
TAOS_RES
*
res
)
{
if
(
TD_RES_TMQ_META
(
res
))
{
tmq_raw_data
*
raw
=
taosMemoryCalloc
(
1
,
sizeof
(
tmq_raw_data
));
int32_t
tmq_get_raw_meta
(
TAOS_RES
*
res
,
tmq_raw_data
*
raw
)
{
if
(
TD_RES_TMQ_META
(
res
)
&&
raw
)
{
SMqMetaRspObj
*
pMetaRspObj
=
(
SMqMetaRspObj
*
)
res
;
raw
->
raw_meta
=
pMetaRspObj
->
metaRsp
.
metaRsp
;
raw
->
raw_meta_len
=
pMetaRspObj
->
metaRsp
.
metaRspLen
;
raw
->
raw_meta_type
=
pMetaRspObj
->
metaRsp
.
resMsgType
;
return
raw
;
return
TSDB_CODE_SUCCESS
;
}
return
NULL
;
return
TSDB_CODE_INVALID_PARA
;
}
static
char
*
buildCreateTableJson
(
SSchemaWrapper
*
schemaRow
,
SSchemaWrapper
*
schemaTag
,
char
*
name
,
int64_t
id
,
int8_t
t
){
...
...
@@ -2875,23 +2868,23 @@ static int32_t taosAlterTable(TAOS *taos, void *meta, int32_t metaLen){
return
code
;
}
int32_t
taos_write_raw_meta
(
TAOS
*
taos
,
tmq_raw_data
*
raw_meta
){
if
(
!
taos
||
!
raw_meta
)
{
int32_t
taos_write_raw_meta
(
TAOS
*
taos
,
tmq_raw_data
raw_meta
){
if
(
!
taos
)
{
return
TSDB_CODE_INVALID_PARA
;
}
if
(
raw_meta
->
raw_meta_type
==
TDMT_VND_CREATE_STB
)
{
return
taosCreateStb
(
taos
,
raw_meta
->
raw_meta
,
raw_meta
->
raw_meta_len
);
}
else
if
(
raw_meta
->
raw_meta_type
==
TDMT_VND_ALTER_STB
){
return
taosCreateStb
(
taos
,
raw_meta
->
raw_meta
,
raw_meta
->
raw_meta_len
);
}
else
if
(
raw_meta
->
raw_meta_type
==
TDMT_VND_DROP_STB
){
return
taosDropStb
(
taos
,
raw_meta
->
raw_meta
,
raw_meta
->
raw_meta_len
);
}
else
if
(
raw_meta
->
raw_meta_type
==
TDMT_VND_CREATE_TABLE
){
return
taosCreateTable
(
taos
,
raw_meta
->
raw_meta
,
raw_meta
->
raw_meta_len
);
}
else
if
(
raw_meta
->
raw_meta_type
==
TDMT_VND_ALTER_TABLE
){
return
taosAlterTable
(
taos
,
raw_meta
->
raw_meta
,
raw_meta
->
raw_meta_len
);
}
else
if
(
raw_meta
->
raw_meta_type
==
TDMT_VND_DROP_TABLE
){
return
taosDropTable
(
taos
,
raw_meta
->
raw_meta
,
raw_meta
->
raw_meta_len
);
if
(
raw_meta
.
raw_meta_type
==
TDMT_VND_CREATE_STB
)
{
return
taosCreateStb
(
taos
,
raw_meta
.
raw_meta
,
raw_meta
.
raw_meta_len
);
}
else
if
(
raw_meta
.
raw_meta_type
==
TDMT_VND_ALTER_STB
){
return
taosCreateStb
(
taos
,
raw_meta
.
raw_meta
,
raw_meta
.
raw_meta_len
);
}
else
if
(
raw_meta
.
raw_meta_type
==
TDMT_VND_DROP_STB
){
return
taosDropStb
(
taos
,
raw_meta
.
raw_meta
,
raw_meta
.
raw_meta_len
);
}
else
if
(
raw_meta
.
raw_meta_type
==
TDMT_VND_CREATE_TABLE
){
return
taosCreateTable
(
taos
,
raw_meta
.
raw_meta
,
raw_meta
.
raw_meta_len
);
}
else
if
(
raw_meta
.
raw_meta_type
==
TDMT_VND_ALTER_TABLE
){
return
taosAlterTable
(
taos
,
raw_meta
.
raw_meta
,
raw_meta
.
raw_meta_len
);
}
else
if
(
raw_meta
.
raw_meta_type
==
TDMT_VND_DROP_TABLE
){
return
taosDropTable
(
taos
,
raw_meta
.
raw_meta
,
raw_meta
.
raw_meta_len
);
}
return
TSDB_CODE_INVALID_PARA
;
}
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
34c87dc4
...
...
@@ -2177,7 +2177,7 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS
SSmlKv
*
kv
=
taosArrayGetP
(
cols
,
i
);
SToken
sToken
=
{.
n
=
kv
->
keyLen
,
.
z
=
(
char
*
)
kv
->
key
};
col_id_t
t
=
lastColIdx
+
1
;
col_id_t
index
=
findCol
(
&
sToken
,
t
,
nCols
,
pSchema
);
col_id_t
index
=
(
t
==
0
?
0
:
findCol
(
&
sToken
,
t
,
nCols
,
pSchema
)
);
if
(
index
<
0
&&
t
>
0
)
{
index
=
findCol
(
&
sToken
,
0
,
t
,
pSchema
);
isOrdered
=
false
;
...
...
@@ -2401,7 +2401,9 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
}
else
{
int32_t
colLen
=
kv
->
length
;
if
(
pColSchema
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
// uError("SML:data before:%ld, precision:%d", kv->i, pTableMeta->tableInfo.precision);
kv
->
i
=
convertTimePrecision
(
kv
->
i
,
TSDB_TIME_PRECISION_NANO
,
pTableMeta
->
tableInfo
.
precision
);
// uError("SML:data after:%ld, precision:%d", kv->i, pTableMeta->tableInfo.precision);
}
if
(
IS_VAR_DATA_TYPE
(
kv
->
type
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录