org.mmbase.storage.search.implementation.database
Class PostgreSqlSqlHandler

java.lang.Object
  extended by org.mmbase.storage.search.implementation.database.BasicSqlHandler
      extended by org.mmbase.storage.search.implementation.database.PostgreSqlSqlHandler
All Implemented Interfaces:
SqlHandler

public class PostgreSqlSqlHandler
extends BasicSqlHandler
implements SqlHandler

The PostgreSQL query handler, implements SqlHandler for standard PostgreSql functionality.
Derived from BasicSqlHandler, overrides

Since:
MMBase-1.7
Version:
$Id: PostgreSqlSqlHandler.java 36317 2009-06-23 14:19:19Z michiel $
Author:
Rob van Maris

Constructor Summary
PostgreSqlSqlHandler()
          Constructor.
 
Method Summary
protected  void appendDateField(StringBuilder sb, Step step, String fieldName, boolean multipleSteps, int datePart)
          date time functions
protected  StringBuilder appendLikeOperator(StringBuilder sb, FieldConstraint constraint)
          Appends the 'LIKE' operator for the given case sensitiviy.
protected  StringBuilder appendRegularExpressionOperator(StringBuilder sb, FieldConstraint constraint)
           
protected  StringBuilder appendSortOrderField(StringBuilder sb, SortOrder sortOrder, boolean multipleSteps, SearchQuery query)
          Normally, Postgresql does not sort case senstively, so we should not sort on UPPER(fieldname).
protected  void appendTableName(StringBuilder sb, Step step)
          Optimizes postgresql queries by adding the ONLY keyword to a relation-table, provided that the role was given (and therefor the selection only applies to the given table).
 int getSupportLevel(int feature, SearchQuery query)
          Gets the level at which a feature is supported for a query by this handler.
 String toSql(SearchQuery query, SqlHandler firstInChain)
          Represents a SearchQuery object as a string in SQL format, using the database configuration.
protected  boolean useLower(FieldConstraint constraint)
          Wether the 'LOWER' function needs to be used to implement case insensitivity.
 
Methods inherited from class org.mmbase.storage.search.implementation.database.BasicSqlHandler
appendCompositeConstraintToSql, appendConstraintToSql, appendDateValue, appendField, appendField, appendField, appendFieldValue, appendLowerField, appendPreField, appendQueryBodyToSql, appendRelationConstraints, appendSortOrderDirection, appendSortOrderField, appendSortOrders, appendTableAlias, forceEncode, getAllowedValue, getSupportLevel, toSqlString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mmbase.storage.search.implementation.database.SqlHandler
appendConstraintToSql, appendQueryBodyToSql, getAllowedValue, getSupportLevel
 

Constructor Detail

PostgreSqlSqlHandler

public PostgreSqlSqlHandler()
Constructor.

Method Detail

getSupportLevel

public int getSupportLevel(int feature,
                           SearchQuery query)
                    throws SearchQueryException
Description copied from interface: SqlHandler
Gets the level at which a feature is supported for a query by this handler. This is one of either: Given the choice, the query handler with the highest level of support is prefered.

Specified by:
getSupportLevel in interface SqlHandler
Overrides:
getSupportLevel in class BasicSqlHandler
Throws:
SearchQueryException

useLower

protected boolean useLower(FieldConstraint constraint)
Description copied from class: BasicSqlHandler
Wether the 'LOWER' function needs to be used to implement case insensitivity. This is not always the case, because some database only match case insensitively, in which case it does not make sense to lowercase.

Overrides:
useLower in class BasicSqlHandler

appendLikeOperator

protected StringBuilder appendLikeOperator(StringBuilder sb,
                                           FieldConstraint constraint)
Description copied from class: BasicSqlHandler
Appends the 'LIKE' operator for the given case sensitiviy. Some databases support a case insensitive LIKE ('ILIKE'). Implementations for those database can override this method.

Overrides:
appendLikeOperator in class BasicSqlHandler
Returns:
The string buffer.

appendSortOrderField

protected StringBuilder appendSortOrderField(StringBuilder sb,
                                             SortOrder sortOrder,
                                             boolean multipleSteps,
                                             SearchQuery query)
Normally, Postgresql does not sort case senstively, so we should not sort on UPPER(fieldname). This is mainly very bad if the query is also distinct. (ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list), may occur.

Overrides:
appendSortOrderField in class BasicSqlHandler

appendRegularExpressionOperator

protected StringBuilder appendRegularExpressionOperator(StringBuilder sb,
                                                        FieldConstraint constraint)
Overrides:
appendRegularExpressionOperator in class BasicSqlHandler

appendDateField

protected void appendDateField(StringBuilder sb,
                               Step step,
                               String fieldName,
                               boolean multipleSteps,
                               int datePart)
date time functions

Overrides:
appendDateField in class BasicSqlHandler
Javadoc:

toSql

public String toSql(SearchQuery query,
                    SqlHandler firstInChain)
             throws SearchQueryException
Description copied from interface: SqlHandler
Represents a SearchQuery object as a string in SQL format, using the database configuration.

Specified by:
toSql in interface SqlHandler
Overrides:
toSql in class BasicSqlHandler
Parameters:
query - The searchquery.
firstInChain - The first element in the chain of handlers. At some point appendQueryBodyToSql() will have to be called on this handler, to generate the body of the query.
Returns:
SQL string representation of the query.
Throws:
SearchQueryException

appendTableName

protected void appendTableName(StringBuilder sb,
                               Step step)
Optimizes postgresql queries by adding the ONLY keyword to a relation-table, provided that the role was given (and therefor the selection only applies to the given table).

Overrides:
appendTableName in class BasicSqlHandler
See Also:
BasicSqlHandler.appendTableName(java.lang.StringBuilder, org.mmbase.storage.search.Step)


MMBase 2.0-SNAPSHOT - null