db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1441436 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ engine/org/apache/derby/iapi/reference/ engine/org/apache/derby/impl/jdbc/ testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/
Date Fri, 01 Feb 2013 13:07:57 GMT
Author: rhillegas
Date: Fri Feb  1 13:07:56 2013
New Revision: 1441436

URL: http://svn.apache.org/viewvc?rev=1441436&view=rev
Log:
DERBY-6000: Add JDBC 4.2 DatabaseMetaData changes to embedded and client drivers.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Wrapper42DBMD.java
  (with props)
Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalDatabaseMetaData40.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Limits.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Wrapper41DBMD.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java?rev=1441436&r1=1441435&r2=1441436&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java Fri Feb
 1 13:07:56 2013
@@ -2886,6 +2886,15 @@ public abstract class DatabaseMetaData i
         return ps.executeQueryX();
     }
 
+    // ------------------- JDBC 4.2 -------------------------
+
+    /** See DatabaseMetaData javadoc and Limits.DB2_LOB_MAXWIDTH */
+    public  long getMaxLogicalLOBSize() { return ((long) Integer.MAX_VALUE) * 2; }
+
+    /** Derby does not support the Types.REF_CURSOR type. */
+    public boolean supportsRefCursors() { return false; }
+
+
     //----------------------------helper methods----------------------------------
 
 

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalDatabaseMetaData40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalDatabaseMetaData40.java?rev=1441436&r1=1441435&r2=1441436&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalDatabaseMetaData40.java
(original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalDatabaseMetaData40.java
Fri Feb  1 13:07:56 2013
@@ -131,4 +131,20 @@ public class LogicalDatabaseMetaData40
             ( catalog, schemaPattern, tableNamePattern, columnNamePattern );
     }
 
+    /////////////////////////////////////////////////////////////////////////
+    //
+    //  JDBC 4.2 - New public methods
+    //
+    /////////////////////////////////////////////////////////////////////////
+
+    /** See DatabaseMetaData javadoc */
+    public  long getMaxLogicalLOBSize() throws SQLException
+    {
+        return ((org.apache.derby.client.am.DatabaseMetaData) getRealMetaDataObject()).getMaxLogicalLOBSize();
+    }
+    public  boolean supportsRefCursors() throws SQLException
+    {
+        return ((org.apache.derby.client.am.DatabaseMetaData) getRealMetaDataObject()).supportsRefCursors();
+    }
+
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Limits.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Limits.java?rev=1441436&r1=1441435&r2=1441436&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Limits.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/Limits.java Fri Feb  1
13:07:56 2013
@@ -57,7 +57,7 @@ public interface Limits
 
 	public static final int	DB2_CHAR_MAXWIDTH = 254;
 	public static final int	DB2_VARCHAR_MAXWIDTH = 32672;
-	public static final int DB2_LOB_MAXWIDTH = 2147483647;
+	public static final int DB2_LOB_MAXWIDTH = 2147483647; // If you change this value, consider
whether you need to change DatabaseMetaData.getMaxLogicalLOBSize().
 	public static final int	DB2_LONGVARCHAR_MAXWIDTH = 32700;
     public static final int DB2_CONCAT_VARCHAR_LENGTH = 4000;
 	public static final int DB2_MAX_FLOATINGPOINT_LITERAL_LENGTH = 30; // note, this value 30
is also contained in err msg 42820

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java?rev=1441436&r1=1441435&r2=1441436&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java
Fri Feb  1 13:07:56 2013
@@ -972,6 +972,18 @@ public class EmbedDatabaseMetaData exten
 	}
 
     /**
+     * Added in JDBC 4.2.
+     *
+     * Derby does not support the Types.REF_CURSOR type.
+     *
+     * @return true if so
+     */
+	public boolean supportsRefCursors()
+    {
+		return false;
+	}
+    
+    /**
      * Is SELECT for UPDATE supported?
      *
      * @return true if so
@@ -1210,6 +1222,20 @@ public class EmbedDatabaseMetaData exten
 	}
 
     /**
+     * Added in JDBC 4.2.
+     *
+     * What's the maximum length of Derby LOB? This
+     * is the maximum number of bytes in a LOB. Since a
+     * CLOB can have DB2_LOB_MAXWIDTH characters, the
+     * maximum number of bytes is 2 * DB2_LOB_MAXWIDTH.
+     * If you change this value, consider whether you need to change
+     * DatabaseMetaData.getMaxLogicalLOBSize().
+     *
+     * @return max index length in bytes
+     */
+	public long getMaxLogicalLOBSize() { return ((long) Limits.DB2_LOB_MAXWIDTH) * 2; }
+
+    /**
      * What's the maximum length allowed for a schema name?
      *
      * @return max name length in bytes

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties?rev=1441436&r1=1441435&r2=1441436&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties Fri Feb
 1 13:07:56 2013
@@ -843,8 +843,8 @@ getIndexInfo=\
 		   COLS.COLUMNNAME AS COLUMN_NAME, \
 		   CASE WHEN CONGLOMS.DESCRIPTOR.isAscending( \
 				CONGLOMS.DESCRIPTOR.getKeyColumnPosition(COLS.COLUMNNUMBER)) THEN 'A' ELSE 'D' END AS
ASC_OR_DESC, \
-		   CAST(NULL AS INT) AS CARDINALITY, \
-		   CAST(NULL AS INT) AS PAGES, \
+		   CAST(NULL AS BIGINT) AS CARDINALITY, \
+		   CAST(NULL AS BIGINT) AS PAGES, \
 		   CAST(NULL AS VARCHAR(128)) AS FILTER_CONDITION \
 	FROM SYS.SYSSCHEMAS S, \
 			SYS.SYSTABLES T, \

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java?rev=1441436&r1=1441435&r2=1441436&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java
Fri Feb  1 13:07:56 2013
@@ -3825,8 +3825,8 @@ public class DatabaseMetaDataTest extend
                 Types.VARCHAR,Types.VARCHAR,Types.VARCHAR,
                 Types.BOOLEAN,Types.VARCHAR,Types.VARCHAR,Types.SMALLINT,
                 // ASC_OR_DESC is Types.CHAR rather than VARCHAR...
-                Types.SMALLINT,Types.VARCHAR,Types.CHAR,Types.INTEGER,
-                Types.INTEGER,Types.VARCHAR};
+                Types.SMALLINT,Types.VARCHAR,Types.CHAR,Types.BIGINT,
+                Types.BIGINT,Types.VARCHAR};
         
         boolean [] nullability = {false,false,false,
             false,false,true,true,true,false,false,true,true,true};
@@ -5013,6 +5013,30 @@ public class DatabaseMetaDataTest extend
         s.execute( "drop table t_jdbc41" );
     }
     
+    /**
+     * Test methods added by JDBC 4.2
+     */
+    public void test_jdbc4_2() throws Exception
+    {
+        Version dataVersion = getDataVersion( getConnection() );
+        if ( dataVersion.compareTo( new Version( 10, 10, 0, 0 ) ) < 0 ) { return; }
+
+        Statement s = createStatement();
+        DatabaseMetaData dmd = getDMD();
+        println( "Testing JDBC 4.2 methods on a " + dmd.getClass().getName() );
+        Wrapper42DBMD wrapper = new Wrapper42DBMD( dmd );
+
+        //
+        // getMaxLogicalLOBSize()
+        //
+        assertEquals( ((long) Integer.MAX_VALUE) * 2, wrapper.getMaxLogicalLOBSize() );
+
+        //
+        // supportsRefCursors()
+        //
+        assertEquals( false, wrapper.supportsRefCursors() );
+    }
+
     public void testBugFixes() throws SQLException {
         
         Statement s = createStatement();

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Wrapper41DBMD.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Wrapper41DBMD.java?rev=1441436&r1=1441435&r2=1441436&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Wrapper41DBMD.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Wrapper41DBMD.java
Fri Feb  1 13:07:56 2013
@@ -39,8 +39,8 @@ public  class   Wrapper41DBMD
     //
     ///////////////////////////////////////////////////////////////////////
 
-    private EmbedDatabaseMetaData    _embedded;
-    private DatabaseMetaData      _netclient;
+    protected EmbedDatabaseMetaData    _embedded;
+    protected DatabaseMetaData      _netclient;
     
     ///////////////////////////////////////////////////////////////////////
     //
@@ -96,7 +96,7 @@ public  class   Wrapper41DBMD
     //
     ///////////////////////////////////////////////////////////////////////
 
-    private SQLException nothingWrapped() { return new SQLException( "Nothing wrapped!" );
}
+    protected SQLException nothingWrapped() { return new SQLException( "Nothing wrapped!"
); }
 
 }
 

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Wrapper42DBMD.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Wrapper42DBMD.java?rev=1441436&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Wrapper42DBMD.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Wrapper42DBMD.java
Fri Feb  1 13:07:56 2013
@@ -0,0 +1,69 @@
+/*
+ 
+   Derby - Class org.apache.derbyTesting.functionTests.tests.jdbcapi.Wrapper42DBMD
+ 
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to you under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+ 
+      http://www.apache.org/licenses/LICENSE-2.0
+ 
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ 
+ */
+
+package org.apache.derbyTesting.functionTests.tests.jdbcapi;
+
+import java.sql.SQLException;
+
+import org.apache.derby.impl.jdbc.EmbedDatabaseMetaData;
+import org.apache.derby.client.am.DatabaseMetaData;
+
+/**
+ * A wrapper around the new DatabaseMetaData methods added by JDBC 4.2.
+ */
+public  class   Wrapper42DBMD   extends Wrapper41DBMD
+{
+    ///////////////////////////////////////////////////////////////////////
+    //
+    // STATE
+    //
+    ///////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////
+    //
+    // CONSTRUCTORS
+    //
+    ///////////////////////////////////////////////////////////////////////
+
+    public Wrapper42DBMD( Object wrapped ) throws Exception { super( wrapped ); }
+    
+    ///////////////////////////////////////////////////////////////////////
+    //
+    // JDBC 4.2 BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////
+
+    public  long getMaxLogicalLOBSize() throws SQLException
+    {
+        if ( _embedded != null ) { return _embedded.getMaxLogicalLOBSize(); }
+        else if ( _netclient != null ) { return _netclient.getMaxLogicalLOBSize(); }
+        else { throw nothingWrapped(); }
+    }
+
+    public  boolean supportsRefCursors() throws SQLException
+    {
+        if ( _embedded != null ) { return _embedded.supportsRefCursors(); }
+        else if ( _netclient != null ) { return _netclient.supportsRefCursors(); }
+        else { throw nothingWrapped(); }
+    }
+
+}
+

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Wrapper42DBMD.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message