Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2c013b7e
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看板
提交
2c013b7e
编写于
12月 02, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:modify submit format for schemaless
上级
6dcdafa4
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
101 addition
and
166 deletion
+101
-166
source/client/src/clientSml.c
source/client/src/clientSml.c
+4
-4
source/libs/parser/inc/parInsertUtil.h
source/libs/parser/inc/parInsertUtil.h
+2
-1
source/libs/parser/src/parInsertSml.c
source/libs/parser/src/parInsertSml.c
+94
-151
source/libs/parser/src/parInsertSql.c
source/libs/parser/src/parInsertSql.c
+0
-2
source/libs/parser/src/parInsertStmt.c
source/libs/parser/src/parInsertStmt.c
+0
-7
source/libs/parser/src/parInsertUtil.c
source/libs/parser/src/parInsertUtil.c
+1
-1
未找到文件。
source/client/src/clientSml.c
浏览文件 @
2c013b7e
...
@@ -707,21 +707,21 @@ static bool smlParseBool(SSmlKv *kvVal) {
...
@@ -707,21 +707,21 @@ static bool smlParseBool(SSmlKv *kvVal) {
const
char
*
pVal
=
kvVal
->
value
;
const
char
*
pVal
=
kvVal
->
value
;
int32_t
len
=
kvVal
->
length
;
int32_t
len
=
kvVal
->
length
;
if
((
len
==
1
)
&&
(
pVal
[
0
]
==
't'
||
pVal
[
0
]
==
'T'
))
{
if
((
len
==
1
)
&&
(
pVal
[
0
]
==
't'
||
pVal
[
0
]
==
'T'
))
{
kvVal
->
i
=
true
;
kvVal
->
i
=
TSDB_TRUE
;
return
true
;
return
true
;
}
}
if
((
len
==
1
)
&&
(
pVal
[
0
]
==
'f'
||
pVal
[
0
]
==
'F'
))
{
if
((
len
==
1
)
&&
(
pVal
[
0
]
==
'f'
||
pVal
[
0
]
==
'F'
))
{
kvVal
->
i
=
false
;
kvVal
->
i
=
TSDB_FALSE
;
return
true
;
return
true
;
}
}
if
((
len
==
4
)
&&
!
strncasecmp
(
pVal
,
"true"
,
len
))
{
if
((
len
==
4
)
&&
!
strncasecmp
(
pVal
,
"true"
,
len
))
{
kvVal
->
i
=
true
;
kvVal
->
i
=
TSDB_TRUE
;
return
true
;
return
true
;
}
}
if
((
len
==
5
)
&&
!
strncasecmp
(
pVal
,
"false"
,
len
))
{
if
((
len
==
5
)
&&
!
strncasecmp
(
pVal
,
"false"
,
len
))
{
kvVal
->
i
=
false
;
kvVal
->
i
=
TSDB_FALSE
;
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
...
source/libs/parser/inc/parInsertUtil.h
浏览文件 @
2c013b7e
...
@@ -167,6 +167,7 @@ int32_t insInitBoundColsInfo(int32_t numOfBound, SBoundColInfo *pInfo);
...
@@ -167,6 +167,7 @@ int32_t insInitBoundColsInfo(int32_t numOfBound, SBoundColInfo *pInfo);
void
insCheckTableDataOrder
(
STableDataCxt
*
pTableCxt
,
TSKEY
tsKey
);
void
insCheckTableDataOrder
(
STableDataCxt
*
pTableCxt
,
TSKEY
tsKey
);
int32_t
insGetTableDataCxt
(
SHashObj
*
pHash
,
void
*
id
,
int32_t
idLen
,
STableMeta
*
pTableMeta
,
int32_t
insGetTableDataCxt
(
SHashObj
*
pHash
,
void
*
id
,
int32_t
idLen
,
STableMeta
*
pTableMeta
,
SVCreateTbReq
**
pCreateTbReq
,
STableDataCxt
**
pTableCxt
,
bool
colMode
);
SVCreateTbReq
**
pCreateTbReq
,
STableDataCxt
**
pTableCxt
,
bool
colMode
);
int32_t
initTableColSubmitData
(
STableDataCxt
*
pTableCxt
);
int32_t
insMergeTableDataCxt
(
SHashObj
*
pTableHash
,
SArray
**
pVgDataBlocks
);
int32_t
insMergeTableDataCxt
(
SHashObj
*
pTableHash
,
SArray
**
pVgDataBlocks
);
int32_t
insBuildVgDataBlocks
(
SHashObj
*
pVgroupsHashObj
,
SArray
*
pVgDataBlocks
,
SArray
**
pDataBlocks
);
int32_t
insBuildVgDataBlocks
(
SHashObj
*
pVgroupsHashObj
,
SArray
*
pVgDataBlocks
,
SArray
**
pDataBlocks
);
void
insDestroyTableDataCxtHashMap
(
SHashObj
*
pTableCxtHash
);
void
insDestroyTableDataCxtHashMap
(
SHashObj
*
pTableCxtHash
);
...
@@ -174,5 +175,5 @@ void insDestroyVgroupDataCxt(SVgroupDataCxt *pVgCxt);
...
@@ -174,5 +175,5 @@ void insDestroyVgroupDataCxt(SVgroupDataCxt *pVgCxt);
void
insDestroyVgroupDataCxtList
(
SArray
*
pVgCxtList
);
void
insDestroyVgroupDataCxtList
(
SArray
*
pVgCxtList
);
void
insDestroyVgroupDataCxtHashMap
(
SHashObj
*
pVgCxtHash
);
void
insDestroyVgroupDataCxtHashMap
(
SHashObj
*
pVgCxtHash
);
void
insDestroyTableDataCxt
(
STableDataCxt
*
pTableCxt
);
void
insDestroyTableDataCxt
(
STableDataCxt
*
pTableCxt
);
void
destroyBoundColInfo
(
SBoundColInfo
*
pInfo
);
#endif // TDENGINE_PAR_INSERT_UTIL_H
#endif // TDENGINE_PAR_INSERT_UTIL_H
source/libs/parser/src/parInsertSml.c
浏览文件 @
2c013b7e
...
@@ -45,95 +45,52 @@ int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char*
...
@@ -45,95 +45,52 @@ int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char*
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
typedef
struct
SmlExecTableHandle
{
SParsedDataColInfo
tags
;
// each table
SVCreateTbReq
createTblReq
;
// each table
}
SmlExecTableHandle
;
typedef
struct
SmlExecHandle
{
typedef
struct
SmlExecHandle
{
SHashObj
*
pBlockHash
;
SHashObj
*
pBlockHash
;
SmlExecTableHandle
tableExecHandle
;
SQuery
*
pQuery
;
SQuery
*
pQuery
;
}
SSmlExecHandle
;
}
SSmlExecHandle
;
static
void
smlDestroyTableHandle
(
void
*
pHandle
)
{
SmlExecTableHandle
*
handle
=
(
SmlExecTableHandle
*
)
pHandle
;
destroyBoundColumnInfo
(
&
handle
->
tags
);
tdDestroySVCreateTbReq
(
&
handle
->
createTblReq
);
}
static
int32_t
smlBoundColumnData
(
SArray
*
cols
,
SParsedDataColInfo
*
pColList
,
SSchema
*
pSchema
,
bool
isTag
)
{
col_id_t
nCols
=
pColList
->
numOfCols
;
pColList
->
numOfBound
=
0
;
static
int32_t
smlBoundColumnData
(
SArray
*
cols
,
SBoundColInfo
*
pBoundInfo
,
SSchema
*
pSchema
,
bool
isTag
)
{
pColList
->
boundNullLen
=
0
;
bool
*
pUseCols
=
taosMemoryCalloc
(
pBoundInfo
->
numOfCols
,
sizeof
(
bool
));
memset
(
pColList
->
boundColumns
,
0
,
sizeof
(
col_id_t
)
*
nCols
);
if
(
NULL
==
pUseCols
)
{
for
(
col_id_t
i
=
0
;
i
<
nCols
;
++
i
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
pColList
->
cols
[
i
].
valStat
=
VAL_STAT_NONE
;
}
}
bool
isOrdered
=
true
;
pBoundInfo
->
numOfBound
=
0
;
col_id_t
lastColIdx
=
-
1
;
// last column found
int16_t
lastColIdx
=
-
1
;
// last column found
int32_t
code
=
TSDB_CODE_SUCCESS
;
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
cols
);
++
i
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
cols
);
++
i
)
{
SSmlKv
*
kv
=
taosArrayGetP
(
cols
,
i
);
SSmlKv
*
kv
=
taosArrayGetP
(
cols
,
i
);
SToken
sToken
=
{.
n
=
kv
->
keyLen
,
.
z
=
(
char
*
)
kv
->
key
};
SToken
sToken
=
{.
n
=
kv
->
keyLen
,
.
z
=
(
char
*
)
kv
->
key
};
col_id_t
t
=
lastColIdx
+
1
;
col_id_t
t
=
lastColIdx
+
1
;
col_id_t
index
=
((
t
==
0
&&
!
isTag
)
?
0
:
insFindCol
(
&
sToken
,
t
,
n
Cols
,
pSchema
));
col_id_t
index
=
((
t
==
0
&&
!
isTag
)
?
0
:
insFindCol
(
&
sToken
,
t
,
pBoundInfo
->
numOf
Cols
,
pSchema
));
uDebug
(
"SML, index:%d, t:%d, ncols:%d"
,
index
,
t
,
n
Cols
);
uDebug
(
"SML, index:%d, t:%d, ncols:%d"
,
index
,
t
,
pBoundInfo
->
numOf
Cols
);
if
(
index
<
0
&&
t
>
0
)
{
if
(
index
<
0
&&
t
>
0
)
{
index
=
insFindCol
(
&
sToken
,
0
,
t
,
pSchema
);
index
=
insFindCol
(
&
sToken
,
0
,
t
,
pSchema
);
isOrdered
=
false
;
}
}
if
(
index
<
0
)
{
if
(
index
<
0
)
{
uError
(
"smlBoundColumnData. index:%d"
,
index
);
uError
(
"smlBoundColumnData. index:%d"
,
index
);
return
TSDB_CODE_SML_INVALID_DATA
;
code
=
TSDB_CODE_SML_INVALID_DATA
;
goto
end
;
}
}
if
(
p
ColList
->
cols
[
index
].
valStat
==
VAL_STAT_HAS
)
{
if
(
p
UseCols
[
index
]
)
{
uError
(
"smlBoundColumnData. already set. index:%d"
,
index
);
uError
(
"smlBoundColumnData. already set. index:%d"
,
index
);
return
TSDB_CODE_SML_INVALID_DATA
;
code
=
TSDB_CODE_SML_INVALID_DATA
;
goto
end
;
}
}
lastColIdx
=
index
;
lastColIdx
=
index
;
pColList
->
cols
[
index
].
valStat
=
VAL_STAT_HAS
;
pUseCols
[
index
]
=
true
;
pColList
->
boundColumns
[
pColList
->
numOfBound
]
=
index
;
pBoundInfo
->
pColIndex
[
pBoundInfo
->
numOfBound
]
=
index
;
++
pColList
->
numOfBound
;
++
pBoundInfo
->
numOfBound
;
switch
(
pSchema
[
t
].
type
)
{
case
TSDB_DATA_TYPE_BINARY
:
pColList
->
boundNullLen
+=
(
sizeof
(
VarDataOffsetT
)
+
VARSTR_HEADER_SIZE
+
CHAR_BYTES
);
break
;
case
TSDB_DATA_TYPE_NCHAR
:
pColList
->
boundNullLen
+=
(
sizeof
(
VarDataOffsetT
)
+
VARSTR_HEADER_SIZE
+
TSDB_NCHAR_SIZE
);
break
;
default:
pColList
->
boundNullLen
+=
TYPE_BYTES
[
pSchema
[
t
].
type
];
break
;
}
}
pColList
->
orderStatus
=
isOrdered
?
ORDER_STATUS_ORDERED
:
ORDER_STATUS_DISORDERED
;
if
(
!
isOrdered
)
{
pColList
->
colIdxInfo
=
taosMemoryCalloc
(
pColList
->
numOfBound
,
sizeof
(
SBoundIdxInfo
));
if
(
NULL
==
pColList
->
colIdxInfo
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
SBoundIdxInfo
*
pColIdx
=
pColList
->
colIdxInfo
;
for
(
col_id_t
i
=
0
;
i
<
pColList
->
numOfBound
;
++
i
)
{
pColIdx
[
i
].
schemaColIdx
=
pColList
->
boundColumns
[
i
];
pColIdx
[
i
].
boundIdx
=
i
;
}
taosSort
(
pColIdx
,
pColList
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
insSchemaIdxCompar
);
for
(
col_id_t
i
=
0
;
i
<
pColList
->
numOfBound
;
++
i
)
{
pColIdx
[
i
].
finalIdx
=
i
;
}
taosSort
(
pColIdx
,
pColList
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
insBoundIdxCompar
);
}
}
if
(
pColList
->
numOfCols
>
pColList
->
numOfBound
)
{
end:
memset
(
&
pColList
->
boundColumns
[
pColList
->
numOfBound
],
0
,
taosMemoryFree
(
pUseCols
);
sizeof
(
col_id_t
)
*
(
pColList
->
numOfCols
-
pColList
->
numOfBound
));
}
return
TSDB_CODE_SUCCESS
;
return
code
;
}
}
/**
/**
...
@@ -146,7 +103,7 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS
...
@@ -146,7 +103,7 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS
* @param msg
* @param msg
* @return int32_t
* @return int32_t
*/
*/
static
int32_t
smlBuildTagRow
(
SArray
*
cols
,
S
ParsedData
ColInfo
*
tags
,
SSchema
*
pSchema
,
STag
**
ppTag
,
SArray
**
tagName
,
static
int32_t
smlBuildTagRow
(
SArray
*
cols
,
S
Bound
ColInfo
*
tags
,
SSchema
*
pSchema
,
STag
**
ppTag
,
SArray
**
tagName
,
SMsgBuf
*
msg
)
{
SMsgBuf
*
msg
)
{
SArray
*
pTagArray
=
taosArrayInit
(
tags
->
numOfBound
,
sizeof
(
STagVal
));
SArray
*
pTagArray
=
taosArrayInit
(
tags
->
numOfBound
,
sizeof
(
STagVal
));
if
(
!
pTagArray
)
{
if
(
!
pTagArray
)
{
...
@@ -159,7 +116,7 @@ static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* p
...
@@ -159,7 +116,7 @@ static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* p
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
for
(
int
i
=
0
;
i
<
tags
->
numOfBound
;
++
i
)
{
for
(
int
i
=
0
;
i
<
tags
->
numOfBound
;
++
i
)
{
SSchema
*
pTagSchema
=
&
pSchema
[
tags
->
boundColumns
[
i
]];
SSchema
*
pTagSchema
=
&
pSchema
[
tags
->
pColIndex
[
i
]];
SSmlKv
*
kv
=
taosArrayGetP
(
cols
,
i
);
SSmlKv
*
kv
=
taosArrayGetP
(
cols
,
i
);
taosArrayPush
(
*
tagName
,
pTagSchema
->
name
);
taosArrayPush
(
*
tagName
,
pTagSchema
->
name
);
...
@@ -212,128 +169,115 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
...
@@ -212,128 +169,115 @@ int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols
SMsgBuf
pBuf
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
SMsgBuf
pBuf
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
SSmlExecHandle
*
smlHandle
=
(
SSmlExecHandle
*
)
handle
;
SSmlExecHandle
*
smlHandle
=
(
SSmlExecHandle
*
)
handle
;
smlDestroyTableHandle
(
&
smlHandle
->
tableExecHandle
);
// free for each table
SSchema
*
pTagsSchema
=
getTableTagSchema
(
pTableMeta
);
SSchema
*
pTagsSchema
=
getTableTagSchema
(
pTableMeta
);
insSetBoundColumnInfo
(
&
smlHandle
->
tableExecHandle
.
tags
,
pTagsSchema
,
getNumOfTags
(
pTableMeta
));
SBoundColInfo
bindTags
=
{
0
};
int
ret
=
smlBoundColumnData
(
tags
,
&
smlHandle
->
tableExecHandle
.
tags
,
pTagsSchema
,
true
);
SVCreateTbReq
*
pCreateTblReq
=
NULL
;
SArray
*
tagName
=
NULL
;
insInitBoundColsInfo
(
getNumOfTags
(
pTableMeta
),
&
bindTags
);
int
ret
=
smlBoundColumnData
(
tags
,
&
bindTags
,
pTagsSchema
,
true
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
buildInvalidOperationMsg
(
&
pBuf
,
"bound tags error"
);
buildInvalidOperationMsg
(
&
pBuf
,
"bound tags error"
);
return
ret
;
goto
end
;
}
}
STag
*
pTag
=
NULL
;
STag
*
pTag
=
NULL
;
SArray
*
tagName
=
NULL
;
ret
=
smlBuildTagRow
(
tags
,
&
smlHandle
->
tableExecHandle
.
t
ags
,
pTagsSchema
,
&
pTag
,
&
tagName
,
&
pBuf
);
ret
=
smlBuildTagRow
(
tags
,
&
bindT
ags
,
pTagsSchema
,
&
pTag
,
&
tagName
,
&
pBuf
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
taosArrayDestroy
(
tagName
);
goto
end
;
return
ret
;
}
}
insBuildCreateTbReq
(
&
smlHandle
->
tableExecHandle
.
createTblReq
,
tableName
,
pTag
,
pTableMeta
->
suid
,
NULL
,
tagName
,
pCreateTblReq
=
taosMemoryCalloc
(
1
,
sizeof
(
SVCreateTbReq
));
if
(
NULL
==
pCreateTblReq
)
{
ret
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
end
;
}
insBuildCreateTbReq
(
pCreateTblReq
,
tableName
,
pTag
,
pTableMeta
->
suid
,
NULL
,
tagName
,
pTableMeta
->
tableInfo
.
numOfTags
,
ttl
);
pTableMeta
->
tableInfo
.
numOfTags
,
ttl
);
taosArrayDestroy
(
tagName
);
smlHandle
->
tableExecHandle
.
createTblReq
.
ctb
.
stbName
=
taosMemoryMalloc
(
sTableNameLen
+
1
);
pCreateTblReq
->
ctb
.
stbName
=
taosMemoryCalloc
(
1
,
sTableNameLen
+
1
);
memcpy
(
smlHandle
->
tableExecHandle
.
createTblReq
.
ctb
.
stbName
,
sTableName
,
sTableNameLen
);
memcpy
(
pCreateTblReq
->
ctb
.
stbName
,
sTableName
,
sTableNameLen
);
smlHandle
->
tableExecHandle
.
createTblReq
.
ctb
.
stbName
[
sTableNameLen
]
=
0
;
STableDataBlocks
*
pDataBlock
=
NULL
;
STableDataCxt
*
pTableCxt
=
NULL
;
ret
=
insGetDataBlockFromList
(
smlHandle
->
pBlockHash
,
&
pTableMeta
->
uid
,
sizeof
(
pTableMeta
->
uid
),
ret
=
insGetTableDataCxt
(
smlHandle
->
pBlockHash
,
&
pTableMeta
->
uid
,
sizeof
(
pTableMeta
->
uid
),
TSDB_DEFAULT_PAYLOAD_SIZE
,
sizeof
(
SSubmitBlk
),
getTableInfo
(
pTableMeta
).
rowSize
,
pTableMeta
,
&
pCreateTblReq
,
&
pTableCxt
,
false
);
pTableMeta
,
&
pDataBlock
,
NULL
,
&
smlHandle
->
tableExecHandle
.
createTblReq
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
buildInvalidOperationMsg
(
&
pBuf
,
"
create data block
error"
);
buildInvalidOperationMsg
(
&
pBuf
,
"
insGetTableDataCxt
error"
);
return
ret
;
goto
end
;
}
}
SSchema
*
pSchema
=
getTableColumnSchema
(
pTableMeta
);
SSchema
*
pSchema
=
getTableColumnSchema
(
pTableMeta
);
ret
=
smlBoundColumnData
(
colsSchema
,
&
pTableCxt
->
boundColsInfo
,
pSchema
,
false
);
ret
=
smlBoundColumnData
(
colsSchema
,
&
pDataBlock
->
boundColumnInfo
,
pSchema
,
false
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
buildInvalidOperationMsg
(
&
pBuf
,
"bound cols error"
);
buildInvalidOperationMsg
(
&
pBuf
,
"bound cols error"
);
return
ret
;
goto
end
;
}
}
int32_t
extendedRowSize
=
insGetExtendedRowSize
(
pDataBlock
);
SParsedDataColInfo
*
spd
=
&
pDataBlock
->
boundColumnInfo
;
SRowBuilder
*
pBuilder
=
&
pDataBlock
->
rowBuilder
;
SMemParam
param
=
{.
rb
=
pBuilder
};
insInitRowBuilder
(
&
pDataBlock
->
rowBuilder
,
pDataBlock
->
pTableMeta
->
sversion
,
&
pDataBlock
->
boundColumnInfo
);
ret
=
initTableColSubmitData
(
pTableCxt
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
buildInvalidOperationMsg
(
&
pBuf
,
"initTableColSubmitData error"
);
goto
end
;
}
int32_t
rowNum
=
taosArrayGetSize
(
cols
);
int32_t
rowNum
=
taosArrayGetSize
(
cols
);
if
(
rowNum
<=
0
)
{
if
(
rowNum
<=
0
)
{
return
buildInvalidOperationMsg
(
&
pBuf
,
"cols size <= 0"
);
ret
=
buildInvalidOperationMsg
(
&
pBuf
,
"cols size <= 0"
);
}
goto
end
;
ret
=
insAllocateMemForSize
(
pDataBlock
,
extendedRowSize
*
rowNum
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
buildInvalidOperationMsg
(
&
pBuf
,
"allocate memory error"
);
return
ret
;
}
}
for
(
int32_t
r
=
0
;
r
<
rowNum
;
++
r
)
{
for
(
int32_t
r
=
0
;
r
<
rowNum
;
++
r
)
{
STSRow
*
row
=
(
STSRow
*
)(
pDataBlock
->
pData
+
pDataBlock
->
size
);
// skip the SSubmitBlk header
tdSRowResetBuf
(
pBuilder
,
row
);
void
*
rowData
=
taosArrayGetP
(
cols
,
r
);
void
*
rowData
=
taosArrayGetP
(
cols
,
r
);
size_t
rowDataSize
=
0
;
if
(
format
)
{
rowDataSize
=
taosArrayGetSize
(
rowData
);
}
// 1. set the parsed value from sql string
// 1. set the parsed value from sql string
for
(
int
c
=
0
,
j
=
0
;
c
<
spd
->
numOfBound
;
++
c
)
{
for
(
int
c
=
0
;
c
<
pTableCxt
->
boundColsInfo
.
numOfBound
;
++
c
)
{
SSchema
*
pColSchema
=
&
pSchema
[
spd
->
boundColumns
[
c
]];
SSchema
*
pColSchema
=
&
pSchema
[
pTableCxt
->
boundColsInfo
.
pColIndex
[
c
]];
SColVal
*
pVal
=
taosArrayGet
(
pTableCxt
->
pValues
,
pTableCxt
->
boundColsInfo
.
pColIndex
[
c
]);
param
.
schema
=
pColSchema
;
insGetSTSRowAppendInfo
(
pBuilder
->
rowType
,
spd
,
c
,
&
param
.
toffset
,
&
param
.
colIdx
);
SSmlKv
*
kv
=
NULL
;
SSmlKv
*
kv
=
NULL
;
if
(
format
)
{
if
(
!
format
){
if
(
j
<
rowDataSize
)
{
kv
=
taosArrayGetP
(
rowData
,
j
);
if
(
rowDataSize
!=
spd
->
numOfBound
&&
j
!=
0
&&
(
kv
->
keyLen
!=
strlen
(
pColSchema
->
name
)
||
strncmp
(
kv
->
key
,
pColSchema
->
name
,
kv
->
keyLen
)
!=
0
))
{
kv
=
NULL
;
}
else
{
j
++
;
}
}
}
else
{
void
**
p
=
taosHashGet
(
rowData
,
pColSchema
->
name
,
strlen
(
pColSchema
->
name
));
void
**
p
=
taosHashGet
(
rowData
,
pColSchema
->
name
,
strlen
(
pColSchema
->
name
));
if
(
p
)
kv
=
*
p
;
if
(
p
)
kv
=
*
p
;
}
}
if
(
kv
)
{
if
(
kv
==
NULL
)
{
int32_t
colLen
=
kv
->
length
;
continue
;
if
(
pColSchema
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
}
uDebug
(
"SML:data before:%"
PRId64
", precision:%d"
,
kv
->
i
,
pTableMeta
->
tableInfo
.
precision
);
if
(
pColSchema
->
type
==
TSDB_DATA_TYPE_TIMESTAMP
)
{
kv
->
i
=
convertTimePrecision
(
kv
->
i
,
TSDB_TIME_PRECISION_NANO
,
pTableMeta
->
tableInfo
.
precision
);
kv
->
i
=
convertTimePrecision
(
kv
->
i
,
TSDB_TIME_PRECISION_NANO
,
pTableMeta
->
tableInfo
.
precision
);
uDebug
(
"SML:data after:%"
PRId64
", precision:%d"
,
kv
->
i
,
pTableMeta
->
tableInfo
.
precision
);
}
if
(
kv
->
type
==
TSDB_DATA_TYPE_NCHAR
){
int32_t
len
=
0
;
char
*
pUcs4
=
taosMemoryCalloc
(
1
,
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
);
if
(
NULL
==
pUcs4
)
{
ret
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
end
;
}
}
if
(
!
taosMbsToUcs4
(
kv
->
value
,
kv
->
length
,
(
TdUcs4
*
)
pUcs4
,
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
,
&
len
))
{
if
(
IS_VAR_DATA_TYPE
(
kv
->
type
))
{
if
(
errno
==
E2BIG
)
{
insMemRowAppend
(
&
pBuf
,
kv
->
value
,
colLen
,
&
param
);
buildInvalidOperationMsg
(
&
pBuf
,
"value too long"
);
}
else
{
ret
=
TSDB_CODE_PAR_VALUE_TOO_LONG
;
insMemRowAppend
(
&
pBuf
,
&
(
kv
->
value
),
colLen
,
&
param
);
goto
end
;
}
ret
=
buildInvalidOperationMsg
(
&
pBuf
,
strerror
(
errno
));
goto
end
;
}
}
pVal
->
value
.
pData
=
pUcs4
;
pVal
->
value
.
nData
=
len
;
}
else
if
(
kv
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
pVal
->
value
.
nData
=
kv
->
length
;
pVal
->
value
.
pData
=
(
uint8_t
*
)
kv
->
value
;
}
else
{
}
else
{
pBuilder
->
hasNone
=
true
;
memcpy
(
&
pVal
->
value
.
val
,
&
(
kv
->
value
),
kv
->
length
);
}
if
(
PRIMARYKEY_TIMESTAMP_COL_ID
==
pColSchema
->
colId
)
{
TSKEY
tsKey
=
TD_ROW_KEY
(
row
);
insCheckTimestamp
(
pDataBlock
,
(
const
char
*
)
&
tsKey
);
}
}
pVal
->
flag
=
CV_FLAG_VALUE
;
}
}
// set the null value for the columns that do not assign values
if
((
spd
->
numOfBound
<
spd
->
numOfCols
)
&&
TD_IS_TP_ROW
(
row
))
{
pBuilder
->
hasNone
=
true
;
}
tdSRowEnd
(
pBuilder
);
pDataBlock
->
size
+=
extendedRowSize
;
}
}
SSubmitBlk
*
pBlocks
=
(
SSubmitBlk
*
)(
pDataBlock
->
pData
);
end:
return
insSetBlockInfo
(
pBlocks
,
pDataBlock
,
rowNum
,
&
pBuf
);
destroyBoundColInfo
(
&
bindTags
);
taosMemoryFree
(
pCreateTblReq
);
taosArrayDestroy
(
tagName
);
return
ret
;
}
}
void
*
smlInitHandle
(
SQuery
*
pQuery
)
{
void
*
smlInitHandle
(
SQuery
*
pQuery
)
{
...
@@ -349,7 +293,6 @@ void smlDestroyHandle(void* pHandle) {
...
@@ -349,7 +293,6 @@ void smlDestroyHandle(void* pHandle) {
if
(
!
pHandle
)
return
;
if
(
!
pHandle
)
return
;
SSmlExecHandle
*
handle
=
(
SSmlExecHandle
*
)
pHandle
;
SSmlExecHandle
*
handle
=
(
SSmlExecHandle
*
)
pHandle
;
insDestroyBlockHashmap
(
handle
->
pBlockHash
);
insDestroyBlockHashmap
(
handle
->
pBlockHash
);
smlDestroyTableHandle
(
&
handle
->
tableExecHandle
);
taosMemoryFree
(
handle
);
taosMemoryFree
(
handle
);
}
}
...
...
source/libs/parser/src/parInsertSql.c
浏览文件 @
2c013b7e
...
@@ -1371,8 +1371,6 @@ static int32_t parseInsertTableClauseBottom(SInsertParseContext* pCxt, SVnodeMod
...
@@ -1371,8 +1371,6 @@ static int32_t parseInsertTableClauseBottom(SInsertParseContext* pCxt, SVnodeMod
return
code
;
return
code
;
}
}
static
void
destroyBoundColInfo
(
SBoundColInfo
*
pInfo
)
{
taosMemoryFreeClear
(
pInfo
->
pColIndex
);
}
static
void
resetEnvPreTable
(
SInsertParseContext
*
pCxt
,
SVnodeModifOpStmt
*
pStmt
)
{
static
void
resetEnvPreTable
(
SInsertParseContext
*
pCxt
,
SVnodeModifOpStmt
*
pStmt
)
{
destroyBoundColInfo
(
&
pCxt
->
tags
);
destroyBoundColInfo
(
&
pCxt
->
tags
);
taosMemoryFreeClear
(
pStmt
->
pTableMeta
);
taosMemoryFreeClear
(
pStmt
->
pTableMeta
);
...
...
source/libs/parser/src/parInsertStmt.c
浏览文件 @
2c013b7e
...
@@ -22,13 +22,6 @@
...
@@ -22,13 +22,6 @@
#include "ttime.h"
#include "ttime.h"
#include "ttypes.h"
#include "ttypes.h"
typedef
struct
SKvParam
{
int16_t
pos
;
SArray
*
pTagVals
;
SSchema
*
schema
;
char
buf
[
TSDB_MAX_TAGS_LEN
];
}
SKvParam
;
int32_t
qBuildStmtOutput
(
SQuery
*
pQuery
,
SHashObj
*
pVgHash
,
SHashObj
*
pBlockHash
)
{
int32_t
qBuildStmtOutput
(
SQuery
*
pQuery
,
SHashObj
*
pVgHash
,
SHashObj
*
pBlockHash
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
SArray
*
pVgDataBlocks
=
NULL
;
SArray
*
pVgDataBlocks
=
NULL
;
...
...
source/libs/parser/src/parInsertUtil.c
浏览文件 @
2c013b7e
...
@@ -999,7 +999,7 @@ void insCheckTableDataOrder(STableDataCxt* pTableCxt, TSKEY tsKey) {
...
@@ -999,7 +999,7 @@ void insCheckTableDataOrder(STableDataCxt* pTableCxt, TSKEY tsKey) {
return
;
return
;
}
}
static
void
destroyBoundColInfo
(
SBoundColInfo
*
pInfo
)
{
taosMemoryFreeClear
(
pInfo
->
pColIndex
);
}
void
destroyBoundColInfo
(
SBoundColInfo
*
pInfo
)
{
taosMemoryFreeClear
(
pInfo
->
pColIndex
);
}
static
int32_t
createTableDataCxt
(
STableMeta
*
pTableMeta
,
SVCreateTbReq
**
pCreateTbReq
,
STableDataCxt
**
pOutput
,
bool
colMode
)
{
static
int32_t
createTableDataCxt
(
STableMeta
*
pTableMeta
,
SVCreateTbReq
**
pCreateTbReq
,
STableDataCxt
**
pOutput
,
bool
colMode
)
{
STableDataCxt
*
pTableCxt
=
taosMemoryCalloc
(
1
,
sizeof
(
STableDataCxt
));
STableDataCxt
*
pTableCxt
=
taosMemoryCalloc
(
1
,
sizeof
(
STableDataCxt
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录