Author: bpendleton
Date: Tue Jun 3 19:44:17 2008
New Revision: 662947
URL: http://svn.apache.org/viewvc?rev=662947&view=rev
Log:
DERBY-3097: Remove unnecessary if stmt from BaseActivation.getColumnFromRow
This change removes an unnecessary if statement from BaseActivation.java.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subqueryFlattening.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subqueryFlattening.sql
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java?rev=662947&r1=662946&r2=662947&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
Tue Jun 3 19:44:17 2008
@@ -1376,13 +1376,6 @@
protected final DataValueDescriptor getColumnFromRow(int rsNumber, int colId)
throws StandardException {
- if( row[rsNumber] == null)
- {
- /* This actually happens. NoPutResultSetImpl.clearOrderableCache attempts to
prefetch invariant values
- * into a cache. This fails in some deeply nested joins. See Beetle 4736 and
4880.
- */
- return null;
- }
return row[rsNumber].getColumn(colId);
}
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java?rev=662947&r1=662946&r2=662947&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/TableScanResultSet.java
Tue Jun 3 19:44:17 2008
@@ -1271,19 +1271,16 @@
if (positioner == null)
{
+ if (numOpens == 0)
+ return "\t" + MessageService.getTextMessage(
+ SQLState.LANG_POSITION_NOT_AVAIL) +
+ "\n";
try
{
positioner = (ExecIndexRow)positionGetter.invoke(activation);
}
catch (StandardException e)
{
- // the positionGetter will fail with a NullPointerException
- // if the outer table is empty
- // (this isn't a problem since we won't call it on the inner
- // table if there are no rows on the outer table)
- if (e.getSQLState() == SQLState.LANG_UNEXPECTED_USER_EXCEPTION )
- return "\t" + MessageService.getTextMessage(
- SQLState.LANG_POSITION_NOT_AVAIL);
return "\t" + MessageService.getTextMessage(
SQLState.LANG_UNEXPECTED_EXC_GETTING_POSITIONER,
e.toString());
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subqueryFlattening.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subqueryFlattening.out?rev=662947&r1=662946&r2=662947&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subqueryFlattening.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subqueryFlattening.out
Tue Jun 3 19:44:17 2008
@@ -7662,6 +7662,58 @@
0 rows inserted/updated/deleted
ij> drop table odd;
0 rows inserted/updated/deleted
+ij> -- regression test from old Cloudscape bug 4736 which demonstrates that
+-- the fix for DERBY-3097 is correct. This query used to cause a NPE in
+-- BaseActivation.getColumnFromRow, but the optimizer data structures are
+-- now generated correctly and the NPE no longer occurs.
+create table a (a1 int not null primary key, a2 int, a3 int, a4
+int, a5 int, a6 int);
+0 rows inserted/updated/deleted
+ij> create table b (b1 int not null primary key, b2 int, b3 int, b4
+int, b5 int, b6 int);
+0 rows inserted/updated/deleted
+ij> create table c (c1 int not null, c2 int, c3 int not null, c4
+int, c5 int, c6 int);
+0 rows inserted/updated/deleted
+ij> create table d (d1 int not null, d2 int, d3 int not null, d4
+int, d5 int, d6 int);
+0 rows inserted/updated/deleted
+ij> alter table c add primary key (c1,c3);
+0 rows inserted/updated/deleted
+ij> alter table d add primary key (d1,d3);
+0 rows inserted/updated/deleted
+ij> insert into a values
+(1,1,3,6,NULL,2),(2,3,2,4,2,2),(3,4,2,NULL,NULL,NULL),
+(4,NULL,4,2,5,2),(5,2,3,5,7,4),(7,1,4,2,3,4),
+ (8,8,8,8,8,8),(6,7,3,2,3,4);
+8 rows inserted/updated/deleted
+ij> insert into b values
+(6,7,2,3,NULL,1),(4,5,9,6,3,2),(1,4,2,NULL,NULL,NULL),
+(5,NULL,2,2,5,2),(3,2,3,3,1,4),(7,3,3,3,3,3),(9,3,3,3,3,3);
+7 rows inserted/updated/deleted
+ij> insert into c values
+(3,7,7,3,NULL,1),(8,3,9,1,3,2),(1,4,1,NULL,NULL,NULL),
+(3,NULL,1,2,4,2),(2,2,5,3,2,4),(1,7,2,3,1,1),(3,8,4,2,4,6);
+7 rows inserted/updated/deleted
+ij> insert into d values
+(1,7,2,3,NULL,3),(2,3,9,1,1,2),(2,2,2,NULL,3,2),
+(1,NULL,3,2,2,1),(2,2,5,3,2,3),(2,5,6,3,7,2);
+6 rows inserted/updated/deleted
+ij> select a1,b1,c1,c3,d1,d3
+ from D join (A left outer join (B join C on b2=c2) on a1=b1)
+on d3=b3 and d1=a2;
+A1 |B1 |C1 |C3 |D1 |D3
+-----------------------------------------------------------------------
+1 |1 |1 |1 |1 |2
+7 |7 |8 |9 |1 |3
+ij> drop table a;
+0 rows inserted/updated/deleted
+ij> drop table b;
+0 rows inserted/updated/deleted
+ij> drop table c;
+0 rows inserted/updated/deleted
+ij> drop table d;
+0 rows inserted/updated/deleted
ij> -- DERBY-3288: Optimizer does not correctly enforce EXISTS join order
-- dependencies in the face of "short-circuited" plans. In this test
-- an EXISTS subquery is flattened into the outer query and thus has
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subqueryFlattening.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subqueryFlattening.sql?rev=662947&r1=662946&r2=662947&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subqueryFlattening.sql
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/subqueryFlattening.sql
Tue Jun 3 19:44:17 2008
@@ -434,6 +434,55 @@
drop table digits;
drop table odd;
+-- regression test from old Cloudscape bug 4736 which demonstrates that
+-- the fix for DERBY-3097 is correct. This query used to cause a NPE in
+-- BaseActivation.getColumnFromRow, but the optimizer data structures are
+-- now generated correctly and the NPE no longer occurs.
+
+create table a (a1 int not null primary key, a2 int, a3 int, a4
+int, a5 int, a6 int);
+create table b (b1 int not null primary key, b2 int, b3 int, b4
+int, b5 int, b6 int);
+create table c (c1 int not null, c2 int, c3 int not null, c4
+int, c5 int, c6 int);
+create table d (d1 int not null, d2 int, d3 int not null, d4
+int, d5 int, d6 int);
+
+alter table c add primary key (c1,c3);
+alter table d add primary key (d1,d3);
+
+insert into a values
+(1,1,3,6,NULL,2),(2,3,2,4,2,2),(3,4,2,NULL,NULL,NULL),
+
+(4,NULL,4,2,5,2),(5,2,3,5,7,4),(7,1,4,2,3,4),
+ (8,8,8,8,8,8),(6,7,3,2,3,4);
+
+insert into b values
+(6,7,2,3,NULL,1),(4,5,9,6,3,2),(1,4,2,NULL,NULL,NULL),
+
+(5,NULL,2,2,5,2),(3,2,3,3,1,4),(7,3,3,3,3,3),(9,3,3,3,3,3);
+
+insert into c values
+(3,7,7,3,NULL,1),(8,3,9,1,3,2),(1,4,1,NULL,NULL,NULL),
+
+(3,NULL,1,2,4,2),(2,2,5,3,2,4),(1,7,2,3,1,1),(3,8,4,2,4,6);
+
+insert into d values
+(1,7,2,3,NULL,3),(2,3,9,1,1,2),(2,2,2,NULL,3,2),
+
+(1,NULL,3,2,2,1),(2,2,5,3,2,3),(2,5,6,3,7,2);
+
+
+
+select a1,b1,c1,c3,d1,d3
+ from D join (A left outer join (B join C on b2=c2) on a1=b1)
+on d3=b3 and d1=a2;
+
+drop table a;
+drop table b;
+drop table c;
+drop table d;
+
-- DERBY-3288: Optimizer does not correctly enforce EXISTS join order
-- dependencies in the face of "short-circuited" plans. In this test
-- an EXISTS subquery is flattened into the outer query and thus has
|