Github user traflm commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/257#discussion_r49535117
--- Diff: core/sql/exp/exp_conv.cpp ---
@@ -9321,6 +9321,33 @@ convDoIt(char * source,
};
break;
+// gb2312 -> utf8
+ case CONV_GBK_F_UTF8_V:
+ {
+ char * targetbuf = new char[sourceLen*4+1];
--- End diff --
very good point, new/delete is better to be avoided. let me check this. As
a change for 'truncate concern' before, I let TRANSLATE raise SQL error if the
target buffer is not long enough. So a better approach is to use the targetbuf
directly and let iconv() to do all the dirty works. If the targetbuf is long
enough, iconv() can success, if targetbuf is not long enough, iconv() will
fail, we don't need to treat all details. iconv is GLibc API, tested and tuned
for years. If iconv() return an error, Trafodion just raise SQL error based on
the error code. This way, we no longer need to new a temp buffer , and do
memcpy, should be a very good optimization.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---