DdlUtils
  1. DdlUtils
  2. DDLUTILS-165

Data type mismatch in PostgreSQL with TEXT columns

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0 RC1
    • Component/s: Core - PostgreSql
    • Labels:
      None
    • Environment:
      PostgreSQL v2.8.3 on Windows with JDBC driver 'postgresql-8.2-504.jdbc3.jar'

      Description

      The PostgreSql jdbc driver returns VARCHAR(2147483647) for columns defined as TEXT. The ModelReader expects VARCHAR(-1) for these data type.
      Maybe the behaviour of the jdbc driver changed lately, because there is a comment in the PostgreSqlModelReader.readColumn method which says that PostgreSQL returns VARCHAR(-1), but in my environment i get VARCHAR(2147483647).

      1. patch.txt
        1 kB
        Martin van den Bemt

        Activity

        Hide
        Martin van den Bemt added a comment -

        commit -m "Fix issue DDLUTILS-165. Thanx to Stefan Huber for spotting and testing this." D:/projects/mvdb.com/DdlUtils/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlModelReader.java
        Sending D:/projects/mvdb.com/DdlUtils/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlModelReader.java
        Transmitting file data ...
        Committed revision 523790.

        Show
        Martin van den Bemt added a comment - commit -m "Fix issue DDLUTILS-165 . Thanx to Stefan Huber for spotting and testing this." D:/projects/mvdb.com/DdlUtils/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlModelReader.java Sending D:/projects/mvdb.com/DdlUtils/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlModelReader.java Transmitting file data ... Committed revision 523790.
        Hide
        Stefan Huber added a comment -

        The patch works fine with LONGVARCHAR values.

        But with LONGVARBINARY fields i have the same effect. So if you add a type conversion for LONGVARBINARY fields (analog to LONGVARCHAR fields) i would classify this bug as resolved.

        // 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); + }

        }

        Show
        Stefan Huber added a comment - The patch works fine with LONGVARCHAR values. But with LONGVARBINARY fields i have the same effect. So if you add a type conversion for LONGVARBINARY fields (analog to LONGVARCHAR fields) i would classify this bug as resolved. // 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); + } }
        Hide
        Martin van den Bemt added a comment -

        I have a patch for this I think. Since I don't have a means to test this atm, instead of committing, I attach the patch here. If someone could check it solves the problem, I will commit it.

        Show
        Martin van den Bemt added a comment - I have a patch for this I think. Since I don't have a means to test this atm, instead of committing, I attach the patch here. If someone could check it solves the problem, I will commit it.

          People

          • Assignee:
            Thomas Dudziak
            Reporter:
            Stefan Huber
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development