Changeset: 7d7fb417049e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/7d7fb417049e
Modified Files:
monetdb5/modules/atoms/pg_jsonpath/jsonpath_exec.c
monetdb5/modules/atoms/pg_jsonpath/postgres_defines_internal.h
Branch: json-extend
Log Message:
proper error handling in binary operations
diffs (47 lines):
diff --git a/monetdb5/modules/atoms/pg_jsonpath/jsonpath_exec.c
b/monetdb5/modules/atoms/pg_jsonpath/jsonpath_exec.c
--- a/monetdb5/modules/atoms/pg_jsonpath/jsonpath_exec.c
+++ b/monetdb5/modules/atoms/pg_jsonpath/jsonpath_exec.c
@@ -1661,19 +1661,22 @@ executeBinaryArithmExpr(JsonPathExecCont
if (jspThrowErrors(cxt))
{
res = func(yyjson2Numeric(lval), yyjson2Numeric(rval), NULL);
- // TODO: throw error
+ if (!res.type)
+ RETURN_ERROR(ereport(ERROR,
+
(errcode(ERRCODE_MONETDB_FUNCTION_CALL_WENT_WRONG),
+
errmsg("function call went wrong %s",
+
jspOperationName(jsp->type)))));
}
else
{
bool error = false;
res = func(yyjson2Numeric(lval), yyjson2Numeric(rval), &error);
-
if (error)
return jperError;
}
if (!(elem = jsp->next) && !found)
- return jperOk; // TODO: weird why do func if not using the
result perhaps check when found is empty
+ return jperOk; // NOTE: this looks weird: why do func if not
using the result. Perhaps to generate the error
lval = Numeric2yyjson(cxt, res);
diff --git a/monetdb5/modules/atoms/pg_jsonpath/postgres_defines_internal.h
b/monetdb5/modules/atoms/pg_jsonpath/postgres_defines_internal.h
--- a/monetdb5/modules/atoms/pg_jsonpath/postgres_defines_internal.h
+++ b/monetdb5/modules/atoms/pg_jsonpath/postgres_defines_internal.h
@@ -300,11 +300,11 @@ numeric_div_opt_error(Numeric num1, Nume
static inline Numeric
numeric_mod_opt_error(Numeric num1, Numeric num2, bool *have_error)
{
- (void) have_error;
Numeric res = {0};
if (num1.type == YYJSON_SUBTYPE_REAL || num2.type ==
YYJSON_SUBTYPE_REAL) {
- // TODO: handle have_error == NULL
- *have_error = true;
+ if (have_error)
+ *have_error = true;
+ return res;
}
res.type = YYJSON_SUBTYPE_SINT; /*cast all other cases as lng for now*/
res.dnum = Numeric_get_as_lng(&num1) % Numeric_get_as_lng(&num2);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]