db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mamta A. Satoor (JIRA)" <derby-...@db.apache.org>
Subject [jira] Updated: (DERBY-1707) Specifying an incorrect optimizer property (constraint=null) gives NullPointerException
Date Tue, 12 Sep 2006 11:56:23 GMT
     [ http://issues.apache.org/jira/browse/DERBY-1707?page=all ]

Mamta A. Satoor updated DERBY-1707:
-----------------------------------

    Attachment: DERBY1707ConstraintNullPropertyV1diff.txt

I have a patch for this Jira entry which is very trivial. Basically, FromBaseTable.verifyProperties
method had following if condition

  if (constraintSpecified)
  {
   ConglomerateDescriptor cd = 
    dDictionary.getConglomerateDescriptor(
     consDesc.getConglomerateId());
   String indexName = cd.getConglomerateName();
   tableProperties.remove("constraint");
   tableProperties.put("index", indexName);
  }


The if condition above did not do null check for consDesc. In Sunitha's case, her sql statement
looked as follows
SELECT * FROM t1 --DERBY-PROPERTIES constraint=null 
;
When null value is supplied for constraint property, consDesc will be null and the code inside
the if condition above should not be executed. I changed the if condition above as follows
  if (constraintSpecified && consDesc != null)
and now constraint=nulll does not result in null pointer exception. I added a test case for
this in lang/optimizerOverrides.sql and noticed that constraint=null resulted in an index
scan. There is already a test which checks for index=null and that property results in a table
scan. This behavior seems to be in line with the documentation in Tuning Derby Guide for 10.2
(section name Overriding the default optimizer behavior) which says that if null is specified
for property index, a table scan will be performed on the table. It does not say anything
about a table scan for constraint=null
 
The files affected by this change are as follows
M      java\engine\org\apache\derby\impl\sql\compile\FromBaseTable.java
M      java\testing\org\apache\derbyTesting\functionTests\tests\lang\optimizerOverrides.sql
M      java\testing\org\apache\derbyTesting\functionTests\master\DerbyNet\optimizerOverrides.out
M      java\testing\org\apache\derbyTesting\functionTests\master\optimizerOverrides.out
M      java\testing\org\apache\derbyTesting\functionTests\master\DerbyNetClient\optimizerOverrides.out

The patch is attached as DERBY1707ConstraintNullPropertyV1diff.txt

Please review the patch and commit it if it looks ready.


> Specifying an incorrect optimizer property (constraint=null) gives NullPointerException
> ---------------------------------------------------------------------------------------
>
>                 Key: DERBY-1707
>                 URL: http://issues.apache.org/jira/browse/DERBY-1707
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.2.1.0, 10.3.0.0
>            Reporter: Deepa Remesh
>         Assigned To: Mamta A. Satoor
>         Attachments: DERBY1707ConstraintNullPropertyV1diff.txt, illegal_overrides.sql
>
>
> After we get the NPE, any other operation gives:
> ERROR 40XT0: An internal error was identified by RawStore module.
> Specifying constraint=null as an optimizer override is actually a usage error. I tried
this thinking it is allowed like index=null which can be used to force a table scan. But specifying
constraint=null gives a NPE and other operations give the above error. I am attaching a repro
'illegal_overrides.sql'. 
> Found this when testing with 10.2.1.0 beta. Stack traces below:
> ij> --- specifying null value for constraint gives NPE
> SELECT * FROM t1 --DERBY-PROPERTIES constraint=null
> ;
> ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
> java.lang.NullPointerException
>         at org.apache.derby.impl.sql.compile.FromBaseTable.verifyProperties(Unknown Source)
>         at org.apache.derby.impl.sql.compile.ProjectRestrictNode.verifyProperties(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.FromList.verifyProperties(Unknown Source)
>         at org.apache.derby.impl.sql.compile.OptimizerImpl.<init>(Unknown Source)
>         at org.apache.derby.impl.sql.compile.Level2OptimizerImpl.<init>(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.Level2OptimizerFactoryImpl.getOptimizerImpl(Unknown
Sou
> rce)
>         at org.apache.derby.impl.sql.compile.OptimizerFactoryImpl.getOptimizer(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.ResultSetNode.getOptimizer(Unknown Source)
>         at org.apache.derby.impl.sql.compile.SelectNode.optimize(Unknown Source)
>         at org.apache.derby.impl.sql.compile.DMLStatementNode.optimize(Unknown Source)
>         at org.apache.derby.impl.sql.compile.CursorNode.optimize(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.EmbedStatement.execute(Unknown Source)
>         at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
>         at org.apache.derby.impl.tools.ij.ij.executeImmediate(Unknown Source)
>         at org.apache.derby.impl.tools.ij.utilMain.doCatch(Unknown Source)
>         at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(Unknown Source)
>         at org.apache.derby.impl.tools.ij.utilMain.go(Unknown Source)
>         at org.apache.derby.impl.tools.ij.Main.go(Unknown Source)
>         at org.apache.derby.impl.tools.ij.Main.mainCore(Unknown Source)
>         at org.apache.derby.impl.tools.ij.Main14.main(Unknown Source)
>         at org.apache.derby.tools.ij.main(Unknown Source)
> ij> --- something goes wrong in validation of properties after we get the NPE
> SELECT * FROM t1 --DERBY-PROPERTIES constrant=cons1
> ;
> ERROR 40XT0: An internal error was identified by RawStore module.
> ERROR 40XT0: An internal error was identified by RawStore module.
>         at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
>         at org.apache.derby.impl.store.raw.xact.Xact.setActiveState(Unknown Source)
>         at org.apache.derby.impl.store.raw.xact.Xact.openContainer(Unknown Source)
>         at org.apache.derby.impl.store.access.conglomerate.OpenConglomerate.init(Unknown
Source)
>         at org.apache.derby.impl.store.access.heap.Heap.open(Unknown Source)
>         at org.apache.derby.impl.store.access.RAMTransaction.openConglomerate(Unknown
Source)
>         at org.apache.derby.impl.store.access.RAMTransaction.openConglomerate(Unknown
Source)
>         at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getDescriptorViaIndex(Unknown
Source
> )
>         at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.locateSchemaRow(Unknown
Source)
>         at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getSchemaDescriptor(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(Unknown
Source)
>         at org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(Unknown Source)
>         at org.apache.derby.impl.sql.compile.FromList.bindTables(Unknown Source)
>         at org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(Unknown Source)
>         at org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(Unknown Source)
>         at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Source)
>         at org.apache.derby.impl.sql.compile.CursorNode.bind(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.EmbedStatement.execute(Unknown Source)
>         at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
>         at org.apache.derby.impl.tools.ij.ij.executeImmediate(Unknown Source)
>         at org.apache.derby.impl.tools.ij.utilMain.doCatch(Unknown Source)
>         at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(Unknown Source)
>         at org.apache.derby.impl.tools.ij.utilMain.go(Unknown Source)
>         at org.apache.derby.impl.tools.ij.Main.go(Unknown Source)
>         at org.apache.derby.impl.tools.ij.Main.mainCore(Unknown Source)
>         at org.apache.derby.impl.tools.ij.Main14.main(Unknown Source)
>         at org.apache.derby.tools.ij.main(Unknown Source)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message