Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.storage.sql.jdbc.dialect
Class DialectPostgreSQL

java.lang.Object
  extended by org.nuxeo.ecm.core.storage.sql.jdbc.dialect.Dialect
      extended by org.nuxeo.ecm.core.storage.sql.jdbc.dialect.DialectPostgreSQL

public class DialectPostgreSQL
extends Dialect

PostgreSQL-specific dialect.

Author:
Florent Guillaume

Nested Class Summary
static class DialectPostgreSQL.PostgreSQLArray
           
 
Nested classes/interfaces inherited from class org.nuxeo.ecm.core.storage.sql.jdbc.dialect.Dialect
Dialect.FulltextMatchInfo, Dialect.FulltextQuery, Dialect.FulltextQueryAnalyzer, Dialect.JDBCInfo
 
Field Summary
 
Fields inherited from class org.nuxeo.ecm.core.storage.sql.jdbc.dialect.Dialect
ARRAY_SEP
 
Constructor Summary
DialectPostgreSQL(DatabaseMetaData metadata, BinaryManager binaryManager, RepositoryDescriptor repositoryDescriptor)
           
 
Method Summary
 Array createArrayOf(int type, Object[] elements, Connection connection)
          Factory method for creating Array objects, suitable for passing to PreparedStatement.setArray(int, java.sql.Array).
 boolean doesUpdateFromRepeatSelf()
          When doing an UPDATE t SET ...
 void existingTableDetected(Connection connection, Table table, Model model, Database database)
          Called after an existing table has been detected in the database.
 String getAncestorsIdsSql()
          Gets the SQL query to get the ancestors of a set of ids.
 String getCascadeDropConstraintsString()
           
 String getClusterGetInvalidations()
          Gets the SQL to query invalidations for this cluster node.
 String getClusterInsertInvalidations()
          Gets the SQL to send an invalidation to the cluster.
 String getCreateFulltextIndexSql(String indexName, String quotedIndexName, Table table, List<Column> columns, Model model)
          Gets a CREATE INDEX statement for a fulltext index.
 String getDialectFulltextQuery(String query)
          Get the dialect-specific version of a fulltext query.
 String getFreeVariableSetterForType(ColumnType type)
          Gets the JDBC expression setting a free value for this column type.
 Serializable getFromResultSet(ResultSet rs, int index, Column column)
           
 int getFulltextIndexedColumns()
          Specifies what columns of the fulltext table have to be indexed.
 Dialect.FulltextMatchInfo 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.
 String getInTreeSql(String idColumnName)
          Gets the expression to use to check tree membership.
 Dialect.JDBCInfo getJDBCTypeAndString(ColumnType type)
          Gets the JDBC type and string from Nuxeo's type abstraction.
 String getMatchMixinType(Column mixinsColumn, String mixin, boolean positive, String[] returnParam)
          Gets the SQL fragment to match a mixin type.
 boolean getMaterializeFulltextSyntheticColumn()
          Does the fulltext synthetic column have to be materialized.
 String getNoColumnsInsertString()
           
 String getPagingClause(long limit, long offset)
          Gets paging clause to be appended at the end of select statement
 List<String> getPostCreateTableSqls(Table table, Model model, Database database)
          Gets the sql statements to call after a table has been created.
 String getReadAclsCheckSql(String idColumnName)
          Gets the expression to check if access is allowed using read acl the dialect must suppportsReadAcl
 String getRebuildReadAclsSql()
          Gets the statement to rebuild the wall read acls
 String getSecurityCheckSql(String idColumnName)
          Gets the expression to use to check security.
 String getSQLStatementsFilename()
          Gets the name of the file containing the SQL statements.
 Map<String,Serializable> getSQLStatementsProperties(Model model, Database database)
          Gets the properties to use with the SQL statements.
 String getTestSQLStatementsFilename()
           
 String getUpdateReadAclsSql()
          Gets the statement to update the read acls
 String getUsersSeparator()
           
 String getValidationQuery()
          A query that, when executed, will make at least a round-trip to the server to check that the connection is alive.
 boolean isAllowedConversion(int expected, int actual, String actualName, int actualSize)
          Check mismatches between expected and actual JDBC types read from database introspection.
 boolean isClusteringSupported()
          Checks that clustering is supported.
 boolean isConnectionClosedException(Throwable t)
          Checks if an exception received means that the low level connection has been trashed and must be reset.
 boolean needsAliasForDerivedTable()
          Whether a derived table (subselect in a FROM statement) needs an alias.
 void performAdditionalStatements(Connection connection)
          Let the dialect processes additional statements after tables creation and conditional statements.
 boolean preCreateTable(Connection connection, Table table, Model model, Database database)
          Called before a table is created, when it's been determined that it doesn't exist yet.
 void setToPreparedStatement(PreparedStatement ps, int index, Serializable value, Column column)
           
 boolean supportsAncestorsTable()
          Checks if the dialect supports an ancestors table.
 boolean supportsArrays()
          Does the dialect support passing ARRAY values (to stored procedures mostly).
 boolean supportsIlike()
          Does the dialect support ILIKE operator
 boolean supportsPaging()
          Indicates if dialect supports paging
 boolean supportsReadAcl()
          Does the dialect support an optimized read security checks
 boolean supportsSysNameArray()
          Checks if the dialect supports storing arrays of system names (for mixins for instance).
 boolean supportsUpdateFrom()
          Does the dialect support UPDATE t SET ...
 boolean supportsWith()
          Does the dialect support SQL-99 WITH common table expressions.
 String toBooleanValueString(boolean bool)
           
 
Methods inherited from class org.nuxeo.ecm.core.storage.sql.jdbc.dialect.Dialect
analyzeFulltextQuery, closeQuote, createDialect, fulltextHasPhrase, getAddColumnString, getAddForeignKeyConstraintString, getAddPrimaryKeyConstraintString, getBinaryManager, getBlobLengthFunction, getClobCast, getClusterDeleteInvalidations, getColumnName, getConnectionSchema, getCreateIndexSql, getForeignKeyConstraintName, getFulltextType, getIdentityGeneratedKeySql, getIndexName, getMaximumArgsForIn, getNullColumnString, getPostCreateIdentityColumnSql, getPrepareUserReadAclsSql, getPrimaryKeyConstraintName, getTableName, getTableTypeString, hasIdentityGeneratedKey, hasNullEmptyString, isClusteringDeleteNeeded, isIdentityAlreadyPrimary, jdbcInfo, jdbcInfo, needsOracleJoins, needsOrderByKeysAfterDistinct, needsOriginalColumnInGroupBy, needsPrepareUserReadAcls, openQuote, performPostOpenStatements, qualifyIndexName, storesUpperCaseIdentifiers, supportsArraysReturnInsteadOfRows, supportsCircularCascadeDeleteConstraints, supportsIfExistsAfterTableName, supportsIfExistsBeforeTableName, supportsMultipleFulltextIndexes, toHexString, translateFulltext
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DialectPostgreSQL

public DialectPostgreSQL(DatabaseMetaData metadata,
                         BinaryManager binaryManager,
                         RepositoryDescriptor repositoryDescriptor)
                  throws StorageException
Throws:
StorageException
Method Detail

toBooleanValueString

public String toBooleanValueString(boolean bool)
Overrides:
toBooleanValueString in class Dialect

getNoColumnsInsertString

public String getNoColumnsInsertString()
Overrides:
getNoColumnsInsertString in class Dialect

getCascadeDropConstraintsString

public String getCascadeDropConstraintsString()
Overrides:
getCascadeDropConstraintsString in class Dialect

getJDBCTypeAndString

public Dialect.JDBCInfo getJDBCTypeAndString(ColumnType type)
Description copied from class: Dialect
Gets the JDBC type and string from Nuxeo's type abstraction.

Specified by:
getJDBCTypeAndString in class Dialect

isAllowedConversion

public boolean isAllowedConversion(int expected,
                                   int actual,
                                   String actualName,
                                   int actualSize)
Description copied from class: Dialect
Check mismatches between expected and actual JDBC types read from database introspection.

Overrides:
isAllowedConversion in class Dialect

setToPreparedStatement

public void setToPreparedStatement(PreparedStatement ps,
                                   int index,
                                   Serializable value,
                                   Column column)
                            throws SQLException
Specified by:
setToPreparedStatement in class Dialect
Throws:
SQLException

getFromResultSet

public Serializable getFromResultSet(ResultSet rs,
                                     int index,
                                     Column column)
                              throws SQLException
Specified by:
getFromResultSet in class Dialect
Throws:
SQLException

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 class Dialect

getDialectFulltextQuery

public String getDialectFulltextQuery(String query)
Description copied from class: Dialect
Get the dialect-specific version of a fulltext query.

Specified by:
getDialectFulltextQuery in class Dialect
Parameters:
query - the CMIS-syntax-based fulltext query string
Returns:
the dialect native fulltext query string

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 class Dialect

getMaterializeFulltextSyntheticColumn

public boolean getMaterializeFulltextSyntheticColumn()
Description copied from class: Dialect
Does the fulltext synthetic column have to be materialized.

Specified by:
getMaterializeFulltextSyntheticColumn in class Dialect

getFulltextIndexedColumns

public int getFulltextIndexedColumns()
Description copied from class: Dialect
Specifies what columns of the fulltext table have to be indexed.

Specified by:
getFulltextIndexedColumns in class Dialect
Returns:
0 for none, 1 for the synthetic one, 2 for the individual ones

getFreeVariableSetterForType

public String getFreeVariableSetterForType(ColumnType type)
Description copied from class: Dialect
Gets the JDBC expression setting a free value for this column type.

Needed for columns that need an expression around the value being set, usually for conversion (this is the case for PostgreSQL fulltext TSVECTOR columns for instance).

Overrides:
getFreeVariableSetterForType in class Dialect
Parameters:
type - the column type
Returns:
the expression containing a free variable

supportsUpdateFrom

public boolean supportsUpdateFrom()
Description copied from class: Dialect
Does the dialect support UPDATE t SET ... FROM t, u WHERE ... ?

Specified by:
supportsUpdateFrom in class Dialect

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 class Dialect

needsAliasForDerivedTable

public boolean needsAliasForDerivedTable()
Description copied from class: Dialect
Whether a derived table (subselect in a FROM statement) needs an alias.

Overrides:
needsAliasForDerivedTable in class Dialect

supportsIlike

public boolean supportsIlike()
Description copied from class: Dialect
Does the dialect support ILIKE operator

Overrides:
supportsIlike in class Dialect

supportsReadAcl

public boolean supportsReadAcl()
Description copied from class: Dialect
Does the dialect support an optimized read security checks

Overrides:
supportsReadAcl in class Dialect

getReadAclsCheckSql

public String getReadAclsCheckSql(String idColumnName)
Description copied from class: Dialect
Gets the expression to check if access is allowed using read acl the dialect must suppportsReadAcl

Overrides:
getReadAclsCheckSql in class Dialect
Parameters:
idColumnName - the quoted name of the read acl_id column to use
Returns:
an SQL expression with one parameter (principals) that is true if access is allowed

getUpdateReadAclsSql

public String getUpdateReadAclsSql()
Description copied from class: Dialect
Gets the statement to update the read acls

Overrides:
getUpdateReadAclsSql in class Dialect

getRebuildReadAclsSql

public String getRebuildReadAclsSql()
Description copied from class: Dialect
Gets the statement to rebuild the wall read acls

Overrides:
getRebuildReadAclsSql in class Dialect

getSecurityCheckSql

public String getSecurityCheckSql(String idColumnName)
Description copied from class: Dialect
Gets the expression to use to check security.

Specified by:
getSecurityCheckSql in class Dialect
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

supportsAncestorsTable

public boolean supportsAncestorsTable()
Description copied from class: Dialect
Checks if the dialect supports an ancestors table.

Overrides:
supportsAncestorsTable in class Dialect

getInTreeSql

public String getInTreeSql(String idColumnName)
Description copied from class: Dialect
Gets the expression to use to check tree membership.

Specified by:
getInTreeSql in class Dialect
Parameters:
idColumnName - the quoted name of the id column to use
Returns:
an SQL expression with one parameters for the based id that is true if the document is under base id

getMatchMixinType

public String getMatchMixinType(Column mixinsColumn,
                                String mixin,
                                boolean positive,
                                String[] returnParam)
Description copied from class: Dialect
Gets the SQL fragment to match a mixin type.

Overrides:
getMatchMixinType in class Dialect

supportsSysNameArray

public boolean supportsSysNameArray()
Description copied from class: Dialect
Checks if the dialect supports storing arrays of system names (for mixins for instance).

Overrides:
supportsSysNameArray in class Dialect

supportsArrays

public boolean supportsArrays()
Description copied from class: Dialect
Does the dialect support passing ARRAY values (to stored procedures mostly).

If not, we'll simulate them using a string and a separator.

Overrides:
supportsArrays in class Dialect
Returns:
true if ARRAY values are supported

createArrayOf

public Array createArrayOf(int type,
                           Object[] elements,
                           Connection connection)
                    throws SQLException
Description copied from class: Dialect
Factory method for creating Array objects, suitable for passing to PreparedStatement.setArray(int, java.sql.Array).

(An equivalent method is defined by JDBC4 on the Connection class.)

Overrides:
createArrayOf in class Dialect
Parameters:
type - the SQL type of the elements
elements - the elements of the array
connection - the connection
Returns:
an Array holding the elements
Throws:
SQLException

getSQLStatementsFilename

public String getSQLStatementsFilename()
Description copied from class: Dialect
Gets the name of the file containing the SQL statements.

Specified by:
getSQLStatementsFilename in class Dialect

getTestSQLStatementsFilename

public String getTestSQLStatementsFilename()
Specified by:
getTestSQLStatementsFilename in class Dialect

getSQLStatementsProperties

public Map<String,Serializable> getSQLStatementsProperties(Model model,
                                                           Database database)
Description copied from class: Dialect
Gets the properties to use with the SQL statements.

Specified by:
getSQLStatementsProperties in class Dialect

preCreateTable

public boolean preCreateTable(Connection connection,
                              Table table,
                              Model model,
                              Database database)
                       throws SQLException
Description copied from class: Dialect
Called before a table is created, when it's been determined that it doesn't exist yet.

Overrides:
preCreateTable in class Dialect
Returns:
false if the table must actually not be created
Throws:
SQLException

getPostCreateTableSqls

public List<String> getPostCreateTableSqls(Table table,
                                           Model model,
                                           Database database)
Description copied from class: Dialect
Gets the sql statements to call after a table has been created.

Used for migrations/upgrades.

Overrides:
getPostCreateTableSqls in class Dialect

existingTableDetected

public void existingTableDetected(Connection connection,
                                  Table table,
                                  Model model,
                                  Database database)
                           throws SQLException
Description copied from class: Dialect
Called after an existing table has been detected in the database.

Used for migrations/upgrades.

Overrides:
existingTableDetected in class Dialect
Throws:
SQLException

isClusteringSupported

public boolean isClusteringSupported()
Description copied from class: Dialect
Checks that clustering is supported.

Overrides:
isClusteringSupported in class Dialect

getClusterInsertInvalidations

public String getClusterInsertInvalidations()
Description copied from class: Dialect
Gets the SQL to send an invalidation to the cluster.

Overrides:
getClusterInsertInvalidations in class Dialect
Returns:
an SQL statement with parameters for: id, fragments, kind

getClusterGetInvalidations

public String getClusterGetInvalidations()
Description copied from class: Dialect
Gets the SQL to query invalidations for this cluster node.

Overrides:
getClusterGetInvalidations in class Dialect
Returns:
an SQL statement returning a result set

isConnectionClosedException

public boolean isConnectionClosedException(Throwable t)
Description copied from class: Dialect
Checks if an exception received means that the low level connection has been trashed and must be reset.

Overrides:
isConnectionClosedException in class Dialect

supportsPaging

public boolean supportsPaging()
Description copied from class: Dialect
Indicates if dialect supports paging

Overrides:
supportsPaging in class Dialect
Returns:
true if the dialect supports paging

getPagingClause

public String getPagingClause(long limit,
                              long offset)
Description copied from class: Dialect
Gets paging clause to be appended at the end of select statement

Overrides:
getPagingClause in class Dialect

supportsWith

public boolean supportsWith()
Description copied from class: Dialect
Does the dialect support SQL-99 WITH common table expressions.

Overrides:
supportsWith in class Dialect

performAdditionalStatements

public void performAdditionalStatements(Connection connection)
                                 throws SQLException
Description copied from class: Dialect
Let the dialect processes additional statements after tables creation and conditional statements. Can be used for specific upgrade procedure.

Overrides:
performAdditionalStatements in class Dialect
Throws:
SQLException

getUsersSeparator

public String getUsersSeparator()

getValidationQuery

public String getValidationQuery()
Description copied from class: Dialect
A query that, when executed, will make at least a round-trip to the server to check that the connection is alive.

The query should throw an error if the connection is dead.

Overrides:
getValidationQuery in class Dialect

getAncestorsIdsSql

public String getAncestorsIdsSql()
Description copied from class: Dialect
Gets the SQL query to get the ancestors of a set of ids.

Overrides:
getAncestorsIdsSql in class Dialect
Returns:
null if not available

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.