db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mamta A. Satoor (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-3718) NPE when firing a trigger
Date Wed, 18 Jun 2008 05:50:45 GMT

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

Mamta A. Satoor commented on DERBY-3718:
----------------------------------------

I think this got broken in 10.4 codeline after the checkin r619995 - 
DERBY-2917 Changed the runtime type DataTypeDescriptor to no longer be a TypeDescriptor (catalog
type) but instead only have a catalog type (TypeDescriptor). Added code to handle upgrade
issue of DataTypeDescriptor's being written as catalog types in RoutineAliasInfo.

iapi.types.DataTypeDescriptor.writeExternal used to write the TypeId and the TypeDescriptor
in 10.3 codeline. So, the code for writeExternal for DataTypeDescriptor was as follows in
10.3
	public void writeExternal( ObjectOutput out )
		 throws IOException
	{
		out.writeObject( typeId );
		out.writeObject( typeDescriptor );
	}
This code was changed in 10.4 codeline to look as follows
	public void writeExternal( ObjectOutput out )
		 throws IOException
	{
		out.writeObject(typeDescriptor);
		out.writeInt(getCollationDerivation());
	}
Starting 10.4, we now rely on loading the TypeId on the fly rather than storing it on the
disk as shown below in the readExternal code
	public void readExternal( ObjectInput in )
		 throws IOException, ClassNotFoundException
	{
		typeDescriptor = (TypeDescriptorImpl) in.readObject();
        
		typeId = TypeId.getBuiltInTypeId(this.getJDBCTypeId());
        
		collationDerivation = in.readInt();
	}

The problem is for some reason, we are not able to read the TypeId for the REF datatype(ie
in the code above, TypeId.getBuiltInTypeId(this.getJDBCTypeId()); returns null when dealing
with REF datatype). I am going to see if we just need a simple case clause for REF in the
switch statement in TypeId.getBuiltInTypeId or something else to fix the problem. I will also
spend some time figuring out how we are able to get
a good TypeId object for REF object in other places when it appears that it is definitely
not available to iapi.types.DataTypeDescriptor.readExternal

Dan, if this rings a bell to you, will you let me know if my analysis is correct and why we
are not able to load TypeId for REF datatype.

> NPE when firing a trigger
> -------------------------
>
>                 Key: DERBY-3718
>                 URL: https://issues.apache.org/jira/browse/DERBY-3718
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.4.1.3, 10.5.0.0
>            Reporter: Rick Hillegas
>            Assignee: Mamta A. Satoor
>
> NullPointerException raised when firing a trigger. Originally reported by Thiyagu P on
the Derby user list: http://www.nabble.com/Trigger-function-broken-in-10.4.1.3--td17760208.html#a17760208
Thiyagu reports that the same script works fine in 10.3.3.0. Here's the script:
> CREATE TABLE TRADE(
>       ID INT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (START WITH 1000),
>       BUYID INT NOT NULL,
>       QTY FLOAT(2) NOT NULL
>    );
>   
>    CREATE TABLE TOTAL(BUYID INT NOT NULL, TOTALQTY FLOAT(2) NOT NULL);
>    CREATE TRIGGER TRADE_INSERT
>      AFTER INSERT ON TRADE
>      REFERENCING NEW AS NEWROW
>      FOR EACH ROW MODE DB2SQL
>      UPDATE TOTAL SET TOTALQTY = NEWROW.QTY WHERE BUYID = NEWROW.BUYID;
>    INSERT INTO TOTAL VALUES (1, 0);
>    INSERT INTO TRADE VALUES(1, 1, 10);
> Here's the stack trace:
> java.lang.NullPointerException
> 	at org.apache.derby.iapi.types.DataTypeDescriptor.getNull(DataTypeDescriptor.java:1008)
> 	at org.apache.derby.iapi.types.DataTypeDescriptor.normalize(DataTypeDescriptor.java:645)
> 	at org.apache.derby.impl.sql.execute.NormalizeResultSet.normalizeRow(NormalizeResultSet.java:329)
> 	at org.apache.derby.impl.sql.execute.NormalizeResultSet.getNextRowCore(NormalizeResultSet.java:189)
> 	at org.apache.derby.impl.sql.execute.DMLWriteResultSet.getNextRowCore(DMLWriteResultSet.java:127)
> 	at org.apache.derby.impl.sql.execute.UpdateResultSet.collectAffectedRows(UpdateResultSet.java:424)
> 	at org.apache.derby.impl.sql.execute.UpdateResultSet.open(UpdateResultSet.java:246)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:384)
> 	at org.apache.derby.impl.sql.execute.GenericTriggerExecutor.executeSPS(GenericTriggerExecutor.java:159)
> 	at org.apache.derby.impl.sql.execute.RowTriggerExecutor.fireTrigger(RowTriggerExecutor.java:111)
> 	at org.apache.derby.impl.sql.execute.TriggerEventActivator.notifyEvent(TriggerEventActivator.java:269)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(InsertResultSet.java:1150)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:487)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:384)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1235)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:625)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:555)
> 	at org.apache.derby.impl.tools.ij.ij.executeImmediate(ij.java:329)
> 	at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:508)
> 	at org.apache.derby.impl.tools.ij.utilMain.runScriptGuts(utilMain.java:350)
> 	at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:248)
> 	at org.apache.derby.impl.tools.ij.Main.go(Main.java:215)
> 	at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:181)
> 	at org.apache.derby.impl.tools.ij.Main.main(Main.java:73)
> 	at org.apache.derby.tools.ij.main(ij.java:59)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message