Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit cabe989

Browse files
committed
Here is a patch for DatabaseMetaData to show precision properly. It is
from Mark Lillywhite. I am adding to the patch queue.
1 parent 0450331 commit cabe989

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* This class provides information about the database as a whole.
1515
*
16-
* $Id: DatabaseMetaData.java,v 1.38 2001/10/24 04:31:50 barry Exp $
16+
* $Id: DatabaseMetaData.java,v 1.39 2001/10/24 17:44:28 momjian Exp $
1717
*
1818
* <p>Many of the methods here return lists of information in ResultSets. You
1919
* can use the normal ResultSet methods such as getString and getInt to
@@ -1999,7 +1999,18 @@ public java.sql.ResultSet getColumns(String catalog, String schemaPattern, Strin
19991999
}
20002000

20012001
tuple[7] = null; // Buffer length
2002-
tuple[8] = "0".getBytes(); // Decimal Digits - how to get this?
2002+
// Decimal digits = scale
2003+
// From the source (see e.g. backend/utils/adt/numeric.c,
2004+
// function numeric()) the scale and precision can be calculated
2005+
// from the typmod value. mark@plasticsoftware.com.au
2006+
if (typname.equals("numeric") || typname.equals("decimal"))
2007+
{
2008+
int attypmod = r.getInt(8);
2009+
tuple[8] =
2010+
Integer.toString((attypmod & 0xffff) - VARHDRSZ).getBytes();
2011+
}
2012+
else
2013+
tuple[8] = "0".getBytes();
20032014
tuple[9] = "10".getBytes(); // Num Prec Radix - assume decimal
20042015
tuple[10] = Integer.toString(nullFlag.equals("f") ?
20052016
java.sql.DatabaseMetaData.columnNullable :

0 commit comments

Comments
 (0)