db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From banda...@apache.org
Subject svn commit: r180459 [2/2] - in /incubator/derby/code/trunk/java: engine/org/apache/derby/catalog/ engine/org/apache/derby/catalog/types/ engine/org/apache/derby/iapi/reference/ engine/org/apache/derby/iapi/services/io/ engine/org/apache/derby/iapi/sql/compile/ engine/org/apache/derby/iapi/sql/dictionary/ engine/org/apache/derby/impl/sql/catalog/ engine/org/apache/derby/impl/sql/compile/ engine/org/apache/derby/impl/sql/execute/ engine/org/apache/derby/loc/ 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/lang/ testing/org/apache/derbyTesting/functionTests/tests/tools/ tools/org/apache/derby/impl/tools/dblook/ tools/org/apache/derby/loc/ tools/org/apache/derby/tools/
Date Mon, 06 Jun 2005 19:19:36 GMT
Modified: 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_StoredProcedure.java?rev=180459&r1=180458&r2=180459&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_StoredProcedure.java
Mon Jun  6 12:19:34 2005
@@ -34,7 +34,6 @@
 
 	// Prepared statements use throughout the DDL
 	// generation process.
-	private static PreparedStatement getSpecificInfoQuery;
 
 	/* ************************************************
 	 * Generate the DDL for all stored procedures in a given
@@ -47,17 +46,6 @@
 	public static void doStoredProcedures(Connection conn)
 		throws SQLException {
 
-		// Note: it is safe to cast the long varchar column "javaclassname"
-		// to varchar(128) because it is defined to correspond to the
-		// 'aliasid' column for a given stored procedure; since the aliasid
-		// column is varchar(128), javaclassname can't be any larger.  We
-		// have to do this cast because DB2 mode doesn't allow equality
-		// checks between long varchar columns.  Note also: the check for
-		// aliastype='S' must come first for this cast to be "safe".
-		getSpecificInfoQuery = conn.prepareStatement("SELECT ALIAS, " +
-			"SYSTEMALIAS FROM SYS.SYSALIASES WHERE ALIASTYPE='S' AND " +
-			"(CAST (JAVACLASSNAME AS VARCHAR(128))) = ?");
-
 		Statement stmt = conn.createStatement();
 		ResultSet rs = stmt.executeQuery("SELECT ALIAS, ALIASINFO, " +
 			"ALIASID, SCHEMAID, JAVACLASSNAME, SYSTEMALIAS FROM SYS.SYSALIASES " +
@@ -95,7 +83,6 @@
 
 		rs.close();
 		stmt.close();
-		getSpecificInfoQuery.close();
 		return;
 
 	}
@@ -130,21 +117,53 @@
 		proc.append(params.substring(0, params.indexOf("(")));
 		proc.append("' ");
 
-		// Specific name (when implemented...)
-		getSpecificInfoQuery.setString(1, aProc.getString(3));
-		ResultSet specificRS = getSpecificInfoQuery.executeQuery();
-		if (specificRS.next()) {
-			if (!specificRS.getBoolean(2)) {
-			// only process it if it's not a system alias.
-				proc.append("SPECIFIC ");
-				proc.append(specificRS.getString(1));
+		return proc.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.
+	 * @param conn Connection to the source database.
+	 * @return 
+	 ****/
+	public static void doSynonyms(Connection conn) throws SQLException
+	{
+		Statement stmt = conn.createStatement();
+		ResultSet rs = stmt.executeQuery("SELECT ALIAS, SCHEMAID, " +
+			"ALIASINFO, SYSTEMALIAS FROM SYS.SYSALIASES A WHERE ALIASTYPE='S'");
+
+		boolean firstTime = true;
+		while (rs.next()) {
+			if (rs.getBoolean(4))
+			// it's a system alias, so we ignore it.
+				continue;
+
+			String aliasSchema = dblook.lookupSchemaId(rs.getString(2));
+			if (dblook.isIgnorableSchema(aliasSchema))
+				continue;
+
+			if (firstTime) {
+				Logs.reportString("----------------------------------------------");
+				Logs.reportMessage("DBLOOK_SynonymHeader");
+				Logs.reportString("----------------------------------------------\n");
 			}
-		}
 
-		specificRS.close();
+			String aliasName = rs.getString(1);
+			String aliasFullName = dblook.addQuotes(
+				dblook.expandDoubleQuotes(aliasName));
+			aliasFullName = aliasSchema + "." + aliasFullName;
 
-		return proc.toString();
+			Logs.writeToNewDDL("CREATE SYNONYM "+aliasFullName+" FOR "+rs.getString(3));
+			Logs.writeStmtEndToNewDDL();
+			Logs.writeNewlineToNewDDL();
+			firstTime = false;
+		}
 
-	}
+		rs.close();
+		stmt.close();
+		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=180459&r1=180458&r2=180459&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 Mon
Jun  6 12:19:34 2005
@@ -211,6 +211,7 @@
 DBLOOK_ForeignHeader=foreign
 DBLOOK_SchemasHeader=DDL Statements for schemas
 DBLOOK_StoredProcHeader=DDL Statements for stored procedures
+DBLOOK_SynonymHeader=DDL Statements for Synonyms
 DBLOOK_TriggersHeader=DDL Statements for triggers
 DBLOOK_ViewsHeader=DDL Statements for views
 DBLOOK_Jar_Note=\

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=180459&r1=180458&r2=180459&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 Mon Jun  6 12:19:34
2005
@@ -528,6 +528,7 @@
 
 			DB_Table.doTables(this.conn, tableIdToNameMap);
 			DB_Index.doIndexes(this.conn);
+			DB_StoredProcedure.doSynonyms(this.conn);
 			DB_Key.doKeys(this.conn);
 			DB_Check.doChecks(this.conn);
 



Mime
View raw message