[Schmitzm-commits] r1731 - trunk/schmitzm-core/src/main/java/de/schmitzm/postgres

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sun Sep 25 12:34:58 CEST 2011


Author: alfonx
Date: 2011-09-25 12:34:57 +0200 (Sun, 25 Sep 2011)
New Revision: 1731

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/postgres/PGUtil.java
Log:
Drop Index korrigiert...

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/postgres/PGUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/postgres/PGUtil.java	2011-09-25 09:52:01 UTC (rev 1730)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/postgres/PGUtil.java	2011-09-25 10:34:57 UTC (rev 1731)
@@ -339,7 +339,7 @@
 	 */
 	public static void addIndex(Connection c, final String tableName, final String columns, String idxPostfix,
 			final boolean unique) throws SQLException {
-		addIndex(c, tableName, columns, idxPostfix, unique, null, false);
+		addIndex(c, tableName, columns, idxPostfix, unique, null, null, false);
 	}
 
 	/**
@@ -386,12 +386,16 @@
 	 * @param tablespace
 	 *            <code>null</code> oder der name des tablespace in dem der
 	 *            Index liegen soll.
+	 * @param type
+	 *            <code>null</code> für DB default oder "hash" oder "btree" oder
+	 *            "gin" etc...
 	 * @param forceRecreationIfExistsAlready
 	 *            wenn <code>true</code> dann werden der Index vorher gedroppt
 	 *            falls er exisitert.
 	 */
 	public static void addIndex(Connection c, final String tableName, final String columns, String idxPostfix,
-			final boolean unique, String tablespace, boolean forceRecreationIfExistsAlready) throws SQLException {
+			final boolean unique, String tablespace, String type, boolean forceRecreationIfExistsAlready)
+			throws SQLException {
 		final String idxName = (tableName + "_" + idxPostfix).replace(".", "_");
 
 		// Wenn der Tablename ein Schema mit "schema.name" enthält, dann liefert
@@ -410,8 +414,7 @@
 				Statement s = c.createStatement();
 
 				// Hier die Schreibweise mit . für schematrennung verwenden
-				final String queryString = "DROP INDEX " + idxName + " ON " + tableName + " (" + columns + ") "
-						+ (tablespace == null ? "" : " TABLESPACE " + tablespace);
+				final String queryString = "DROP INDEX " + idxName;
 				try {
 					s.execute(queryString);
 					c.commit();
@@ -440,7 +443,8 @@
 		Statement s = c.createStatement();
 
 		final String queryString = "CREATE " + (unique ? "UNIQUE " : "") + "INDEX " + idxName + " ON " + tableName
-				+ " (" + columns + ") " + (tablespace == null ? "" : " TABLESPACE " + tablespace);
+				+ " (" + columns + ") " + (tablespace == null ? "" : " TABLESPACE " + tablespace)
+				+ (type == null ? "" : " USING  " + type);
 		try {
 			s.execute(queryString);
 			c.commit();



More information about the Schmitzm-commits mailing list