Well, after that paragraph of justification, it turns out that there are only three places where we use the 42Z79 SQLSTATE. But still, I think it's a useful error message and should be kept around; it could come in handy further down the road if SQL/XML functionality is expanded.
As for line/column numbers, it turns out that those values are readily available from within sqlgrammar.jj and thus can easily be passed as part of the error message. The only potential downside that I can see is that we have to create an Integer object out of the line/col numbers in order to pass them to the StandardException constructor...but maybe that's not a big deal...? The fact that no one has done this earlier makes me wonder if there's some "gotcha" here that I'm missing, but I haven't seen any problems with it just yet...
Attaching a patch d1776_v1.patch that changes the error message for 42Z79 as mentioned in my previous comment and also does the following:
1. Adds line and column numbers to the error message to indicate where
the missing keyword is expected.
2. Removes one "lookahead" call that was causing 42Z79 to be raised
for a missing "AS" keyword when in fact the keyword was present
(what was missing was the datatype). To avoid confusion, I
removed the lookahead and now the user will see a more generic
42X01 error in that particular case.
3. Updated xml_general master files accordingly.
So with this patch applied, instead of:
select xmlserialize from t;
ERROR 42Z72: XML syntax error; missing keyword(s): 'AS'.
we'll now see:
create table t (i int, x xml);
ERROR 42Z72: Missing SQL/XML keyword(s) 'AS' at line 1, column 22.
I ran xmlSuite with this patch and all of the tests passed. I haven't run derbyall yet and I don't expect any failures (since the changes are theoretically limited to XML) but I will try to run it tonight just for sanity. In the meantime, review comments would be great.