db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r382379 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/jdbc/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/jdbc4/
Date Thu, 02 Mar 2006 13:28:58 GMT
Author: rhillegas
Date: Thu Mar  2 05:28:56 2006
New Revision: 382379

URL: http://svn.apache.org/viewcvs?rev=382379&view=rev
Log:
Dyre's patch for DERBY-924: Implementing new JDBC4 method for embedded case, DatabaseMetadata.getFunctions()

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestDbMetaData.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java?rev=382379&r1=382378&r2=382379&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java
Thu Mar  2 05:28:56 2006
@@ -66,13 +66,32 @@
     public boolean providesQueryObjectGenerator() throws SQLException {
         return false;
     }
-    
+
+    /**
+     * Implements DatabaseMetaData.getFunctions() for an
+     * embedded database. Queries the database to get information
+     * about functions (procedures returning values). Executes the
+     * 'getFunctions' query from metadata.properties to obtain the
+     * ResultSet to return.
+     * @param catalog limit the search to functions in this catalog 
+     * (not used)
+     * @param schemaPattern limit the search to functions in schemas 
+     * matching this pattern
+     * @param functionNamePattern limit the search to functions 
+     * matching this pattern
+     * @return a ResultSet with metadata information
+     * @throws SQLException if any of the underlying jdbc methods fail
+     */
     public ResultSet getFunctions(java.lang.String catalog,
-                       java.lang.String schemaPattern,
-                       java.lang.String functionNamePattern)
-                       throws SQLException
+                                  java.lang.String schemaPattern,
+                                  java.lang.String functionNamePattern)
+        throws SQLException
     {
-        return getSimpleQuery("getFunctions");
+        PreparedStatement s = getPreparedQuery("getFunctions");
+        s.setString(1, swapNull(catalog));
+        s.setString(2, swapNull(schemaPattern));
+        s.setString(3, swapNull(functionNamePattern));
+        return s.executeQuery();
     }
     
     public ResultSet getFunctionParameters(java.lang.String catalog,

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties?rev=382379&r1=382378&r2=382379&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 Thu Mar
 2 05:28:56 2006
@@ -1032,17 +1032,28 @@
     FROM SYSIBM.SYSDUMMY1 WHERE 1=0 WITH UR
 
 #
-# getFunctions - Not yet implemented.  Logged in JIRA as DERBY-924
-# Return an empty result set with the right shape.
+# getFunctions - From JDBC 4.0, JDK 1.6.  Returns NULL for
+# catalog. Returns fully qualified method name as REMARKS 
+# Param 1 catalog - dummy parameter that is not used
+# Param 2 schemaPattern - NULL=>any, "" => no schema (none) 
+# Param 3 functionNamePattern - NULL=>any 
+# Return a result set with the right shape.
 #
 getFunctions=SELECT \
-        CAST(NULL AS VARCHAR(128)) AS FUNCTION_CAT, \
-        CAST(NULL AS VARCHAR(128)) AS FUNCTION_SCHEM, \
-        CAST(NULL AS VARCHAR(128)) AS FUNCTION_NAME, \
-        CAST(NULL AS VARCHAR(128)) AS REMARKS, \
-        CAST(NULL AS VARCHAR(128)) AS SPECIFIC_NAME \
-    FROM SYSIBM.SYSDUMMY1 WHERE 1=0 WITH UR
-
+	CAST(NULL AS VARCHAR(128)) AS FUNCTION_CAT, \
+        SYS.SYSSCHEMAS.SCHEMANAME AS FUNCTION_SCHEM, \
+        SYS.SYSALIASES.ALIAS AS FUNCTION_NAME, \
+        CAST ((SYS.SYSALIASES.JAVACLASSNAME || '.' || \
+               SYS.SYSALIASES.ALIASINFO->getMethodName()) \
+             AS VARCHAR(32672)) AS REMARKS, \
+        SYS.SYSALIASES.SPECIFICNAME AS SPECIFIC_NAME \
+    FROM SYS.SYSSCHEMAS, SYS.SYSALIASES \
+    WHERE SYS.SYSALIASES.SCHEMAID = SYS.SYSSCHEMAS.SCHEMAID \
+    AND SYS.SYSALIASES.ALIASTYPE = 'F' \
+    AND ((1=1) OR ? IS NOT NULL) \
+    AND SYS.SYSSCHEMAS.SCHEMANAME LIKE ? \
+    AND SYS.SYSALIASES.ALIAS LIKE ? \
+    ORDER BY FUNCTION_SCHEM, FUNCTION_NAME, SPECIFIC_NAME
 #
 # getFunctionParameters - Not yet implemented.  Logged in JIRA as DERBY-925
 # Return an empty result set with the right shape.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestDbMetaData.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestDbMetaData.out?rev=382379&r1=382378&r2=382379&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestDbMetaData.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/TestDbMetaData.out
Thu Mar  2 05:28:56 2006
@@ -1,3 +1,26 @@
+FUNCTION_CAT,FUNCTION_SCHEM,FUNCTION_NAME,REMARKS,SPECIFIC_NAME
+null,APP,DUMMY1,java.some.func,xxxxGENERATED-IDxxxx
+null,APP,DUMMY2,java.some.func,xxxxGENERATED-IDxxxx
+null,APP,DUMMY3,java.some.func,xxxxGENERATED-IDxxxx
+null,APP,DUMMY4,java.some.func,xxxxGENERATED-IDxxxx
+null,SYSCS_UTIL,SYSCS_CHECK_TABLE,org.apache.derby.catalog.SystemProcedures.SYSCS_CHECK_TABLE,xxxxGENERATED-IDxxxx
+null,SYSCS_UTIL,SYSCS_GET_DATABASE_PROPERTY,org.apache.derby.catalog.SystemProcedures.SYSCS_GET_DATABASE_PROPERTY,xxxxGENERATED-IDxxxx
+null,SYSCS_UTIL,SYSCS_GET_RUNTIMESTATISTICS,org.apache.derby.catalog.SystemProcedures.SYSCS_GET_RUNTIMESTATISTICS,xxxxGENERATED-IDxxxx
+FUNCTION_CAT,FUNCTION_SCHEM,FUNCTION_NAME,REMARKS,SPECIFIC_NAME
+null,APP,DUMMY1,java.some.func,xxxxGENERATED-IDxxxx
+null,APP,DUMMY2,java.some.func,xxxxGENERATED-IDxxxx
+null,APP,DUMMY3,java.some.func,xxxxGENERATED-IDxxxx
+null,APP,DUMMY4,java.some.func,xxxxGENERATED-IDxxxx
+null,SYSCS_UTIL,SYSCS_CHECK_TABLE,org.apache.derby.catalog.SystemProcedures.SYSCS_CHECK_TABLE,xxxxGENERATED-IDxxxx
+null,SYSCS_UTIL,SYSCS_GET_DATABASE_PROPERTY,org.apache.derby.catalog.SystemProcedures.SYSCS_GET_DATABASE_PROPERTY,xxxxGENERATED-IDxxxx
+null,SYSCS_UTIL,SYSCS_GET_RUNTIMESTATISTICS,org.apache.derby.catalog.SystemProcedures.SYSCS_GET_RUNTIMESTATISTICS,xxxxGENERATED-IDxxxx
+FUNCTION_CAT,FUNCTION_SCHEM,FUNCTION_NAME,REMARKS,SPECIFIC_NAME
+null,SYSCS_UTIL,SYSCS_CHECK_TABLE,org.apache.derby.catalog.SystemProcedures.SYSCS_CHECK_TABLE,xxxxGENERATED-IDxxxx
+null,SYSCS_UTIL,SYSCS_GET_DATABASE_PROPERTY,org.apache.derby.catalog.SystemProcedures.SYSCS_GET_DATABASE_PROPERTY,xxxxGENERATED-IDxxxx
+null,SYSCS_UTIL,SYSCS_GET_RUNTIMESTATISTICS,org.apache.derby.catalog.SystemProcedures.SYSCS_GET_RUNTIMESTATISTICS,xxxxGENERATED-IDxxxx
+FUNCTION_CAT,FUNCTION_SCHEM,FUNCTION_NAME,REMARKS,SPECIFIC_NAME
+null,SYSCS_UTIL,SYSCS_GET_DATABASE_PROPERTY,org.apache.derby.catalog.SystemProcedures.SYSCS_GET_DATABASE_PROPERTY,xxxxGENERATED-IDxxxx
+null,SYSCS_UTIL,SYSCS_GET_RUNTIMESTATISTICS,org.apache.derby.catalog.SystemProcedures.SYSCS_GET_RUNTIMESTATISTICS,xxxxGENERATED-IDxxxx
 TABLE_SCHEM,TABLE_CATALOG
 APP,null
 NULLID,null

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java?rev=382379&r1=382378&r2=382379&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
Thu Mar  2 05:28:56 2006
@@ -79,9 +79,37 @@
 
 			checkEmptyRS(met.getClientInfoProperties());
 
-			checkEmptyRS(met.getFunctions(null,null,null));
-        
+			// Create some functions in the default schema (app) to make the output
+			// from getFunctions() and getFunctionParameters more interesting
+			s.execute("CREATE FUNCTION DUMMY1 ( X SMALLINT ) RETURNS SMALLINT "+
+					  "PARAMETER STYLE JAVA NO SQL LANGUAGE JAVA EXTERNAL "+
+					  "NAME 'java.some.func'");
+			s.execute("CREATE FUNCTION DUMMY2 ( X INTEGER, Y SMALLINT ) RETURNS"+
+					  " INTEGER PARAMETER STYLE JAVA NO SQL LANGUAGE JAVA "+
+					  "EXTERNAL NAME 'java.some.func'");
+			s.execute("CREATE FUNCTION DUMMY3 ( X VARCHAR(16), Y INTEGER ) "+
+					  "RETURNS VARCHAR(16) PARAMETER STYLE JAVA NO SQL LANGUAGE"+
+					  " JAVA EXTERNAL NAME 'java.some.func'");
+			s.execute("CREATE FUNCTION DUMMY4 ( X VARCHAR(128), Y INTEGER ) "+
+					  "RETURNS INTEGER PARAMETER STYLE JAVA NO SQL LANGUAGE "+
+					  "JAVA EXTERNAL NAME 'java.some.func'");
+
 			checkEmptyRS(met.getFunctionParameters(null,null,null,null));
+
+			// Any function in any schema in any catalog
+			dumpRS(met.getFunctions(null, null, null));
+			// Any function in any schema in "Dummy
+			// Catalog". Same as above since the catalog
+			// argument is ignored (is always null)
+			dumpRS(met.getFunctions("Dummy Catalog", null, null));
+			// Any function in a schema starting with "SYS"
+			dumpRS(met.getFunctions(null, "SYS%", null));
+			// All functions containing "GET" in any schema 
+			// (and any catalog)
+			dumpRS(met.getFunctions(null, null, "%GET%"));
+			// Any function that belongs to NO schema and 
+			// NO catalog (none)
+			checkEmptyRS(met.getFunctions("", "", null));
             
             // 
             // Test the new getSchemas() with no schema qualifiers



Mime
View raw message