Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 52882 invoked from network); 30 Nov 2005 16:35:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 30 Nov 2005 16:35:56 -0000 Received: (qmail 96416 invoked by uid 500); 30 Nov 2005 16:35:55 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 96380 invoked by uid 500); 30 Nov 2005 16:35:54 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 96371 invoked by uid 99); 30 Nov 2005 16:35:54 -0000 X-ASF-Spam-Status: No, hits=1.3 required=10.0 tests=SPF_FAIL X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Nov 2005 08:35:52 -0800 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 922F5DE for ; Wed, 30 Nov 2005 17:35:31 +0100 (CET) Message-ID: <1552261566.1133368531596.JavaMail.jira@ajax.apache.org> Date: Wed, 30 Nov 2005 17:35:31 +0100 (CET) From: "Dyre Tjeldvoll (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Updated: (DERBY-85) NPE when creating a trigger on a table and default schema doesn't exist. In-Reply-To: <1283329719.1101867088475.JavaMail.apache@nagoya> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/DERBY-85?page=all ] Dyre Tjeldvoll updated DERBY-85: -------------------------------- Attachment: derby-85.diff derby-85.stat derbyall_report.txt New patch with Junit test case. Note that I had to modify the SecurityManager policy to grant more privileges to derbyTesting.jar and junit.jar Anyone interested SecurityManager issues may want to review those changes carefully. Also note that the current patch does NOT use DDLConstantAction.getSchemaDescriptorForCreate() , but accesses the dictionary directly. This works fine because the trigger is NOT created in this schema. You ONLY need the oid of the default schema to fill in a column in the SYSSTATEMENTS table, (described in more detail in earlier comments). lang/closed.java failed when I ran derbyall, but I don't think this is related to the patch (see DERBY-734). > 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: 10.0.2.0 > Reporter: A B > Assignee: Dyre Tjeldvoll > Attachments: Bugs.java, derby-85.diff, derby-85.stat, derbyall_report.txt > > BACKGROUND: > 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". > PROBLEM: > 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. > REPRO: > 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: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira