db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r448034 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ engine/org/apache/derby/loc/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/DerbyNet/ testing/org/...
Date Wed, 20 Sep 2006 02:40:58 GMT
Author: mikem
Date: Tue Sep 19 19:40:57 2006
New Revision: 448034

URL: http://svn.apache.org/viewvc?view=rev&rev=448034
Log:
DERBY-1766
contributed by Army Brown

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(x) 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. 


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/xml_general.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/xml_general.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/xml_general.out

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?view=diff&rev=448034&r1=448033&r2=448034
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Tue Sep
19 19:40:57 2006
@@ -4218,7 +4218,9 @@
 		(getToken(1).kind != CONTENT) })
 	{
 		throw StandardException.newException(
-			SQLState.LANG_XML_KEYWORD_MISSING, "DOCUMENT");
+			SQLState.LANG_XML_KEYWORD_MISSING, "DOCUMENT",
+			new Integer(getToken(1).beginLine),
+			new Integer(getToken(1).beginColumn));
 	}
 |
 	LOOKAHEAD({ getToken(1).kind == CONTENT }) <CONTENT>
@@ -6749,7 +6751,9 @@
 		(getToken(1).kind != PRESERVE) })
 	{
 		throw StandardException.newException(
-			SQLState.LANG_XML_KEYWORD_MISSING, "PRESERVE WHITESPACE");
+			SQLState.LANG_XML_KEYWORD_MISSING, "PRESERVE WHITESPACE",
+			new Integer(getToken(1).beginLine),
+			new Integer(getToken(1).beginColumn));
 	}
 |
 	<STRIP> <WHITESPACE>
@@ -6810,10 +6814,12 @@
 	DataTypeDescriptor targetType;
 }
 {
-	LOOKAHEAD({ (getToken(1).kind != AS) || (getToken(2).kind == RIGHT_PAREN) })
+	LOOKAHEAD({ (getToken(1).kind != AS) })
 	{
 		throw StandardException.newException(
-			SQLState.LANG_XML_KEYWORD_MISSING, "AS");
+			SQLState.LANG_XML_KEYWORD_MISSING, "AS",
+			new Integer(getToken(1).beginLine),
+			new Integer(getToken(1).beginColumn));
 	}
 |
 	<AS> targetType = dataTypeDDL()

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties?view=diff&rev=448034&r1=448033&r2=448034
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties Tue Sep 19
19:40:57 2006
@@ -429,7 +429,7 @@
 01522=The newly defined synonym ''{0}'' resolved to the object ''{1}'' which is currently
undefined.
 01001=An attempt to update or delete an already deleted row was made: No row was updated
or deleted.
 01003=Null values were eliminated from the argument of a column function.
-01006=Privilege not revoked from {0}.
+01006=Privilege not revoked from user {0}.
 0100E=XX Attempt to return too many result sets. 
 02000=No row was found for FETCH, UPDATE or DELETE; or the result of a query is an empty
table.
 # Next one is generic XQuery error per SQL/XML[2006]
@@ -781,7 +781,7 @@
 # Derby-specific XML compile errors (42Z70 - 42Z7Z)
 42Z70=Binding directly to an XML value is not allowed; try using XMLPARSE.
 42Z71=XML values are not allowed in top-level result sets; try using XMLSERIALIZE.
-42Z72=XML syntax error; missing keyword(s): ''{0}''.
+42Z72=Missing SQL/XML keyword(s) ''{0}'' at line {1}, column {2}.
 42Z73=Invalid target type for XMLSERIALIZE: ''{0}''.
 42Z74=XML feature not supported: ''{0}''.
 42Z75=XML query expression must be a string literal.
@@ -1290,7 +1290,7 @@
 XJ212.S=Invalid attribute syntax: {0}
 XJ213.C=The traceLevel connection property does not have a valid format for a number.
 XJ214.S=An IO Error occurred when calling free() on a CLOB or BLOB.
-XJ215.S=You cannot invoke other Clob/Blob methods after calling free.
+XJ215.S=You cannot invoke other java.sql.Clob/java.sql.Blob methods after calling the free()
method.
 
 #XN - Network level messages
 XN001.S=Connection reset is not allowed when inside a unit of work.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/xml_general.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/xml_general.out?view=diff&rev=448034&r1=448033&r2=448034
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/xml_general.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/xml_general.out
Tue Sep 19 19:40:57 2006
@@ -170,9 +170,9 @@
 insert into t1 values (1, xmlparse(document '<hmm/>' strip whitespace));
 ERROR 42Z74: XML feature not supported: 'STRIP WHITESPACE'.
 ij> insert into t1 values (1, xmlparse(document '<hmm/>'));
-ERROR 42Z72: XML syntax error; missing keyword(s): 'PRESERVE WHITESPACE'.
+ERROR 42Z72: Missing SQL/XML keyword(s) 'PRESERVE WHITESPACE' at line 1, column 53.
 ij> insert into t1 values (1, xmlparse('<hmm/>' preserve whitespace));
-ERROR 42Z72: XML syntax error; missing keyword(s): 'DOCUMENT'.
+ERROR 42Z72: Missing SQL/XML keyword(s) 'DOCUMENT' at line 1, column 36.
 ij> insert into t1 values (1, xmlparse(content '<hmm/>' preserve whitespace));
 ERROR 42Z74: XML feature not supported: 'CONTENT'.
 ij> select xmlparse(document xmlparse(document '<hein/>' preserve whitespace) preserve
whitespace) from t1;
@@ -253,9 +253,9 @@
 1 row inserted/updated/deleted
 ij> -- These should fail.
 select xmlserialize(x) from t1;
-ERROR 42Z72: XML syntax error; missing keyword(s): 'AS'.
+ERROR 42Z72: Missing SQL/XML keyword(s) 'AS' at line 1, column 22.
 ij> select xmlserialize(x as) from t1;
-ERROR 42Z72: XML syntax error; missing keyword(s): 'AS'.
+ERROR 42X01: Syntax error: Encountered "" at line 1, column 25.
 ij> select xmlserialize(x as int) from t1;
 ERROR 42Z73: Invalid target type for XMLSERIALIZE: 'INTEGER'.
 ij> select xmlserialize(x as varchar(20) for bit data) from t1;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/xml_general.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/xml_general.out?view=diff&rev=448034&r1=448033&r2=448034
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/xml_general.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/xml_general.out
Tue Sep 19 19:40:57 2006
@@ -170,9 +170,9 @@
 insert into t1 values (1, xmlparse(document '<hmm/>' strip whitespace));
 ERROR 42Z74: XML feature not supported: 'STRIP WHITESPACE'.
 ij> insert into t1 values (1, xmlparse(document '<hmm/>'));
-ERROR 42Z72: XML syntax error; missing keyword(s): 'PRESERVE WHITESPACE'.
+ERROR 42Z72: Missing SQL/XML keyword(s) 'PRESERVE WHITESPACE' at line 1, column 53.
 ij> insert into t1 values (1, xmlparse('<hmm/>' preserve whitespace));
-ERROR 42Z72: XML syntax error; missing keyword(s): 'DOCUMENT'.
+ERROR 42Z72: Missing SQL/XML keyword(s) 'DOCUMENT' at line 1, column 36.
 ij> insert into t1 values (1, xmlparse(content '<hmm/>' preserve whitespace));
 ERROR 42Z74: XML feature not supported: 'CONTENT'.
 ij> select xmlparse(document xmlparse(document '<hein/>' preserve whitespace) preserve
whitespace) from t1;
@@ -254,9 +254,9 @@
 1 row inserted/updated/deleted
 ij> -- These should fail.
 select xmlserialize(x) from t1;
-ERROR 42Z72: XML syntax error; missing keyword(s): 'AS'.
+ERROR 42Z72: Missing SQL/XML keyword(s) 'AS' at line 2, column 22.
 ij> select xmlserialize(x as) from t1;
-ERROR 42Z72: XML syntax error; missing keyword(s): 'AS'.
+ERROR 42X01: Syntax error: Encountered "" at line 1, column 25.
 ij> select xmlserialize(x as int) from t1;
 ERROR 42Z73: Invalid target type for XMLSERIALIZE: 'INTEGER'.
 ij> select xmlserialize(x as varchar(20) for bit data) from t1;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/xml_general.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/xml_general.out?view=diff&rev=448034&r1=448033&r2=448034
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/xml_general.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/xml_general.out
Tue Sep 19 19:40:57 2006
@@ -172,9 +172,9 @@
 insert into t1 values (1, xmlparse(document '<hmm/>' strip whitespace));
 ERROR 42Z74: XML feature not supported: 'STRIP WHITESPACE'.
 ij> insert into t1 values (1, xmlparse(document '<hmm/>'));
-ERROR 42Z72: XML syntax error; missing keyword(s): 'PRESERVE WHITESPACE'.
+ERROR 42Z72: Missing SQL/XML keyword(s) 'PRESERVE WHITESPACE' at line 1, column 53.
 ij> insert into t1 values (1, xmlparse('<hmm/>' preserve whitespace));
-ERROR 42Z72: XML syntax error; missing keyword(s): 'DOCUMENT'.
+ERROR 42Z72: Missing SQL/XML keyword(s) 'DOCUMENT' at line 1, column 36.
 ij> insert into t1 values (1, xmlparse(content '<hmm/>' preserve whitespace));
 ERROR 42Z74: XML feature not supported: 'CONTENT'.
 ij> select xmlparse(document xmlparse(document '<hein/>' preserve whitespace) preserve
whitespace) from t1;
@@ -257,9 +257,9 @@
 1 row inserted/updated/deleted
 ij> -- These should fail.
 select xmlserialize(x) from t1;
-ERROR 42Z72: XML syntax error; missing keyword(s): 'AS'.
+ERROR 42Z72: Missing SQL/XML keyword(s) 'AS' at line 2, column 22.
 ij> select xmlserialize(x as) from t1;
-ERROR 42Z72: XML syntax error; missing keyword(s): 'AS'.
+ERROR 42X01: Syntax error: Encountered "" at line 1, column 25.
 ij> select xmlserialize(x as int) from t1;
 ERROR 42Z73: Invalid target type for XMLSERIALIZE: 'INTEGER'.
 ij> select xmlserialize(x as varchar(20) for bit data) from t1;



Mime
View raw message