Attaching derby-4684-01-ab-implicitCastsToBoolean.diff. This causes Derby to raise an exception if you try to implicitly cast to or from BOOLEAN in a way which violates the SQL Standard. Regression tests passed for me with this patch applied.
This patch removes the ability to cast numerics to boolean. It also prevents String values from being cast to BOOLEAN unless they are the handful of legal values allowed by the Standard. I believe that most users won't even notice these changes, for the following reasons:
1) Getting Derby to implicitly cast to BOOLEAN involves writing a very contrived query whose point is to trick Derby into returning an unsupported data type.
2) No existing tests failed with this patch.
Touches the following files:
Don't allow numerics to be stored in BOOLEANs.
Raise an error if, at run time, you try to cast a bad String to BOOLEAN.
Regression test to verify the Standard behavior.