Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1439#discussion_r166060055
--- Diff: 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];
--- End diff --
I'm wondering if we need to delete jsonStr and jsonAttr after the
json_extract_path_text call to avoid unnecessary heap pressure. Though if
json_extract_path_text itself does new's on the same heap, we'd get heap
fragmentation.
Another approach would be to allocate these on the stack instead, avoiding
both concerns:
char jsonStr[len1+1];
char jsonAttr[len2+1];
...
---