public class DialectPostgreSQL extends Dialect
| Modifier and Type | Class and Description |
|---|---|
static class |
DialectPostgreSQL.ArraySubQueryPostgreSQL |
Dialect.ArraySubQuery, Dialect.DialectIdType, Dialect.FulltextMatchInfo, Dialect.JDBCInfo| Modifier and Type | Field and Description |
|---|---|
protected boolean |
arrayColumnsEnabled |
protected boolean |
childNameUniqueConstraintEnabled |
protected boolean |
collectionUniqueConstraintEnabled |
protected boolean |
compatibilityFulltextTable |
protected static String |
FT_LIKE_COL |
protected static String |
FT_LIKE_SEP |
protected String |
fulltextAnalyzer |
protected boolean |
hierarchyCreated |
protected String |
idSequenceName |
protected Dialect.DialectIdType |
idType |
protected boolean |
pathOptimizationsEnabled |
protected boolean |
supportsWith |
protected String |
unloggedKeyword |
protected String |
usersSeparator |
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 and Description |
|---|
DialectPostgreSQL(DatabaseMetaData metadata,
RepositoryDescriptor repositoryDescriptor) |
| Modifier and Type | Method and Description |
|---|---|
String |
addPagingClause(String sql,
long limit,
long offset)
Returns the SQL query with a paging clause
|
protected static FulltextQueryAnalyzer.FulltextQuery |
breakPhrases(FulltextQueryAnalyzer.FulltextQuery ft)
Returns a fulltext query that is a superset of the original one and does not have phrase searches.
|
String |
castIdToVarchar(String expr)
Casts an id column to a VARCHAR type.
|
List<String> |
checkStoredProcedure(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.
|
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 ...
|
protected static void |
generateLikeSql(FulltextQueryAnalyzer.FulltextQuery ft,
StringBuilder buf) |
String |
getAncestorsIdsSql()
Gets the SQL query to get the ancestors of a set of ids.
|
String |
getArrayElementString(String arrayColumnName,
int arrayElementIndex)
Get SQL Array Element Subscripted string.
|
String |
getArrayIlikeSql(Column arrayColumn,
String refName,
boolean positive,
Table dataHierTable)
Gets the SQL string for an array column ILIKE expression.
|
String |
getArrayInSql(Column arrayColumn,
String cast,
boolean positive,
List<Serializable> params)
Gets the SQL string for an array column IN expression.
|
String |
getArrayLikeSql(Column arrayColumn,
String refName,
boolean positive,
Table dataHierTable)
Gets the SQL string for an array column LIKE expression.
|
protected String |
getArrayOpSql(Column arrayColumn,
String refName,
boolean positive,
Table dataHierTable,
String op) |
Dialect.ArraySubQuery |
getArraySubQuery(Column arrayColumn,
String subQueryAlias)
Gets the dialect-specific subquery for an array column.
|
String |
getBinaryFulltextSql(List<String> columns)
Return the SQL to get the columns fulltext fields
|
String |
getCascadeDropConstraintsString() |
protected String |
getCastForArray(String cast) |
protected String |
getCastForId(String id) |
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 |
getColumnName(String name) |
protected boolean |
getCompatibilityFulltextTable(DatabaseMetaData metadata) |
String |
getCreateFulltextIndexSql(String indexName,
String quotedIndexName,
Table table,
List<Column> columns,
Model model)
Gets a CREATE INDEX statement for a fulltext index.
|
List<String> |
getCustomPostCreateSqls(Table table,
Model model)
Additional things to execute after CREATE TABLE.
|
String |
getDateCast()
Get the expression to use to cast a column to a DATE type.
|
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.
|
Serializable |
getGeneratedId(Connection connection)
Gets a generated id if so configured, otherwise returns null.
|
Serializable |
getId(ResultSet rs,
int index) |
Dialect.DialectIdType |
getIdType()
Gets the type of id when stored in the database.
|
String |
getInTreeSql(String idColumnName,
String id)
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.
|
protected int |
getMaxNameSize() |
String |
getNoColumnsInsertString(Column idColumn) |
String |
getPrepareUserReadAclsSql()
Gets the SQL expression to prepare the user read acls cache.
|
String |
getReadAclsCheckSql(String userIdCol)
Gets the expression to check if access is allowed using read acls.
|
String |
getRebuildReadAclsSql()
Gets the statement to rebuild the wall read acls
|
String |
getSecurityCheckSql(String idColumnName)
Gets the expression to use to check security.
|
String |
getSoftDeleteCleanupSql()
SQL to clean soft-delete documents.
|
String |
getSoftDeleteSql()
SQL to soft delete documents.
|
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.
|
List<String> |
getStartupSqls(Model model,
Database database)
Gets the sql statements to execute after the repository init (at startup).
|
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 |
isConcurrentUpdateException(Throwable t)
Checks if an exception received means that a concurrent update was detected.
|
boolean |
needsAliasForDerivedTable()
Whether a derived table (subselect in a FROM statement) needs an alias.
|
boolean |
needsNullsLastOnDescSort()
True if the dialect need an extra NULLS LAST on DESC sort.
|
protected static String |
normalizeArgs(String args)
Normalize PostgreSQL type aliases.
|
protected static String |
normalizeString(String string) |
void |
performAdditionalStatements(Connection connection)
Let the dialect processes additional statements after tables creation and conditional statements.
|
protected static FulltextQueryAnalyzer.FulltextQuery |
removeToplevelAndedWords(FulltextQueryAnalyzer.FulltextQuery ft)
Removes toplevel ANDed simple words from the query.
|
void |
setId(PreparedStatement ps,
int index,
Serializable value)
Sets a prepared statement value that is a Nuxeo main id (usually UUID).
|
void |
setToPreparedStatement(PreparedStatement ps,
int index,
Serializable value,
Column column) |
boolean |
supportsAncestorsTable()
Checks if the dialect supports an ancestors table.
|
boolean |
supportsArrayColumns()
Does the dialect support storing arrays in table columns.
|
boolean |
supportsArrays()
Does the dialect support passing ARRAY values (to stored procedures mostly).
|
boolean |
supportsFastDescendants()
Checks whether
Dialect.getInTreeSql(String, String) is optimized for fast results (using an ancestors or
descendants table). |
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) |
closeQuote, createDialect, getAddColumnString, getAddForeignKeyConstraintString, getAddPrimaryKeyConstraintString, getArrayResult, getBlobLengthFunction, getCalendarFromTimestamp, getCalendarFromTimestamp, getClobCast, getConnectionSchema, getCreateIndexSql, getCustomColumnDefinition, getDescending, getDumpStart, getDumpStop, getForeignKeyConstraintName, getFromResultSetString, getFromResultSetTimestamp, getFulltextType, getIdentityGeneratedKeySql, getIgnoredColumns, getIndexName, getLikeEscaping, getMaximumArgsForIn, getMaxIndexNameSize, getNullColumnString, getPostCreateIdentityColumnSql, getPrimaryKeyConstraintName, getSQLForDump, getTableName, getTableTypeString, getTimestampFromCalendar, getTimestampFromCalendar, hasIdentityGeneratedKey, hasNullEmptyString, isClusteringDeleteNeeded, isIdentityAlreadyPrimary, jdbcInfo, jdbcInfo, jdbcInfo, jdbcInfo, makeName, makeName, needsOracleJoins, needsOrderByKeysAfterDistinct, needsOriginalColumnInGroupBy, needsPrepareUserReadAcls, openQuote, performPostOpenStatements, qualifyIndexName, setIdLong, setToPreparedStatementString, setToPreparedStatementTimestamp, storesUpperCaseIdentifiers, supportsArraysReturnInsteadOfRows, supportsBatchUpdateCount, supportsCircularCascadeDeleteConstraints, supportsIfExistsAfterTableName, supportsIfExistsBeforeTableName, supportsMultipleFulltextIndexes, supportsScroll, toHexStringprotected final String fulltextAnalyzer
protected final boolean supportsWith
protected boolean hierarchyCreated
protected boolean pathOptimizationsEnabled
protected final boolean arrayColumnsEnabled
protected final boolean childNameUniqueConstraintEnabled
protected final boolean collectionUniqueConstraintEnabled
protected String usersSeparator
protected final Dialect.DialectIdType idType
protected boolean compatibilityFulltextTable
protected final String unloggedKeyword
protected String idSequenceName
protected static final String FT_LIKE_SEP
protected static final String FT_LIKE_COL
public DialectPostgreSQL(DatabaseMetaData metadata, RepositoryDescriptor repositoryDescriptor)
protected boolean getCompatibilityFulltextTable(DatabaseMetaData metadata) throws SQLException
SQLExceptionpublic String toBooleanValueString(boolean bool)
toBooleanValueString in class Dialectpublic String getNoColumnsInsertString(Column idColumn)
getNoColumnsInsertString in class Dialectpublic String getCascadeDropConstraintsString()
getCascadeDropConstraintsString in class Dialectpublic Dialect.JDBCInfo getJDBCTypeAndString(ColumnType type)
DialectgetJDBCTypeAndString in class Dialectpublic boolean isAllowedConversion(int expected, int actual, String actualName, int actualSize)
DialectisAllowedConversion in class Dialectpublic Serializable getGeneratedId(Connection connection) throws SQLException
DialectgetGeneratedId in class DialectSQLExceptionpublic void setId(PreparedStatement ps, int index, Serializable value) throws SQLException
DialectsetId in class Dialectps - the prepared statementindex - the parameter index in the prepared statementvalue - the value to setSQLExceptionpublic Serializable getId(ResultSet rs, int index) throws SQLException
SQLExceptionpublic void setToPreparedStatement(PreparedStatement ps, int index, Serializable value, Column column) throws SQLException
setToPreparedStatement in class DialectSQLExceptionpublic Serializable getFromResultSet(ResultSet rs, int index, Column column) throws SQLException
getFromResultSet in class DialectSQLExceptionprotected int getMaxNameSize()
getMaxNameSize in class Dialectpublic String getColumnName(String name)
getColumnName in class Dialectpublic List<String> getCustomPostCreateSqls(Table table, Model model)
DialectgetCustomPostCreateSqls in class Dialectpublic String getCreateFulltextIndexSql(String indexName, String quotedIndexName, Table table, List<Column> columns, Model model)
DialectgetCreateFulltextIndexSql in class Dialectpublic String getDialectFulltextQuery(String query)
The result of this is passed to getFulltextScoredMatchInfo(java.lang.String, java.lang.String, int, org.nuxeo.ecm.core.storage.sql.jdbc.db.Column, org.nuxeo.ecm.core.storage.sql.Model, org.nuxeo.ecm.core.storage.sql.jdbc.db.Database).
getDialectFulltextQuery in class Dialectquery - the CMIS-syntax-based fulltext query stringprotected static FulltextQueryAnalyzer.FulltextQuery breakPhrases(FulltextQueryAnalyzer.FulltextQuery ft)
Negative phrases (which are at AND level) are removed, positive phrases are split into ANDed words.
protected static FulltextQueryAnalyzer.FulltextQuery removeToplevelAndedWords(FulltextQueryAnalyzer.FulltextQuery ft)
protected static void generateLikeSql(FulltextQueryAnalyzer.FulltextQuery ft, StringBuilder buf)
public Dialect.FulltextMatchInfo getFulltextScoredMatchInfo(String fulltextQuery, String indexName, int nthMatch, Column mainColumn, Model model, Database database)
DialectgetFulltextScoredMatchInfo in class Dialectpublic boolean getMaterializeFulltextSyntheticColumn()
DialectgetMaterializeFulltextSyntheticColumn in class Dialectpublic int getFulltextIndexedColumns()
DialectgetFulltextIndexedColumns in class Dialectpublic String getFreeVariableSetterForType(ColumnType type)
Dialect
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).
getFreeVariableSetterForType in class Dialecttype - the column typepublic boolean supportsUpdateFrom()
DialectsupportsUpdateFrom in class Dialectpublic boolean doesUpdateFromRepeatSelf()
DialectdoesUpdateFromRepeatSelf in class Dialectpublic boolean needsAliasForDerivedTable()
DialectneedsAliasForDerivedTable in class Dialectpublic boolean supportsIlike()
DialectsupportsIlike in class Dialectpublic boolean supportsReadAcl()
DialectsupportsReadAcl in class Dialectpublic String getPrepareUserReadAclsSql()
DialectgetPrepareUserReadAclsSql in class Dialectpublic String getReadAclsCheckSql(String userIdCol)
DialectgetReadAclsCheckSql in class DialectuserIdCol - the quoted name of the aclr_user_map user_id column to usepublic String getUpdateReadAclsSql()
DialectgetUpdateReadAclsSql in class Dialectpublic String getRebuildReadAclsSql()
DialectgetRebuildReadAclsSql in class Dialectpublic String getSecurityCheckSql(String idColumnName)
DialectgetSecurityCheckSql in class DialectidColumnName - the quoted name of the id column to usepublic boolean supportsAncestorsTable()
DialectsupportsAncestorsTable in class Dialectpublic boolean supportsFastDescendants()
DialectDialect.getInTreeSql(String, String) is optimized for fast results (using an ancestors or
descendants table).supportsFastDescendants in class Dialectpublic String getInTreeSql(String idColumnName, String id)
DialectgetInTreeSql in class DialectidColumnName - the quoted name of the id column to useid - the id, to check syntax with respect to specialized id column typesnull if the query cannot matchprotected String getCastForArray(String cast)
protected String getCastForId(String id)
public String getMatchMixinType(Column mixinsColumn, String mixin, boolean positive, String[] returnParam)
DialectgetMatchMixinType in class Dialectpublic boolean supportsSysNameArray()
DialectsupportsSysNameArray in class Dialectpublic boolean supportsArrays()
DialectIf not, we'll simulate them using a string and a separator.
supportsArrays in class Dialectpublic boolean supportsArrayColumns()
DialectsupportsArrayColumns in class Dialectpublic Dialect.ArraySubQuery getArraySubQuery(Column arrayColumn, String subQueryAlias)
DialectgetArraySubQuery in class Dialectpublic String getArrayElementString(String arrayColumnName, int arrayElementIndex)
DialectgetArrayElementString in class Dialectpublic String getArrayInSql(Column arrayColumn, String cast, boolean positive, List<Serializable> params)
DialectgetArrayInSql in class Dialectpublic String getArrayLikeSql(Column arrayColumn, String refName, boolean positive, Table dataHierTable)
DialectgetArrayLikeSql in class Dialectpublic String getArrayIlikeSql(Column arrayColumn, String refName, boolean positive, Table dataHierTable)
DialectgetArrayIlikeSql in class Dialectprotected String getArrayOpSql(Column arrayColumn, String refName, boolean positive, Table dataHierTable, String op)
public Array createArrayOf(int type, Object[] elements, Connection connection) throws SQLException
DialectPreparedStatement.setArray(int, java.sql.Array).
(An equivalent method is defined by JDBC4 on the Connection class.)
createArrayOf in class Dialecttype - the SQL type of the elementselements - the elements of the arrayconnection - the connectionSQLExceptionpublic String getSQLStatementsFilename()
DialectgetSQLStatementsFilename in class Dialectpublic String getTestSQLStatementsFilename()
getTestSQLStatementsFilename in class Dialectpublic Map<String,Serializable> getSQLStatementsProperties(Model model, Database database)
DialectgetSQLStatementsProperties in class Dialectpublic List<String> getStartupSqls(Model model, Database database)
DialectUsed for vacuum-like operations.
getStartupSqls in class Dialectpublic boolean isClusteringSupported()
DialectisClusteringSupported in class Dialectpublic String getClusterInsertInvalidations()
DialectgetClusterInsertInvalidations in class Dialectpublic String getClusterGetInvalidations()
DialectgetClusterGetInvalidations in class Dialectpublic boolean isConcurrentUpdateException(Throwable t)
DialectisConcurrentUpdateException in class Dialectpublic boolean supportsPaging()
DialectsupportsPaging in class Dialectpublic String addPagingClause(String sql, long limit, long offset)
DialectaddPagingClause in class Dialectpublic boolean supportsWith()
DialectsupportsWith in class Dialectpublic void performAdditionalStatements(Connection connection) throws SQLException
DialectperformAdditionalStatements in class DialectSQLExceptionpublic String getUsersSeparator()
public String getValidationQuery()
DialectThe query should throw an error if the connection is dead.
getValidationQuery in class Dialectpublic String getAncestorsIdsSql()
DialectgetAncestorsIdsSql in class Dialectpublic boolean needsNullsLastOnDescSort()
DialectneedsNullsLastOnDescSort in class Dialectpublic String getDateCast()
DialectgetDateCast in class Dialectpublic String castIdToVarchar(String expr)
DialectUsed for uuid/varchar joins.
castIdToVarchar in class Dialectpublic Dialect.DialectIdType getIdType()
Dialectpublic String getSoftDeleteSql()
DialectgetSoftDeleteSql in class Dialectpublic String getSoftDeleteCleanupSql()
DialectgetSoftDeleteCleanupSql in class Dialectpublic String getBinaryFulltextSql(List<String> columns)
DialectgetBinaryFulltextSql in class Dialectpublic List<String> checkStoredProcedure(String procName, String procCreate, String ddlMode, Connection connection, JDBCLogger logger, Map<String,Serializable> properties) throws SQLException
DialectThere are 3 cases to deal with, and actions to perform:
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.
checkStoredProcedure in class DialectprocName - the stored procedure nameprocCreate - the creation SQL for the stored procedureddlMode - the DDL modeconnection - the connectionlogger - the loggerproperties - the statement execution propertiesSQLExceptionprotected static String normalizeString(String string)
protected static String normalizeArgs(String args)
Copyright © 2018 Nuxeo. All rights reserved.