Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f4f0f938
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f4f0f938
编写于
12月 02, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: add nchar column convertion
上级
472d3a34
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
57 addition
and
4 deletion
+57
-4
source/libs/parser/src/parInsertStmt.c
source/libs/parser/src/parInsertStmt.c
+57
-4
未找到文件。
source/libs/parser/src/parInsertStmt.c
浏览文件 @
f4f0f938
...
@@ -156,31 +156,84 @@ end:
...
@@ -156,31 +156,84 @@ end:
return
code
;
return
code
;
}
}
int32_t
convertStmtNcharCol
(
SSchema
*
pSchema
,
TAOS_MULTI_BIND
*
src
,
TAOS_MULTI_BIND
*
dst
)
{
int32_t
output
=
0
;
int32_t
newBuflen
=
pSchema
->
bytes
-
VARSTR_HEADER_SIZE
;
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
;
}
}
if
(
!
taosMbsToUcs4
(
value
,
len
,
(
TdUcs4
*
)
varDataVal
(
rowEnd
),
pa
->
schema
->
bytes
-
VARSTR_HEADER_SIZE
,
&
output
))
{
if
(
errno
==
E2BIG
)
{
return
generateSyntaxErrMsg
(
pMsgBuf
,
TSDB_CODE_PAR_VALUE_TOO_LONG
,
pa
->
schema
->
name
);
}
char
buf
[
512
]
=
{
0
};
snprintf
(
buf
,
tListLen
(
buf
),
"%s"
,
strerror
(
errno
));
return
buildSyntaxErrMsg
(
pMsgBuf
,
buf
,
value
);
}
}
int32_t
qBindStmtColsValue
(
void
*
pBlock
,
TAOS_MULTI_BIND
*
bind
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
int32_t
qBindStmtColsValue
(
void
*
pBlock
,
TAOS_MULTI_BIND
*
bind
,
char
*
msgBuf
,
int32_t
msgBufLen
)
{
STableDataCxt
*
pDataBlock
=
(
STableDataCxt
*
)
pBlock
;
STableDataCxt
*
pDataBlock
=
(
STableDataCxt
*
)
pBlock
;
SSchema
*
pSchema
=
getTableColumnSchema
(
pDataBlock
->
pMeta
);
SSchema
*
pSchema
=
getTableColumnSchema
(
pDataBlock
->
pMeta
);
SBoundColInfo
*
boundInfo
=
&
pDataBlock
->
boundColsInfo
;
SBoundColInfo
*
boundInfo
=
&
pDataBlock
->
boundColsInfo
;
SMsgBuf
pBuf
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
SMsgBuf
pBuf
=
{.
buf
=
msgBuf
,
.
len
=
msgBufLen
};
int32_t
rowNum
=
bind
->
num
;
int32_t
rowNum
=
bind
->
num
;
TAOS_MULTI_BIND
ncharBind
=
{
0
};
TAOS_MULTI_BIND
*
pBind
=
NULL
;
int32_t
code
=
0
;
char
tmpBuf
[
128
];
for
(
int
c
=
0
;
c
<
boundInfo
->
numOfBound
;
++
c
)
{
for
(
int
c
=
0
;
c
<
boundInfo
->
numOfBound
;
++
c
)
{
SSchema
*
pColSchema
=
&
pSchema
[
boundInfo
->
pColIndex
[
c
]];
SSchema
*
pColSchema
=
&
pSchema
[
boundInfo
->
pColIndex
[
c
]];
SColData
*
pCol
=
taosArrayGet
(
pDataBlock
->
pData
->
aCol
,
c
);
SColData
*
pCol
=
taosArrayGet
(
pDataBlock
->
pData
->
aCol
,
c
);
if
(
bind
[
c
].
num
!=
rowNum
)
{
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
)
{
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
;
}
if
(
TSDB_DATA_TYPE_NCHAR
==
pColSchema
->
type
)
{
code
=
convertStmtNcharCol
(
pColSchema
,
bind
+
c
,
&
ncharBind
);
if
(
code
)
{
snprintf
(
tmpBuf
,
sizeof
(
tmpBuf
)
-
1
,
"The %dth nchar column convert to ucs4 failed, error:%s"
,
c
,
tstrerror
(
code
));
tmpBuf
[
sizeof
(
tmpBuf
)
-
1
]
=
0
;
code
=
buildInvalidOperationMsg
(
&
pBuf
,
tmpBuf
);
goto
_return
;
}
pBind
=
&
ncharBind
;
}
else
{
pBind
=
bind
+
c
;
}
}
tColDataAddValueByBind
(
pCol
,
bind
+
c
);
tColDataAddValueByBind
(
pCol
,
pBind
);
}
}
qDebug
(
"stmt all %d columns bind %d rows data"
,
boundInfo
->
numOfBound
,
rowNum
);
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
,
int32_t
qBindStmtSingleColValue
(
void
*
pBlock
,
TAOS_MULTI_BIND
*
bind
,
char
*
msgBuf
,
int32_t
msgBufLen
,
int32_t
colIdx
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录