Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/1069#discussion_r112583946
--- Diff: core/sql/exp/exp_function.cpp ---
@@ -2484,6 +2491,79 @@ ex_expr::exp_return_type
ExFunctionTokenStr::eval(char *op_data[],
return ex_expr::EXPR_OK;
};
+
+ex_expr::exp_return_type ExFunctionReverseStr::eval(char *op_data[],
+ CollHeap* heap,
+ ComDiagsArea**
diagsArea)
+{
+ CharInfo::CharSet cs = ((SimpleType *)getOperand(1))->getCharSet();
+ Lng32 len1 = getOperand(1)->getLength(op_data[-MAX_OPERANDS+1]);
+
+ char * tgt = op_data[0];
+ char * src = op_data[1];
+ Lng32 srcPos = 0;
+ Lng32 tgtPos = 0;
+ if (cs == CharInfo::ISO88591)
+ {
+ tgtPos = len1 - 1;
+ for (srcPos = 0; srcPos < len1; srcPos++)
+ {
+ tgt[tgtPos--] = src[srcPos];
+ }
+ }
+ else if (cs == CharInfo::UCS2)
+ {
+ Lng32 bpc = unicode_char_set::bytesPerChar();
+ srcPos = 0;
+ tgtPos = len1 - bpc;
+ while (srcPos < len1)
+ {
+ str_cpy_all(&tgt[tgtPos], &src[srcPos], bpc);
+ tgtPos -= bpc;
+ srcPos += bpc;
+ }
+ }
+ else if (cs == CharInfo::UTF8)
+ {
+ UInt32 UCS4value;
+
+ cnv_charset charset = convertCharsetEnum(cs);
+ Lng32 charLen;
+ srcPos = 0;
+ tgtPos = len1;
+ while(srcPos < len1)
+ {
+ charLen = LocaleCharToUCS4(&op_data[1][srcPos],
+ len1 - srcPos,
+ &UCS4value,
+ charset);
+ if (charLen < 0)
+ {
+ const char *csname = CharInfo::getCharSetName(cs);
+ ExRaiseSqlError(heap, diagsArea, EXE_INVALID_CHARACTER);
+ *(*diagsArea) << DgString0(csname) << DgString1("REVERSE
FUNCTION");
+ return ex_expr::EXPR_ERROR;
+ }
+
+ tgtPos -= charLen;
+ str_cpy_all(&tgt[tgtPos], &src[srcPos], charLen);
+ srcPos += charLen;
+ }
+ }
+ else
+ {
+ const char *csname = CharInfo::getCharSetName(cs);
+ ExRaiseSqlError(heap, diagsArea, EXE_INVALID_CHARACTER);
--- End diff --
Is this the error you want? Looks like it is error 8433 with text, "Invalid
$0~string0 character encountered in $1~string1." But the error here is an
invalid character set.
---
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.
---