db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Hillegas (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-6593) NPE when joining table with Lucene VTI
Date Tue, 03 Jun 2014 18:25:02 GMT

    [ https://issues.apache.org/jira/browse/DERBY-6593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14016953#comment-14016953
] 

Rick Hillegas commented on DERBY-6593:
--------------------------------------

Thanks for logging this issue, Knut. As you suggest, this is not a problem with the Lucene
plugin. It is a general problem with all table functions and is another example of a table
function accepting an argument which is not constant in its query block. This usage falls
outside the SQL Standard.

I can reproduce this problem without the Lucene plugin as follows. First, compile the following
class…

{noformat}
import java.sql.*;

public class QueryVTI
{
    public  static  ResultSet   query( String query )
        throws SQLException
    {
        Connection          conn = DriverManager.getConnection( "jdbc:default:connection"
);
        PreparedStatement   ps = conn.prepareStatement( query );

        return ps.executeQuery();
    }
}
{noformat}

Then run the following script. The last select raises the same NPE…

{noformat}
connect 'jdbc:derby:memory:db;create=true';

create function oneColumnQuery( queryText varchar( 32672 ) ) returns table
(
    a int
)
language java parameter style derby_jdbc_result_set reads sql data
external name 'QueryVTI.query';

create table s( a int );
insert into s values ( 1 );

create table t( id int primary key, x varchar( 20 ) );
insert into t values ( 1, 'select * from s' );

-- this works
select * from table ( oneColumnQuery( 'select * from s' ) ) lt;

-- but this raises an npe. it is an attempt to execute a table function
-- using a parameter which is out of scope.
select * from t natural join
( select * from table ( oneColumnQuery( t.x ) ) lt ) lt;
{noformat}



> NPE when joining table with Lucene VTI
> --------------------------------------
>
>                 Key: DERBY-6593
>                 URL: https://issues.apache.org/jira/browse/DERBY-6593
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.11.0.0
>            Reporter: Knut Anders Hatlen
>
> I'm seeing a NullPointerException when joining a table with a Lucene VTI.
> Here's a script that reproduces the NPE:
> {noformat}
> ij version 10.11
> ij> connect 'jdbc:derby:memory:db;create=true';
> ij> create table t(id int primary key, x varchar(20));
> 0 rows inserted/updated/deleted
> ij> insert into t values (1, 'abc');
> 1 row inserted/updated/deleted
> ij> call syscs_util.syscs_register_tool( 'luceneSupport', true );
> 0 rows inserted/updated/deleted
> ij> call lucenesupport.createindex('app', 't', 'x', null);
> 0 rows inserted/updated/deleted
> ij> select * from t natural join (select * from table (t__x(t.x, null, 100, null))
lt) lt;
> ERROR 38000: The exception 'java.lang.NullPointerException' was thrown while evaluating
an expression.
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
> {noformat}
> Full stack trace:
> {noformat}
> java.lang.NullPointerException
> 	at org.apache.derby.iapi.types.DataType.setValue(DataType.java:537)
> 	at org.apache.derby.exe.aced8940a7x0146x5c7fx5474x0000188928898.g0(Unknown Source)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:483)
> 	at org.apache.derby.impl.services.reflect.ReflectMethod.invoke(ReflectMethod.java:46)
> 	at org.apache.derby.impl.sql.execute.VTIResultSet.openCore(VTIResultSet.java:251)
> 	at org.apache.derby.impl.sql.execute.JoinResultSet.openCore(JoinResultSet.java:146)
> 	at org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.openCore(ProjectRestrictResultSet.java:181)
> 	at org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.open(BasicNoPutResultSetImpl.java:266)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:470)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:349)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1338)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:704)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:631)
> 	at org.apache.derby.impl.tools.ij.ij.executeImmediate(ij.java:367)
> 	at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:527)
> 	at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:372)
> 	at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:245)
> 	at org.apache.derby.impl.tools.ij.Main.go(Main.java:229)
> 	at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:184)
> 	at org.apache.derby.impl.tools.ij.Main.main(Main.java:75)
> 	at org.apache.derby.tools.ij.main(ij.java:59)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message