Invalid Column Length

Поиск
Список
Период
Сортировка
Искать

Invalid Column Length

От:
Perepelkin Andrew <perepelkin.work@gmail.com>
Дата:
Hello,

I am using Liquibase with postgres JDBC driver postgresql-8.4-702.jdbc4.jar
PostgreSQL - 8.4.4
My table structure, for example, is
CREATE TABLE applications
(
  id character varying NOT NULL,
  "name" character varying NOT NULL,
  "version" character varying NOT NULL,
)

When i try export my database structure to the Liquibase script it makes column with length 2147483647.
            <column name="id" type="VARCHAR(10485760)">
                <constraints nullable="false" primaryKey="true" primaryKeyName="applications_pkey"/>
            </column>
Maximum length of type character varying is 10485760.
Generated script is broken.

I looked at Liquibase code and found that ResultSet.getInt("COLUMN_SIZE") returns 2147483647 when length not set implicitly.

Is this a bug?
Is there any workaround exist?

Thank You!




Re: Invalid Column Length

От:
"Kevin Grittner" <Kevin.Grittner@wicourts.gov>
Дата:
Perepelkin Andrew  wrote:
 
> Is there any workaround exist?
 
Use a maximum length on your varchar declarations?:
 
CREATE TABLE applications
(
  id character varying(10000000) NOT NULL,
  "name" character varying(10000000) NOT NULL,
  "version" character varying(10000000) NOT NULL,
)
 
Of course, if you don't intend to support ten million characters for
any of those, you could use a smaller number....
 
-Kevin

Re: Invalid Column Length

От:
Kris Jurka <books@ejurka.com>
Дата:


On Tue, 2 Nov 2010, Perepelkin Andrew wrote:

> Hello,
> 
> I am using Liquibase with postgres JDBC driver postgresql-8.4-702.jdbc4.jar
> PostgreSQL - 8.4.4
> My table structure, for example, is
> CREATE TABLE applications
> (
>   id character varying NOT NULL,
>   "name" character varying NOT NULL,
>   "version" character varying NOT NULL,
> )
> 
> When i try export my database structure to the Liquibase script it makes
> column with length 2147483647.
>             
>                  primaryKeyName="applications_pkey"/>
>             
> Maximum length of type character varying is 10485760.
> Generated script is broken.
> 
> I looked at Liquibase code and found that ResultSet.getInt("COLUMN_SIZE")
> returns 2147483647 when length not set implicitly.
> 
> Is this a bug?
> Is there any workaround exist?
>

You can set the unknownLength URL parameter to say whay you think the size 
of an unspecified string should be:

http://jdbc.postgresql.org/documentation/84/connect.html#connection-parameters

Kris Jurka

Re: Invalid Column Length

От:
Perepelkin Andrew <perepelkin.work@gmail.com>
Дата:


2010/11/2 Kris Jurka <books@ejurka.com>


On Tue, 2 Nov 2010, Perepelkin Andrew wrote:

Hello,

I am using Liquibase with postgres JDBC driver postgresql-8.4-702.jdbc4.jar
PostgreSQL - 8.4.4
My table structure, for example, is
CREATE TABLE applications
(
  id character varying NOT NULL,
  "name" character varying NOT NULL,
  "version" character varying NOT NULL,
)

When i try export my database structure to the Liquibase script it makes
column with length 2147483647.
            <column name="id" type="VARCHAR(10485760)">
                <constraints nullable="false" primaryKey="true"
primaryKeyName="applications_pkey"/>
            </column>
Maximum length of type character varying is 10485760.
Generated script is broken.

I looked at Liquibase code and found that ResultSet.getInt("COLUMN_SIZE")
returns 2147483647 when length not set implicitly.

Is this a bug?
Is there any workaround exist?


You can set the unknownLength URL parameter to say whay you think the size of an unspecified string should be:

http://jdbc.postgresql.org/documentation/84/connect.html#connection-parameters


Thank You, Kris

Your solution suits me.
FAQ