postgres.git / summary / log / commit / refs
commit d80d4baa09c7fb7590e865e08bd5acddda0c5094
Author: Barry Lind <barry@xythos.com>
Date: Tue Oct 30 05:05:25 2001 +0000
First released in: 7.2
applied patch from Mark Lillywhite, patch was already applied to jdbc2, this applies same fix to jdbc1 code
.../jdbc/org/postgresql/jdbc1/DatabaseMetaData.java | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java b/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
index 1029e7adcc7..fcb6352277a 100644
--- a/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
+++ b/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
@@ -13,7 +13,7 @@ import org.postgresql.util.PSQLException;
/**
* This class provides information about the database as a whole.
*
- * $Id: DatabaseMetaData.java,v 1.35 2001/10/25 05:59:59 momjian Exp $
+ * $Id: DatabaseMetaData.java,v 1.36 2001/10/30 05:05:25 barry Exp $
*
* <p>Many of the methods here return lists of information in ResultSets. You
* can use the normal ResultSet methods such as getString and getInt to
@@ -2011,7 +2011,19 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
}
tuple[7] = null; // Buffer length
- tuple[8] = "0".getBytes(); // Decimal Digits - how to get this?
+ // Decimal digits = scale
+ // From the source (see e.g. backend/utils/adt/numeric.c,
+ // function numeric()) the scale and precision can be calculated
+ // from the typmod value.
+ if (typname.equals("numeric") || typname.equals("decimal"))
+ {
+ int attypmod = r.getInt(8);
+ tuple[8] =
+ Integer.toString((attypmod - VARHDRSZ) & 0xffff).getBytes();
+ }
+ else
+ tuple[8] = "0".getBytes();
+
tuple[9] = "10".getBytes(); // Num Prec Radix - assume decimal
tuple[10] = Integer.toString(nullFlag.equals("f") ?
java.sql.DatabaseMetaData.columnNullable :
[parent: cd01c32f5578]