Repository: trafodion
Updated Branches:
  refs/heads/master 86c2284f6 -> 8d3f7edc8


[TRAFODION-2772] - retrieve a value from Json string got an error


Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/b2984e1f
Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/b2984e1f
Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/b2984e1f

Branch: refs/heads/master
Commit: b2984e1ff96423d82ebd86d4e9a7e2beb6fb40d1
Parents: d80f009
Author: Andy Yang <[email protected]>
Authored: Mon Feb 5 16:32:19 2018 +0800
Committer: Andy Yang <[email protected]>
Committed: Mon Feb 5 16:32:19 2018 +0800

----------------------------------------------------------------------
 core/sql/exp/exp_function.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/b2984e1f/core/sql/exp/exp_function.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_function.cpp b/core/sql/exp/exp_function.cpp
index 1f757fa..c439559 100644
--- a/core/sql/exp/exp_function.cpp
+++ b/core/sql/exp/exp_function.cpp
@@ -6503,8 +6503,15 @@ ex_expr::exp_return_type 
ex_function_json_object_field_text::eval(char *op_data[
         Int32 prec2 = ((SimpleType *)getOperand(2))->getPrecision();
         len2 = Attributes::trimFillerSpaces( op_data[2], prec2, len2, cs );
     }
+
     char *rltStr = NULL;
-    JsonReturnType ret = json_extract_path_text(&rltStr, op_data[1], 1, 
op_data[2]);
+    char *jsonStr = new(heap) char[len1+1];
+    char *jsonAttr = new(heap) char[len2+1];
+    strncpy(jsonStr, op_data[1], len1);
+    jsonStr[len1] = '\0';
+    strncpy(jsonAttr, op_data[2], len2);
+    jsonAttr[len2] = '\0';
+    JsonReturnType ret = json_extract_path_text(&rltStr, jsonStr, 1, jsonAttr);
     if (ret != JSON_OK)
     {
         ExRaiseJSONError(heap, diagsArea, ret);

Reply via email to