I wrote a fix for this, but seeing the comments at https://issues.apache.org/jira/browse/DERBY-3676 I am not sure its a good idea.
Please feel free to attach the patch proposal to the JIRA issue anyway, even if you think it may not be perfect. It may be just the thing to help somebody else, or somebody else may have a look at it and make a follow-on suggestion. thanks, bryan
