db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r826616 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ engine/org/apache/derby/loc/ shared/org/apache/derby/shared/common/reference/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Mon, 19 Oct 2009 09:30:00 GMT
Author: kahatlen
Date: Mon Oct 19 09:30:00 2009
New Revision: 826616

URL: http://svn.apache.org/viewvc?rev=826616&view=rev
Log:
DERBY-4407: StringIndexOutOfBoundsException in ij when result has no columns

Raise a compile-time error if a query returns no columns.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
    db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java?rev=826616&r1=826615&r2=826616&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/SelectNode.java Mon
Oct 19 09:30:00 2009
@@ -643,6 +643,13 @@
 		{
 			throw StandardException.newException(SQLState.LANG_TOO_MANY_ELEMENTS);
 		}
+
+        // DERBY-4407: A derived table must have at least one column.
+        if (resultColumns.size() == 0)
+        {
+            throw StandardException.newException(
+                    SQLState.LANG_EMPTY_COLUMN_LIST);
+        }
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml?rev=826616&r1=826615&r2=826616&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml Mon Oct 19 09:30:00
2009
@@ -1895,6 +1895,11 @@
             </msg>
 
             <msg>
+                <name>42X81</name>
+                <text>A query expression must return at least one column.</text>
+            </msg>
+
+            <msg>
                 <name>42X82</name>
                 <text>The USING clause returned more than one row. Only single-row
ResultSets are permissible.</text>
             </msg>

Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java?rev=826616&r1=826615&r2=826616&view=diff
==============================================================================
--- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
(original)
+++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
Mon Oct 19 09:30:00 2009
@@ -882,6 +882,7 @@
 	String LANG_DISTINCT_ORDER_BY                                      = "42879";
 	String LANG_DISTINCT_ORDER_BY_EXPRESSION                           = "4287A";
 	String LANG_EMPTY_VALUES_CLAUSE                                    = "42X80";
+	String LANG_EMPTY_COLUMN_LIST                                      = "42X81";
 	String LANG_USING_CARDINALITY_VIOLATION                            = "42X82";
 	String LANG_ADDING_COLUMN_WITH_NULL_AND_NOT_NULL_CONSTRAINT        = "42X83";
 	String LANG_CANT_DROP_BACKING_INDEX                                = "42X84";

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java?rev=826616&r1=826615&r2=826616&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/JoinTest.java
Mon Oct 19 09:30:00 2009
@@ -38,6 +38,7 @@
     private static final String AMBIGUOUS_COLNAME = "42X03";
     private static final String COLUMN_NOT_IN_SCOPE = "42X04";
     private static final String NON_COMPARABLE = "42818";
+    private static final String NO_COLUMNS = "42X81";
 
     public JoinTest(String name) {
         super(name);
@@ -641,5 +642,15 @@
         // of the columns to use.
         assertStatementError(AMBIGUOUS_COLNAME, s,
                 "select * from (t1 cross join t2) join t2 tt2 using(b)");
+
+        // DERBY-4407: If all the columns of table X are in the USING clause,
+        // X.* will expand to no columns. A result should always have at least
+        // one column.
+        assertStatementError(NO_COLUMNS, s,
+                "select x.* from t1 x inner join t1 y using (a,b,c)");
+        assertStatementError(NO_COLUMNS, s,
+                "select x.* from t1 x left join t1 y using (a,b,c)");
+        assertStatementError(NO_COLUMNS, s,
+                "select x.* from t1 x right join t1 y using (a,b,c)");
     }
 }



Mime
View raw message