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 Fri, 20 Jun 2008 18:21:45 GMT

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

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

Since we are dealing with the internal type which will be assigned a Types.OTHER type then
we can't rely on Types.xxx to get us the correct data type. I am attaching a patch which relies
on using the name of the data type rather than it's Type.xxx to construct the correct TypeId.
I am accomplising that by changing DataTypeDescriptor.readExternal to use this.getTypeName
rather than this.getJDBCTypeId to construct the TypeId. In addition to this change, I had
to change DataTypeDescriptor.getTypeName() to use TypeDescriptor to get the type name rather
than TypeId. This is because TypeId is not available when DataTypeDescriptor.readExternal
calls DataTypeDescriptor.getTypeName. This will match how we already implement DataTypeDescriptor.getJDBCTypeId().
With my patch, I have run Junit and old harness suite with no new regressions. Please let
me know if anyone has any comments on the patch. I will plan on committing it early next week
if there are no comments. I will also work on writing a test case for this Jira entry.


> 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