Bug #51712 Display Size is always 0 for columns returned by getProcedureColumns()
Submitted: 4 Mar 2010 9:19 Modified: 7 Jul 2010 6:50
Reporter: Bogdan Degtyariov Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.12 OS:Any
Assigned to: CPU Architecture:Any
Tags: getColumnDisplaySize, getProcedureColumns

[4 Mar 2010 9:19] Bogdan Degtyariov
Description:
getColumnDisplaySize() returns 0 for columns returned by getProcedureColumns().
This does not happen for any other function such as getProcedures().

I presume this is so because createProcedureColumnsFields and createFunctionColumnsFields have been all initialized with 0.

How to repeat:
Run the java test case uploaded below

Suggested fix:
=== modified file 'src/com/mysql/jdbc/DatabaseMetaData.java'
--- src/com/mysql/jdbc/DatabaseMetaData.java	2010-01-28 23:59:15 +0000
+++ src/com/mysql/jdbc/DatabaseMetaData.java	2010-03-04 09:06:11 +0000
@@ -4065,19 +4065,19 @@
 	protected Field[] createProcedureColumnsFields() {
 		Field[] fields = new Field[13];
 
-		fields[0] = new Field("", "PROCEDURE_CAT", Types.CHAR, 0);
+		fields[0] = new Field("", "PROCEDURE_CAT", Types.CHAR, 255);
 		fields[1] = new Field("", "PROCEDURE_SCHEM", Types.CHAR, 0);
-		fields[2] = new Field("", "PROCEDURE_NAME", Types.CHAR, 0);
-		fields[3] = new Field("", "COLUMN_NAME", Types.CHAR, 0);
-		fields[4] = new Field("", "COLUMN_TYPE", Types.CHAR, 0);
-		fields[5] = new Field("", "DATA_TYPE", Types.SMALLINT, 0);
-		fields[6] = new Field("", "TYPE_NAME", Types.CHAR, 0);
-		fields[7] = new Field("", "PRECISION", Types.INTEGER, 0);
-		fields[8] = new Field("", "LENGTH", Types.INTEGER, 0);
-		fields[9] = new Field("", "SCALE", Types.SMALLINT, 0);
-		fields[10] = new Field("", "RADIX", Types.SMALLINT, 0);
-		fields[11] = new Field("", "NULLABLE", Types.SMALLINT, 0);
-		fields[12] = new Field("", "REMARKS", Types.CHAR, 0);
+		fields[2] = new Field("", "PROCEDURE_NAME", Types.CHAR, 255);
+		fields[3] = new Field("", "COLUMN_NAME", Types.CHAR, 32);
+		fields[4] = new Field("", "COLUMN_TYPE", Types.CHAR, 255);
+		fields[5] = new Field("", "DATA_TYPE", Types.SMALLINT, 5);
+		fields[6] = new Field("", "TYPE_NAME", Types.CHAR, 32);
+		fields[7] = new Field("", "PRECISION", Types.INTEGER, 10);
+		fields[8] = new Field("", "LENGTH", Types.INTEGER, 10);
+		fields[9] = new Field("", "SCALE", Types.SMALLINT, 5);
+		fields[10] = new Field("", "RADIX", Types.SMALLINT, 2);
+		fields[11] = new Field("", "NULLABLE", Types.SMALLINT, 1);
+		fields[12] = new Field("", "REMARKS", Types.CHAR, 255);
 		return fields;
 	}
 	
@@ -8102,23 +8102,23 @@
 
 	protected Field[] createFunctionColumnsFields() {
 		Field[] fields = {
-    			new Field("", "FUNCTION_CAT", Types.VARCHAR, 0),
+    			new Field("", "FUNCTION_CAT", Types.VARCHAR, 255),
     			new Field("", "FUNCTION_SCHEM", Types.VARCHAR, 0),
-    			new Field("", "FUNCTION_NAME", Types.VARCHAR, 0),
-    			new Field("", "COLUMN_NAME", Types.VARCHAR, 0),
-    			new Field("", "COLUMN_TYPE", Types.VARCHAR, 0),
-    			new Field("", "DATA_TYPE", Types.SMALLINT, 0),
-    			new Field("", "TYPE_NAME", Types.VARCHAR, 0),
-    			new Field("", "PRECISION", Types.INTEGER, 0),
-    			new Field("", "LENGTH", Types.INTEGER, 0),
-    			new Field("", "SCALE", Types.SMALLINT, 0),
-    			new Field("", "RADIX", Types.SMALLINT, 0),
-    			new Field("", "NULLABLE", Types.SMALLINT, 0),
-    			new Field("", "REMARKS", Types.VARCHAR, 0),
-    			new Field("", "CHAR_OCTET_LENGTH", Types.INTEGER, 0),
-    			new Field("", "ORDINAL_POSITION", Types.INTEGER, 0),
+    			new Field("", "FUNCTION_NAME", Types.VARCHAR, 255),
+    			new Field("", "COLUMN_NAME", Types.VARCHAR, 32),
+    			new Field("", "COLUMN_TYPE", Types.VARCHAR, 255),
+    			new Field("", "DATA_TYPE", Types.SMALLINT, 5),
+    			new Field("", "TYPE_NAME", Types.VARCHAR, 32),
+    			new Field("", "PRECISION", Types.INTEGER, 10),
+    			new Field("", "LENGTH", Types.INTEGER, 10),
+    			new Field("", "SCALE", Types.SMALLINT, 5),
+    			new Field("", "RADIX", Types.SMALLINT, 2),
+    			new Field("", "NULLABLE", Types.SMALLINT, 1),
+    			new Field("", "REMARKS", Types.VARCHAR, 255),
+    			new Field("", "CHAR_OCTET_LENGTH", Types.INTEGER, 10),
+    			new Field("", "ORDINAL_POSITION", Types.INTEGER, 2),
     			new Field("", "IS_NULLABLE", Types.VARCHAR, 3),
-    			new Field("", "SPECIFIC_NAME", Types.VARCHAR, 0)};
+    			new Field("", "SPECIFIC_NAME", Types.VARCHAR, 255)};
 		return fields;
 	}
[4 Mar 2010 9:20] Bogdan Degtyariov
test case

Attachment: bug_procedure_columns.java (text/x-java), 2.41 KiB.

[18 Mar 2010 10:18] Tonci Grgin
This also seems to be fixed with patch for Bug#51912, at least in my test case.
[24 Mar 2010 7:08] Tonci Grgin
Problem was actually not in DisplaySize itself. That was fixed in Bug#41269. After applying proper patch for PROC_CAT things work as expected (Bug#51912).
[2 Jul 2010 10:16] Tonci Grgin
Apparently patch for Bug#41269 did not addressed the problem fully so Bogdan was right all along.
getColumnDisplaySize on resultset consisting of metadata (already) is not functional without his patch.

After testing, I'll push it.
[7 Jul 2010 6:50] Tonci Grgin
A patch for this bug has been committed.