Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d86e4cee
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看板
未验证
提交
d86e4cee
编写于
12月 03, 2022
作者:
wmmhello
提交者:
GitHub
12月 03, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18660 from taosdata/refact/submit_req
fix:submit req
上级
30cf1d5b
51795b06
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
88 addition
and
6 deletion
+88
-6
source/libs/parser/src/parInsertStmt.c
source/libs/parser/src/parInsertStmt.c
+88
-6
未找到文件。
source/libs/parser/src/parInsertStmt.c
浏览文件 @
d86e4cee
...
...
@@ -149,31 +149,95 @@ end:
return
code
;
}
int32_t
convertStmtNcharCol
(
SMsgBuf
*
pMsgBuf
,
SSchema
*
pSchema
,
TAOS_MULTI_BIND
*
src
,
TAOS_MULTI_BIND
*
dst
)
{
int32_t
output
=
0
;
int32_t
newBuflen
=
(
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
)
*
src
->
num
;
if
(
dst
->
buffer_length
<
newBuflen
)
{
dst
->
buffer
=
taosMemoryRealloc
(
dst
->
buffer
,
newBuflen
);
if
(
NULL
==
dst
->
buffer
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
NULL
==
dst
->
length
)
{
dst
->
length
=
taosMemoryRealloc
(
dst
->
length
,
sizeof
(
int32_t
)
*
src
->
num
);
if
(
NULL
==
dst
->
buffer
)
{
taosMemoryFreeClear
(
dst
->
buffer
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
dst
->
buffer_length
=
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
;
for
(
int32_t
i
=
0
;
i
<
src
->
num
;
++
i
)
{
if
(
src
->
is_null
&&
src
->
is_null
[
i
])
{
continue
;
}
if
(
!
taosMbsToUcs4
(
src
->
buffer
+
src
->
buffer_length
*
i
,
src
->
length
[
i
],
(
TdUcs4
*
)(
dst
->
buffer
+
dst
->
buffer_length
*
i
),
dst
->
buffer_length
,
&
output
))
{
if
(
errno
==
E2BIG
)
{
return
generateSyntaxErrMsg
(
pMsgBuf
,
TSDB_CODE_PAR_VALUE_TOO_LONG
,
pSchema
->
name
);
}
char
buf
[
512
]
=
{
0
};
snprintf
(
buf
,
tListLen
(
buf
),
"%s"
,
strerror
(
errno
));
return
buildSyntaxErrMsg
(
pMsgBuf
,
buf
,
NULL
);
}
dst
->
length
[
i
]
=
output
;
}
dst
->
buffer_type
=
src
->
buffer_type
;
dst
->
is_null
=
src
->
is_null
;
dst
->
num
=
src
->
num
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
qBindStmtColsValue
(
void
*
pBlock
,
TAOS_MULTI_BIND
*
bind
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
STableDataCxt
*
pDataBlock
=
(
STableDataCxt
*
)
pBlock
;
SSchema
*
pSchema
=
getTableColumnSchema
(
pDataBlock
->
pMeta
);
SBoundColInfo
*
boundInfo
=
&
pDataBlock
->
boundColsInfo
;
SMsgBuf
pBuf
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
int32_t
rowNum
=
bind
->
num
;
TAOS_MULTI_BIND
ncharBind
=
{
0
};
TAOS_MULTI_BIND
*
pBind
=
NULL
;
int32_t
code
=
0
;
for
(
int
c
=
0
;
c
<
boundInfo
->
numOfBound
;
++
c
)
{
SSchema
*
pColSchema
=
&
pSchema
[
boundInfo
->
pColIndex
[
c
]];
SColData
*
pCol
=
taosArrayGet
(
pDataBlock
->
pData
->
aCol
,
c
);
if
(
bind
[
c
].
num
!=
rowNum
)
{
return
buildInvalidOperationMsg
(
&
pBuf
,
"row number in each bind param should be the same"
);
code
=
buildInvalidOperationMsg
(
&
pBuf
,
"row number in each bind param should be the same"
);
goto
_return
;
}
if
(
bind
[
c
].
buffer_type
!=
pColSchema
->
type
)
{
return
buildInvalidOperationMsg
(
&
pBuf
,
"column type mis-match with buffer type"
);
code
=
buildInvalidOperationMsg
(
&
pBuf
,
"column type mis-match with buffer type"
);
goto
_return
;
}
tColDataAddValueByBind
(
pCol
,
bind
+
c
);
if
(
TSDB_DATA_TYPE_NCHAR
==
pColSchema
->
type
)
{
code
=
convertStmtNcharCol
(
&
pBuf
,
pColSchema
,
bind
+
c
,
&
ncharBind
);
if
(
code
)
{
goto
_return
;
}
pBind
=
&
ncharBind
;
}
else
{
pBind
=
bind
+
c
;
}
tColDataAddValueByBind
(
pCol
,
pBind
);
}
qDebug
(
"stmt all %d columns bind %d rows data"
,
boundInfo
->
numOfBound
,
rowNum
);
return
TSDB_CODE_SUCCESS
;
_return:
taosMemoryFree
(
ncharBind
.
buffer
);
taosMemoryFree
(
ncharBind
.
length
);
return
code
;
}
int32_t
qBindStmtSingleColValue
(
void
*
pBlock
,
TAOS_MULTI_BIND
*
bind
,
char
*
msgBuf
,
int32_t
msgBufLen
,
int32_t
colIdx
,
...
...
@@ -184,6 +248,9 @@ int32_t qBindStmtSingleColValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBu
SMsgBuf
pBuf
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
SSchema
*
pColSchema
=
&
pSchema
[
boundInfo
->
pColIndex
[
colIdx
]];
SColData
*
pCol
=
taosArrayGet
(
pDataBlock
->
pData
->
aCol
,
colIdx
);
TAOS_MULTI_BIND
ncharBind
=
{
0
};
TAOS_MULTI_BIND
*
pBind
=
NULL
;
int32_t
code
=
0
;
if
(
bind
->
num
!=
rowNum
)
{
return
buildInvalidOperationMsg
(
&
pBuf
,
"row number in each bind param should be the same"
);
...
...
@@ -192,12 +259,27 @@ int32_t qBindStmtSingleColValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBu
if
(
bind
->
buffer_type
!=
pColSchema
->
type
)
{
return
buildInvalidOperationMsg
(
&
pBuf
,
"column type mis-match with buffer type"
);
}
if
(
TSDB_DATA_TYPE_NCHAR
==
pColSchema
->
type
)
{
code
=
convertStmtNcharCol
(
&
pBuf
,
pColSchema
,
bind
,
&
ncharBind
);
if
(
code
)
{
goto
_return
;
}
pBind
=
&
ncharBind
;
}
else
{
pBind
=
bind
;
}
tColDataAddValueByBind
(
pCol
,
b
ind
);
tColDataAddValueByBind
(
pCol
,
pB
ind
);
qDebug
(
"stmt col %d bind %d rows data"
,
colIdx
,
rowNum
);
return
TSDB_CODE_SUCCESS
;
_return:
taosMemoryFree
(
ncharBind
.
buffer
);
taosMemoryFree
(
ncharBind
.
length
);
return
code
;
}
int32_t
buildBoundFields
(
int32_t
numOfBound
,
int16_t
*
boundColumns
,
SSchema
*
pSchema
,
int32_t
*
fieldNum
,
TAOS_FIELD_E
**
fields
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录