Java Code Examples for org.apache.ddlutils.model.TypeMap#isTextType()

The following examples show how to use org.apache.ddlutils.model.TypeMap#isTextType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SapDbBuilder.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void writeCastExpression(Column sourceColumn, Column targetColumn) throws IOException
{
    boolean charSizeChanged = TypeMap.isTextType(targetColumn.getTypeCode()) &&
                              TypeMap.isTextType(targetColumn.getTypeCode()) &&
                              ColumnDefinitionChange.isSizeChanged(getPlatformInfo(), sourceColumn, targetColumn) &&
                              !StringUtilsExt.isEmpty(targetColumn.getSize());

    if (charSizeChanged)
    {
        print("SUBSTR(");
    }
    printIdentifier(getColumnName(sourceColumn));
    if (charSizeChanged)
    {
        print(",1,");
        print(targetColumn.getSize());
        print(")");
    }
}
 
Example 2
Source File: InterbaseModelReader.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Adjusts the columns in the table by fixing types and default values.
 * 
 * @param table The table
 */
protected void adjustColumns(Table table)
{
    Column[] columns = table.getColumns();

    for (int idx = 0; idx < columns.length; idx++)
    {
        if (columns[idx].getTypeCode() == Types.FLOAT)
        {
            columns[idx].setTypeCode(Types.REAL);
        }
        else if ((columns[idx].getTypeCode() == Types.NUMERIC) || (columns[idx].getTypeCode() == Types.DECIMAL))
        {
            if ((columns[idx].getTypeCode() == Types.NUMERIC) && (columns[idx].getSizeAsInt() == 18) && (columns[idx].getScale() == 0))
            {
                columns[idx].setTypeCode(Types.BIGINT);
            }
        }
        else if (TypeMap.isTextType(columns[idx].getTypeCode()))
        {
            columns[idx].setDefaultValue(unescape(columns[idx].getDefaultValue(), "'", "''"));
        }
    }
}
 
Example 3
Source File: SapDbBuilder.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void writeCastExpression(Column sourceColumn, Column targetColumn) throws IOException
{
    boolean charSizeChanged = TypeMap.isTextType(targetColumn.getTypeCode()) &&
                              TypeMap.isTextType(targetColumn.getTypeCode()) &&
                              ColumnDefinitionChange.isSizeChanged(getPlatformInfo(), sourceColumn, targetColumn) &&
                              !StringUtilsExt.isEmpty(targetColumn.getSize());

    if (charSizeChanged)
    {
        print("SUBSTR(");
    }
    printIdentifier(getColumnName(sourceColumn));
    if (charSizeChanged)
    {
        print(",1,");
        print(targetColumn.getSize());
        print(")");
    }
}
 
Example 4
Source File: DerbyModelReader.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
{
    Column column       = super.readColumn(metaData, values);
    String defaultValue = column.getDefaultValue();

    if (defaultValue != null)
    {
        // we check for these strings
        //   GENERATED_BY_DEFAULT               -> 'GENERATED BY DEFAULT AS IDENTITY'
        //   AUTOINCREMENT: start 1 increment 1 -> 'GENERATED ALWAYS AS IDENTITY'
        if ("GENERATED_BY_DEFAULT".equals(defaultValue) || defaultValue.startsWith("AUTOINCREMENT:"))
        {
            column.setDefaultValue(null);
            column.setAutoIncrement(true);
        }
        else if (TypeMap.isTextType(column.getTypeCode()))
        {
            column.setDefaultValue(unescape(defaultValue, "'", "''"));
        }
    }
    return column;
}
 
Example 5
Source File: InterbaseModelReader.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Adjusts the columns in the table by fixing types and default values.
 * 
 * @param table The table
 */
protected void adjustColumns(Table table)
{
    Column[] columns = table.getColumns();

    for (int idx = 0; idx < columns.length; idx++)
    {
        if (columns[idx].getTypeCode() == Types.FLOAT)
        {
            columns[idx].setTypeCode(Types.REAL);
        }
        else if ((columns[idx].getTypeCode() == Types.NUMERIC) || (columns[idx].getTypeCode() == Types.DECIMAL))
        {
            if ((columns[idx].getTypeCode() == Types.NUMERIC) && (columns[idx].getSizeAsInt() == 18) && (columns[idx].getScale() == 0))
            {
                columns[idx].setTypeCode(Types.BIGINT);
            }
        }
        else if (TypeMap.isTextType(columns[idx].getTypeCode()))
        {
            columns[idx].setDefaultValue(unescape(columns[idx].getDefaultValue(), "'", "''"));
        }
    }
}
 
Example 6
Source File: DerbyModelReader.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
{
    Column column       = super.readColumn(metaData, values);
    String defaultValue = column.getDefaultValue();

    if (defaultValue != null)
    {
        // we check for these strings
        //   GENERATED_BY_DEFAULT               -> 'GENERATED BY DEFAULT AS IDENTITY'
        //   AUTOINCREMENT: start 1 increment 1 -> 'GENERATED ALWAYS AS IDENTITY'
        if ("GENERATED_BY_DEFAULT".equals(defaultValue) || defaultValue.startsWith("AUTOINCREMENT:"))
        {
            column.setDefaultValue(null);
            column.setAutoIncrement(true);
        }
        else if (TypeMap.isTextType(column.getTypeCode()))
        {
            column.setDefaultValue(unescape(defaultValue, "'", "''"));
        }
    }
    return column;
}
 
Example 7
Source File: HsqlDbModelReader.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
{
    Column column = super.readColumn(metaData, values);

    if (TypeMap.isTextType(column.getTypeCode()) &&
        (column.getDefaultValue() != null))
    {
        column.setDefaultValue(unescape(column.getDefaultValue(), "'", "''"));
    }
    return column;
}
 
Example 8
Source File: MckoiModelReader.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
{
    Column column = super.readColumn(metaData, values);

    if (column.getSize() != null)
    {
        if (column.getSizeAsInt() <= 0)
        {
            column.setSize(null);
        }
    }

    String defaultValue = column.getDefaultValue();

    if (defaultValue != null)
    {
        if (defaultValue.toLowerCase().startsWith("nextval('") ||
            defaultValue.toLowerCase().startsWith("uniquekey('"))
        {
            column.setDefaultValue(null);
            column.setAutoIncrement(true);
        }
        else if (TypeMap.isTextType(column.getTypeCode()))
        {
            column.setDefaultValue(unescape(column.getDefaultValue(), "'", "\\'"));
        }
    }
    return column;
}
 
Example 9
Source File: FirebirdBuilder.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void writeCastExpression(Column sourceColumn, Column targetColumn) throws IOException
{
    boolean sizeChanged = ColumnDefinitionChange.isSizeChanged(getPlatformInfo(), sourceColumn, targetColumn);
    boolean typeChanged = ColumnDefinitionChange.isTypeChanged(getPlatformInfo(), sourceColumn, targetColumn);

    if (sizeChanged || typeChanged)
    {
        boolean needSubstr = TypeMap.isTextType(targetColumn.getTypeCode()) && sizeChanged &&
                             (targetColumn.getSize() != null) && (sourceColumn.getSizeAsInt() > targetColumn.getSizeAsInt());

        if (needSubstr)
        {
            print("SUBSTRING(");
        }
        // we're not using CAST but instead string construction which does not require us to know the size
        print("(");
        printIdentifier(getColumnName(sourceColumn));
        print(" || '' ");
        if (needSubstr)
        {
            print(") FROM 1 FOR ");
            print(targetColumn.getSize());
            print(")");
        }
        else
        {
            print(")");
        }
    }
    else
    {
        super.writeCastExpression(sourceColumn, targetColumn);
    }
}
 
Example 10
Source File: MSSqlBuilder.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void writeCastExpression(Column sourceColumn, Column targetColumn) throws IOException
{
    boolean sizeChanged = ColumnDefinitionChange.isSizeChanged(getPlatformInfo(), sourceColumn, targetColumn);
    boolean typeChanged = ColumnDefinitionChange.isTypeChanged(getPlatformInfo(), sourceColumn, targetColumn);

    if (sizeChanged || typeChanged)
    {
        if (TypeMap.isTextType(targetColumn.getTypeCode()) && sizeChanged &&
            (targetColumn.getSize() != null) && (sourceColumn.getSizeAsInt() > targetColumn.getSizeAsInt()))
        {
            print("SUBSTRING(CAST(");
            printIdentifier(getColumnName(sourceColumn));
            print(" AS ");
            print(getNativeType(targetColumn));
            print("),1,");
            print(getSizeSpec(targetColumn));
            print(")");
        }
        else
        {
            print("CAST(");
            printIdentifier(getColumnName(sourceColumn));
            print(" AS ");
            print(getSqlType(targetColumn));
            print(")");
        }
    }
    else
    {
        printIdentifier(getColumnName(sourceColumn));
    }
}
 
Example 11
Source File: PlatformImplBase.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Allows the platform to postprocess the model just read from the database.
 * 
 * @param model The model
 */
protected void postprocessModelFromDatabase(Database model)
{
    // Default values for CHAR/VARCHAR/LONGVARCHAR columns have quotation marks
    // around them which we'll remove now
    for (int tableIdx = 0; tableIdx < model.getTableCount(); tableIdx++)
    {
        Table table = model.getTable(tableIdx);

        for (int columnIdx = 0; columnIdx < table.getColumnCount(); columnIdx++)
        {
            Column column = table.getColumn(columnIdx);

            if (TypeMap.isTextType(column.getTypeCode()) ||
                TypeMap.isDateTimeType(column.getTypeCode()))
            {
                String defaultValue = column.getDefaultValue();

                if ((defaultValue != null) && (defaultValue.length() >= 2) &&
                    defaultValue.startsWith("'") && defaultValue.endsWith("'"))
                {
                    defaultValue = defaultValue.substring(1, defaultValue.length() - 1);
                    column.setDefaultValue(defaultValue);
                }
            }
        }
    }
}
 
Example 12
Source File: HsqlDbModelReader.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
{
    Column column = super.readColumn(metaData, values);

    if (TypeMap.isTextType(column.getTypeCode()) &&
        (column.getDefaultValue() != null))
    {
        column.setDefaultValue(unescape(column.getDefaultValue(), "'", "''"));
    }
    return column;
}
 
Example 13
Source File: HsqlDbBuilder.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void writeCastExpression(Column sourceColumn, Column targetColumn) throws IOException
{
    boolean sizeChanged = ColumnDefinitionChange.isSizeChanged(getPlatformInfo(), sourceColumn, targetColumn);
    boolean typeChanged = ColumnDefinitionChange.isTypeChanged(getPlatformInfo(), sourceColumn, targetColumn);

    if (sizeChanged || typeChanged)
    {
        boolean needSubstr = TypeMap.isTextType(targetColumn.getTypeCode()) && sizeChanged && (sourceColumn.getSizeAsInt() > targetColumn.getSizeAsInt());

        if (needSubstr)
        {
            print("SUBSTR(");
        }
        print("CAST(");
        printIdentifier(getColumnName(sourceColumn));
        print(" AS ");
        if (needSubstr)
        {
            print(getNativeType(targetColumn));
        }
        else
        {
            print(getSqlType(targetColumn));
        }
        print(")");
        if (needSubstr)
        {
            print(",1,");
            print(targetColumn.getSize());
            print(")");
        }
    }
    else
    {
        super.writeCastExpression(sourceColumn, targetColumn);
    }
}
 
Example 14
Source File: MckoiModelReader.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
{
    Column column = super.readColumn(metaData, values);

    if (column.getSize() != null)
    {
        if (column.getSizeAsInt() <= 0)
        {
            column.setSize(null);
        }
    }

    String defaultValue = column.getDefaultValue();

    if (defaultValue != null)
    {
        if (defaultValue.toLowerCase().startsWith("nextval('") ||
            defaultValue.toLowerCase().startsWith("uniquekey('"))
        {
            column.setDefaultValue(null);
            column.setAutoIncrement(true);
        }
        else if (TypeMap.isTextType(column.getTypeCode()))
        {
            column.setDefaultValue(unescape(column.getDefaultValue(), "'", "\\'"));
        }
    }
    return column;
}
 
Example 15
Source File: FirebirdBuilder.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void writeCastExpression(Column sourceColumn, Column targetColumn) throws IOException
{
    boolean sizeChanged = ColumnDefinitionChange.isSizeChanged(getPlatformInfo(), sourceColumn, targetColumn);
    boolean typeChanged = ColumnDefinitionChange.isTypeChanged(getPlatformInfo(), sourceColumn, targetColumn);

    if (sizeChanged || typeChanged)
    {
        boolean needSubstr = TypeMap.isTextType(targetColumn.getTypeCode()) && sizeChanged &&
                             (targetColumn.getSize() != null) && (sourceColumn.getSizeAsInt() > targetColumn.getSizeAsInt());

        if (needSubstr)
        {
            print("SUBSTRING(");
        }
        // we're not using CAST but instead string construction which does not require us to know the size
        print("(");
        printIdentifier(getColumnName(sourceColumn));
        print(" || '' ");
        if (needSubstr)
        {
            print(") FROM 1 FOR ");
            print(targetColumn.getSize());
            print(")");
        }
        else
        {
            print(")");
        }
    }
    else
    {
        super.writeCastExpression(sourceColumn, targetColumn);
    }
}
 
Example 16
Source File: FirebirdModelReader.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
{
	Column column = super.readColumn(metaData, values);

	if (column.getTypeCode() == Types.FLOAT)
	{
		column.setTypeCode(Types.REAL);
	}
       else if (TypeMap.isTextType(column.getTypeCode()))
       {
           column.setDefaultValue(unescape(column.getDefaultValue(), "'", "''"));
       }
	return column;
}
 
Example 17
Source File: PlatformImplBase.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Allows the platform to postprocess the model just read from the database.
 * 
 * @param model The model
 */
protected void postprocessModelFromDatabase(Database model)
{
    // Default values for CHAR/VARCHAR/LONGVARCHAR columns have quotation marks
    // around them which we'll remove now
    for (int tableIdx = 0; tableIdx < model.getTableCount(); tableIdx++)
    {
        Table table = model.getTable(tableIdx);

        for (int columnIdx = 0; columnIdx < table.getColumnCount(); columnIdx++)
        {
            Column column = table.getColumn(columnIdx);

            if (TypeMap.isTextType(column.getTypeCode()) ||
                TypeMap.isDateTimeType(column.getTypeCode()))
            {
                String defaultValue = column.getDefaultValue();

                if ((defaultValue != null) && (defaultValue.length() >= 2) &&
                    defaultValue.startsWith("'") && defaultValue.endsWith("'"))
                {
                    defaultValue = defaultValue.substring(1, defaultValue.length() - 1);
                    column.setDefaultValue(defaultValue);
                }
            }
        }
    }
}
 
Example 18
Source File: MySqlBuilder.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void writeCastExpression(Column sourceColumn, Column targetColumn) throws IOException
{
    boolean sizeChanged = ColumnDefinitionChange.isSizeChanged(getPlatformInfo(), sourceColumn, targetColumn);
    boolean typeChanged = ColumnDefinitionChange.isTypeChanged(getPlatformInfo(), sourceColumn, targetColumn);

    if (sizeChanged || typeChanged)
    {
        String targetNativeType = getNativeType(targetColumn);

        switch (targetColumn.getTypeCode())
        {
            case Types.BIT:
            case Types.BOOLEAN:
            case Types.TINYINT:
            case Types.SMALLINT:
            case Types.INTEGER:
            case Types.BIGINT:
                targetNativeType = "SIGNED";
                break;
            case Types.FLOAT:
            case Types.REAL:
            case Types.DOUBLE:
                targetNativeType = "SIGNED"; // ?
                break;
            case Types.DECIMAL:
            case Types.NUMERIC:
                targetNativeType = "DECIMAL";
                break;
            case Types.DATE:
                targetNativeType = "DATE";
                break;
            case Types.TIMESTAMP:
                targetNativeType = "DATETIME";
                break;
            case Types.CHAR:
            case Types.VARCHAR:
            case Types.LONGVARCHAR:
            case Types.CLOB:
                targetNativeType = "CHAR";
                break;
            default:
                targetNativeType = "BINARY";
                break;
        }

        print("CAST(");
        if (TypeMap.isTextType(sourceColumn.getTypeCode()) && TypeMap.isTextType(targetColumn.getTypeCode()) && sizeChanged)
        {
            print("LEFT(");
            printIdentifier(getColumnName(sourceColumn));
            print(",");
            print(targetColumn.getSize());
            print(")");
        }
        else
        {
            printIdentifier(getColumnName(sourceColumn));
        }
        print(" AS ");
        print(getSqlType(targetColumn, targetNativeType));
        print(")");
    }
    else
    {
        printIdentifier(getColumnName(sourceColumn));
    }
}
 
Example 19
Source File: PostgreSqlModelReader.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
{
    Column column = super.readColumn(metaData, values);

    if (column.getSize() != null)
    {
        if (column.getSizeAsInt() <= 0)
        {
            column.setSize(null);
            // PostgreSQL reports BYTEA and TEXT as BINARY(-1) and VARCHAR(-1) respectively
            // Since we cannot currently use the Blob/Clob interface with BYTEA, we instead
            // map them to LONGVARBINARY/LONGVARCHAR
            if (column.getTypeCode() == Types.BINARY)
            {
                column.setTypeCode(Types.LONGVARBINARY);
            }
            else if (column.getTypeCode() == Types.VARCHAR)
            {
                column.setTypeCode(Types.LONGVARCHAR);
            }
        }
        // fix issue DDLUTILS-165 as postgresql-8.2-504-jdbc3.jar seems to return Integer.MAX_VALUE
        // on columns defined as TEXT.
        else if (column.getSizeAsInt() == Integer.MAX_VALUE)
        {
            column.setSize(null);
            if (column.getTypeCode() == Types.VARCHAR)
            {
                column.setTypeCode(Types.LONGVARCHAR);
            }
            else if (column.getTypeCode() == Types.BINARY)
            {
                column.setTypeCode(Types.LONGVARBINARY);
            }
        }
    }

    String defaultValue = column.getDefaultValue();

    if ((defaultValue != null) && (defaultValue.length() > 0))
    {
        // If the default value looks like "nextval('ROUNDTRIP_VALUE_seq'::text)"
        // then it is an auto-increment column
        if (defaultValue.startsWith("nextval("))
        {
            column.setAutoIncrement(true);
            defaultValue = null;
        }
        else
        {
            // PostgreSQL returns default values in the forms "-9000000000000000000::bigint" or
            // "'some value'::character varying" or "'2000-01-01'::date"
            switch (column.getTypeCode())
            {
                case Types.INTEGER:
                case Types.BIGINT:
                case Types.DECIMAL:
                case Types.NUMERIC:
                    defaultValue = extractUndelimitedDefaultValue(defaultValue);
                    break;
                case Types.CHAR:
                case Types.VARCHAR:
                case Types.LONGVARCHAR:
                case Types.DATE:
                case Types.TIME:
                case Types.TIMESTAMP:
                    defaultValue = extractDelimitedDefaultValue(defaultValue);
                    break;
            }
            if (TypeMap.isTextType(column.getTypeCode()))
            {
                // We assume escaping via double quote (see also the backslash_quote setting:
                // http://www.postgresql.org/docs/7.4/interactive/runtime-config.html#RUNTIME-CONFIG-COMPATIBLE)
                defaultValue = unescape(defaultValue, "'", "''");
            }
        }
        column.setDefaultValue(defaultValue);
    }
    return column;
}
 
Example 20
Source File: PostgreSqlModelReader.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
{
    Column column = super.readColumn(metaData, values);

    if (column.getSize() != null)
    {
        if (column.getSizeAsInt() <= 0)
        {
            column.setSize(null);
            // PostgreSQL reports BYTEA and TEXT as BINARY(-1) and VARCHAR(-1) respectively
            // Since we cannot currently use the Blob/Clob interface with BYTEA, we instead
            // map them to LONGVARBINARY/LONGVARCHAR
            if (column.getTypeCode() == Types.BINARY)
            {
                column.setTypeCode(Types.LONGVARBINARY);
            }
            else if (column.getTypeCode() == Types.VARCHAR)
            {
                column.setTypeCode(Types.LONGVARCHAR);
            }
        }
        // fix issue DDLUTILS-165 as postgresql-8.2-504-jdbc3.jar seems to return Integer.MAX_VALUE
        // on columns defined as TEXT.
        else if (column.getSizeAsInt() == Integer.MAX_VALUE)
        {
            column.setSize(null);
            if (column.getTypeCode() == Types.VARCHAR)
            {
                column.setTypeCode(Types.LONGVARCHAR);
            }
            else if (column.getTypeCode() == Types.BINARY)
            {
                column.setTypeCode(Types.LONGVARBINARY);
            }
        }
    }

    String defaultValue = column.getDefaultValue();

    if ((defaultValue != null) && (defaultValue.length() > 0))
    {
        // If the default value looks like "nextval('ROUNDTRIP_VALUE_seq'::text)"
        // then it is an auto-increment column
        if (defaultValue.startsWith("nextval("))
        {
            column.setAutoIncrement(true);
            defaultValue = null;
        }
        else
        {
            // PostgreSQL returns default values in the forms "-9000000000000000000::bigint" or
            // "'some value'::character varying" or "'2000-01-01'::date"
            switch (column.getTypeCode())
            {
                case Types.INTEGER:
                case Types.BIGINT:
                case Types.DECIMAL:
                case Types.NUMERIC:
                    defaultValue = extractUndelimitedDefaultValue(defaultValue);
                    break;
                case Types.CHAR:
                case Types.VARCHAR:
                case Types.LONGVARCHAR:
                case Types.DATE:
                case Types.TIME:
                case Types.TIMESTAMP:
                    defaultValue = extractDelimitedDefaultValue(defaultValue);
                    break;
            }
            if (TypeMap.isTextType(column.getTypeCode()))
            {
                // We assume escaping via double quote (see also the backslash_quote setting:
                // http://www.postgresql.org/docs/7.4/interactive/runtime-config.html#RUNTIME-CONFIG-COMPATIBLE)
                defaultValue = unescape(defaultValue, "'", "''");
            }
        }
        column.setDefaultValue(defaultValue);
    }
    return column;
}