I enclose 3 Dialects for PostgreSQL, as discussed on -hackers.
The PostgreSQL83Dialect is essentially identical to 82Dialect, but the
principle of having one file per release seems easiest way of doing
things.
Further additions very welcome; I don't suppose at all this is the final
version.
--
Simon Riggs
2ndQuadrant http://www.2ndQuadrant.com
//$Id: PostgreSQLDialect.java 11367 2007-03-29 13:26:40Z [EMAIL PROTECTED] $
package org.hibernate.dialect;
import java.sql.Types;
import java.sql.SQLException;
import org.hibernate.Hibernate;
import org.hibernate.exception.ViolatedConstraintNameExtracter;
import org.hibernate.exception.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.JDBCExceptionHelper;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.function.NoArgSQLFunction;
import org.hibernate.dialect.function.PositionSubstringFunction;
import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.dialect.function.VarArgsSQLFunction;
import org.hibernate.id.SequenceGenerator;
/**
* An SQL dialect for Postgres
* @author Gavin King
*
* Dialect reorganized to follow sequence in base Dialect, few
* additions and corrections from earlier PostgreSQLDialect
*
* This is the base class for PostgreSQL 8.x versions
* PostgreSQL 8.0 and 8.1 can use the unmodified, later releases provide
* further extensions and so are provided as separate Dialects
* [EMAIL PROTECTED] 12 Nov 2007
*/
public class PostgreSQL8Dialect extends Dialect {
public PostgreSQL8Dialect() {
super();
getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE);
// database type mapping support ~~
registerColumnType( Types.BIT, bool );
registerColumnType( Types.BIGINT, int8 );
registerColumnType( Types.SMALLINT, int2 );
registerColumnType( Types.TINYINT, int2 );
registerColumnType( Types.INTEGER, int4 );
registerColumnType( Types.CHAR, char(1) );
registerColumnType( Types.VARCHAR, varchar($l) );
registerColumnType( Types.FLOAT, float4 );
registerColumnType( Types.DOUBLE, float8 );
registerColumnType( Types.DATE, date );
registerColumnType( Types.TIME, time );
registerColumnType( Types.TIMESTAMP, timestamp );
registerColumnType( Types.VARBINARY, bytea );
registerColumnType( Types.CLOB, text );
registerColumnType( Types.BLOB, oid );
registerColumnType( Types.NUMERIC, numeric($p, $s) );
// function support ~~~
registerFunction( abs, new StandardSQLFunction(abs) );
registerFunction( sign, new StandardSQLFunction(sign, Hibernate.INTEGER) );
registerFunction( acos, new StandardSQLFunction(acos, Hibernate.DOUBLE) );
registerFunction( asin, new StandardSQLFunction(asin, Hibernate.DOUBLE) );
registerFunction( atan, new StandardSQLFunction(atan, Hibernate.DOUBLE) );
registerFunction( cos, new StandardSQLFunction(cos, Hibernate.DOUBLE) );
registerFunction( cot, new StandardSQLFunction(cot, Hibernate.DOUBLE) );
registerFunction( exp, new StandardSQLFunction(exp, Hibernate.DOUBLE) );
registerFunction( ln, new StandardSQLFunction(ln, Hibernate.DOUBLE) );
registerFunction( log, new StandardSQLFunction(log, Hibernate.DOUBLE) );
registerFunction( sin, new StandardSQLFunction(sin, Hibernate.DOUBLE) );
registerFunction( sqrt, new StandardSQLFunction(sqrt, Hibernate.DOUBLE) );
registerFunction( cbrt, new StandardSQLFunction(cbrt, Hibernate.DOUBLE) );
registerFunction( tan, new StandardSQLFunction(tan, Hibernate.DOUBLE) );
registerFunction( radians, new StandardSQLFunction(radians, Hibernate.DOUBLE) );
registerFunction( degrees, new StandardSQLFunction(degrees, Hibernate.DOUBLE) );
registerFunction( stddev, new StandardSQLFunction(stddev, Hibernate.DOUBLE) );
registerFunction( variance, new StandardSQLFunction(variance, Hibernate.DOUBLE) );
registerFunction( random, new NoArgSQLFunction(random, Hibernate.DOUBLE) );
registerFunction( round, new StandardSQLFunction(round) );
registerFunction( trunc, new StandardSQLFunction(trunc) );
registerFunction( ceil, new StandardSQLFunction(ceil) );
registerFunction( floor, new StandardSQLFunction(floor) );
registerFunction( chr, new StandardSQLFunction(chr, Hibernate.CHARACTER) );
registerFunction( lower, new StandardSQLFunction(lower) );
registerFunction( upper, new StandardSQLFunction(upper) );
registerFunction( substr, new StandardSQLFunction(substr, Hibernate.STRING) );
registerFunction( initcap, new StandardSQLFunction(initcap) );
registerFunction( to_ascii, new StandardSQLFunction(to_ascii) );
registerFunction( quote_ident, new StandardSQLFunction(quote_ident, Hibernate.STRING) );
registerFunction( quote_literal, new StandardSQLFunction(quote_literal, Hibernate.STRING) );
registerFunction( md5, new StandardSQLFunction(md5) );
registerFunction( ascii,