Class DBInterfaceMySQL
- java.lang.Object
-
- org.apache.manifoldcf.core.database.Database
-
- org.apache.manifoldcf.core.database.DBInterfaceMySQL
-
- All Implemented Interfaces:
IDBInterface
- Direct Known Subclasses:
DBInterfaceMariaDB
public class DBInterfaceMySQL extends Database implements IDBInterface
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classDBInterfaceMySQL.TableStatisticsTable accumulation records.-
Nested classes/interfaces inherited from class org.apache.manifoldcf.core.database.Database
Database.ExecuteQueryThread, Database.Modifications, Database.QueryCacheExecutor
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String_rcsidprotected static java.util.Map<java.lang.String,java.lang.Integer>analyzeThresholdsTable analyze thresholds, as read from configuration information.protected java.lang.StringcacheKeyprotected static intcommitThresholdThe number of inserts, deletes, etc.protected static java.util.Map<java.lang.String,DBInterfaceMySQL.TableStatistics>currentAnalyzeStatisticsAccumulated analyze statistics.protected ILockManagerlockManagerA lock manager handle.static java.lang.StringmysqlClientPropertySource system name or IPstatic java.lang.StringmysqlServerPropertyMySQL server propertystatic java.lang.StringmysqlSslPropertyMySQL ssl propertyprotected intserializableDepthprotected static java.lang.StringstatsAnalyzePrefixprotected static java.lang.StringstatslockAnalyzePrefixprotected java.util.List<java.lang.String>tablesToAnalyze-
Fields inherited from class org.apache.manifoldcf.core.database.Database
_TRANSACTION_, cacheManager, commitDone, connection, context, databaseName, debug, delayedTransactionDepth, doRollback, jdbcDriverClass, jdbcUrl, maxDBConnections, maxQueryTime, modificationsSet, password, random, th, userName
-
Fields inherited from interface org.apache.manifoldcf.core.interfaces.IDBInterface
TRANSACTION_ENCLOSING, TRANSACTION_READCOMMITTED, TRANSACTION_REPEATABLEREAD, TRANSACTION_SERIALIZED
-
-
Constructor Summary
Constructors Modifier Constructor Description DBInterfaceMySQL(IThreadContext tc, java.lang.String databaseName, java.lang.String userName, java.lang.String password)protectedDBInterfaceMySQL(IThreadContext tc, java.lang.String jdbcDriverClass, java.lang.String databaseName, java.lang.String userName, java.lang.String password)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddIndex(java.util.Map rval, java.lang.String indexName, boolean isUnique, java.util.List<java.lang.String> indexColumns)voidaddTableIndex(java.lang.String tableName, boolean unique, java.util.List<java.lang.String> columnList)Add an index to a table.voidanalyzeTable(java.lang.String tableName)Analyze a table.protected voidanalyzeTableInternal(java.lang.String tableName)protected static voidappendDescription(java.lang.StringBuilder queryBuffer, java.lang.String columnName, ColumnDescription cd, boolean forceNull, boolean includeRestrict)voidbeginTransaction()Begin a database transaction.voidbeginTransaction(int transactionType)Begin a database transaction.voidcloseDatabase()Uninitialize.protected voidcommitCurrentTransaction()Abstract method to commit a transactionjava.lang.StringconstructCountClause(java.lang.String column)Construct a count clause.java.lang.StringconstructDistinctOnClause(java.util.List outputParameters, java.lang.String baseQuery, java.util.List baseParameters, java.lang.String[] distinctFields, java.lang.String[] orderFields, boolean[] orderFieldsAscending, java.util.Map<java.lang.String,java.lang.String> otherFields)Construct a 'distinct on (x)' filter.java.lang.StringconstructDoubleCastClause(java.lang.String value)Construct a cast to a double value.java.lang.StringconstructIndexHintClause(java.lang.String tableName, IndexDescription description)Construct index hint clause.java.lang.StringconstructOffsetLimitClause(int offset, int limit, boolean afterOrderBy)Construct an offset/limit clause.java.lang.StringconstructRegexpClause(java.lang.String column, java.lang.String regularExpression, boolean caseInsensitive)Construct a regular-expression match clause.java.lang.StringconstructSubstringClause(java.lang.String column, java.lang.String regularExpression, boolean caseInsensitive)Construct a regular-expression substring clause.voidcreateUserAndDatabase(java.lang.String adminUserName, java.lang.String adminPassword, StringSet invalidateKeys)Create user and database.voiddropUserAndDatabase(java.lang.String adminUserName, java.lang.String adminPassword, StringSet invalidateKeys)Drop user and database.voidendTransaction()End a database transaction, either performing a commit or a rollback (depending on whether signalRollback() was called within the transaction).protected intgetActualTransactionType()StringSetgetAllTables(StringSet cacheKeys, java.lang.String queryClass)Get a database's tables.java.lang.StringgetDatabaseCacheKey()Get the database general cache key.protected java.lang.StringgetJdbcDriverClass()intgetMaxInClause()Obtain the maximum number of individual items that should be present in an IN clause.intgetMaxOrClause()Obtain the maximum number of individual clauses that should be present in a sequence of OR clauses.java.util.Map<java.lang.String,IndexDescription>getTableIndexes(java.lang.String tableName, StringSet cacheKeys, java.lang.String queryClass)Get a table's indexes.java.util.Map<java.lang.String,ColumnDescription>getTableSchema(java.lang.String tableName, StringSet cacheKeys, java.lang.String queryClass)Get a table's schema.intgetWindowedReportMaxRows()For windowed report queries, e.g.protected voidinterruptCleanup(java.sql.Connection connection)This method must clean up after a execute query thread has been forcibly interrupted.protected java.lang.StringmapLookupName(java.lang.String rawColumnName, java.lang.String rawLabelName)Abstract method for mapping a column lookup name from resultsetprotected static java.lang.StringmapType(java.lang.String inputType)Map a standard type into a derby type.protected voidnoteModificationsNoTransactions(java.lang.String tableName, int insertCount, int modifyCount, int deleteCount)Note a number of inserts, modifications, or deletions to a specific table.voidopenDatabase()Initialize.voidperformAddIndex(java.lang.String indexName, java.lang.String tableName, IndexDescription description)Add an index to a table.voidperformAlter(java.lang.String tableName, java.util.Map<java.lang.String,ColumnDescription> columnMap, java.util.Map<java.lang.String,ColumnDescription> columnModifyMap, java.util.List<java.lang.String> columnDeleteList, StringSet invalidateKeys)Perform a table alter operation.voidperformCreate(java.lang.String tableName, java.util.Map<java.lang.String,ColumnDescription> columnMap, StringSet invalidateKeys)Perform a table creation operation.voidperformDelete(java.lang.String tableName, java.lang.String whereClause, java.util.List whereParameters, StringSet invalidateKeys)Perform a delete operation.voidperformDrop(java.lang.String tableName, StringSet invalidateKeys)Perform a table drop operation.voidperformInsert(java.lang.String tableName, java.util.Map<java.lang.String,java.lang.Object> parameterMap, StringSet invalidateKeys)Perform an insert operation.voidperformModification(java.lang.String query, java.util.List params, StringSet invalidateKeys)Perform a general database modification query.IResultSetperformQuery(java.lang.String query, java.util.List params, StringSet cacheKeys, java.lang.String queryClass)Perform a general "data fetch" query.IResultSetperformQuery(java.lang.String query, java.util.List params, StringSet cacheKeys, java.lang.String queryClass, int maxResults, ILimitChecker returnLimit)Perform a general "data fetch" query.IResultSetperformQuery(java.lang.String query, java.util.List params, StringSet cacheKeys, java.lang.String queryClass, int maxResults, ResultSpecification resultSpec, ILimitChecker returnLimit)Perform a general "data fetch" query.voidperformRemoveIndex(java.lang.String indexName, java.lang.String tableName)Remove an index.voidperformUpdate(java.lang.String tableName, java.util.Map<java.lang.String,java.lang.Object> parameterMap, java.lang.String whereClause, java.util.List whereParameters, StringSet invalidateKeys)Perform an update operation.protected intreadDatum(java.lang.String datumName)Read a datum, presuming zero if the datum does not exist.voidreindexTable(java.lang.String tableName)Reindex a table.protected ManifoldCFExceptionreinterpretException(ManifoldCFException theException)Reinterpret an exception tossed by the database layer.protected voidrollbackCurrentTransaction()Abstract method to roll back a transactionvoidsignalRollback()Signal that a rollback should occur on the next endTransaction().protected voidstartATransaction()Abstract method to start a transactionprotected voidwriteDatum(java.lang.String datumName, int value)Write a datum, presuming zero if the datum does not exist.-
Methods inherited from class org.apache.manifoldcf.core.database.Database
buildConjunctionClause, cleanupParameters, constructIndexOrderByClause, constructOffsetLimitClause, execute, executeQuery, executeUncachedQuery, executeViaThread, explainQuery, findColumn, findConjunctionClauseMax, getBLOB, getCurrentTransactionType, getData, getDatabaseName, getObject, getSleepAmt, getTransactionID, initializeConnection, internalTransactionBegin, isBinary, isBLOB, loadPS, mapLabelName, noteModifications, performCommit, prepareForDatabaseCreate, sleepFor, synchronizeTransactions
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.manifoldcf.core.interfaces.IDBInterface
buildConjunctionClause, constructIndexOrderByClause, constructOffsetLimitClause, findConjunctionClauseMax, getDatabaseName, getSleepAmt, getTransactionID, noteModifications, performCommit, sleepFor
-
-
-
-
Field Detail
-
_rcsid
public static final java.lang.String _rcsid
- See Also:
- Constant Field Values
-
mysqlServerProperty
public static final java.lang.String mysqlServerProperty
MySQL server property- See Also:
- Constant Field Values
-
mysqlClientProperty
public static final java.lang.String mysqlClientProperty
Source system name or IP- See Also:
- Constant Field Values
-
mysqlSslProperty
public static final java.lang.String mysqlSslProperty
MySQL ssl property- See Also:
- Constant Field Values
-
lockManager
protected ILockManager lockManager
A lock manager handle.
-
serializableDepth
protected int serializableDepth
-
tablesToAnalyze
protected java.util.List<java.lang.String> tablesToAnalyze
-
currentAnalyzeStatistics
protected static java.util.Map<java.lang.String,DBInterfaceMySQL.TableStatistics> currentAnalyzeStatistics
Accumulated analyze statistics. This map is keyed by the table name, and contains TableStatistics values.
-
analyzeThresholds
protected static java.util.Map<java.lang.String,java.lang.Integer> analyzeThresholds
Table analyze thresholds, as read from configuration information. Keyed by table name, contains Integer values.
-
commitThreshold
protected static final int commitThreshold
The number of inserts, deletes, etc. before we update the shared area.- See Also:
- Constant Field Values
-
statslockAnalyzePrefix
protected static final java.lang.String statslockAnalyzePrefix
- See Also:
- Constant Field Values
-
statsAnalyzePrefix
protected static final java.lang.String statsAnalyzePrefix
- See Also:
- Constant Field Values
-
cacheKey
protected java.lang.String cacheKey
-
-
Constructor Detail
-
DBInterfaceMySQL
public DBInterfaceMySQL(IThreadContext tc, java.lang.String databaseName, java.lang.String userName, java.lang.String password) throws ManifoldCFException
- Throws:
ManifoldCFException
-
DBInterfaceMySQL
protected DBInterfaceMySQL(IThreadContext tc, java.lang.String jdbcDriverClass, java.lang.String databaseName, java.lang.String userName, java.lang.String password) throws ManifoldCFException
- Throws:
ManifoldCFException
-
-
Method Detail
-
getJdbcDriverClass
protected java.lang.String getJdbcDriverClass()
-
interruptCleanup
protected void interruptCleanup(java.sql.Connection connection)
This method must clean up after a execute query thread has been forcibly interrupted. It has been separated because some JDBC drivers don't handle forcible interrupts appropriately.- Overrides:
interruptCleanupin classDatabase
-
reinterpretException
protected ManifoldCFException reinterpretException(ManifoldCFException theException)
Reinterpret an exception tossed by the database layer. We need to disambiguate the various kinds of exception that should be thrown.- Parameters:
theException- is the exception to reinterpret- Returns:
- the reinterpreted exception to throw.
-
mapLookupName
protected java.lang.String mapLookupName(java.lang.String rawColumnName, java.lang.String rawLabelName)Abstract method for mapping a column lookup name from resultset- Overrides:
mapLookupNamein classDatabase
-
openDatabase
public void openDatabase() throws ManifoldCFExceptionInitialize. This method is called once per JVM instance, in order to set up database communication.- Specified by:
openDatabasein interfaceIDBInterface- Throws:
ManifoldCFException
-
closeDatabase
public void closeDatabase() throws ManifoldCFExceptionUninitialize. This method is called during JVM shutdown, in order to close all database communication.- Specified by:
closeDatabasein interfaceIDBInterface- Throws:
ManifoldCFException
-
getDatabaseCacheKey
public java.lang.String getDatabaseCacheKey()
Get the database general cache key.- Specified by:
getDatabaseCacheKeyin interfaceIDBInterface- Returns:
- the general cache key for the database.
-
performInsert
public void performInsert(java.lang.String tableName, java.util.Map<java.lang.String,java.lang.Object> parameterMap, StringSet invalidateKeys) throws ManifoldCFExceptionPerform an insert operation.- Specified by:
performInsertin interfaceIDBInterface- Parameters:
tableName- is the name of the table.invalidateKeys- are the cache keys that should be invalidated.parameterMap- is the map of column name/values to write.- Throws:
ManifoldCFException
-
performUpdate
public void performUpdate(java.lang.String tableName, java.util.Map<java.lang.String,java.lang.Object> parameterMap, java.lang.String whereClause, java.util.List whereParameters, StringSet invalidateKeys) throws ManifoldCFExceptionPerform an update operation.- Specified by:
performUpdatein interfaceIDBInterface- Parameters:
tableName- is the name of the table.invalidateKeys- are the cache keys that should be invalidated.parameterMap- is the map of column name/values to write.whereClause- is the where clause describing the match (including the WHERE), or null if none.whereParameters- are the parameters that come with the where clause, if any.- Throws:
ManifoldCFException
-
performDelete
public void performDelete(java.lang.String tableName, java.lang.String whereClause, java.util.List whereParameters, StringSet invalidateKeys) throws ManifoldCFExceptionPerform a delete operation.- Specified by:
performDeletein interfaceIDBInterface- Parameters:
tableName- is the name of the table to delete from.invalidateKeys- are the cache keys that should be invalidated.whereClause- is the where clause describing the match (including the WHERE), or null if none.whereParameters- are the parameters that come with the where clause, if any.- Throws:
ManifoldCFException
-
performCreate
public void performCreate(java.lang.String tableName, java.util.Map<java.lang.String,ColumnDescription> columnMap, StringSet invalidateKeys) throws ManifoldCFExceptionPerform a table creation operation.- Specified by:
performCreatein interfaceIDBInterface- Parameters:
tableName- is the name of the table to create.columnMap- is the map describing the columns and types. NOTE that these are abstract types, which will be mapped to the proper types for the actual database inside this layer.invalidateKeys- are the cache keys that should be invalidated, if any.- Throws:
ManifoldCFException
-
appendDescription
protected static void appendDescription(java.lang.StringBuilder queryBuffer, java.lang.String columnName, ColumnDescription cd, boolean forceNull, boolean includeRestrict)
-
mapType
protected static java.lang.String mapType(java.lang.String inputType)
Map a standard type into a derby type.- Parameters:
inputType- is the input type.- Returns:
- the output type.
-
performAlter
public void performAlter(java.lang.String tableName, java.util.Map<java.lang.String,ColumnDescription> columnMap, java.util.Map<java.lang.String,ColumnDescription> columnModifyMap, java.util.List<java.lang.String> columnDeleteList, StringSet invalidateKeys) throws ManifoldCFExceptionPerform a table alter operation.- Specified by:
performAlterin interfaceIDBInterface- Parameters:
tableName- is the name of the table to alter.columnMap- is the map describing the columns and types to add. These are in the same form as for performCreate.columnModifyMap- is the map describing the columns to be changed. The key is the existing column name, and the value is the new type of the column. Data will be copied from the old column to the new.columnDeleteList- is the list of column names to delete.invalidateKeys- are the cache keys that should be invalidated, if any.- Throws:
ManifoldCFException
-
addTableIndex
public void addTableIndex(java.lang.String tableName, boolean unique, java.util.List<java.lang.String> columnList) throws ManifoldCFExceptionAdd an index to a table.- Specified by:
addTableIndexin interfaceIDBInterface- Parameters:
tableName- is the name of the table to add the index for.unique- is a boolean that if true describes a unique index.columnList- is the list of columns that need to be included in the index, in order.- Throws:
ManifoldCFException
-
performAddIndex
public void performAddIndex(java.lang.String indexName, java.lang.String tableName, IndexDescription description) throws ManifoldCFExceptionAdd an index to a table.- Specified by:
performAddIndexin interfaceIDBInterface- Parameters:
tableName- is the name of the table to add the index for.indexName- is the optional name of the table index. If null, a name will be chosen automatically.description- is the index description.- Throws:
ManifoldCFException
-
performRemoveIndex
public void performRemoveIndex(java.lang.String indexName, java.lang.String tableName) throws ManifoldCFExceptionRemove an index.- Specified by:
performRemoveIndexin interfaceIDBInterface- Parameters:
indexName- is the name of the index to remove.tableName- is the table the index belongs to.- Throws:
ManifoldCFException
-
readDatum
protected int readDatum(java.lang.String datumName) throws ManifoldCFExceptionRead a datum, presuming zero if the datum does not exist.- Throws:
ManifoldCFException
-
writeDatum
protected void writeDatum(java.lang.String datumName, int value) throws ManifoldCFExceptionWrite a datum, presuming zero if the datum does not exist.- Throws:
ManifoldCFException
-
analyzeTable
public void analyzeTable(java.lang.String tableName) throws ManifoldCFExceptionAnalyze a table.- Specified by:
analyzeTablein interfaceIDBInterface- Parameters:
tableName- is the name of the table to analyze/calculate statistics for.- Throws:
ManifoldCFException
-
reindexTable
public void reindexTable(java.lang.String tableName) throws ManifoldCFExceptionReindex a table.- Specified by:
reindexTablein interfaceIDBInterface- Parameters:
tableName- is the name of the table to rebuild indexes for.- Throws:
ManifoldCFException
-
analyzeTableInternal
protected void analyzeTableInternal(java.lang.String tableName) throws ManifoldCFException- Throws:
ManifoldCFException
-
performDrop
public void performDrop(java.lang.String tableName, StringSet invalidateKeys) throws ManifoldCFExceptionPerform a table drop operation.- Specified by:
performDropin interfaceIDBInterface- Parameters:
tableName- is the name of the table to drop.invalidateKeys- are the cache keys that should be invalidated, if any.- Throws:
ManifoldCFException
-
createUserAndDatabase
public void createUserAndDatabase(java.lang.String adminUserName, java.lang.String adminPassword, StringSet invalidateKeys) throws ManifoldCFExceptionCreate user and database.- Specified by:
createUserAndDatabasein interfaceIDBInterface- Parameters:
adminUserName- is the admin user name.adminPassword- is the admin password.invalidateKeys- are the cache keys that should be invalidated, if any.- Throws:
ManifoldCFException
-
dropUserAndDatabase
public void dropUserAndDatabase(java.lang.String adminUserName, java.lang.String adminPassword, StringSet invalidateKeys) throws ManifoldCFExceptionDrop user and database.- Specified by:
dropUserAndDatabasein interfaceIDBInterface- Parameters:
adminUserName- is the admin user name.adminPassword- is the admin password.invalidateKeys- are the cache keys that should be invalidated, if any.- Throws:
ManifoldCFException
-
performModification
public void performModification(java.lang.String query, java.util.List params, StringSet invalidateKeys) throws ManifoldCFExceptionPerform a general database modification query.- Specified by:
performModificationin interfaceIDBInterface- Parameters:
query- is the query string.params- are the parameterized values, if needed.invalidateKeys- are the cache keys to invalidate.- Throws:
ManifoldCFException
-
getTableSchema
public java.util.Map<java.lang.String,ColumnDescription> getTableSchema(java.lang.String tableName, StringSet cacheKeys, java.lang.String queryClass) throws ManifoldCFException
Get a table's schema.- Specified by:
getTableSchemain interfaceIDBInterface- Parameters:
tableName- is the name of the table.cacheKeys- are the keys against which to cache the query, or null.queryClass- is the name of the query class, or null.- Returns:
- a map of column names and ColumnDescription objects, describing the schema.
- Throws:
ManifoldCFException
-
getTableIndexes
public java.util.Map<java.lang.String,IndexDescription> getTableIndexes(java.lang.String tableName, StringSet cacheKeys, java.lang.String queryClass) throws ManifoldCFException
Get a table's indexes.- Specified by:
getTableIndexesin interfaceIDBInterface- Parameters:
tableName- is the name of the table.cacheKeys- are the keys against which to cache the query, or null.queryClass- is the name of the query class, or null.- Returns:
- a map of index names and IndexDescription objects, describing the indexes.
- Throws:
ManifoldCFException
-
addIndex
protected void addIndex(java.util.Map rval, java.lang.String indexName, boolean isUnique, java.util.List<java.lang.String> indexColumns)
-
getAllTables
public StringSet getAllTables(StringSet cacheKeys, java.lang.String queryClass) throws ManifoldCFException
Get a database's tables.- Specified by:
getAllTablesin interfaceIDBInterface- Parameters:
cacheKeys- are the cache keys for the query, or null.queryClass- is the name of the query class, or null.- Returns:
- the set of tables.
- Throws:
ManifoldCFException
-
performQuery
public IResultSet performQuery(java.lang.String query, java.util.List params, StringSet cacheKeys, java.lang.String queryClass) throws ManifoldCFException
Perform a general "data fetch" query.- Specified by:
performQueryin interfaceIDBInterface- Parameters:
query- is the query string.params- are the parameterized values, if needed.cacheKeys- are the cache keys, if needed (null if no cache desired).queryClass- is the LRU class name against which this query would be cached, or null if no LRU behavior desired.- Returns:
- a resultset.
- Throws:
ManifoldCFException
-
performQuery
public IResultSet performQuery(java.lang.String query, java.util.List params, StringSet cacheKeys, java.lang.String queryClass, int maxResults, ILimitChecker returnLimit) throws ManifoldCFException
Perform a general "data fetch" query.- Specified by:
performQueryin interfaceIDBInterface- Parameters:
query- is the query string.params- are the parameterized values, if needed.cacheKeys- are the cache keys, if needed (null if no cache desired).queryClass- is the LRU class name against which this query would be cached, or null if no LRU behavior desired.maxResults- is the maximum number of results returned (-1 for all).returnLimit- is a description of how to limit the return result, or null if no limit.- Returns:
- a resultset.
- Throws:
ManifoldCFException
-
performQuery
public IResultSet performQuery(java.lang.String query, java.util.List params, StringSet cacheKeys, java.lang.String queryClass, int maxResults, ResultSpecification resultSpec, ILimitChecker returnLimit) throws ManifoldCFException
Perform a general "data fetch" query.- Specified by:
performQueryin interfaceIDBInterface- Parameters:
query- is the query string.params- are the parameterized values, if needed.cacheKeys- are the cache keys, if needed (null if no cache desired).queryClass- is the LRU class name against which this query would be cached, or null if no LRU behavior desired.maxResults- is the maximum number of results returned (-1 for all).resultSpec- is a result specification, or null for the standard treatment.returnLimit- is a description of how to limit the return result, or null if no limit.- Returns:
- a resultset.
- Throws:
ManifoldCFException
-
constructIndexHintClause
public java.lang.String constructIndexHintClause(java.lang.String tableName, IndexDescription description) throws ManifoldCFExceptionConstruct index hint clause. On most databases this returns an empty string, but on MySQL this returns a USE INDEX hint. It requires the name of an index.- Specified by:
constructIndexHintClausein interfaceIDBInterface- Overrides:
constructIndexHintClausein classDatabase- Parameters:
tableName- is the table the index is from.description- is the description of an index, which is expected to exist.- Returns:
- the query chunk that should go between the table names and the WHERE clause.
- Throws:
ManifoldCFException
-
constructDoubleCastClause
public java.lang.String constructDoubleCastClause(java.lang.String value)
Construct a cast to a double value. On most databases this cast needs to be explicit, but on some it is implicit (and cannot be in fact specified).- Specified by:
constructDoubleCastClausein interfaceIDBInterface- Parameters:
value- is the value to be cast.- Returns:
- the query chunk needed.
-
constructCountClause
public java.lang.String constructCountClause(java.lang.String column)
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.- Specified by:
constructCountClausein interfaceIDBInterface- Parameters:
column- is the column string to be counted.- Returns:
- the query chunk needed.
-
constructRegexpClause
public java.lang.String constructRegexpClause(java.lang.String column, java.lang.String regularExpression, boolean caseInsensitive)Construct a regular-expression match clause. This method builds both the text part of a regular-expression match.- Specified by:
constructRegexpClausein interfaceIDBInterface- Parameters:
column- is the column specifier string.regularExpression- is the properly-quoted regular expression string, or "?" if a parameterized value is to be used.caseInsensitive- is true of the regular expression match is to be case insensitive.- Returns:
- the query chunk needed, not padded with spaces on either side.
-
constructSubstringClause
public java.lang.String constructSubstringClause(java.lang.String column, java.lang.String regularExpression, boolean caseInsensitive)Construct a regular-expression substring clause. This method builds an expression that extracts a specified string section from a field, based on a regular expression.- Specified by:
constructSubstringClausein interfaceIDBInterface- Parameters:
column- is the column specifier string.regularExpression- is the properly-quoted regular expression string, or "?" if a parameterized value is to be used.caseInsensitive- is true if the regular expression match is to be case insensitive.- Returns:
- the expression chunk needed, not padded with spaces on either side.
-
constructOffsetLimitClause
public java.lang.String constructOffsetLimitClause(int offset, int limit, boolean afterOrderBy)Construct an offset/limit clause. This method constructs an offset/limit clause in the proper manner for the database in question.- Specified by:
constructOffsetLimitClausein interfaceIDBInterface- Specified by:
constructOffsetLimitClausein classDatabase- Parameters:
offset- is the starting offset number.limit- is the limit of result rows to return.afterOrderBy- is true if this offset/limit comes after an ORDER BY.- Returns:
- the proper clause, with no padding spaces on either side.
-
constructDistinctOnClause
public java.lang.String constructDistinctOnClause(java.util.List outputParameters, java.lang.String baseQuery, java.util.List baseParameters, java.lang.String[] distinctFields, java.lang.String[] orderFields, boolean[] orderFieldsAscending, java.util.Map<java.lang.String,java.lang.String> otherFields)Construct a 'distinct on (x)' filter. This filter wraps a query and returns a new query whose results are similar to POSTGRESQL's DISTINCT-ON feature. Specifically, for each combination of the specified distinct fields in the result, only the first such row is included in the final result.- Specified by:
constructDistinctOnClausein interfaceIDBInterface- Parameters:
outputParameters- is a blank list into which to put parameters. Null may be used if the baseParameters parameter is null.baseQuery- is the base query, which is another SELECT statement, without parens, e.g. "SELECT ..."baseParameters- are the parameters corresponding to the baseQuery.distinctFields- are the fields to consider to be distinct. These should all be keys in otherFields below.orderFields- are the otherfield keys that determine the ordering.orderFieldsAscending- are true for orderFields that are ordered as ASC, false for DESC.otherFields- are the rest of the fields to return, keyed by the AS name, value being the base query column value, e.g. "value AS key"- Returns:
- a revised query that performs the necessary DISTINCT ON operation. The list outputParameters will also be appropriately filled in.
-
getMaxInClause
public int getMaxInClause()
Obtain the maximum number of individual items that should be present in an IN clause. Exceeding this amount will potentially cause the query performance to drop.- Specified by:
getMaxInClausein interfaceIDBInterface- Specified by:
getMaxInClausein classDatabase- Returns:
- the maximum number of IN clause members.
-
getMaxOrClause
public int getMaxOrClause()
Obtain the maximum number of individual clauses that should be present in a sequence of OR clauses. Exceeding this amount will potentially cause the query performance to drop.- Specified by:
getMaxOrClausein interfaceIDBInterface- Returns:
- the maximum number of OR clause members.
-
getWindowedReportMaxRows
public int getWindowedReportMaxRows()
For windowed report queries, e.g. maxActivity or maxBandwidth, obtain the maximum number of rows that can reasonably be expected to complete in an acceptable time.- Specified by:
getWindowedReportMaxRowsin interfaceIDBInterface- Returns:
- the maximum number of rows.
-
beginTransaction
public void beginTransaction() throws ManifoldCFExceptionBegin a database transaction. This method call MUST be paired with an endTransaction() call, or database handles will be lost. If the transaction should be rolled back, then signalRollback() should be called before the transaction is ended. It is strongly recommended that the code that uses transactions be structured so that a try block starts immediately after this method call. The body of the try block will contain all direct or indirect calls to executeQuery(). After this should be a catch for every exception type, including Error, which should call the signalRollback() method, and rethrow the exception. Then, after that a finally{} block which calls endTransaction().- Specified by:
beginTransactionin interfaceIDBInterface- Throws:
ManifoldCFException
-
getActualTransactionType
protected int getActualTransactionType()
-
beginTransaction
public void beginTransaction(int transactionType) throws ManifoldCFExceptionBegin a database transaction. This method call MUST be paired with an endTransaction() call, or database handles will be lost. If the transaction should be rolled back, then signalRollback() should be called before the transaction is ended. It is strongly recommended that the code that uses transactions be structured so that a try block starts immediately after this method call. The body of the try block will contain all direct or indirect calls to executeQuery(). After this should be a catch for every exception type, including Error, which should call the signalRollback() method, and rethrow the exception. Then, after that a finally{} block which calls endTransaction().- Specified by:
beginTransactionin interfaceIDBInterface- Overrides:
beginTransactionin classDatabase- Parameters:
transactionType- is the kind of transaction desired.- Throws:
ManifoldCFException
-
startATransaction
protected void startATransaction() throws ManifoldCFExceptionAbstract method to start a transaction- Overrides:
startATransactionin classDatabase- Throws:
ManifoldCFException
-
commitCurrentTransaction
protected void commitCurrentTransaction() throws ManifoldCFExceptionAbstract method to commit a transaction- Overrides:
commitCurrentTransactionin classDatabase- Throws:
ManifoldCFException
-
signalRollback
public void signalRollback()
Signal that a rollback should occur on the next endTransaction().- Specified by:
signalRollbackin interfaceIDBInterface- Overrides:
signalRollbackin classDatabase
-
endTransaction
public void endTransaction() throws ManifoldCFExceptionEnd a database transaction, either performing a commit or a rollback (depending on whether signalRollback() was called within the transaction).- Specified by:
endTransactionin interfaceIDBInterface- Overrides:
endTransactionin classDatabase- Throws:
ManifoldCFException
-
rollbackCurrentTransaction
protected void rollbackCurrentTransaction() throws ManifoldCFExceptionAbstract method to roll back a transaction- Overrides:
rollbackCurrentTransactionin classDatabase- Throws:
ManifoldCFException
-
noteModificationsNoTransactions
protected void noteModificationsNoTransactions(java.lang.String tableName, int insertCount, int modifyCount, int deleteCount) throws ManifoldCFExceptionNote a number of inserts, modifications, or deletions to a specific table. This is so we can decide when to do appropriate maintenance.- Overrides:
noteModificationsNoTransactionsin classDatabase- Parameters:
tableName- is the name of the table being modified.insertCount- is the number of inserts.modifyCount- is the number of updates.deleteCount- is the number of deletions.- Throws:
ManifoldCFException
-
-