db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dyre Tjeldvoll (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-85) NPE when creating a trigger on a table and default schema doesn't exist.
Date Tue, 14 Jun 2005 15:49:46 GMT
    [ http://issues.apache.org/jira/browse/DERBY-85?page=comments#action_12313599 ] 

Dyre Tjeldvoll commented on DERBY-85:

The javadoc for the CreateTriggerConstantAction constructor seems to confirm that the default
schema is used if no other compile schema is provided:

spsCompSchemaId - the compilation schema for the action and when spses. If null, will be set
to the current default schema

The code confirms this:

		return	getGenericConstantActionFactory().getCreateTriggerConstantAction(
											(UUID)null,			// when SPSID
											(UUID)null,			// action SPSid 
											(actionCompSchemaId == null) ?
												compSchemaDescriptor.getUUID() :
											(Timestamp)null,	// creation time
I tried to add:
		if (SanityManager.DEBUG) {
		    SanityManager.ASSERT((actionCompSchemaId != null ||
					 "No valid compile schema");

		return	getGenericConstantActionFactory().getCreateTriggerConstantAction(...

and this shows that both are null in this case:

dt136804@atum10~/java$ run-app.sh Try
Try starting in embedded mode.
TRACE: Class.forName(driver).newInstance();  @Try.java.m4:89
TRACE: conn = DriverManager.getConnection(protocol + db + ";create=true", props);  @Try.java.m4:105
TRACE: conn.setAutoCommit(false);  @Try.java.m4:107
TRACE: Statement s = conn.createStatement();  @Try.java.m4:113
s=org.apache.derby.impl.jdbc.EmbedStatement@126e85f @Try.java.m4:114
conn=0 @Try.java.m4:115
TRACE: s.execute("create table itko.t1 (i int)");  @Try.java.m4:121
TRACE: s.execute("create schema USER1");  @Try.java.m4:122
TRACE: s.execute("create trigger ikto.trig1 after update on itko.t1 for each row mode db2sql
select * from sys.systables");  @Try.java.m4:128
exception thrown:
SQL Exception: Java exception: 'ASSERT FAILED No valid compile schema: org.apache.derby.iapi.services.sanity.AssertFailure'.
SQLState: XJ001 MessageId: XJ001.U
org.apache.derby.iapi.services.sanity.AssertFailure: ASSERT FAILED No valid compile schema
        at org.apache.derby.iapi.services.sanity.SanityManager.ASSERT(SanityManager.java:121)
        at org.apache.derby.impl.sql.compile.CreateTriggerNode.makeConstantAction(CreateTriggerNode.java:728)
        at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:459)
        at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:107)
        at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:688)
        at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:501)
        at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:475)
        at Try.go(Try.java:128)
        at Try.main(Try.java:73)
Try finished

> 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
>     Versions:
>     Reporter: A B

> 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...
> java.lang.NullPointerException
> 	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)

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:

View raw message