Return-Path: X-Original-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5BF9B9BC1 for ; Wed, 21 Dec 2011 00:34:39 +0000 (UTC) Received: (qmail 4772 invoked by uid 500); 21 Dec 2011 00:34:39 -0000 Delivered-To: apmail-incubator-connectors-commits-archive@incubator.apache.org Received: (qmail 4722 invoked by uid 500); 21 Dec 2011 00:34:39 -0000 Mailing-List: contact connectors-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: connectors-dev@incubator.apache.org Delivered-To: mailing list connectors-commits@incubator.apache.org Received: (qmail 4715 invoked by uid 99); 21 Dec 2011 00:34:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Dec 2011 00:34:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_FILL_THIS_FORM_SHORT X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Dec 2011 00:34:36 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 27AA323889C5; Wed, 21 Dec 2011 00:34:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1221538 - in /incubator/lcf/trunk: ./ connectors/jdbc/ framework/ framework/core/src/main/java/org/apache/manifoldcf/core/database/ framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/ Date: Wed, 21 Dec 2011 00:34:15 -0000 To: connectors-commits@incubator.apache.org From: kwright@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111221003416.27AA323889C5@eris.apache.org> Author: kwright Date: Wed Dec 21 00:34:15 2011 New Revision: 1221538 URL: http://svn.apache.org/viewvc?rev=1221538&view=rev Log: Part of CONNECTORS-334. Incorporate changes from CONNECTORS-314 into the ant build, so that MySQL is usable as a database driver, for everything except reports. Modified: incubator/lcf/trunk/build.xml incubator/lcf/trunk/connectors/jdbc/build.xml incubator/lcf/trunk/framework/build.xml incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/BaseTable.java incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java Modified: incubator/lcf/trunk/build.xml URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/build.xml?rev=1221538&r1=1221537&r2=1221538&view=diff ============================================================================== --- incubator/lcf/trunk/build.xml (original) +++ incubator/lcf/trunk/build.xml Wed Dec 21 00:34:15 2011 @@ -172,6 +172,7 @@ + @@ -1212,7 +1213,7 @@ - + @@ -3703,7 +3704,11 @@ Use Apache Forrest version forrest-0.9-d - + + + + + Modified: incubator/lcf/trunk/connectors/jdbc/build.xml URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/connectors/jdbc/build.xml?rev=1221538&r1=1221537&r2=1221538&view=diff ============================================================================== --- incubator/lcf/trunk/connectors/jdbc/build.xml (original) +++ incubator/lcf/trunk/connectors/jdbc/build.xml Wed Dec 21 00:34:15 2011 @@ -70,10 +70,6 @@ - - - - - + Modified: incubator/lcf/trunk/framework/build.xml URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/build.xml?rev=1221538&r1=1221537&r2=1221538&view=diff ============================================================================== --- incubator/lcf/trunk/framework/build.xml (original) +++ incubator/lcf/trunk/framework/build.xml Wed Dec 21 00:34:15 2011 @@ -253,6 +253,7 @@ + @@ -288,6 +289,7 @@ + @@ -329,6 +331,7 @@ + @@ -404,6 +407,7 @@ + @@ -494,6 +498,7 @@ + Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/BaseTable.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/BaseTable.java?rev=1221538&r1=1221537&r2=1221538&view=diff ============================================================================== --- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/BaseTable.java (original) +++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/BaseTable.java Wed Dec 21 00:34:15 2011 @@ -153,7 +153,7 @@ public class BaseTable public void performRemoveIndex(String indexName) throws ManifoldCFException { - dbInterface.performRemoveIndex(indexName); + dbInterface.performRemoveIndex(indexName,tableName); } /** Analyze this table. @@ -318,6 +318,17 @@ public class BaseTable return CacheKeyFactory.makeTableKey(null,tableName,dbInterface.getDatabaseName()); } + /** Construct a count clause. + * On most databases this will be COUNT(col), but on some the count needs to be cast to a BIGINT, so + * CAST(COUNT(col) AS BIGINT) will be emitted instead. + *@param column is the column string to be counted. + *@return the query chunk needed. + */ + public String constructCountClause(String column) + { + return dbInterface.constructCountClause(column); + } + /** Construct a regular-expression match clause. * This method builds both the text part of a regular-expression match. *@param column is the column specifier string. Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java?rev=1221538&r1=1221537&r2=1221538&view=diff ============================================================================== --- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java (original) +++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java Wed Dec 21 00:34:15 2011 @@ -538,8 +538,9 @@ public class DBInterfaceDerby extends Da /** Remove an index. *@param indexName is the name of the index to remove. + *@param tableName is the table the index belongs to. */ - public void performRemoveIndex(String indexName) + public void performRemoveIndex(String indexName, String tableName) throws ManifoldCFException { performModification("DROP INDEX "+indexName,null,null); @@ -672,7 +673,7 @@ public class DBInterfaceDerby extends Da { String indexName = iter.next(); IndexDescription id = x.get(indexName); - performRemoveIndex(indexName); + performRemoveIndex(indexName,tableName); performAddIndex(indexName,tableName,id); } break; @@ -1027,6 +1028,17 @@ public class DBInterfaceDerby extends Da } } + /** Construct a count clause. + * On most databases this will be COUNT(col), but on some the count needs to be cast to a BIGINT, so + * CAST(COUNT(col) AS BIGINT) will be emitted instead. + *@param column is the column string to be counted. + *@return the query chunk needed. + */ + public String constructCountClause(String column) + { + return "CAST(COUNT("+column+") AS bigint)"; + } + /** Construct a regular-expression match clause. * This method builds both the text part of a regular-expression match. *@param column is the column specifier string. Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java?rev=1221538&r1=1221537&r2=1221538&view=diff ============================================================================== --- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java (original) +++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java Wed Dec 21 00:34:15 2011 @@ -546,8 +546,9 @@ public class DBInterfaceHSQLDB extends D /** Remove an index. *@param indexName is the name of the index to remove. + *@param tableName is the table the index belongs to. */ - public void performRemoveIndex(String indexName) + public void performRemoveIndex(String indexName, String tableName) throws ManifoldCFException { performModification("DROP INDEX "+indexName,null,null); @@ -978,6 +979,17 @@ public class DBInterfaceHSQLDB extends D } } + /** Construct a count clause. + * On most databases this will be COUNT(col), but on some the count needs to be cast to a BIGINT, so + * CAST(COUNT(col) AS BIGINT) will be emitted instead. + *@param column is the column string to be counted. + *@return the query chunk needed. + */ + public String constructCountClause(String column) + { + return "CAST(COUNT("+column+") AS bigint)"; + } + /** Construct a regular-expression match clause. * This method builds both the text part of a regular-expression match. *@param column is the column specifier string. Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java?rev=1221538&r1=1221537&r2=1221538&view=diff ============================================================================== --- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java (original) +++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceMySQL.java Wed Dec 21 00:34:15 2011 @@ -19,24 +19,35 @@ package org.apache.manifoldcf.core.database; import org.apache.manifoldcf.core.interfaces.*; +import org.apache.manifoldcf.core.system.ManifoldCF; import java.util.*; public class DBInterfaceMySQL extends Database implements IDBInterface { public static final String _rcsid = "@(#)$Id: DBInterfaceMySQL.java 999670 2010-09-21 22:18:19Z kwright $"; - private static final String _url = "jdbc:mysql://localhost/"; - private static final String _driver = "org.gjt.mm.mysql.Driver"; + /** MySQL server property */ + public static final String mysqlServerProperty = "org.apache.manifoldcf.mysql.server"; + private static final String _driver = "com.mysql.jdbc.Driver"; + protected String cacheKey; public DBInterfaceMySQL(IThreadContext tc, String databaseName, String userName, String password) throws ManifoldCFException { - super(tc,_url+databaseName,_driver,databaseName,userName,password); + super(tc,getJdbcUrl(databaseName),_driver,databaseName,userName,password); cacheKey = CacheKeyFactory.makeDatabaseKey(this.databaseName); } + private static String getJdbcUrl(String theDatabaseName) + { + String server = ManifoldCF.getProperty(mysqlServerProperty); + if (server == null || server.length() == 0) + server = "localhost"; + return "jdbc:mysql://"+server+"/"+theDatabaseName; + } + /** Initialize. This method is called once per JVM instance, in order to set up * database communication. */ @@ -69,7 +80,7 @@ public class DBInterfaceMySQL extends Da public void performLock(String tableName) throws ManifoldCFException { - performModification("LOCK TABLE "+tableName+" IN EXCLUSIVE MODE",null,null); + //performModification("LOCK TABLE "+tableName+" IN EXCLUSIVE MODE",null,null); } /** Perform an insert operation. @@ -239,32 +250,35 @@ public class DBInterfaceMySQL extends Da queryBuffer.append(','); else first = false; - queryBuffer.append(columnName); - queryBuffer.append(' '); - queryBuffer.append(cd.getTypeString()); - if (cd.getIsNull()) - queryBuffer.append(" NULL"); - else - queryBuffer.append(" NOT NULL"); - if (cd.getIsPrimaryKey()) - queryBuffer.append(" PRIMARY KEY"); - if (cd.getReferenceTable() != null) - { - queryBuffer.append(" REFERENCES "); - queryBuffer.append(cd.getReferenceTable()); - queryBuffer.append('('); - queryBuffer.append(cd.getReferenceColumn()); - queryBuffer.append(") ON DELETE"); - if (cd.getReferenceCascade()) - queryBuffer.append(" CASCADE"); - else - queryBuffer.append(" RESTRICT"); - } + appendDescription(queryBuffer,columnName,cd,false); } queryBuffer.append(')'); - performModification(queryBuffer.toString(),null,invalidateKeys); + } + protected static void appendDescription(StringBuilder queryBuffer, String columnName, ColumnDescription cd, boolean forceNull) + { + queryBuffer.append(columnName); + queryBuffer.append(' '); + queryBuffer.append(cd.getTypeString()); + if (forceNull || cd.getIsNull()) + queryBuffer.append(" NULL"); + else + queryBuffer.append(" NOT NULL"); + if (cd.getIsPrimaryKey()) + queryBuffer.append(" PRIMARY KEY"); + if (cd.getReferenceTable() != null) + { + queryBuffer.append(" REFERENCES "); + queryBuffer.append(cd.getReferenceTable()); + queryBuffer.append('('); + queryBuffer.append(cd.getReferenceColumn()); + queryBuffer.append(") ON DELETE"); + if (cd.getReferenceCascade()) + queryBuffer.append(" CASCADE"); + else + queryBuffer.append(" RESTRICT"); + } } /** Perform a table alter operation. @@ -282,7 +296,61 @@ public class DBInterfaceMySQL extends Da StringSet invalidateKeys) throws ManifoldCFException { - // MHL + beginTransaction(TRANSACTION_ENCLOSING); + try + { + if (columnDeleteList != null) + { + int i = 0; + while (i < columnDeleteList.size()) + { + String columnName = columnDeleteList.get(i++); + performModification("ALTER TABLE "+tableName+" DROP "+columnName,null,invalidateKeys); + } + } + + // Do the modifies. This involves renaming each column to a temp column, then creating a new one, then copying + if (columnModifyMap != null) + { + Iterator iter = columnModifyMap.keySet().iterator(); + while (iter.hasNext()) + { + String columnName = iter.next(); + ColumnDescription cd = columnModifyMap.get(columnName); + StringBuilder sb = new StringBuilder(); + appendDescription(sb,columnName,cd,false); + performModification("ALTER TABLE "+tableName+" MODIFY "+sb.toString(),null,invalidateKeys); + } + } + + // Now, do the adds + if (columnMap != null) + { + Iterator iter = columnMap.keySet().iterator(); + while (iter.hasNext()) + { + String columnName = iter.next(); + ColumnDescription cd = columnMap.get(columnName); + StringBuilder sb = new StringBuilder(); + appendDescription(sb,columnName,cd,false); + performModification("ALTER TABLE "+tableName+" ADD "+sb.toString(),null,invalidateKeys); + } + } + } + catch (ManifoldCFException e) + { + signalRollback(); + throw e; + } + catch (Error e) + { + signalRollback(); + throw e; + } + finally + { + endTransaction(); + } } /** Add an index to a table. @@ -343,11 +411,12 @@ public class DBInterfaceMySQL extends Da /** Remove an index. *@param indexName is the name of the index to remove. + *@param tableName is the table the index belongs to. */ - public void performRemoveIndex(String indexName) + public void performRemoveIndex(String indexName, String tableName) throws ManifoldCFException { - performModification("DROP INDEX "+indexName,null,null); + performModification("DROP INDEX "+indexName+" ON "+tableName,null,null); } /** Analyze a table. @@ -387,19 +456,34 @@ public class DBInterfaceMySQL extends Da throws ManifoldCFException { // Connect to super database + Database masterDatabase = new DBInterfaceMySQL(context,"mysql",adminUserName,adminPassword); + List list = new ArrayList(); - list.add("utf8"); - masterDatabase.executeQuery("CREATE DATABASE "+databaseName+" CHARACTER SET ?",list, - null,invalidateKeys,null,false,0,null,null); - if (userName != null) + try { - list.clear(); - list.add(userName); - list.add("localhost"); - list.add(password); - masterDatabase.executeQuery("GRANT ALL ON "+databaseName+".* TO ?@? IDENTIFIED BY ?",list, + list.add("utf8"); + masterDatabase.executeQuery("CREATE DATABASE "+databaseName+" CHARACTER SET ?",list, null,invalidateKeys,null,false,0,null,null); + } catch (ManifoldCFException e){ + if (e.getErrorCode() != 4) + throw new ManifoldCFException(e.getMessage()); + } + if (userName != null) + { + try { + list.clear(); + list.add(userName); + list.add("localhost"); + list.add(password); + masterDatabase.executeQuery("GRANT ALL ON "+databaseName+".* TO ?@? IDENTIFIED BY ?",list, + null,invalidateKeys,null,false,0,null,null); + } catch (ManifoldCFException e){ + if (e.getErrorCode() != 4) + throw new ManifoldCFException(e.getMessage()); + } + //masterDatabase.executeQuery("USE " + databaseName,null, + // null,invalidateKeys,null,false,0,null,null); } } @@ -414,6 +498,8 @@ public class DBInterfaceMySQL extends Da // Connect to super database Database masterDatabase = new DBInterfaceMySQL(context,"mysql",adminUserName,adminPassword); masterDatabase.executeQuery("DROP DATABASE "+databaseName,null,null,invalidateKeys,null,false,0,null,null); + //masterDatabase.executeQuery("USE mysql",null, + // null,invalidateKeys,null,false,0,null,null); } /** Perform a general database modification query. @@ -436,17 +522,48 @@ public class DBInterfaceMySQL extends Da public Map getTableSchema(String tableName, StringSet cacheKeys, String queryClass) throws ManifoldCFException { - IResultSet set = performQuery("DESCRIBE "+tableName,null,cacheKeys,queryClass); + StringBuilder query = new StringBuilder(); + List list = new ArrayList(); + list.add(databaseName.toUpperCase()); + list.add(tableName.toUpperCase()); + query.append("SELECT column_name, is_nullable, data_type, character_maximum_length ") + .append("FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA=? AND TABLE_NAME=?"); + IResultSet set = performQuery(query.toString(),list,cacheKeys,queryClass); + if (set.getRowCount() == 0) + return null; + + query = new StringBuilder(); + query.append("SELECT t1.column_name ") + .append("FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE t1, INFORMATION_SCHEMA.TABLE_CONSTRAINTS t2 ") + .append("WHERE t1.CONSTRAINT_NAME=t2.CONSTRAINT_NAME AND t1.TABLE_NAME=t2.TABLE_NAME AND ") + .append("t1.TABLE_SCHEMA=t2.TABLE_SCHEMA AND ") + .append("t1.TABLE_SCHEMA=? AND t1.TABLE_NAME=? AND t2.CONSTRAINT_TYPE='PRIMARY KEY'"); + IResultSet primarySet = performQuery(query.toString(),list,cacheKeys,queryClass); + String primaryKey = null; + if (primarySet.getRowCount() != 0) + primaryKey = ((String)primarySet.getRow(0).getValue("column_name")).toLowerCase(); + if (primaryKey == null) + primaryKey = ""; + // Digest the result Map rval = new HashMap(); int i = 0; while (i < set.getRowCount()) { IResultRow row = set.getRow(i++); - String fieldName = row.getValue("Field").toString(); - String type = row.getValue("Type").toString(); - boolean isNull = row.getValue("Null").toString().equals("YES"); - boolean isPrimaryKey = row.getValue("Key").toString().equals("PRI"); + String fieldName = ((String)row.getValue("column_name")).toLowerCase(); + String type = (String)row.getValue("data_type"); + Long width = (Long)row.getValue("character_maximum_length"); + String isNullable = (String)row.getValue("is_nullable"); + boolean isPrimaryKey = primaryKey.equals(fieldName); + boolean isNull = isNullable.equals("YES"); + String dataType; + if (type.equals("CHARACTER VARYING")) + dataType = "VARCHAR("+width.toString()+")"; + else if (type.equals("CLOB")) + dataType = "LONGVARCHAR"; + else + dataType = type; rval.put(fieldName,new ColumnDescription(type,isPrimaryKey,isNull,null,null,false)); } @@ -462,8 +579,61 @@ public class DBInterfaceMySQL extends Da public Map getTableIndexes(String tableName, StringSet cacheKeys, String queryClass) throws ManifoldCFException { - // MHL - return null; + Map rval = new HashMap(); + + String query = "SELECT index_name,column_name,non_unique,seq_in_index FROM INFORMATION_SCHEMA.STATISTICS "+ + "WHERE TABLE_SCHEMA=? AND TABLE_NAME=? ORDER BY index_name,seq_in_index ASC"; + List list = new ArrayList(); + list.add(databaseName.toUpperCase()); + list.add(tableName.toUpperCase()); + IResultSet result = performQuery(query,list,cacheKeys,queryClass); + String lastIndexName = null; + List indexColumns = null; + boolean isUnique = false; + int i = 0; + while (i < result.getRowCount()) + { + IResultRow row = result.getRow(i++); + String indexName = ((String)row.getValue("index_name")).toLowerCase(); + String columnName = ((String)row.getValue("column_name")).toLowerCase(); + String nonUnique = row.getValue("non_unique").toString(); + + if (lastIndexName != null && !lastIndexName.equals(indexName)) + { + addIndex(rval,lastIndexName,isUnique,indexColumns); + lastIndexName = null; + indexColumns = null; + isUnique = false; + } + + if (lastIndexName == null) + { + lastIndexName = indexName; + indexColumns = new ArrayList(); + isUnique = false; + } + indexColumns.add(columnName); + isUnique = nonUnique.equals("0"); + } + + if (lastIndexName != null) + addIndex(rval,lastIndexName,isUnique,indexColumns); + + return rval; + } + + protected void addIndex(Map rval, String indexName, boolean isUnique, List indexColumns) + { + if (indexName.equals("primary")) + return; + String[] columnNames = new String[indexColumns.size()]; + int i = 0; + while (i < columnNames.length) + { + columnNames[i] = indexColumns.get(i); + i++; + } + rval.put(indexName,new IndexDescription(isUnique,columnNames)); } /** Get a database's tables. @@ -541,6 +711,17 @@ public class DBInterfaceMySQL extends Da return executeQuery(query,params,cacheKeys,null,queryClass,true,maxResults,resultSpec,returnLimit); } + /** Construct a count clause. + * On most databases this will be COUNT(col), but on some the count needs to be cast to a BIGINT, so + * CAST(COUNT(col) AS BIGINT) will be emitted instead. + *@param column is the column string to be counted. + *@return the query chunk needed. + */ + public String constructCountClause(String column) + { + return "COUNT("+column+")"; + } + /** Construct a regular-expression match clause. * This method builds both the text part of a regular-expression match. *@param column is the column specifier string. Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java?rev=1221538&r1=1221537&r2=1221538&view=diff ============================================================================== --- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java (original) +++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfacePostgreSQL.java Wed Dec 21 00:34:15 2011 @@ -496,8 +496,9 @@ public class DBInterfacePostgreSQL exten /** Remove an index. *@param indexName is the name of the index to remove. + *@param tableName is the table the index belongs to. */ - public void performRemoveIndex(String indexName) + public void performRemoveIndex(String indexName, String tableName) throws ManifoldCFException { performModification("DROP INDEX "+indexName,null,null); @@ -865,6 +866,17 @@ public class DBInterfacePostgreSQL exten } } + /** Construct a count clause. + * On most databases this will be COUNT(col), but on some the count needs to be cast to a BIGINT, so + * CAST(COUNT(col) AS BIGINT) will be emitted instead. + *@param column is the column string to be counted. + *@return the query chunk needed. + */ + public String constructCountClause(String column) + { + return "COUNT("+column+")"; + } + /** Construct a regular-expression match clause. * This method builds both the text part of a regular-expression match. *@param column is the column specifier string. Modified: incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java?rev=1221538&r1=1221537&r2=1221538&view=diff ============================================================================== --- incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java (original) +++ incubator/lcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IDBInterface.java Wed Dec 21 00:34:15 2011 @@ -145,8 +145,9 @@ public interface IDBInterface /** Remove an index. *@param indexName is the name of the index to remove. + *@param tableName is the table the index belongs to. */ - public void performRemoveIndex(String indexName) + public void performRemoveIndex(String indexName, String tableName) throws ManifoldCFException; /** Analyze a table. @@ -258,6 +259,14 @@ public interface IDBInterface int maxResults, ResultSpecification resultSpec, ILimitChecker returnLimit) throws ManifoldCFException; + /** Construct a count clause. + * On most databases this will be COUNT(col), but on some the count needs to be cast to a BIGINT, so + * CAST(COUNT(col) AS BIGINT) will be emitted instead. + *@param column is the column string to be counted. + *@return the query chunk needed. + */ + public String constructCountClause(String column); + /** Construct a regular-expression match clause. * This method builds a regular-expression match expression. *@param column is the column specifier string.