Hi, I have a case where I get ArrayIndexOutOfBoundsException in GenericParameterValueSet.initialize after a call to DatabaseMetaData.getIndexInfo() in 10.2.2.0. I am completely unable to reproduce the bug (I create the exact same schema with the exact same number of sesions and the same different metadata calls). The actual case bails out each time while my repro code works every time (on the same VM the same OS). The stack dump is at the end.
I have found that the cause is a call to
ExecPreparedStatement.getParameterTypes() returning a zero length
array when called from BaseActivation.setupActivation. The app in
quiestion works for Derby 10.1.2. I have also found that
BaseActivation.setupActivation was changed in Dec 2005.
Does anyone have any ideas of how I can track down this one?
$ svn diff -r354141:354142 BaseActivation.java
------------------------------------------------------------------------
r354142 | djd | 2005-12-05 20:33:06 +0100 (Mon, 05 Dec 2005) | 7 lines
DERBY-738 Remove use of generated code per parameter for initiailizing
parameters.
Previously the language compiler would generate some amount of code per paramter
in order to set up the parameter with a holder DataValueDescriptor of the
correct type.
This patch changes the parameter set to be initialized when the activation is
linked
to the language PreparedStatement (plan) utilizing the list of parameter types
the plan has.
Thus no generated code is needed per parameter for set up.
------------------------------------------------------------------------
$ svn diff -r354141:354142 BaseActivation.java
Index: BaseActivation.java
===================================================================
--- BaseActivation.java (revision 354141)
+++ BaseActivation.java (revision 354142)
@@ -274,11 +274,17 @@
*/
public final void setupActivation(ExecPreparedStatement ps, boolean
scrollable) {
preStmt = ps;
-
+
if (ps != null) {
// get the result set description
resultDescription = ps.getResultDescription();
this.scrollable = scrollable;
+
+ // Initialize the parameter set to have allocated
+ // DataValueDescriptor objects for each parameter.
+ if (pvs != null && pvs.getParameterCount() != 0)
+ pvs.initialize(ps.getParameterTypes());
+
} else {
resultDescription = null;
this.scrollable = false;
@@ -1215,7 +1221,7 @@
pvs = lcc.getLanguageFactory().newParameterValueSet(
lcc.getLanguageConnectionFactory().getClassFactory().getClassInspector(),
paramCount, hasReturnParam);
- }
+ }
/**
return the parameters.
==========================================================================
2007-04-17 16:20:20.191 GMT Thread[DRDAConnThread_5,5,main] (XID = 1554),
(SESSIONID = 10), (DATABASE = communitymc_portal1), (DRDAID =
C0124DC3.H92B-954198994222304164{11}), Failed Statement is: CALL
SYSIBM.SQLSTATISTICS(?,?,?,?,?,?) with 6 parameters begin parameter #1: null
:end parameter begin parameter #2: PORTAL :end parameter begin parameter #3:
COMMUNITY :end parameter begin parameter #4: 1 :end parameter begin parameter
#5: 1 :end parameter begin parameter #6:
DATATYPE='JDBC';DYNAMIC=0;REPORTPUBLICPRIVILEGES=1;CURSORHOLD=1 :end parameter
java.lang.ArrayIndexOutOfBoundsException: 0
at
org.apache.derby.impl.sql.GenericParameterValueSet.initialize(Unknown Source)
at
org.apache.derby.impl.sql.execute.BaseActivation.setupActivation(Unknown Source)
at org.apache.derby.impl.sql.GenericActivationHolder.<init>(Unknown
Source)
at
org.apache.derby.impl.sql.GenericPreparedStatement.getActivation(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.<init>(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.<init>(Unknown
Source)
at org.apache.derby.jdbc.Driver30.newEmbedPreparedStatement(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedConnection.prepareMetaDataStatement(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.prepareSPS(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.getPreparedQueryUsingSystemTables(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.getPreparedQuery(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.getPreparedQuery(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.doGetIndexInfo(Unknown Source)
at
org.apache.derby.impl.jdbc.EmbedDatabaseMetaData.getIndexInfo(Unknown Source)
at org.apache.derby.catalog.SystemProcedures.SQLSTATISTICS(Unknown
Source)
at
org.apache.derby.exe.ac72e9c096x0112x0056x2b09xffffcd3424e39.g0(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.derby.impl.services.reflect.ReflectMethod.invoke(Unknown
Source)
at
org.apache.derby.impl.sql.execute.CallStatementResultSet.open(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedCallableStatement.executeStatement(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(Unknown
Source)
at org.apache.derby.impl.drda.DRDAStatement.execute(Unknown Source)
at
org.apache.derby.impl.drda.DRDAConnThread.parseEXCSQLSTTobjects(Unknown Source)
at org.apache.derby.impl.drda.DRDAConnThread.parseEXCSQLSTT(Unknown
Source)
at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown
Source)
at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
--
Bernt Marius Johnsen, Database Technology Group,
Staff Engineer, Technical Lead Derby/Java DB
Sun Microsystems, Trondheim, Norway
pgp0gw1KfJ5ba.pgp
Description: PGP signature
