Return-Path: X-Original-To: apmail-db-derby-commits-archive@www.apache.org Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 93F96DE1B for ; Tue, 16 Oct 2012 18:25:57 +0000 (UTC) Received: (qmail 37732 invoked by uid 500); 16 Oct 2012 18:25:57 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 37685 invoked by uid 500); 16 Oct 2012 18:25:57 -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 37676 invoked by uid 99); 16 Oct 2012 18:25:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Oct 2012 18:25:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Oct 2012 18:25:55 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A224223888FE; Tue, 16 Oct 2012 18:25:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1398914 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/types/ testing/org/apache/derbyTesting/functionTests/tests/lang/ Date: Tue, 16 Oct 2012 18:25:12 -0000 To: derby-commits@db.apache.org From: rhillegas@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121016182512.A224223888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rhillegas Date: Tue Oct 16 18:25:11 2012 New Revision: 1398914 URL: http://svn.apache.org/viewvc?rev=1398914&view=rev Log: DERBY-5951: Supply missing CLOB instantiator. Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLClob.java db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLClob.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLClob.java?rev=1398914&r1=1398913&r2=1398914&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLClob.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/CollatorSQLClob.java Tue Oct 16 18:25:11 2012 @@ -21,6 +21,8 @@ package org.apache.derby.iapi.types; +import java.sql.Clob; + import org.apache.derby.iapi.error.StandardException; import org.apache.derby.iapi.services.sanity.SanityManager; @@ -66,6 +68,16 @@ class CollatorSQLClob extends SQLClob im setCollator(collatorForCharacterDatatypes); } + /** + * Create SQL CLOB value initially set to value that + * performs collation according to collatorForCharacterDatatypes + */ + CollatorSQLClob(Clob val, RuleBasedCollator collatorForCharacterDatatypes) + { + super(val); + setCollator(collatorForCharacterDatatypes); + } + /** * Set the RuleBasedCollator for this instance of CollatorSQLClob. It will * be used to do the collation. @@ -136,7 +148,7 @@ class CollatorSQLClob extends SQLClob im */ public DataValueDescriptor getNewNull() { - CollatorSQLClob result = new CollatorSQLClob(null, + CollatorSQLClob result = new CollatorSQLClob((String) null, holderForCollationSensitiveInfo.getCollatorForCollation()); return result; } Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java?rev=1398914&r1=1398913&r2=1398914&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactory.java Tue Oct 16 18:25:11 2012 @@ -244,6 +244,18 @@ public interface DataValueFactory int collationType) throws StandardException; /** + * Get a StringDataValue to represent a SQL CLOB with the + * passed in collationType. A null argument means get a SQL NULL value. + * If previous is not null (Java reference) then it will be set + * to the value passed in and returned, otherwise a new StringDataValue + * will be created and set to the value. + * If collationType is equal to StringDataValue.COLLATION_TYPE_UCS_BASIC + * then the call is the equivalent of the overload without collationType. + */ + StringDataValue getClobDataValue(Clob value, StringDataValue previous, + int collationType) throws StandardException; + + /** * Get a User-defined data value with the given value and type name. * A null argument means get a SQL null value. The second arg uses * the previous value (if non-null) hold the return value. Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java?rev=1398914&r1=1398913&r2=1398914&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataValueFactoryImpl.java Tue Oct 16 18:25:11 2012 @@ -519,6 +519,22 @@ abstract class DataValueFactoryImpl impl return previous; } + public StringDataValue getClobDataValue(Clob value, + StringDataValue previous, int collationType) + throws StandardException + { + if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC) + return getClobDataValue(value, previous); + + if (previous == null) + { + return new CollatorSQLClob(value, + getCharacterCollator(collationType)); + } + + previous.setValue(value); + return previous; + } /** * Return a StringDataValue to represent a SQL CLOB Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java?rev=1398914&r1=1398913&r2=1398914&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest.java Tue Oct 16 18:25:11 2012 @@ -21,6 +21,7 @@ package org.apache.derbyTesting.functionTests.tests.lang; +import java.sql.Clob; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; @@ -37,6 +38,8 @@ import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; +import org.apache.derby.iapi.types.HarmonySerialClob; + import org.apache.derbyTesting.functionTests.tests.jdbcapi.BatchUpdateTest; import org.apache.derbyTesting.functionTests.tests.jdbcapi.DatabaseMetaDataTest; import org.apache.derbyTesting.functionTests.tests.nist.NistScripts; @@ -2150,4 +2153,34 @@ public void testMissingCollatorSupport() : Decorator.territoryCollatedDatabase(suite, locale); } + /** + * Test for an overload which was missing. + */ + public void test_5951() throws Exception + { + Statement s = createStatement(); + + ResultSet rs = null; + s.execute("CREATE TABLE derby5951( a clob )"); + s.execute + ( + "create function makeClob( contents varchar( 32672 ) ) returns clob\n" + + "language java parameter style java no sql deterministic\n" + + "external name 'org.apache.derbyTesting.functionTests.tests.lang.CollationTest.makeClob'\n" + ); + s.executeUpdate("INSERT INTO derby5951 VALUES( makeClob( 'a' ) )"); + rs = s.executeQuery("select * from derby5591"); + JDBC.assertFullResultSet(rs, + new String[][] {{"a"}}); + + s.executeUpdate("DROP TABLE derby5591"); + s.executeUpdate("DROP function makeClob"); + } + + /** Clob-creating function */ + public static Clob makeClob( String contents ) throws Exception + { + return new HarmonySerialClob( contents ); + } + }