Class DialectMySQL
java.lang.Object
org.nuxeo.ecm.core.storage.sql.jdbc.dialect.Dialect
org.nuxeo.ecm.core.storage.sql.jdbc.dialect.DialectMySQL
MySQL-specific dialect.
- Author:
- Florent Guillaume
-
Nested Class Summary
Nested classes/interfaces inherited from class org.nuxeo.ecm.core.storage.sql.jdbc.dialect.Dialect
Dialect.ArraySubQuery, Dialect.DialectIdType, Dialect.FulltextMatchInfo, Dialect.JDBCInfo
-
Field Summary
Modifier and TypeFieldDescriptionprotected final boolean
protected final boolean
Fields inherited from class org.nuxeo.ecm.core.storage.sql.jdbc.dialect.Dialect
aclOptimizationsEnabled, ARRAY_SEP, clusteringEnabled, DEBUG_REAL_UUIDS, DEBUG_UUIDS, descending, DIALECT_CLASS, DIALECTS, fulltextDisabled, fulltextSearchDisabled, HEX_DIGITS, NULLS_LAST_ON_DESC_PROP, proxiesEnabled, readAclMaxSize, softDeleteEnabled, storesUpperCaseIdentifiers
-
Constructor Summary
ConstructorDescriptionDialectMySQL
(DatabaseMetaData metadata, RepositoryDescriptor repositoryDescriptor) -
Method Summary
Modifier and TypeMethodDescriptionaddPagingClause
(String sql, long limit, long offset) Returns the SQL query with a paging clausecheckStoredProcedure
(String procName, String procCreate, String ddlMode, Connection connection, JDBCLogger logger, Map<String, Serializable> properties) Checks if a given stored procedure exists and is identical to the passed creation SQL.char
boolean
When doing an UPDATE t SET ...getAddForeignKeyConstraintString
(String constraintName, String[] foreignKeys, String referencedTable, String[] primaryKeys, boolean referencesPrimaryKey) getBinaryFulltextSql
(List<String> columns) Return the SQL to get the columns fulltext fieldsGets the SQL to query invalidations for this cluster node.Gets the SQL to send an invalidation to the cluster.getCreateFulltextIndexSql
(String indexName, String quotedIndexName, Table table, List<Column> columns, Model model) Gets a CREATE INDEX statement for a fulltext index.getDialectFulltextQuery
(String query) Get the dialect-specific version of a fulltext query.Collection<? extends String>
Returns the initial DDL statements to add to a DDL dump.Collection<? extends String>
Returns the final DDL statements to add to a DDL dump.getFromResultSet
(ResultSet rs, int index, Column column) int
Specifies what columns of the fulltext table have to be indexed.getFulltextScoredMatchInfo
(String fulltextQuery, String indexName, int nthMatch, Column mainColumn, Model model, Database database) Gets the SQL information needed to do a a fulltext match, either with a direct expression in the WHERE clause, or using a join with an additional table.getInsertOnConflictDoNothingSql
(List<Column> columns, List<Serializable> values, List<Column> outColumns, List<Serializable> outValues) Gets the SQL string for an INSERT ...getInTreeSql
(String idColumnName, String id) Gets the expression to use to check tree membership.Gets the JDBC type and string from Nuxeo's type abstraction.boolean
Does the fulltext synthetic column have to be materialized.protected int
getSecurityCheckSql
(String idColumnName) Gets the expression to use to check security.getSQLForDump
(String sql) Returns the SQL statement with proper terminator to use in a dump.Gets the name of the file containing the SQL statements.getSQLStatementsProperties
(Model model, Database database) Gets the properties to use with the SQL statements.getTableTypeString
(Table table) getUpsertSql
(List<Column> columns, List<Serializable> values, List<Column> outColumns, List<Serializable> outValues) Gets the SQL string for an UPSERT expression.boolean
isAllowedConversion
(int expected, int actual, String actualName, int actualSize) Check mismatches between expected and actual JDBC types read from database introspection.boolean
Does clustering fetch of invalidations (Dialect.getClusterGetInvalidations()
) need a separate delete for them.boolean
Checks that clustering is supported.boolean
Checks if an exception received means that a concurrent update was detected.boolean
Checks if an identity column is already defined as a primary key and does not need a separate index added.boolean
Whether a derived table (subselect in a FROM statement) needs an alias.boolean
When doing a SELECT DISTINCT that uses a ORDER BY, do the keys along which we order have to be mentioned in the DISTINCT clause?protected static String
normalizeString
(String string) char
boolean
void
setToPreparedStatement
(PreparedStatement ps, int index, Serializable value, Column column) boolean
boolean
Indicates if dialect supports pagingboolean
Does the dialect support UPDATE t SET ...protected static void
translateForMySQL
(FulltextQueryAnalyzer.FulltextQuery ft, FulltextQueryAnalyzer.Op superOp, StringBuilder sb) Methods inherited from class org.nuxeo.ecm.core.storage.sql.jdbc.dialect.Dialect
castIdToVarchar, createArrayOf, createDialect, getAddColumnString, getAddPrimaryKeyConstraintString, getAncestorsIdsSql, getArrayElementString, getArrayIlikeSql, getArrayInSql, getArrayLikeSql, getArrayResult, getArraySubQuery, getBlobLengthFunction, getCalendarFromTimestamp, getCalendarFromTimestamp, getCascadeDropConstraintsString, getClobCast, getColumnName, getConnectionSchema, getCreateIndexSql, getCustomColumnDefinition, getCustomPostCreateSqls, getDateCast, getDescending, getForeignKeyConstraintName, getFreeVariableSetterForType, getFromResultSetString, getFromResultSetTimestamp, getFulltextType, getGeneratedId, getIdentityGeneratedKeySql, getIdType, getIgnoredColumns, getIndexName, getLikeEscaping, getMatchMixinType, getMaximumArgsForIn, getMaxIndexNameSize, getNoColumnsInsertString, getNullColumnString, getPostCreateIdentityColumnSql, getPrepareUserReadAclsSql, getPrimaryKeyConstraintName, getQuotedNameForExpression, getReadAclsCheckSql, getRebuildReadAclsSql, getReturnResultSet, getSoftDeleteCleanupSql, getSoftDeleteSql, getStartupSqls, getTableName, getTimestampFromCalendar, getTimestampFromCalendar, getUpdateReadAclsSql, getValidationQuery, hasIdentityGeneratedKey, hasNullEmptyString, jdbcInfo, jdbcInfo, jdbcInfo, jdbcInfo, makeName, makeName, needsNullsLastOnDescSort, needsOracleJoins, needsOriginalColumnInGroupBy, needsPrepareUserReadAcls, performAdditionalStatements, performPostOpenStatements, registerReturnParameter, setId, setIdLong, setToPreparedStatementString, setToPreparedStatementTimestamp, storesUpperCaseIdentifiers, supportsAncestorsTable, supportsArrayColumns, supportsArrays, supportsArraysReturnInsteadOfRows, supportsBatchUpdateCount, supportsCircularCascadeDeleteConstraints, supportsFastDescendants, supportsIfExistsAfterTableName, supportsIlike, supportsMultipleFulltextIndexes, supportsReadAcl, supportsScroll, supportsSysNameArray, supportsWith, toBooleanValueString, toHexString
-
Field Details
-
disableVersionACL
protected final boolean disableVersionACL -
disableReadVersionPermission
protected final boolean disableReadVersionPermission
-
-
Constructor Details
-
DialectMySQL
-
-
Method Details
-
openQuote
public char openQuote() -
closeQuote
public char closeQuote()- Overrides:
closeQuote
in classDialect
-
getAddForeignKeyConstraintString
public String getAddForeignKeyConstraintString(String constraintName, String[] foreignKeys, String referencedTable, String[] primaryKeys, boolean referencesPrimaryKey) - Overrides:
getAddForeignKeyConstraintString
in classDialect
-
qualifyIndexName
public boolean qualifyIndexName()- Overrides:
qualifyIndexName
in classDialect
-
supportsIfExistsBeforeTableName
public boolean supportsIfExistsBeforeTableName()- Overrides:
supportsIfExistsBeforeTableName
in classDialect
-
getJDBCTypeAndString
Description copied from class:Dialect
Gets the JDBC type and string from Nuxeo's type abstraction.- Specified by:
getJDBCTypeAndString
in classDialect
-
isAllowedConversion
Description copied from class:Dialect
Check mismatches between expected and actual JDBC types read from database introspection.- Overrides:
isAllowedConversion
in classDialect
-
setToPreparedStatement
public void setToPreparedStatement(PreparedStatement ps, int index, Serializable value, Column column) throws SQLException - Specified by:
setToPreparedStatement
in classDialect
- Throws:
SQLException
-
getFromResultSet
- Specified by:
getFromResultSet
in classDialect
- Throws:
SQLException
-
getMaxNameSize
protected int getMaxNameSize()- Overrides:
getMaxNameSize
in classDialect
-
getCreateFulltextIndexSql
public String getCreateFulltextIndexSql(String indexName, String quotedIndexName, Table table, List<Column> columns, Model model) Description copied from class:Dialect
Gets a CREATE INDEX statement for a fulltext index.- Specified by:
getCreateFulltextIndexSql
in classDialect
-
getDialectFulltextQuery
Description copied from class:Dialect
Get the dialect-specific version of a fulltext query.- Specified by:
getDialectFulltextQuery
in classDialect
- Parameters:
query
- the CMIS-syntax-based fulltext query string- Returns:
- the dialect native fulltext query string
-
translateForMySQL
protected static void translateForMySQL(FulltextQueryAnalyzer.FulltextQuery ft, FulltextQueryAnalyzer.Op superOp, StringBuilder sb) -
getFulltextScoredMatchInfo
public Dialect.FulltextMatchInfo getFulltextScoredMatchInfo(String fulltextQuery, String indexName, int nthMatch, Column mainColumn, Model model, Database database) Description copied from class:Dialect
Gets the SQL information needed to do a a fulltext match, either with a direct expression in the WHERE clause, or using a join with an additional table.- Specified by:
getFulltextScoredMatchInfo
in classDialect
-
getMaterializeFulltextSyntheticColumn
public boolean getMaterializeFulltextSyntheticColumn()Description copied from class:Dialect
Does the fulltext synthetic column have to be materialized.- Specified by:
getMaterializeFulltextSyntheticColumn
in classDialect
-
getFulltextIndexedColumns
public int getFulltextIndexedColumns()Description copied from class:Dialect
Specifies what columns of the fulltext table have to be indexed.- Specified by:
getFulltextIndexedColumns
in classDialect
- Returns:
- 0 for none, 1 for the synthetic one, 2 for the individual ones
-
getTableTypeString
- Overrides:
getTableTypeString
in classDialect
-
supportsUpdateFrom
public boolean supportsUpdateFrom()Description copied from class:Dialect
Does the dialect support UPDATE t SET ... FROM t, u WHERE ... ?- Specified by:
supportsUpdateFrom
in classDialect
-
doesUpdateFromRepeatSelf
public boolean doesUpdateFromRepeatSelf()Description copied from class:Dialect
When doing an UPDATE t SET ... FROM t, u WHERE ..., does the FROM clause need to repeate the updated table (t).- Specified by:
doesUpdateFromRepeatSelf
in classDialect
-
needsOrderByKeysAfterDistinct
public boolean needsOrderByKeysAfterDistinct()Description copied from class:Dialect
When doing a SELECT DISTINCT that uses a ORDER BY, do the keys along which we order have to be mentioned in the DISTINCT clause?- Overrides:
needsOrderByKeysAfterDistinct
in classDialect
-
needsAliasForDerivedTable
public boolean needsAliasForDerivedTable()Description copied from class:Dialect
Whether a derived table (subselect in a FROM statement) needs an alias.- Overrides:
needsAliasForDerivedTable
in classDialect
-
getSecurityCheckSql
Description copied from class:Dialect
Gets the expression to use to check security.- Specified by:
getSecurityCheckSql
in classDialect
- Parameters:
idColumnName
- the quoted name of the id column to use- Returns:
- an SQL expression with two parameters (principals and permissions) that is true if access is allowed
-
getInTreeSql
Description copied from class:Dialect
Gets the expression to use to check tree membership.- Specified by:
getInTreeSql
in classDialect
- Parameters:
idColumnName
- the quoted name of the id column to useid
- the id, to check syntax with respect to specialized id column types- Returns:
- an SQL expression with one parameters for the based id that is true if the document is under base id, or
null
if the query cannot match
-
getUpsertSql
public String getUpsertSql(List<Column> columns, List<Serializable> values, List<Column> outColumns, List<Serializable> outValues) Description copied from class:Dialect
Gets the SQL string for an UPSERT expression.- Specified by:
getUpsertSql
in classDialect
- Parameters:
columns
- the columns to upsert (first one being the key column)values
- the values to upsert (first one being the key value)outColumns
- the columns to use in the prepared statementoutValues
- the values to use in the prepared statement
-
getInsertOnConflictDoNothingSql
public String getInsertOnConflictDoNothingSql(List<Column> columns, List<Serializable> values, List<Column> outColumns, List<Serializable> outValues) Description copied from class:Dialect
Gets the SQL string for an INSERT ... ON CONFLICT DO NOTHING expression.- Overrides:
getInsertOnConflictDoNothingSql
in classDialect
- Parameters:
columns
- the columns to insert (first one being the key column)values
- the values to insert (first one being the key value)outColumns
- the columns to use in the prepared statementoutValues
- the values to use in the prepared statement
-
getSQLStatementsFilename
Description copied from class:Dialect
Gets the name of the file containing the SQL statements.- Specified by:
getSQLStatementsFilename
in classDialect
-
getTestSQLStatementsFilename
- Specified by:
getTestSQLStatementsFilename
in classDialect
-
getSQLStatementsProperties
Description copied from class:Dialect
Gets the properties to use with the SQL statements.- Specified by:
getSQLStatementsProperties
in classDialect
-
isConcurrentUpdateException
Description copied from class:Dialect
Checks if an exception received means that a concurrent update was detected.- Overrides:
isConcurrentUpdateException
in classDialect
-
isClusteringSupported
public boolean isClusteringSupported()Description copied from class:Dialect
Checks that clustering is supported.- Overrides:
isClusteringSupported
in classDialect
-
isClusteringDeleteNeeded
public boolean isClusteringDeleteNeeded()Description copied from class:Dialect
Does clustering fetch of invalidations (Dialect.getClusterGetInvalidations()
) need a separate delete for them.- Overrides:
isClusteringDeleteNeeded
in classDialect
-
getClusterInsertInvalidations
Description copied from class:Dialect
Gets the SQL to send an invalidation to the cluster.- Overrides:
getClusterInsertInvalidations
in classDialect
- Returns:
- an SQL statement with parameters for: nodeId, id, fragments, kind
-
getClusterGetInvalidations
Description copied from class:Dialect
Gets the SQL to query invalidations for this cluster node.- Overrides:
getClusterGetInvalidations
in classDialect
- Returns:
- an SQL statement returning a result set
-
supportsPaging
public boolean supportsPaging()Description copied from class:Dialect
Indicates if dialect supports paging- Overrides:
supportsPaging
in classDialect
- Returns:
- true if the dialect supports paging
-
addPagingClause
Description copied from class:Dialect
Returns the SQL query with a paging clause- Overrides:
addPagingClause
in classDialect
-
isIdentityAlreadyPrimary
public boolean isIdentityAlreadyPrimary()Description copied from class:Dialect
Checks if an identity column is already defined as a primary key and does not need a separate index added.MySQL defines the identity column directly as primary key.
- Overrides:
isIdentityAlreadyPrimary
in classDialect
-
getBinaryFulltextSql
Description copied from class:Dialect
Return the SQL to get the columns fulltext fields- Overrides:
getBinaryFulltextSql
in classDialect
-
checkStoredProcedure
public List<String> checkStoredProcedure(String procName, String procCreate, String ddlMode, Connection connection, JDBCLogger logger, Map<String, Serializable> properties) throws SQLExceptionDescription copied from class:Dialect
Checks if a given stored procedure exists and is identical to the passed creation SQL.There are 3 cases to deal with, and actions to perform:
- the stored procedure doesn't exist, and must be created (create the stored procedure);
- the stored procedure exists but is not up to date (drop the old stored procedure and re-create it);
- the stored procedure exists and is up to date (nothing to do).
When there is nothing to do,
null
is returned. Otherwise the returned value is a list of SQL statements to execute. Note that the SQL statements will include also INSERT statements to be executed to remember the creation SQL itself.- Specified by:
checkStoredProcedure
in classDialect
- Parameters:
procName
- the stored procedure nameprocCreate
- the creation SQL for the stored procedureddlMode
- the DDL modeconnection
- the connectionlogger
- the loggerproperties
- the statement execution properties- Returns:
- a list of SQL statements
- Throws:
SQLException
-
normalizeString
-
getDumpStart
Description copied from class:Dialect
Returns the initial DDL statements to add to a DDL dump.- Overrides:
getDumpStart
in classDialect
- Returns:
- a list of SQL statements, usually empty
-
getDumpStop
Description copied from class:Dialect
Returns the final DDL statements to add to a DDL dump.- Overrides:
getDumpStop
in classDialect
- Returns:
- a list of SQL statements, usually empty
-
getSQLForDump
Description copied from class:Dialect
Returns the SQL statement with proper terminator to use in a dump.- Overrides:
getSQLForDump
in classDialect
- Returns:
- the SQL statement
-