db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r828950 - in /db/derby/code/trunk/java: testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/tools/ tools/org/apache/derby/impl/tools/ij/ tools/org/apache/derby/loc/
Date Fri, 23 Oct 2009 07:28:55 GMT
Author: kahatlen
Date: Fri Oct 23 07:28:55 2009
New Revision: 828950

URL: http://svn.apache.org/viewvc?rev=828950&view=rev
Log:
DERBY-3809: Add a SHOW FUNCTONS command to ij

Patch contributed by Sylvain Leroux <sylvain@chicoree.fr>.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7.sql
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj
    db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij.out?rev=828950&r1=828949&r2=828950&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij.out Fri
Oct 23 07:28:55 2009
@@ -78,8 +78,8 @@
                                -- drop current, named, or all connections;
                                -- the default is CURRENT
   SHOW SCHEMAS;                -- lists all schemas in the current database
-  SHOW [ TABLES | VIEWS | PROCEDURES | SYNONYMS ] { IN schema };
-                               -- lists tables, views, procedures or synonyms
+  SHOW [ TABLES | VIEWS | PROCEDURES | FUNCTIONS | SYNONYMS ] { IN schema };
+                               -- lists tables, views, procedures, functions or synonyms
   SHOW INDEXES { IN schema | FROM table };
                                -- lists indexes in a schema, or for a table
   SHOW ROLES;                  -- lists all defined roles in the database,

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out?rev=828950&r1=828949&r2=828950&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij7.out
Fri Oct 23 07:28:55 2009
@@ -66,6 +66,13 @@
 PARAMETER STYLE JAVA READS SQL DATA LANGUAGE JAVA 
 EXTERNAL NAME 'a.b.c.d.e';
 0 rows inserted/updated/deleted
+ij> CREATE FUNCTION APP.FUNCTTEST(A INTEGER)
+RETURNS INTEGER
+PARAMETER STYLE JAVA
+LANGUAGE JAVA
+NO SQL
+EXTERNAL NAME 'a.b.c.d.e.f';
+0 rows inserted/updated/deleted
 ij> -- first display all tables, then display tables in one schema
 SHOW TABLES;
 TABLE_SCHEM         |TABLE_NAME                    |REMARKS             
@@ -136,6 +143,30 @@
 PROCEDURE_SCHEM     |PROCEDURE_NAME                |REMARKS             
 ------------------------------------------------------------------------
 APP                 |PROCTEST                      |a.b.c.d.e           
+ij> SHOW FUNCTIONS IN APP;
+FUNCTION_SCHEM|FUNCTION_NAME               |REMARKS                            
+-------------------------------------------------------------------------------
+APP           |FUNCTTEST                   |a.b.c.d.e.f                        
+ij> SHOW FUNCTIONS;
+FUNCTION_SCHEM|FUNCTION_NAME               |REMARKS                            
+-------------------------------------------------------------------------------
+APP           |FUNCTTEST                   |a.b.c.d.e.f                        
+SYSCS_UTIL    |SYSCS_CHECK_TABLE           |org.apache.derby.catalog.SystemPro&
+SYSCS_UTIL    |SYSCS_GET_DATABASE_PROPERTY |org.apache.derby.catalog.SystemPro&
+SYSCS_UTIL    |SYSCS_GET_RUNTIMESTATISTICS |org.apache.derby.catalog.SystemPro&
+SYSCS_UTIL    |SYSCS_GET_USER_ACCESS       |org.apache.derby.catalog.SystemPro&
+SYSCS_UTIL    |SYSCS_GET_XPLAIN_MODE       |org.apache.derby.catalog.SystemPro&
+SYSCS_UTIL    |SYSCS_GET_XPLAIN_SCHEMA     |org.apache.derby.catalog.SystemPro&
+SYSIBM        |BLOBCREATELOCATOR           |org.apache.derby.impl.jdbc.LOBStor&
+SYSIBM        |BLOBGETBYTES                |org.apache.derby.impl.jdbc.LOBStor&
+SYSIBM        |BLOBGETLENGTH               |org.apache.derby.impl.jdbc.LOBStor&
+SYSIBM        |BLOBGETPOSITIONFROMBYTES    |org.apache.derby.impl.jdbc.LOBStor&
+SYSIBM        |BLOBGETPOSITIONFROMLOCATOR  |org.apache.derby.impl.jdbc.LOBStor&
+SYSIBM        |CLOBCREATELOCATOR           |org.apache.derby.impl.jdbc.LOBStor&
+SYSIBM        |CLOBGETLENGTH               |org.apache.derby.impl.jdbc.LOBStor&
+SYSIBM        |CLOBGETPOSITIONFROMLOCATOR  |org.apache.derby.impl.jdbc.LOBStor&
+SYSIBM        |CLOBGETPOSITIONFROMSTRING   |org.apache.derby.impl.jdbc.LOBStor&
+SYSIBM        |CLOBGETSUBSTRING            |org.apache.derby.impl.jdbc.LOBStor&
 ij> SHOW SYNONYMS IN USER1;
 TABLE_SCHEM         |TABLE_NAME                    |REMARKS             
 ------------------------------------------------------------------------

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7.sql?rev=828950&r1=828949&r2=828950&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7.sql
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ij7.sql
Fri Oct 23 07:28:55 2009
@@ -35,6 +35,13 @@
 CREATE PROCEDURE APP.PROCTEST(IN A INTEGER, OUT B DECIMAL(10,2))
 PARAMETER STYLE JAVA READS SQL DATA LANGUAGE JAVA 
 EXTERNAL NAME 'a.b.c.d.e';
+CREATE FUNCTION APP.FUNCTTEST(A INTEGER)
+RETURNS INTEGER
+PARAMETER STYLE JAVA
+LANGUAGE JAVA
+NO SQL
+EXTERNAL NAME 'a.b.c.d.e.f';
+
 
 -- first display all tables, then display tables in one schema
 SHOW TABLES;
@@ -48,6 +55,8 @@
 SHOW SCHEMAS;
 SHOW VIEWS IN USER1;
 SHOW PROCEDURES IN APP;
+SHOW FUNCTIONS IN APP;
+SHOW FUNCTIONS;
 SHOW SYNONYMS IN USER1;
 
 -- DERBY-2019: ensure that tables with mixed-case names can be described:

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj?rev=828950&r1=828949&r2=828950&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj Fri Oct 23 07:28:55
2009
@@ -799,6 +799,55 @@
 		}
 	}
 
+    /**
+       Return a resultset of functions from database metadata.
+
+       JDBC4.0 has a method in DatabaseMetaData called getFunctions().
+       Since this method is implemented in Derby's JDBC3.0 driver
+       we can use it. But only through Java reflection.
+     */
+    public ijResult showFunctions(String schema) throws SQLException {
+        ResultSet rs = null;
+
+        try {
+            haveConnection();
+
+            DatabaseMetaData dbmd = theConnection.getMetaData();
+            Method getFunctions;
+            try {
+                getFunctions = dbmd.getClass().getMethod("getFunctions",
+                                                    new Class[] { String.class,
+                                                               String.class,
+                                                               String.class});
+                rs = (ResultSet)getFunctions.invoke(dbmd, new Object[] { null, schema, null});
+            } catch(NoSuchMethodException nsme) {
+                throw ijException.notAvailableForDriver(dbmd.getDriverName());
+            } catch(IllegalAccessException iae) {
+                throw ijException.notAvailableForDriver(dbmd.getDriverName());
+            } catch(InvocationTargetException ite) {
+                // getFunctions throws only SQLException
+                throw (SQLException)ite.getCause();
+            }
+
+            int[] displayColumns = new int[] {
+                    rs.findColumn("FUNCTION_SCHEM"),
+                    rs.findColumn("FUNCTION_NAME"),
+                    rs.findColumn("REMARKS")
+            };
+            int[] columnWidths = new int[] {
+                    14,
+                    28,
+                    35
+            };
+
+            return new ijResultSetResult(rs, displayColumns, columnWidths);
+        } catch (SQLException e) {
+            if(rs!=null)
+                rs.close();
+            throw e;
+        }
+    }
+
 	/**
 	   Return a resultset of schemas from database metadata
 	 */
@@ -1108,6 +1157,7 @@
 |	<FIRST: "first">
 |	<FOR: "for">
 |	<FROM: "from">
+|	<FUNCTIONS: "functions">
 |	<GET: "get">
 |	<GETCURRENTROWNUMBER: "getcurrentrownumber">
 |	<HOLD: "hold">
@@ -1930,6 +1980,11 @@
 	{
 		return showProcedures(schema);
 	}
+|	<SHOW> <FUNCTIONS>
+		[ <IN> schema=identifier() ]
+	{
+		return showFunctions(schema);
+	}
 |	<SHOW> <SCHEMAS>
 	{
 		return showSchemas();

Modified: db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties?rev=828950&r1=828949&r2=828950&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties Fri Oct 23
07:28:55 2009
@@ -66,8 +66,8 @@
 \                               -- the default is CURRENT\n\
 \ \n\
 \  SHOW SCHEMAS;                -- lists all schemas in the current database\n\
-\  SHOW [ TABLES | VIEWS | PROCEDURES | SYNONYMS ] { IN schema };\n\
-\                               -- lists tables, views, procedures or synonyms\n\
+\  SHOW [ TABLES | VIEWS | PROCEDURES | FUNCTIONS | SYNONYMS ] { IN schema };\n\
+\                               -- lists tables, views, procedures, functions or synonyms\n\
 \  SHOW INDEXES { IN schema | FROM table };\n\
 \                               -- lists indexes in a schema, or for a table\n\
 \  SHOW ROLES;                  -- lists all defined roles in the database,\n\



Mime
View raw message