Bug #22613 getColumns() shows misleading COLUMN_SIZE for SET column
Submitted: 22 Sep 2006 18:26 Modified: 18 Oct 2006 21:37
Reporter: Kolbe Kegel Email Updates:
Status: Closed Impact on me:
Category:Connector / J Severity:S3 (Non-critical)
Version:3.1.13 OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[22 Sep 2006 18:26] Kolbe Kegel
For a column of the SET data type, the DatabaseMetaData.getColumns() function returns a value for COLUMN_SIZE equal to the longest name used by a member of the set.

For example, a SET column defined as ('a','bc','def','ghij') will have a COLUMN_SIZE of 4.

This does not fulfill the requirements of the common use case for the COLUMN_SIZE value, which is to impose some restriction on the length of incoming data.

A SET column can accept a maximum value of the sum of the lenghts of the name of each of N set members plus N-1 commas. For the example above, the maximum length that can be inserted into the column is 13: a,bc,def,ghij

How to repeat:
  `s` set('a','bc','def','ghij') default NULL

DatabaseMetaData meta = conn.getMetaData();
ResultSet rs = meta.getColumns(null,"test","t1","s");


(A proper test case will be submitted shortly.)

Suggested fix:
DatabaseMetaData.getColumns() should return a value for COLUMN_SIZE equal to the maximum legal string that can be inserted into a SET column.
[28 Sep 2006 18:57] Kolbe Kegel
JUnit test case for bug #22613

Attachment: BUG22613.java (text/x-java), 2.46 KiB.

[5 Oct 2006 16:45] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

[21 Oct 2006 0:47] Mark Matthews
Fixed in 5.0.4.