db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David W. Van Couvering" <David.Vancouver...@Sun.COM>
Subject Re: [jira] Updated: (DERBY-85) NPE when creating a trigger on a table and default schema doesn't exist.
Date Tue, 22 Nov 2005 18:12:54 GMT
Hi, Dyre.  It is fairly easy to integrate with the test harness.

- Place your test under tests/junitTests.  Create a new subdirectory 
(lang is most likely correct) if it seems appropriate.

- Have your test extend 

- Make sure it has a main() routine, which runs the unit test.  See 
junitTests.compatibility.CompatibilitySuite for an example

- All public methods with the pattern testXXX() will automatically be run

- Add your test to a test suite (e.g. derbylang)



Dyre Tjeldvoll (JIRA) wrote:
>      [ http://issues.apache.org/jira/browse/DERBY-85?page=all ]
> Dyre Tjeldvoll updated DERBY-85:
> --------------------------------
>     Attachment: Bugs.java
> This is my attempt at creating a JUnit test for DERBY-85. It is currently just an ordinary
JUnit test, I have not done anything to try to integrate it with the existing 
> test harness (I could not find any info on how to do that). I have run the test using
junit.swingui.TestRunner and that seems to work. If someone would like to review it that would
be great.
>>NPE when creating a trigger on a table and default schema doesn't exist.
>>         Key: DERBY-85
>>         URL: http://issues.apache.org/jira/browse/DERBY-85
>>     Project: Derby
>>        Type: Bug
>>  Components: SQL
>>    Versions:
>>    Reporter: A B
>>    Assignee: Dyre Tjeldvoll
>> Attachments: Bugs.java, derby-85-notabs.diff
>>When connecting to a Derby db with a user id and password, the default schema is USER.
 For example, if I connect with:
>>ij> connect 'jdbc:derby:myDB;user=someUser;password=somePwd';
>>then the default schema is "SOMEUSER".
>>It turns out that if a table t1 exists in a non-default schema and the default schema
(in this case, "SOMEUSER") doesn't exist yet (because no objects have been created in that
schema), then attempts to create a trigger on t1 using its qualified name will lead to a null
pointer exception in the Derby engine.
>>In ij:
>>-- Create database with default schema "SOMEUSER".
>>ij> connect 'jdbc:derby:myDB;create=true;user=someUser;password=somePwd';
>>-- Create table t1 in a non-default schema; in this case, call it "ITKO".
>>ij> create table itko.t1 (i int);
>>0 rows inserted/updated/deleted
>>-- Now schema ITKO exists, and T1 exists in schema ITKO, but default schema SOMEUSER
does NOT exist, because we haven't created any objects in that schema yet.
>>-- So now we try to create a trigger in the ITKO (i.e. the non-default) schema...
>>ij> create trigger trig1 after update on itko.t1 for each row mode db2sql select
* from sys.systables;
>>ERROR XJ001: Java exception: ': java.lang.NullPointerException'.
>>A look at the derby.log file shows the stack trace given below.  In a word, it looks
like the "compilation schema" field of SYS.SYSTRIGGERS isn't getting set, and so it ends up
being null.  That causes the NPE in subsequent processing...
>>	at org.apache.derby.impl.sql.catalog.SYSSTATEMENTSRowFactory.makeSYSSTATEMENTSrow(SYSSTATEMENTSRowFactory.java:200)
>>	at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.addSPSDescriptor(DataDictionaryImpl.java:2890)
>>	at org.apache.derby.impl.sql.execute.CreateTriggerConstantAction.createSPS(CreateTriggerConstantAction.java:354)
>>	at org.apache.derby.impl.sql.execute.CreateTriggerConstantAction.executeConstantAction(CreateTriggerConstantAction.java:258)
>>	at org.apache.derby.impl.sql.execute.MiscResultSet.open(MiscResultSet.java:56)
>>	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:366)
>>	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1100)
>>	at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:509)
>>	at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:467)
>>	at org.apache.derby.impl.tools.ij.ij.executeImmediate(ij.java:299)
>>	at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:433)
>>	at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:310)
>>	at org.apache.derby.impl.tools.ij.Main.go(Main.java:210)
>>	at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:176)
>>	at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:56)
>>	at org.apache.derby.tools.ij.main(ij.java:60)

View raw message