Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 76283 invoked from network); 11 Apr 2006 21:55:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Apr 2006 21:55:45 -0000 Received: (qmail 88708 invoked by uid 500); 11 Apr 2006 21:55:44 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 88645 invoked by uid 500); 11 Apr 2006 21:55:44 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 88634 invoked by uid 99); 11 Apr 2006 21:55:44 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Apr 2006 14:55:44 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 11 Apr 2006 14:55:43 -0700 Received: (qmail 75992 invoked by uid 65534); 11 Apr 2006 21:55:23 -0000 Message-ID: <20060411215523.75991.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r393318 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/types/SQLBlob.java testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral.sql Date: Tue, 11 Apr 2006 21:55:15 -0000 To: derby-commits@db.apache.org From: djd@apache.org X-Mailer: svnmailer-1.0.7 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: djd Date: Tue Apr 11 14:55:13 2006 New Revision: 393318 URL: http://svn.apache.org/viewcvs?rev=393318&view=rev Log: DERBY-438 (partial) Support BLOBs as column in trigger actions. Initial testing with small BLOB values, will add other test cases for larger BLOB values, and then subsequently CLOBs. Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral.sql Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java?rev=393318&r1=393317&r2=393318&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/SQLBlob.java Tue Apr 11 14:55:13 2006 @@ -44,6 +44,7 @@ import java.io.ObjectOutput; import java.io.ObjectInput; import java.io.IOException; +import java.sql.Blob; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.PreparedStatement; @@ -195,6 +196,22 @@ // This may cause problems for streaming blobs, by materializing the whole blob. ps.setBytes(position, getBytes()); + } + + /** + * Set the value from an non-null object. + */ + final void setObject(Object theValue) + throws StandardException + { + Blob vb = (Blob) theValue; + try { + stream = vb.getBinaryStream(); + } catch (SQLException e) { + throw dataTypeConversion("DAN-438-tmp"); + } + streamLength = -1; // unknown + dataValue = null; } } Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out?rev=393318&r1=393317&r2=393318&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out Tue Apr 11 14:55:13 2006 @@ -897,4 +897,38 @@ ij(CONNECTION1)> create trigger mytrigger after update on myschema.mytable for each row mode db2sql select * from sys.systables; 0 rows inserted/updated/deleted ij(CONNECTION1)> rollback; -ij(CONNECTION1)> +ij(CONNECTION1)> disconnect; +ij> -- DERBY-438 - Working triggers with BLOB columns +set connection CONNECTION0; +ij> autocommit on; +ij> create table t438 (id int, cost decimal(6,2), bl blob); +0 rows inserted/updated/deleted +ij> create table t438_t (id int, bl blob, l int, nc decimal(6,2), oc decimal(6,2)); +0 rows inserted/updated/deleted +ij> create trigger tr_438 after update on t438 +referencing new as n old as o +for each row mode db2sql +insert into t438_t(id, bl, l, nc, oc) values (n.id, n.bl, length(n.bl), n.cost, o.cost); +0 rows inserted/updated/deleted +ij> -- initially just some small BLOB values. +insert into t438 values (1, 34.53, cast (X'124594322143423214ab35f2e34c' as blob)); +1 row inserted/updated/deleted +ij> insert into t438 values (0, 95.32, null); +1 row inserted/updated/deleted +ij> insert into t438 values (2, 22.21, cast (X'aa' as blob)); +1 row inserted/updated/deleted +ij> select id, cost, length(bl) from t438 order by 1; +ID |COST |3 +--------------------------------- +0 |95.32 |NULL +1 |34.53 |14 +2 |22.21 |1 +ij> update t438 set cost = cost + 1.23; +3 rows inserted/updated/deleted +ij> select id, length(bl), l, nc, oc from t438_t order by 1,5,4; +ID |2 |L |NC |OC +------------------------------------------------------- +0 |NULL |NULL |96.55 |95.32 +1 |14 |14 |35.76 |34.53 +2 |1 |1 |23.44 |22.21 +ij> Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral.sql URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral.sql?rev=393318&r1=393317&r2=393318&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral.sql (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral.sql Tue Apr 11 14:55:13 2006 @@ -501,4 +501,24 @@ create table myschema.mytable (i int); create trigger mytrigger after update on myschema.mytable for each row mode db2sql select * from sys.systables; rollback; +disconnect; + +-- DERBY-438 - Working triggers with BLOB columns +set connection CONNECTION0; +autocommit on; +create table t438 (id int, cost decimal(6,2), bl blob); +create table t438_t (id int, bl blob, l int, nc decimal(6,2), oc decimal(6,2)); +create trigger tr_438 after update on t438 +referencing new as n old as o +for each row mode db2sql +insert into t438_t(id, bl, l, nc, oc) values (n.id, n.bl, length(n.bl), n.cost, o.cost); + +-- initially just some small BLOB values. +insert into t438 values (1, 34.53, cast (X'124594322143423214ab35f2e34c' as blob)); +insert into t438 values (0, 95.32, null); +insert into t438 values (2, 22.21, cast (X'aa' as blob)); +select id, cost, length(bl) from t438 order by 1; + +update t438 set cost = cost + 1.23; +select id, length(bl), l, nc, oc from t438_t order by 1,5,4;