You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ba...@apache.org on 2005/06/09 00:00:44 UTC

svn commit: r189650 - in /incubator/derby/code/trunk/java: engine/org/apache/derby/catalog/types/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/DerbyNet/ testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/ testing/org/apache/derbyTesting/functionTests/tests/tools/ tools/org/apache/derby/impl/tools/dblook/ tools/org/apache/derby/loc/ tools/org/apache/derby/tools/

Author: bandaram
Date: Wed Jun  8 15:00:43 2005
New Revision: 189650

URL: http://svn.apache.org/viewcvs?rev=189650&view=rev
Log:
Derby-337: Enhance dblook to support SQL functions.

1 - Renames "impl/tools/dblook/DB_StoredProcedure.java" to "impl/tools/dblook/DB_Alias.java" because that file now handles stored procedures AND functions AND synonyms, all of which are based on the SYSALIASES system catalog.

2 - Adds logic to new DB_Alias.java file to generate DDL for functions.

3 - Modifies the "toString()" method of the catalog/types/RoutineAliasInfo file to generate a string that is SYNTACTICALLY VALID based on whether an instance of that class is for a PROCEDURE or for a FUNCTION.  The reason this change is required is because the "ALIASINFO" column that is returned as part of the SYS.SYSALIASES result set is an instance of RoutineAliasInfo, and thus a call to ResultSet.getString() on the ALIASINFO column ultimately makes a call to RoutineAliasInfo.toString().  That said, the dblook utility makes a "getString()" call on the ALIASINFO column and uses the result to generate the corresponding DDL.  Before this patch, the result of the toString() method always corresponded to the PROCEDURE syntax; but now, since dblook is generating DDL for FUNCTIONs, the RoutineAliasInfo.toString() method must recognize if an instance is a PROCEDURE or FUNCTION and return the appropriate syntax.

4 - Adds test cases for FUNCTIONS to the dblook tests and updates the master files accordingly.

Submitted by Army Brown (qozinx@sbcglobal.net)

Added:
    incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Alias.java
      - copied, changed from r189635, incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_StoredProcedure.java
Removed:
    incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_StoredProcedure.java
Modified:
    incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB.sql
    incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql
    incubator/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties
    incubator/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java?rev=189650&r1=189649&r2=189650&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java (original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java Wed Jun  8 15:00:43 2005
@@ -88,6 +88,9 @@
 	*/
 	private boolean	calledOnNullInput;
 
+	// What type of alias is this: PROCEDURE or FUNCTION?
+	private char aliasType;
+
 	public RoutineAliasInfo() {
 	}
 
@@ -119,6 +122,7 @@
 		this.sqlAllowed = sqlAllowed;
 		this.calledOnNullInput = calledOnNullInput;
 		this.returnType = returnType;
+		setAliasType();
 
 		if (SanityManager.DEBUG) {
 
@@ -228,6 +232,7 @@
 			parameterTypes = null;
 			parameterModes = null;
 		}
+		setAliasType();
 	}
 
 	/**
@@ -263,6 +268,15 @@
 	 */
 	public	int	getTypeFormatId()	{ return StoredFormatIds.ROUTINE_INFO_V01_ID; }
 
+	/**
+	 * Get this alias info as a string.  NOTE: The "ALIASINFO" column
+	 * in the SYSALIASES table will return the result of this method
+	 * on a ResultSet.getString() call.  That said, since the dblook
+	 * utility uses ResultSet.getString() to retrieve ALIASINFO and
+	 * to generate the DDL, THIS METHOD MUST RETURN A STRING THAT
+	 * IS SYNTACTICALLY VALID, or else the DDL generated by dblook
+	 * will be incorrect.
+	 */
 	public String toString() {
 
 		StringBuffer sb = new StringBuffer(100);
@@ -272,21 +286,42 @@
 			if (i != 0)
 				sb.append(',');
 
-			sb.append(RoutineAliasInfo.parameterMode(parameterModes[i]));
-			sb.append(' ');
+			if (aliasType == AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR) {
+			// This is a PROCEDURE.  We only want to print the
+			// parameter mode (ex. "IN", "OUT", "INOUT") for procedures--
+			// we don't do it for functions since use of the "IN" keyword
+			// is not part of the FUNCTION syntax.
+				sb.append(RoutineAliasInfo.parameterMode(parameterModes[i]));
+				sb.append(' ');
+			}
 			sb.append(parameterNames[i]);
 			sb.append(' ');
 			sb.append(parameterTypes[i].getSQLstring());
 		}
 		sb.append(')');
 
+		if (aliasType == AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR) {
+		// this a FUNCTION, so syntax requires us to append the return type.
+			sb.append(" RETURNS " + returnType.getSQLstring());
+		}
+
 		sb.append(" LANGUAGE JAVA PARAMETER STYLE JAVA ");
 		sb.append(RoutineAliasInfo.SQL_CONTROL[getSQLAllowed()]);
-		if (dynamicResultSets != 0) {
+		if ((aliasType == AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR) &&
+			(dynamicResultSets != 0))
+		{ // Only print dynamic result sets if this is a PROCEDURE
+		  // because it's not valid syntax for FUNCTIONs.
 			sb.append(" DYNAMIC RESULT SETS ");
 			sb.append(dynamicResultSets);
 		}
 
+		if (aliasType == AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR) {
+		// this a FUNCTION, so append the syntax telling what to
+		// do with a null parameter.
+			sb.append(calledOnNullInput ? " CALLED " : " RETURNS NULL ");
+			sb.append("ON NULL INPUT");
+		}
+		
 		return sb.toString();
 	}
 
@@ -301,5 +336,19 @@
 		default:
 			return "UNKNOWN";
 		}
+	}
+
+	/**
+	 * Set the type of this alias based on whether or not
+	 * the returnType is null.
+	 */
+	private void setAliasType()
+	{
+		if (returnType == null)
+		// must be a PROCEDURE.
+			aliasType = AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR;
+		else
+		// must be a FUNCTION.
+			aliasType = AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR;
 	}
 }

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net.out?rev=189650&r1=189649&r2=189650&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net.out (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net.out Wed Jun  8 15:00:43 2005
@@ -23,6 +23,26 @@
 <systemname>
 -----
 <systemid>
+GATP2
+FOO
+org.apache.derbyTesting.functionTests.util.TestPropertyInfo
+F
+F
+false
+getAllTableProperties(SCH VARCHAR(128),TBL VARCHAR(128)) RETURNS VARCHAR(1000) LANGUAGE JAVA PARAMETER STYLE JAVA READS SQL DATA RETURNS NULL ON NULL INPUT
+<systemname>
+-----
+<systemid>
+GATP
+APP
+org.apache.derbyTesting.functionTests.util.TestPropertyInfo
+F
+F
+false
+getAllTableProperties(SCH VARCHAR(128),TBL VARCHAR(128)) RETURNS VARCHAR(1000) LANGUAGE JAVA PARAMETER STYLE JAVA CONTAINS SQL CALLED ON NULL INPUT
+<systemname>
+-----
+<systemid>
 OP4
 BAR
 org.apache.derbyTesting.functionTests.util.ProcedureTest

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net.out?rev=189650&r1=189649&r2=189650&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net.out (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net.out Wed Jun  8 15:00:43 2005
@@ -23,6 +23,26 @@
 <systemname>
 -----
 <systemid>
+GATP2
+FOO
+org.apache.derbyTesting.functionTests.util.TestPropertyInfo
+F
+F
+false
+getAllTableProperties(SCH VARCHAR(128),TBL VARCHAR(128)) RETURNS VARCHAR(1000) LANGUAGE JAVA PARAMETER STYLE JAVA READS SQL DATA RETURNS NULL ON NULL INPUT
+<systemname>
+-----
+<systemid>
+GATP
+APP
+org.apache.derbyTesting.functionTests.util.TestPropertyInfo
+F
+F
+false
+getAllTableProperties(SCH VARCHAR(128),TBL VARCHAR(128)) RETURNS VARCHAR(1000) LANGUAGE JAVA PARAMETER STYLE JAVA CONTAINS SQL CALLED ON NULL INPUT
+<systemname>
+-----
+<systemid>
 OP4
 BAR
 org.apache.derbyTesting.functionTests.util.ProcedureTest

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out?rev=189650&r1=189649&r2=189650&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out Wed Jun  8 15:00:43 2005
@@ -16,6 +16,26 @@
 <systemname>
 ----
 <systemid>
+GATP2
+FOO
+org.apache.derbyTesting.functionTests.util.TestPropertyInfo
+F
+F
+false
+getAllTableProperties(SCH VARCHAR(128),TBL VARCHAR(128)) RETURNS VARCHAR(1000) LANGUAGE JAVA PARAMETER STYLE JAVA READS SQL DATA RETURNS NULL ON NULL INPUT
+<systemname>
+----
+<systemid>
+GATP
+APP
+org.apache.derbyTesting.functionTests.util.TestPropertyInfo
+F
+F
+false
+getAllTableProperties(SCH VARCHAR(128),TBL VARCHAR(128)) RETURNS VARCHAR(1000) LANGUAGE JAVA PARAMETER STYLE JAVA CONTAINS SQL CALLED ON NULL INPUT
+<systemname>
+----
+<systemid>
 OP4
 BAR
 org.apache.derbyTesting.functionTests.util.ProcedureTest
@@ -1940,6 +1960,26 @@
 <systemname>
 ----
 <systemid>
+GATP2
+FOO
+org.apache.derbyTesting.functionTests.util.TestPropertyInfo
+F
+F
+false
+getAllTableProperties(SCH VARCHAR(128),TBL VARCHAR(128)) RETURNS VARCHAR(1000) LANGUAGE JAVA PARAMETER STYLE JAVA READS SQL DATA RETURNS NULL ON NULL INPUT
+<systemname>
+----
+<systemid>
+GATP
+APP
+org.apache.derbyTesting.functionTests.util.TestPropertyInfo
+F
+F
+false
+getAllTableProperties(SCH VARCHAR(128),TBL VARCHAR(128)) RETURNS VARCHAR(1000) LANGUAGE JAVA PARAMETER STYLE JAVA CONTAINS SQL CALLED ON NULL INPUT
+<systemname>
+----
+<systemid>
 OP4
 BAR
 org.apache.derbyTesting.functionTests.util.ProcedureTest
@@ -5178,6 +5218,10 @@
 -- ----------------------------------------------
 CREATE PROCEDURE "APP"."PROC1" (INOUT A CHAR(10),IN B INTEGER) LANGUAGE JAVA PARAMETER STYLE JAVA CONTAINS SQL DYNAMIC RESULT SETS 4 EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.ProcedureTest.inoutparams3' 
 -- ----------------------------------------------
+-- DDL Statements for functions
+-- ----------------------------------------------
+CREATE FUNCTION "APP"."GATP" (SCH VARCHAR(128),TBL VARCHAR(128)) RETURNS VARCHAR(1000) LANGUAGE JAVA PARAMETER STYLE JAVA CONTAINS SQL CALLED ON NULL INPUT EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestPropertyInfo.getAllTableProperties' 
+-- ----------------------------------------------
 -- DDL Statements for tables
 -- ----------------------------------------------
 CREATE TABLE "BAR"."T1" ("C" CHAR(5) NOT NULL, "I" INTEGER, "VC" VARCHAR(10), "FKCHAR" CHAR(5))
@@ -5300,6 +5344,10 @@
 -- DDL Statements for stored procedures
 -- ----------------------------------------------
 CREATE PROCEDURE "APP"."PROC1" (INOUT A CHAR(10),IN B INTEGER) LANGUAGE JAVA PARAMETER STYLE JAVA CONTAINS SQL DYNAMIC RESULT SETS 4 EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.ProcedureTest.inoutparams3'  #
+-- ----------------------------------------------
+-- DDL Statements for functions
+-- ----------------------------------------------
+CREATE FUNCTION "APP"."GATP" (SCH VARCHAR(128),TBL VARCHAR(128)) RETURNS VARCHAR(1000) LANGUAGE JAVA PARAMETER STYLE JAVA CONTAINS SQL CALLED ON NULL INPUT EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestPropertyInfo.getAllTableProperties'  #
 -- ----------------------------------------------
 -- DDL Statements for tables
 -- ----------------------------------------------

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB.sql
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB.sql?rev=189650&r1=189649&r2=189650&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB.sql (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB.sql Wed Jun  8 15:00:43 2005
@@ -56,6 +56,14 @@
 create procedure """proc ""In Quotes with spaces""" (INOUT a CHAR(10), IN b int) language java external name 'org.apache.derbyTesting.functionTests.util.ProcedureTest.inoutparams3' parameter style java dynamic result sets 2 modifies sql data;
 
 -- ----------------------------------------------
+-- Functions.
+-- ----------------------------------------------
+
+create function gatp(SCH VARCHAR(128), TBL VARCHAR(128)) RETURNS VARCHAR(1000) EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestPropertyInfo.getAllTableProperties' LANGUAGE JAVA PARAMETER STYLE JAVA CONTAINS SQL;
+
+create function foo.gatp2(SCH VARCHAR(128), TBL VARCHAR(128)) RETURNS VARCHAR(1000) EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestPropertyInfo.getAllTableProperties' LANGUAGE JAVA PARAMETER STYLE JAVA RETURNS NULL ON NULL INPUT;
+
+-- ----------------------------------------------
 -- Tables
 -- ----------------------------------------------
 

Modified: incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql?rev=189650&r1=189649&r2=189650&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql (original)
+++ incubator/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB_2.sql Wed Jun  8 15:00:43 2005
@@ -36,6 +36,12 @@
 create procedure proc1 (INOUT a CHAR(10), IN b int) language java external name 'org.apache.derbyTesting.functionTests.util.ProcedureTest.inoutparams3' parameter style java dynamic result sets 4 contains sql;
 
 -- ----------------------------------------------
+-- Functions.
+-- ----------------------------------------------
+
+create function gatp(SCH VARCHAR(128), TBL VARCHAR(128)) RETURNS VARCHAR(1000) EXTERNAL NAME 'org.apache.derbyTesting.functionTests.util.TestPropertyInfo.getAllTableProperties' LANGUAGE JAVA PARAMETER STYLE JAVA CONTAINS SQL;
+
+-- ----------------------------------------------
 -- Tables
 -- ----------------------------------------------
 

Copied: incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Alias.java (from r189635, incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_StoredProcedure.java)
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Alias.java?p2=incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Alias.java&p1=incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_StoredProcedure.java&r1=189635&r2=189650&rev=189650&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_StoredProcedure.java (original)
+++ incubator/derby/code/trunk/java/tools/org/apache/derby/impl/tools/dblook/DB_Alias.java Wed Jun  8 15:00:43 2005
@@ -1,6 +1,6 @@
 /*
 
-   Derby - Class org.apache.derby.impl.tools.dblook.DB_StoredProcedure
+   Derby - Class org.apache.derby.impl.tools.dblook.DB_Alias
 
    Copyright 2004 The Apache Software Foundation or its licensors, as applicable.
 
@@ -30,26 +30,52 @@
 import java.util.HashMap;
 import org.apache.derby.tools.dblook;
 
-public class DB_StoredProcedure {
+public class DB_Alias {
 
 	// Prepared statements use throughout the DDL
 	// generation process.
 
 	/* ************************************************
-	 * Generate the DDL for all stored procedures in a given
-	 * database.
+	 * Generate the DDL for all stored procedures and
+	 * functions in a given database and write it to
+	 * output via Logs.java.
 	 * @param conn Connection to the source database.
-	 * @return The DDL for the stored procedures has been
-	 *  written to output via Logs.java.
 	 ****/
 
-	public static void doStoredProcedures(Connection conn)
+	public static void doProceduresAndFunctions(Connection conn)
 		throws SQLException {
 
+		// First do stored procedures.
 		Statement stmt = conn.createStatement();
 		ResultSet rs = stmt.executeQuery("SELECT ALIAS, ALIASINFO, " +
 			"ALIASID, SCHEMAID, JAVACLASSNAME, SYSTEMALIAS FROM SYS.SYSALIASES " +
 			"WHERE ALIASTYPE='P'");
+		generateDDL(rs, 'P');	// 'P' => for PROCEDURES
+
+		// Now do functions.
+		rs = stmt.executeQuery("SELECT ALIAS, ALIASINFO, " +
+			"ALIASID, SCHEMAID, JAVACLASSNAME, SYSTEMALIAS FROM SYS.SYSALIASES " +
+			"WHERE ALIASTYPE='F'");
+		generateDDL(rs, 'F');	// 'F' => for FUNCTIONS
+
+		rs.close();
+		stmt.close();
+		return;
+
+	}
+
+	/* ************************************************
+	 * Generate the DDL for either stored procedures or
+	 * functions in a given database, depending on the
+	 * the received aliasType.
+	 * @param rs Result set holding either stored procedures
+	 *  or functions.
+	 * @param aliasType Indication of whether we're generating
+	 *  stored procedures or functions.
+	 ****/
+	private static void generateDDL(ResultSet rs, char aliasType)
+		throws SQLException
+	{
 
 		boolean firstTime = true;
 		while (rs.next()) {
@@ -64,16 +90,19 @@
 
 			if (firstTime) {
 				Logs.reportString("----------------------------------------------");
-				Logs.reportMessage("DBLOOK_StoredProcHeader");
+				Logs.reportMessage((aliasType == 'P')
+					? "DBLOOK_StoredProcHeader"
+					: "DBLOOK_FunctionHeader");
 				Logs.reportString("----------------------------------------------\n");
 			}
 
-			String procName = rs.getString(1);
-			String procFullName = dblook.addQuotes(
-				dblook.expandDoubleQuotes(procName));
-			procFullName = procSchema + "." + procFullName;
+			String aliasName = rs.getString(1);
+			String fullName = dblook.addQuotes(
+				dblook.expandDoubleQuotes(aliasName));
+			fullName = procSchema + "." + fullName;
 
-			String creationString = createProcString(procFullName, rs);
+			String creationString = createProcOrFuncString(
+				fullName, rs, aliasType);
 			Logs.writeToNewDDL(creationString);
 			Logs.writeStmtEndToNewDDL();
 			Logs.writeNewlineToNewDDL();
@@ -81,50 +110,53 @@
 
 		}
 
-		rs.close();
-		stmt.close();
-		return;
-
 	}
 
 	/* ************************************************
-	 * Generate DDL for a specific stored procedure.
-	 * @param procName Name of the current stored procedure.
-	 * @param aProc Info about the current stored procedure.
+	 * Generate DDL for a specific stored procedure or
+	 * function.
+	 * @param aliasName Name of the current procedure/function
+	 * @param aliasInfo Info about the current procedure/function
+	 * @param aliasType Indicator of whether we're generating
+	 *  a stored procedure or a function.
 	 * @return DDL for the current stored procedure is
 	 *   returned, as a String.
 	 ****/
 
-	private static String createProcString(String procName,
-		ResultSet aProc) throws SQLException
+	private static String createProcOrFuncString(String aliasName,
+		ResultSet aliasInfo, char aliasType) throws SQLException
 	{
 
-		StringBuffer proc = new StringBuffer("CREATE PROCEDURE ");
-		proc.append(procName);
-		proc.append(" ");
+		StringBuffer alias = new StringBuffer("CREATE ");
+		if (aliasType == 'P')
+			alias.append("PROCEDURE ");
+		else if (aliasType == 'F')
+			alias.append("FUNCTION ");
+		alias.append(aliasName);
+		alias.append(" ");
 
-		String params = aProc.getString(2);
+		String params = aliasInfo.getString(2);
 
 		// Just grab the parameter part; we'll get the method name later.
-		proc.append(params.substring(params.indexOf("("), params.length()));
-		proc.append(" ");
+		alias.append(params.substring(params.indexOf("("), params.length()));
+		alias.append(" ");
 
 		// Now add the external name.
-		proc.append("EXTERNAL NAME '");
-		proc.append(aProc.getString(5));
-		proc.append(".");
+		alias.append("EXTERNAL NAME '");
+		alias.append(aliasInfo.getString(5));
+		alias.append(".");
 		// Get method name from parameter string fetched above.
-		proc.append(params.substring(0, params.indexOf("(")));
-		proc.append("' ");
+		alias.append(params.substring(0, params.indexOf("(")));
+		alias.append("' ");
 
-		return proc.toString();
+		return alias.toString();
 
 	}
 
 	/* ************************************************
 	 * Generate the DDL for all synonyms in a given
-	 * database. On successul return, the DDL for the stored procedures
-	 * has been written to output via Logs.java.
+	 * database. On successul return, the DDL for the
+	 * synonyms has been written to output via Logs.java.
 	 * @param conn Connection to the source database.
 	 * @return 
 	 ****/

Modified: incubator/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties?rev=189650&r1=189649&r2=189650&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties (original)
+++ incubator/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties Wed Jun  8 15:00:43 2005
@@ -209,6 +209,7 @@
 DBLOOK_KeysHeader=DDL Statements for keys
 DBLOOK_PrimUniqueHeader=primary/unique
 DBLOOK_ForeignHeader=foreign
+DBLOOK_FunctionHeader=DDL Statements for functions
 DBLOOK_SchemasHeader=DDL Statements for schemas
 DBLOOK_StoredProcHeader=DDL Statements for stored procedures
 DBLOOK_SynonymHeader=DDL Statements for Synonyms

Modified: incubator/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java?rev=189650&r1=189649&r2=189650&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java (original)
+++ incubator/derby/code/trunk/java/tools/org/apache/derby/tools/dblook.java Wed Jun  8 15:00:43 2005
@@ -44,7 +44,7 @@
 import org.apache.derby.impl.tools.dblook.DB_Key;
 import org.apache.derby.impl.tools.dblook.DB_Table;
 import org.apache.derby.impl.tools.dblook.DB_Schema;
-import org.apache.derby.impl.tools.dblook.DB_StoredProcedure;
+import org.apache.derby.impl.tools.dblook.DB_Alias;
 import org.apache.derby.impl.tools.dblook.DB_Trigger;
 import org.apache.derby.impl.tools.dblook.DB_View;
 import org.apache.derby.impl.tools.dblook.Logs;
@@ -523,12 +523,12 @@
 			if (tableList == null) {
 			// Don't do these if user just wants table-related objects.
 				DB_Jar.doJars(sourceDBName, this.conn);
-				DB_StoredProcedure.doStoredProcedures(this.conn);
+				DB_Alias.doProceduresAndFunctions(this.conn);
 			}
 
 			DB_Table.doTables(this.conn, tableIdToNameMap);
 			DB_Index.doIndexes(this.conn);
-			DB_StoredProcedure.doSynonyms(this.conn);
+			DB_Alias.doSynonyms(this.conn);
 			DB_Key.doKeys(this.conn);
 			DB_Check.doChecks(this.conn);