I am reasonably sure checked arithmetic is left to implementation to define
due to the mixed concerns of different DBs.  If you define checked
arithmetic, it limits certain optimizations that may be made, such as
pushing an agg below a join.  For instance, if a rewrite because a rewrite
could change the order of operations such that an overflow does or does not
happen, what is the correct answer in this case?  The error, the garbage
result from an overflow, or the result that did not hit the overflow?

I believe some systems have CURRENCY and BIG DECIMAL types, and this might
be the reason.  Maybe the CURRENCY types disallow rewrites to at least make
the query repeatable and consistent.

An alternative to a visitor, would be to use a different operator table
with safe operators.

Considering Calcite as planner, I think the operator/type needs to expose
if over-follow is defined or not, as opposed to checked or unchecked which
is an implementation issue.

James

Reply via email to