You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2006/07/03 04:37:44 UTC
svn commit: r418672 - in /db/derby/code/trunk/java:
engine/org/apache/derby/impl/sql/compile/
testing/org/apache/derbyTesting/functionTests/master/
testing/org/apache/derbyTesting/functionTests/master/j9_13/
testing/org/apache/derbyTesting/functionTest...
Author: kmarsden
Date: Sun Jul 2 19:37:42 2006
New Revision: 418672
URL: http://svn.apache.org/viewvc?rev=418672&view=rev
Log:
DERBY-578 - Grouped select from temporary table raises null pointer exception in byte code generator
DERBY-1464 - runtimestatistics can show that an index is being used even when it isn't
Contributed by Manish Khettry
The problem is simple enough-- we didn't have a conglomerate name for temporary tables. I fixed the code to behave more like what fillInScanArgs does.
Earlier, we would set the indexName field in DistinctScanResult to the conglomerate name (cd.getName()) used to scan the table. If the conglomerate was the base table itself then this was just plain wrong. The change, for this patch, passes null if no index is being used.
Modified:
db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/distinct.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/distinctElimination.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/distinct.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_22/distinct.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/predicatePushdown.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/distinct.sql
db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java
Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java?rev=418672&r1=418671&r2=418672&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromBaseTable.java Sun Jul 2 19:37:42 2006
@@ -3085,8 +3085,33 @@
{
return getTrulyTheBestAccessPath().getCostEstimate();
}
-
- private void generateMaxSpecialResultSet
+
+ /* helper method used by generateMaxSpecialResultSet and
+ * generateDistinctScan to return the name of the index if the
+ * conglomerate is an index.
+ * @param cd Conglomerate for which we need to push the index name
+ * @param mb Associated MethodBuilder
+ * @throws StandardException
+ */
+ private void pushIndexName(ConglomerateDescriptor cd, MethodBuilder mb)
+ throws StandardException
+ {
+ if (cd.isConstraint()) {
+ DataDictionary dd = getDataDictionary();
+ ConstraintDescriptor constraintDesc =
+ dd.getConstraintDescriptor(tableDescriptor, cd.getUUID());
+ mb.push(constraintDesc.getConstraintName());
+ } else if (cd.isIndex()) {
+ mb.push(cd.getConglomerateName());
+ } else {
+ // If the conglomerate is the base table itself, make sure we push null.
+ // Before the fix for DERBY-578, we would push the base table name
+ // and this was just plain wrong and would cause statistics information to be incorrect.
+ mb.pushNull("java.lang.String");
+ }
+ }
+
+ private void generateMaxSpecialResultSet
(
ExpressionClassBuilder acb,
MethodBuilder mb
@@ -3106,7 +3131,8 @@
** resultSetNumber,
** resultRowAllocator,
** conglomereNumber,
- ** tableName,
+ ** tableName,
+ ** optimizeroverride
** indexName,
** colRefItem,
** lockMode,
@@ -3132,7 +3158,7 @@
mb.push(org.apache.derby.iapi.util.PropertyUtil.sortProperties(tableProperties));
else
mb.pushNull("java.lang.String");
- mb.push(cd.getConglomerateName());
+ pushIndexName(cd, mb);
mb.push(colRefItem);
mb.push(getTrulyTheBestAccessPath().getLockMode());
mb.push(tableLockGranularity);
@@ -3167,7 +3193,8 @@
** resultSetNumber,
** resultRowAllocator,
** conglomereNumber,
- ** tableName,
+ ** tableName,
+ ** optimizeroverride
** indexName,
** colRefItem,
** lockMode,
@@ -3226,7 +3253,7 @@
mb.push(org.apache.derby.iapi.util.PropertyUtil.sortProperties(tableProperties));
else
mb.pushNull("java.lang.String");
- mb.push(cd.getConglomerateName());
+ pushIndexName(cd, mb);
mb.push(cd.isConstraint());
mb.push(colRefItem);
mb.push(getTrulyTheBestAccessPath().getLockMode());
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/distinct.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/distinct.out?rev=418672&r1=418671&r2=418672&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/distinct.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/distinct.out Sun Jul 2 19:37:42 2006
@@ -2614,7 +2614,7 @@
Begin Execution Timestamp : null
End Execution Timestamp : null
Statement Execution Plan Text:
-Distinct Scan ResultSet for NAMES using index xxxxFILTERED-UUIDxxxx at read committed isolation level using instantaneous share row locking:
+Distinct Scan ResultSet for NAMES at read committed isolation level using instantaneous share row locking:
Number of opens = 1
Hash table size = 3
Distinct column is column number 1
@@ -2633,10 +2633,8 @@
Number of rows visited=6
Scan type=heap
start position:
- None
- stop position:
- None
- scan qualifiers:
+null stop position:
+null scan qualifiers:
None
next qualifiers:
None
@@ -2681,7 +2679,7 @@
restriction time (milliseconds) = 0
projection time (milliseconds) = 0
Source result set:
- Distinct Scan ResultSet for NAMES using index xxxxFILTERED-UUIDxxxx at read committed isolation level using instantaneous share row locking:
+ Distinct Scan ResultSet for NAMES at read committed isolation level using instantaneous share row locking:
Number of opens = 1
Hash table size = 6
Distinct columns are column numbers (0,1)
@@ -2700,10 +2698,8 @@
Number of rows visited=6
Scan type=heap
start position:
- None
- stop position:
- None
- scan qualifiers:
+null stop position:
+null scan qualifiers:
None
next qualifiers:
None
@@ -2784,6 +2780,14 @@
0 rows inserted/updated/deleted
ij> drop table names;
0 rows inserted/updated/deleted
+ij> -- bug 578.
+declare global temporary table session.ztemp
+( orderID varchar( 50 ) )
+not logged;
+0 rows inserted/updated/deleted
+ij> select orderID from session.ztemp group by orderID;
+ORDERID
+--------------------------------------------------
ij> -- reset autocommit
autocommit on;
ij>
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/distinctElimination.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/distinctElimination.out?rev=418672&r1=418671&r2=418672&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/distinctElimination.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/distinctElimination.out Sun Jul 2 19:37:42 2006
@@ -134,7 +134,7 @@
Begin Execution Timestamp : null
End Execution Timestamp : null
Statement Execution Plan Text:
-Distinct Scan ResultSet for ONE using index xxxxFILTERED-UUIDxxxx at serializable isolation level using share table locking:
+Distinct Scan ResultSet for ONE at serializable isolation level using share table locking:
Number of opens = 1
Hash table size = 1
Distinct column is column number 1
@@ -153,10 +153,8 @@
Number of rows visited=8
Scan type=heap
start position:
- None
- stop position:
- None
- scan qualifiers:
+null stop position:
+null scan qualifiers:
None
next qualifiers:
None
@@ -219,7 +217,7 @@
Rows inserted = 3
Indexes updated = 0
Execute Time = 0
- Distinct Scan ResultSet for TWO using index xxxxFILTERED-UUIDxxxx at serializable isolation level using share table locking:
+ Distinct Scan ResultSet for TWO at serializable isolation level using share table locking:
Number of opens = 1
Hash table size = 3
Distinct columns are column numbers (1,2)
@@ -238,10 +236,8 @@
Number of rows visited=9
Scan type=heap
start position:
- None
- stop position:
- None
- scan qualifiers:
+null stop position:
+null scan qualifiers:
None
next qualifiers:
None
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/distinct.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/distinct.out?rev=418672&r1=418671&r2=418672&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/distinct.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/distinct.out Sun Jul 2 19:37:42 2006
@@ -2614,7 +2614,7 @@
Begin Execution Timestamp : null
End Execution Timestamp : null
Statement Execution Plan Text:
-Distinct Scan ResultSet for NAMES using index xxxxFILTERED-UUIDxxxx at read committed isolation level using instantaneous share row locking:
+Distinct Scan ResultSet for NAMES at read committed isolation level using instantaneous share row locking:
Number of opens = 1
Hash table size = 3
Distinct column is column number 1
@@ -2633,10 +2633,8 @@
Number of rows visited=6
Scan type=heap
start position:
- None
- stop position:
- None
- scan qualifiers:
+null stop position:
+null scan qualifiers:
None
next qualifiers:
None
@@ -2681,7 +2679,7 @@
restriction time (milliseconds) = 0
projection time (milliseconds) = 0
Source result set:
- Distinct Scan ResultSet for NAMES using index xxxxFILTERED-UUIDxxxx at read committed isolation level using instantaneous share row locking:
+ Distinct Scan ResultSet for NAMES at read committed isolation level using instantaneous share row locking:
Number of opens = 1
Hash table size = 6
Distinct columns are column numbers (0,1)
@@ -2700,10 +2698,8 @@
Number of rows visited=6
Scan type=heap
start position:
- None
- stop position:
- None
- scan qualifiers:
+null stop position:
+null scan qualifiers:
None
next qualifiers:
None
@@ -2784,6 +2780,14 @@
0 rows inserted/updated/deleted
ij> drop table names;
0 rows inserted/updated/deleted
+ij> -- bug 578.
+declare global temporary table session.ztemp
+( orderID varchar( 50 ) )
+not logged;
+0 rows inserted/updated/deleted
+ij> select orderID from session.ztemp group by orderID;
+ORDERID
+--------------------------------------------------
ij> -- reset autocommit
autocommit on;
ij>
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_22/distinct.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_22/distinct.out?rev=418672&r1=418671&r2=418672&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_22/distinct.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_22/distinct.out Sun Jul 2 19:37:42 2006
@@ -2784,6 +2784,14 @@
0 rows inserted/updated/deleted
ij> drop table names;
0 rows inserted/updated/deleted
+ij> -- bug 578.
+declare global temporary table session.ztemp
+( orderID varchar( 50 ) )
+not logged;
+0 rows inserted/updated/deleted
+ij> select orderID from session.ztemp group by orderID;
+ORDERID
+--------------------------------------------------
ij> -- reset autocommit
autocommit on;
ij>
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/predicatePushdown.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/predicatePushdown.out?rev=418672&r1=418671&r2=418672&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/predicatePushdown.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/predicatePushdown.out Sun Jul 2 19:37:42 2006
@@ -9052,7 +9052,7 @@
next time (milliseconds) = 0
close time (milliseconds) = 0
Left result set:
- Distinct Scan ResultSet for T1 using index xxxxFILTERED-UUIDxxxx at read committed isolation level using instantaneous share row locking:
+ Distinct Scan ResultSet for T1 at read committed isolation level using instantaneous share row locking:
Number of opens = 1
Hash table size = 5
Distinct columns are column numbers (0,1)
@@ -9071,10 +9071,8 @@
Number of rows visited=5
Scan type=heap
start position:
- None
- stop position:
- None
- scan qualifiers:
+null stop position:
+null scan qualifiers:
None
next qualifiers:
None
@@ -9092,7 +9090,7 @@
restriction time (milliseconds) = 0
projection time (milliseconds) = 0
Source result set:
- Distinct Scan ResultSet for T3 using index xxxxFILTERED-UUIDxxxx at read committed isolation level using instantaneous share row locking:
+ Distinct Scan ResultSet for T3 at read committed isolation level using instantaneous share row locking:
Number of opens = 5
Hash table size = 99
Distinct columns are column numbers (0,1)
@@ -9111,10 +9109,8 @@
Number of rows visited=54579
Scan type=heap
start position:
- None
- stop position:
- None
- scan qualifiers:
+null stop position:
+null scan qualifiers:
None
next qualifiers:
None
@@ -9219,7 +9215,7 @@
next time (milliseconds) = 0
close time (milliseconds) = 0
Left result set:
- Distinct Scan ResultSet for T2 using index xxxxFILTERED-UUIDxxxx at read committed isolation level using instantaneous share row locking:
+ Distinct Scan ResultSet for T2 at read committed isolation level using instantaneous share row locking:
Number of opens = 1
Hash table size = 5
Distinct columns are column numbers (0,1)
@@ -9238,15 +9234,13 @@
Number of rows visited=5
Scan type=heap
start position:
- None
- stop position:
- None
- scan qualifiers:
+null stop position:
+null scan qualifiers:
None
next qualifiers:
None
Right result set:
- Distinct Scan ResultSet for T1 using index xxxxFILTERED-UUIDxxxx at read committed isolation level using instantaneous share row locking:
+ Distinct Scan ResultSet for T1 at read committed isolation level using instantaneous share row locking:
Number of opens = 5
Hash table size = 5
Distinct columns are column numbers (0,1)
@@ -9265,10 +9259,8 @@
Number of rows visited=5
Scan type=heap
start position:
- None
- stop position:
- None
- scan qualifiers:
+null stop position:
+null scan qualifiers:
None
next qualifiers:
None
@@ -9286,7 +9278,7 @@
restriction time (milliseconds) = 0
projection time (milliseconds) = 0
Source result set:
- Distinct Scan ResultSet for T3 using index xxxxFILTERED-UUIDxxxx at read committed isolation level using instantaneous share row locking:
+ Distinct Scan ResultSet for T3 at read committed isolation level using instantaneous share row locking:
Number of opens = 25
Hash table size = 99
Distinct columns are column numbers (0,1)
@@ -9305,10 +9297,8 @@
Number of rows visited=54579
Scan type=heap
start position:
- None
- stop position:
- None
- scan qualifiers:
+null stop position:
+null scan qualifiers:
None
next qualifiers:
None
@@ -9326,7 +9316,7 @@
restriction time (milliseconds) = 0
projection time (milliseconds) = 0
Source result set:
- Distinct Scan ResultSet for T4 using index xxxxFILTERED-UUIDxxxx at read committed isolation level using instantaneous share row locking:
+ Distinct Scan ResultSet for T4 at read committed isolation level using instantaneous share row locking:
Number of opens = 20
Hash table size = 92
Distinct columns are column numbers (0,1)
@@ -9345,10 +9335,8 @@
Number of rows visited=48812
Scan type=heap
start position:
- None
- stop position:
- None
- scan qualifiers:
+null stop position:
+null scan qualifiers:
None
next qualifiers:
None
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out?rev=418672&r1=418671&r2=418672&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/subquery.out Sun Jul 2 19:37:42 2006
@@ -959,7 +959,7 @@
next time (milliseconds) = 0
close time (milliseconds) = 0
Left result set:
- Distinct Scan ResultSet for T1 using index xxxxFILTERED-UUIDxxxx at read committed isolation level using instantaneous share row locking:
+ Distinct Scan ResultSet for T1 at read committed isolation level using instantaneous share row locking:
Number of opens = 1
Hash table size = 5
Distinct columns are column numbers (0,1)
@@ -978,10 +978,8 @@
Number of rows visited=5
Scan type=heap
start position:
- None
- stop position:
- None
- scan qualifiers:
+null stop position:
+null scan qualifiers:
None
next qualifiers:
None
@@ -999,7 +997,7 @@
restriction time (milliseconds) = 0
projection time (milliseconds) = 0
Source result set:
- Distinct Scan ResultSet for T3 using index xxxxFILTERED-UUIDxxxx at read committed isolation level using instantaneous share row locking:
+ Distinct Scan ResultSet for T3 at read committed isolation level using instantaneous share row locking:
Number of opens = 5
Hash table size = 9
Distinct columns are column numbers (0,1)
@@ -1018,10 +1016,8 @@
Number of rows visited=9
Scan type=heap
start position:
- None
- stop position:
- None
- scan qualifiers:
+null stop position:
+null scan qualifiers:
None
next qualifiers:
None
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/distinct.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/distinct.sql?rev=418672&r1=418671&r2=418672&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/distinct.sql (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/distinct.sql Sun Jul 2 19:37:42 2006
@@ -377,5 +377,12 @@
drop table names;
+-- bug 578.
+declare global temporary table session.ztemp
+( orderID varchar( 50 ) )
+not logged;
+
+select orderID from session.ztemp group by orderID;
+
-- reset autocommit
autocommit on;
Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java?rev=418672&r1=418671&r2=418672&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java Sun Jul 2 19:37:42 2006
@@ -64,6 +64,9 @@
public void setFramework(String fm)
{
+ if (fm == null) {
+ return;
+ }
framework = fm.toUpperCase(Locale.ENGLISH);
if (framework.endsWith("NET") ||
framework.equals("DB2JCC"))