db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stanislav Bryzgalov" <lef...@gmail.com>
Subject NPE on an innocent query
Date Thu, 09 Oct 2008 17:29:58 GMT
Hello,

I am getting an NPE when trying to run a pretty innocent query. I suspect
this might be because of the platform I am using which is JDK 1.5 "diablo"
on FreeBSD. I got it first on 10.3.2.1, then upgraded to 10.4.2.0 but the
problem did not go away.

After some playing, I narrowed the problem down do a pretty simple example.
Can someone run it please and share results.

-- create two simple tables
CREATE TABLE T1( D1 DATE NOT NULL PRIMARY KEY, N1 VARCHAR( 10 ) );
CREATE TABLE T2( D2 DATE NOT NULL PRIMARY KEY, N2 VARCHAR( 10 ) );

-- insert some data, two recs in T1 and one in T2
INSERT INTO T1 VALUES( DATE( '2008-10-01' ), 'something' ), ( DATE(
'2008-10-02' ), 'something' );
INSERT INTO T2 VALUES( DATE( '2008-10-01' ), 'something' );

-- this runs fine, gives one record '2008-10-02'
SELECT T1.D1
  FROM T1
  LEFT JOIN T2
  ON T1.D1 = T2.D2
  WHERE T2.D2 IS NULL;

-- this runs fine too, gives one record '2008-10-02'
SELECT MAX( T1.D1 ) as D
  FROM T1
  WHERE T1.D1 NOT IN ( SELECT T2.D2 FROM T2 );

-- this one breaks!!!
-- SQL State = XJ001 SQL Code = -1 SQL Message = DERBY SQL error: SQLCODE:
-1, SQLSTATE: XJ001, SQLERRMC: java.lang.NullPointerException
SELECT MAX( T1.D1 ) AS D
  FROM T1
  LEFT JOIN T2
  ON T1.D1 = T2.D2
  WHERE T2.D2 IS NULL;

My derby.log has this:

2008-10-09 17:11:58.357 GMT Thread[DRDAConnThread_3,5,main] (XID = 7676),
(SESSIONID = 0), (DATABASE = coco2), (DRDAID =
NF000001.E6C3-4327113593400890529{19}), Failed Statement is: SELECT MAX(
T1.D1 ) AS D
  FROM T1
  LEFT JOIN T2
  ON T1.D1 = T2.D2
  WHERE T2.D2 IS NULL
java.lang.NullPointerException
 at
org.apache.derby.impl.sql.compile.GroupByNode.considerPostOptimizeOptimizations(Unknown
Source)
 at org.apache.derby.impl.sql.compile.SelectNode.genProjectRestrict(Unknown
Source)
 at org.apache.derby.impl.sql.compile.SelectNode.modifyAccessPaths(Unknown
Source)
 at
org.apache.derby.impl.sql.compile.DMLStatementNode.optimizeStatement(Unknown
Source)
 at org.apache.derby.impl.sql.compile.CursorNode.optimizeStatement(Unknown
Source)
 at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
 at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
 at
org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(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.prepareStatement(Unknown
Source)
 at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown
Source)
 at org.apache.derby.impl.drda.DRDAStatement.prepare(Unknown Source)
 at org.apache.derby.impl.drda.DRDAStatement.explicitPrepare(Unknown Source)
 at org.apache.derby.impl.drda.DRDAConnThread.parsePRPSQLSTT(Unknown Source)
 at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown
Source)
 at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)

WBR,
   Stanislav

Mime
View raw message