You are viewing a plain text version of this content. The canonical link for it is here.
Posted to codereview@trafodion.apache.org by SuJinpei <gi...@git.apache.org> on 2018/11/15 07:00:39 UTC
[GitHub] trafodion pull request #1747: [TRAFODION-3235] add div and trim function for...
GitHub user SuJinpei opened a pull request:
https://github.com/apache/trafodion/pull/1747
[TRAFODION-3235] add div and trim function for map feature, improve bad file print function.
Some customer asks for this feature and these feature has been tested.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/SuJinpei/incubator-trafodion TRAFODION-3235
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/trafodion/pull/1747.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1747
----
commit 5161f7bf2059912ede0617ea2f81178a2f18168a
Author: SuJinpei <87...@...>
Date: 2018-07-31T07:12:49Z
add div operation to map file
commit e77546a81831dbce6157d0082a1dceb3b2169f67
Author: SuJinpei <87...@...>
Date: 2018-08-13T03:26:06Z
special feature(trim, and error print) for China Unino Pay
commit edce322a193351d541cc646348ad2c38828cd6f9
Author: SuJinpei <87...@...>
Date: 2018-11-15T04:50:19Z
print all error message but one bad record associated
----
---
[GitHub] trafodion pull request #1747: [TRAFODION-3235] add div and trim function for...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/trafodion/pull/1747
---
[GitHub] trafodion pull request #1747: [TRAFODION-3235] add div and trim function for...
Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1747#discussion_r234717573
--- Diff: core/conn/odb/src/odb.c ---
@@ -14685,6 +14743,56 @@ static void addGlobalPointer(void *ptr)
globalPointers[nGlobalPointers++] = ptr;
}
+/* is_valid_numeric:
+* check if the string is valid numeric
+*
+* Input: str: string to be validate.
+* Input: n: length of str
+*
+* return: if str is valid numeric return 1 else return 0
+*/
+static int is_valid_numeric(const char* str, size_t n) {
+ int s = 1;
+ for (size_t i = 0; i < n; ++i) {
+ switch (s) {
+ case 1:
+ if (str[i] == '+' || str[i] == '-') s = 2;
+ else if (isdigit(str[i])) s = 3;
+ else return 0;
+ break;
+ case 2:
+ if (!isdigit(str[i])) return 0;
+ s = 3;
+ break;
+ case 3:
+ if (str[i] == '.') s = 4;
+ else if (str[i] == 'e') s = 6;
+ else if (!isdigit(str[i])) return 0;
+ break;
+ case 4:
+ if (!isdigit(str[i])) return 0;
+ s = 5;
+ break;
+ case 5:
+ if (str[i] == 'e') s = 6;
+ else if (!isdigit(str[i])) return 0;
+ break;
+ case 6:
+ if (str[i] == '+' || str[i] == '-') s = 7;
+ else if (isdigit(str[i])) s = 7;
+ else return 0;
+ break;
+ case 7:
+ if (!isdigit(str[i])) return 0;
+ break;
+ default:
+ return 0;
+ }
+ }
+ if (s == 3 || s == 7 || s == 5) return 1;
--- End diff --
I am wondering if s == 4 should be allowed here too. Consider the string "1234."
---
[GitHub] trafodion pull request #1747: [TRAFODION-3235] add div and trim function for...
Posted by SuJinpei <gi...@git.apache.org>.
Github user SuJinpei commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1747#discussion_r234883979
--- Diff: core/conn/odb/src/odb.c ---
@@ -10076,6 +10114,7 @@ static int Oloadbuff(int eid)
clock_gettime(CLOCK_MONOTONIC, &tsp1);
#endif
Or = SQLExecute(thps[tid].Os) ; /* Execute INSERT (load/copy) or tgt command */
+ SQLLEN tLastRow = -1; /* this is special solution for China Union Pay, print only first error message for state 22003 */
--- End diff --
Thank you, I will fix this.
---
[GitHub] trafodion pull request #1747: [TRAFODION-3235] add div and trim function for...
Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1747#discussion_r234716204
--- Diff: core/conn/odb/src/odb.c ---
@@ -10076,6 +10114,7 @@ static int Oloadbuff(int eid)
clock_gettime(CLOCK_MONOTONIC, &tsp1);
#endif
Or = SQLExecute(thps[tid].Os) ; /* Execute INSERT (load/copy) or tgt command */
+ SQLLEN tLastRow = -1; /* this is special solution for China Union Pay, print only first error message for state 22003 */
--- End diff --
Probably best not to put customer names into the code. Consider changing the comment to just "/* print only first error message for state 22003 */"
---
[GitHub] trafodion pull request #1747: [TRAFODION-3235] add div and trim function for...
Posted by SuJinpei <gi...@git.apache.org>.
Github user SuJinpei commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1747#discussion_r234884122
--- Diff: core/conn/odb/src/odb.c ---
@@ -14685,6 +14743,56 @@ static void addGlobalPointer(void *ptr)
globalPointers[nGlobalPointers++] = ptr;
}
+/* is_valid_numeric:
+* check if the string is valid numeric
+*
+* Input: str: string to be validate.
+* Input: n: length of str
+*
+* return: if str is valid numeric return 1 else return 0
+*/
+static int is_valid_numeric(const char* str, size_t n) {
+ int s = 1;
+ for (size_t i = 0; i < n; ++i) {
+ switch (s) {
+ case 1:
+ if (str[i] == '+' || str[i] == '-') s = 2;
+ else if (isdigit(str[i])) s = 3;
+ else return 0;
+ break;
+ case 2:
+ if (!isdigit(str[i])) return 0;
+ s = 3;
+ break;
+ case 3:
+ if (str[i] == '.') s = 4;
+ else if (str[i] == 'e') s = 6;
+ else if (!isdigit(str[i])) return 0;
+ break;
+ case 4:
+ if (!isdigit(str[i])) return 0;
+ s = 5;
+ break;
+ case 5:
+ if (str[i] == 'e') s = 6;
+ else if (!isdigit(str[i])) return 0;
+ break;
+ case 6:
+ if (str[i] == '+' || str[i] == '-') s = 7;
+ else if (isdigit(str[i])) s = 7;
+ else return 0;
+ break;
+ case 7:
+ if (!isdigit(str[i])) return 0;
+ break;
+ default:
+ return 0;
+ }
+ }
+ if (s == 3 || s == 7 || s == 5) return 1;
--- End diff --
Yes, this is also a valid numeric value.
---
[GitHub] trafodion pull request #1747: [TRAFODION-3235] add div and trim function for...
Posted by SuJinpei <gi...@git.apache.org>.
Github user SuJinpei commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1747#discussion_r234883931
--- Diff: core/conn/odb/src/odb.c ---
@@ -6246,7 +6248,8 @@ static void Oload(int eid)
trt[16]; /* translit to array */
char op; /* 1=substr, 2=dconv, 3=tconv, 4=tsconv, 5=replace,
6=toupper, 7=tolower, 8=firstup, 9=csubstr, 10=translit,
- 11=comp, 12=comp3, 13=zoned, 14=emptyasconst, 15=emptyasempty */
+ 11=comp, 12=comp3, 13=zoned, 14=emptyasconst, 15=emptyasempty,
+ 16=div */
--- End diff --
Thank you, I will fix this.
---
[GitHub] trafodion pull request #1747: [TRAFODION-3235] add div and trim function for...
Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1747#discussion_r234715228
--- Diff: core/conn/odb/src/odb.c ---
@@ -6246,7 +6248,8 @@ static void Oload(int eid)
trt[16]; /* translit to array */
char op; /* 1=substr, 2=dconv, 3=tconv, 4=tsconv, 5=replace,
6=toupper, 7=tolower, 8=firstup, 9=csubstr, 10=translit,
- 11=comp, 12=comp3, 13=zoned, 14=emptyasconst, 15=emptyasempty */
+ 11=comp, 12=comp3, 13=zoned, 14=emptyasconst, 15=emptyasempty,
+ 16=div */
--- End diff --
Should the comments also include 17=trim?
---