changeset 315:4793f9b80bb3

Removed the catalog parameter from the Exporter.dumpSchema method as it is always null for MonetDB.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Wed, 28 Aug 2019 18:51:43 +0200 (2019-08-28)
parents 6d98a1d3af00
children d479475888e3
files src/main/java/nl/cwi/monetdb/client/JdbcClient.java src/main/java/nl/cwi/monetdb/util/Exporter.java src/main/java/nl/cwi/monetdb/util/SQLExporter.java src/main/java/nl/cwi/monetdb/util/XMLExporter.java
diffstat 4 files changed, 13 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/nl/cwi/monetdb/client/JdbcClient.java
+++ b/src/main/java/nl/cwi/monetdb/client/JdbcClient.java
@@ -680,7 +680,6 @@ public final class JdbcClient {
 											// we found it, describe it
 											exporter.dumpSchema(dbmd,
 												tbl.getString(4),	// 4 = "TABLE_TYPE"
-												tbl.getString(1),	// 1 = "TABLE_CAT"
 												schemaName,
 												tableName);
 
@@ -922,7 +921,7 @@ public final class JdbcClient {
 		final String tableType = table.getType();
 
 		// dump CREATE definition of this table/view
-		exporter.dumpSchema(dbmd, tableType, null, table.getSchem(), table.getName());
+		exporter.dumpSchema(dbmd, tableType, table.getSchem(), table.getName());
 		out.println();
 
 		// only dump data from real tables, not from views / MERGE / REMOTE / REPLICA tables
--- a/src/main/java/nl/cwi/monetdb/util/Exporter.java
+++ b/src/main/java/nl/cwi/monetdb/util/Exporter.java
@@ -24,7 +24,6 @@ public abstract class Exporter {
 	public abstract void dumpSchema(
 			final DatabaseMetaData dbmd,
 			final String type,
-			final String catalog,
 			final String schema,
 			final String name) throws SQLException;
 
--- a/src/main/java/nl/cwi/monetdb/util/SQLExporter.java
+++ b/src/main/java/nl/cwi/monetdb/util/SQLExporter.java
@@ -39,7 +39,6 @@ public final class SQLExporter extends E
 	 *
 	 * @param dbmd a DatabaseMetaData object to query on (not null)
 	 * @param type the type of the object, e.g. VIEW, TABLE (not null)
-	 * @param catalog the catalog the object is in
 	 * @param schema the schema the object is in (not null)
 	 * @param name the table to describe in SQL CREATE format (not null)
 	 * @throws SQLException if a database related error occurs
@@ -47,7 +46,6 @@ public final class SQLExporter extends E
 	public void dumpSchema(
 			final DatabaseMetaData dbmd,
 			final String type,
-			final String catalog,
 			final String schema,
 			final String name)
 		throws SQLException
@@ -66,7 +64,7 @@ public final class SQLExporter extends E
 		if (type.indexOf("VIEW") != -1) {	// for types: VIEW and SYSTEM VIEW
 			final String[] types = new String[1];
 			types[0] = type;
-			final ResultSet tbl = dbmd.getTables(catalog, schema, name, types);
+			final ResultSet tbl = dbmd.getTables(null, schema, name, types);
 			if (tbl != null) {
 				if (!tbl.next()) {
 					tbl.close();
@@ -90,7 +88,7 @@ public final class SQLExporter extends E
 		out.println("CREATE " + type + " " + fqname + " (");
 
 		// add all columns with their type, nullability and default definition
-		ResultSet cols = dbmd.getColumns(catalog, schema, name, null);
+		ResultSet cols = dbmd.getColumns(null, schema, name, null);
 		int colNmIndex = cols.findColumn("COLUMN_NAME");
 		final int colTypeNmIndex = cols.findColumn("TYPE_NAME");
 		final int datatypeIndex = cols.findColumn("DATA_TYPE");
@@ -189,7 +187,7 @@ public final class SQLExporter extends E
 		// unfortunately some idiot defined that getPrimaryKeys()
 		// returns the primary key columns sorted by column name, not
 		// key sequence order.  So we have to sort ourself :(
-		cols = dbmd.getPrimaryKeys(catalog, schema, name);
+		cols = dbmd.getPrimaryKeys(null, schema, name);
 		int colKeySeq = cols.findColumn("KEY_SEQ");
 		// first make a 'index' of the KEY_SEQ columns
 		final java.util.SortedMap<Integer, Integer> seqIndex = new java.util.TreeMap<Integer, Integer>();
@@ -218,7 +216,7 @@ public final class SQLExporter extends E
 		// add unique constraint definitions
 		// we use getIndexInfo to get unique indexes, but need to exclude
 		// the indexes which are generated by the system for pkey constraints
-		cols = dbmd.getIndexInfo(catalog, schema, name, true, true);
+		cols = dbmd.getIndexInfo(null, schema, name, true, true);
 		int colIndexNm = cols.findColumn("INDEX_NAME");
 		colNmIndex = cols.findColumn("COLUMN_NAME");
 		while (cols.next()) {
@@ -241,7 +239,7 @@ public final class SQLExporter extends E
 		cols.close();
 
 		// add foreign keys definitions
-		cols = dbmd.getImportedKeys(catalog, schema, name);
+		cols = dbmd.getImportedKeys(null, schema, name);
 		final int colFkNm = cols.findColumn("FK_NAME");
 		final int colFkColNm = cols.findColumn("FKCOLUMN_NAME");
 		final int colPkColNm = cols.findColumn("PKCOLUMN_NAME");
@@ -291,7 +289,7 @@ public final class SQLExporter extends E
 		// we use getIndexInfo to get non-unique indexes, but need to exclude
 		// the indexes which are generated by the system for fkey constraints
 		// (and pkey and unique constraints but those are marked as unique and not requested)
-		cols = dbmd.getIndexInfo(catalog, schema, name, false, true);
+		cols = dbmd.getIndexInfo(null, schema, name, false, true);
 		colIndexNm = cols.findColumn("INDEX_NAME");
 		colNmIndex = cols.findColumn("COLUMN_NAME");
 		final int tblNmIndex = cols.findColumn("TABLE_NAME");
--- a/src/main/java/nl/cwi/monetdb/util/XMLExporter.java
+++ b/src/main/java/nl/cwi/monetdb/util/XMLExporter.java
@@ -32,7 +32,6 @@ public final class XMLExporter extends E
 	 *
 	 * @param dbmd a DatabaseMetaData object to query on (not null)
 	 * @param type the type of the object, e.g. VIEW, TABLE (not null)
-	 * @param catalog the catalog the object is in
 	 * @param schema the schema the object is in (not null)
 	 * @param name the table to describe (not null)
 	 * @throws SQLException if a database related error occurs
@@ -40,7 +39,6 @@ public final class XMLExporter extends E
 	public void dumpSchema(
 			final java.sql.DatabaseMetaData dbmd,
 			final String type,
-			final String catalog,
 			final String schema,
 			final String name)
 		throws SQLException
@@ -49,7 +47,7 @@ public final class XMLExporter extends E
 		if (type.indexOf("VIEW") != -1) {	// for types: VIEW and SYSTEM VIEW
 			final String[] types = new String[1];
 			types[0] = type;
-			final ResultSet tbl = dbmd.getTables(catalog, schema, name, types);
+			final ResultSet tbl = dbmd.getTables(null, schema, name, types);
 			if (tbl != null) {
 				final String fqname = dq(schema) + "." + dq(name);
 				if (!tbl.next()) {
@@ -73,7 +71,7 @@ public final class XMLExporter extends E
 
 		out.println("<xsd:schema>");
 
-		final ResultSet cols = dbmd.getColumns(catalog, schema, name, null);
+		final ResultSet cols = dbmd.getColumns(null, schema, name, null);
 		final int colNmIndex = cols.findColumn("COLUMN_NAME");
 		final int colTypeNmIndex = cols.findColumn("TYPE_NAME");
 		final int datatypeIndex = cols.findColumn("DATA_TYPE");
@@ -275,10 +273,9 @@ public final class XMLExporter extends E
 		cols.beforeFirst();
 
 		// create the RowType
+		final String tablenm = schema.replaceAll("\\.", "_x002e_") + "." + name.replaceAll("\\.", "_x002e_");
 		out.print("  <xsd:complexType name=");
-		out.print(dq("RowType." + catalog.replaceAll("\\.", "_x002e_") +
-					"." + schema.replaceAll("\\.", "_x002e_") +
-					"." + name.replaceAll("\\.", "_x002e_")));
+		out.print(dq("RowType." + tablenm));
 		out.println(">");
 		out.println("    <xsd:sequence>");
 		while (cols.next()) {
@@ -347,15 +344,11 @@ public final class XMLExporter extends E
 		out.println("  </xsd:complexType>");
 
 		out.print("  <xsd:complexType name=");
-		out.print(dq("TableType." + catalog.replaceAll("\\.", "_x002e_") +
-					"." + schema.replaceAll("\\.", "_x002e_") +
-					"." + name.replaceAll("\\.", "_x002e_")));
+		out.print(dq("TableType." + tablenm));
 		out.println(">");
 		out.println("    <xsd:sequence>");
 		out.print("      <xsd:element name=\"row\" type=");
-		out.print(dq("RowType." + catalog.replaceAll("\\.", "_x002e_") +
-					"." + schema.replaceAll("\\.", "_x002e_") +
-					"." + name.replaceAll("\\.", "_x002e_")));
+		out.print(dq("RowType." + tablenm));
 		out.println(" minOccurs=\"0\" maxOccurs=\"unbounded\" />");
 		out.println("    </xsd:sequence>");
 		out.println("  </xsd:complexType>");