2.17.2: 2011-06-17

net.sf.basedb.core.dbengine
Class MySQLEngine

java.lang.Object
  extended by net.sf.basedb.core.dbengine.AbstractDbEngine
      extended by net.sf.basedb.core.dbengine.MySQLEngine
All Implemented Interfaces:
DbEngine

public class MySQLEngine
extends AbstractDbEngine
implements DbEngine

Database engine for My SQL.

Version:
2.0
Author:
nicklas
Last modified
$Date: 2009-06-23 12:00:57 +0200 (Tue, 23 Jun 2009) $

Constructor Summary
MySQLEngine()
          Create MySQLEngine.
 
Method Summary
 boolean analyzeAfterBatchOperation()
          Return true.
 boolean caseInsensitiveComparison()
          Returns TRUE.
 String getAnalyzeTableSql(String catalog, String schema, String table)
          Generate ANALYZE TABLE <catalog>.
 String getCaseSensitiveVarchar(int length)
          Return varchar(length) CHARACTER SET utf8 COLLATE utf8_bin.
 String getCreateIndexSql(String catalog, String schema, String table, String name, Set<String> columns, boolean unique)
          Generate ALTER TABLE <catalog>.
 String getDropIndexSql(String catalog, String schema, String table, String name, boolean unique)
          Generate DROP INDEX <name> ON <catalog>.
 String getOptimizeTableSql(String catalog, String schema, String table)
          Generate OPTIMIZE TABLE <catalog>.
private  String getQuotedName(String name)
          Put quotes (`) around the name.
 String ln(String value)
          Return LOG(<value>).
 String makeSafeCreateTable(String sql, String catalog, String schema, String table)
          Replace CREATE TABLE with CREATE TABLE IF NOT EXISTS...
 String rlike(String value, String regexp)
          Return <value> RLIKE <regexp>.
 boolean supportColumnAliasInGroupBy()
          Returns TRUE.
 boolean supportColumnAliasInHaving()
          Returns TRUE.
 boolean supportColumnAliasInOrderBy()
          Returns TRUE.
 boolean supportsColumnAliasInWhere()
          Returns FALSE.
 boolean useThetaJoin()
          Always false.
 
Methods inherited from class net.sf.basedb.core.dbengine.AbstractDbEngine
abs, castToDate, checkForInvalidNumberOperation, exp, inspectSchemaGenerationSQL, isValidColumnName, isValidName, isValidTableName, power, selectOrderByColumnsIfDistinct
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.basedb.core.dbengine.DbEngine
abs, castToDate, checkForInvalidNumberOperation, exp, inspectSchemaGenerationSQL, isValidColumnName, isValidTableName, power, selectOrderByColumnsIfDistinct
 

Constructor Detail

MySQLEngine

public MySQLEngine()
Create MySQLEngine.

Method Detail

useThetaJoin

public boolean useThetaJoin()
Always false.

Specified by:
useThetaJoin in interface DbEngine
Overrides:
useThetaJoin in class AbstractDbEngine
Returns:
TRUE for theta join, FALSE for ansi join

getCreateIndexSql

public String getCreateIndexSql(String catalog,
                                String schema,
                                String table,
                                String name,
                                Set<String> columns,
                                boolean unique)
Generate ALTER TABLE <catalog>.<table> ADD [UNIQUE] INDEX <name> (<columns>). The schema parameter is not supported.

Specified by:
getCreateIndexSql in interface DbEngine
Parameters:
catalog - The name of the catalog (database) where the table is located, or null if it is located in the current catalog
schema - The name of the schema where the table is located, or null if is located in the current schema
table - The name of the table
name - The name of the index to be created
columns - The name of the columns in the index
unique - If the index must contain unique values or not
Returns:
The SQL to execute

getDropIndexSql

public String getDropIndexSql(String catalog,
                              String schema,
                              String table,
                              String name,
                              boolean unique)
Generate DROP INDEX <name> ON <catalog>.<table>. The schema parameter is not supported.

Specified by:
getDropIndexSql in interface DbEngine
Parameters:
catalog - The name of the catalog (database) where the table is located, or null if it is located in the current catalog
schema - The name of the schema where the table is located, or null if is located in the current schema
table - The name of the table
name - The name of the index
unique - If the index contains unique values or not
Returns:
The SQL to execute

analyzeAfterBatchOperation

public boolean analyzeAfterBatchOperation()
Return true.

Specified by:
analyzeAfterBatchOperation in interface DbEngine

getOptimizeTableSql

public String getOptimizeTableSql(String catalog,
                                  String schema,
                                  String table)
Generate OPTIMIZE TABLE <catalog>.<table>. The schema parameter is not supported.

Specified by:
getOptimizeTableSql in interface DbEngine
Parameters:
catalog - The name of the catalog (database) where the table is located, or null if it is located in the current catalog
schema - The name of the schema where the table is located, or null if is located in the current schema
table - The name of the table to optimize
Returns:
The SQL to execute
See Also:
DbEngine.getAnalyzeTableSql(String, String, String)

getAnalyzeTableSql

public String getAnalyzeTableSql(String catalog,
                                 String schema,
                                 String table)
Generate ANALYZE TABLE <catalog>.<table>. The schema parameter is not supported.

Specified by:
getAnalyzeTableSql in interface DbEngine
Parameters:
catalog - The name of the catalog (database) where the table is located, or null if it is located in the current catalog
schema - The name of the schema where the table is located, or null if is located in the current schema
table - The name of the table to analyze
Returns:
The SQL to execute, or null if not supported
See Also:
DbEngine.getOptimizeTableSql(String, String, String)

makeSafeCreateTable

public String makeSafeCreateTable(String sql,
                                  String catalog,
                                  String schema,
                                  String table)
Replace CREATE TABLE with CREATE TABLE IF NOT EXISTS...

Specified by:
makeSafeCreateTable in interface DbEngine
Overrides:
makeSafeCreateTable in class AbstractDbEngine
Parameters:
sql - The original SQL
catalog - The name of the catalog (database) where the table is being create, or null if it is located in the current catalog
schema - The name of the schema where the table is being created, or null if is located in the current schema
table - The name of the table that is being created
Returns:
The modified or unmodified SQL statement
Since:
2.6

caseInsensitiveComparison

public boolean caseInsensitiveComparison()
Returns TRUE.

Specified by:
caseInsensitiveComparison in interface DbEngine
Returns:
FALSE if comparisons are case sensitive (ABC != abc), TRUE if they are case insensitive (ABC = abc)
Since:
2.4

supportsColumnAliasInWhere

public boolean supportsColumnAliasInWhere()
Returns FALSE.

Specified by:
supportsColumnAliasInWhere in interface DbEngine
Overrides:
supportsColumnAliasInWhere in class AbstractDbEngine
Returns:
TRUE if column aliases are supported, FALSE otherwise

supportColumnAliasInOrderBy

public boolean supportColumnAliasInOrderBy()
Returns TRUE.

Specified by:
supportColumnAliasInOrderBy in interface DbEngine
Overrides:
supportColumnAliasInOrderBy in class AbstractDbEngine
Returns:
TRUE if column aliases are supported, FALSE otherwise

supportColumnAliasInGroupBy

public boolean supportColumnAliasInGroupBy()
Returns TRUE.

Specified by:
supportColumnAliasInGroupBy in interface DbEngine
Overrides:
supportColumnAliasInGroupBy in class AbstractDbEngine
Returns:
TRUE if column aliases are supported, FALSE otherwise

supportColumnAliasInHaving

public boolean supportColumnAliasInHaving()
Returns TRUE.

Specified by:
supportColumnAliasInHaving in interface DbEngine
Overrides:
supportColumnAliasInHaving in class AbstractDbEngine
Returns:
TRUE if column aliases are supported, FALSE otherwise

ln

public String ln(String value)
Return LOG(<value>).

Specified by:
ln in interface DbEngine
Overrides:
ln in class AbstractDbEngine
Parameters:
value - The value to take the logarithm of
Returns:
The function call that calculates the logartihm

rlike

public String rlike(String value,
                    String regexp)
Return <value> RLIKE <regexp>.

Specified by:
rlike in interface DbEngine
Overrides:
rlike in class AbstractDbEngine
Parameters:
value - The left value
regexp - The regular expression as a string
Returns:
The function call/expression that matches the value agains the regular expression
Since:
2.8

getCaseSensitiveVarchar

public String getCaseSensitiveVarchar(int length)
Return varchar(length) CHARACTER SET utf8 COLLATE utf8_bin.

Specified by:
getCaseSensitiveVarchar in interface DbEngine
Overrides:
getCaseSensitiveVarchar in class AbstractDbEngine
Parameters:
length - The maximum length that needs to be stored in the column
Returns:
The SQL snippet that creates the column, or null to let Hibernate use the default SQL
Since:
2.9

getQuotedName

private String getQuotedName(String name)
Put quotes (`) around the name.


2.17.2: 2011-06-17