[libpostgresql-jdbc-java] 01/14: Correct the display size calculations for numeric data. Don't add precision and scale because scale is just a subset of precision.

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:19:50 UTC 2017


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to tag REL8_1_405
in repository libpostgresql-jdbc-java.

commit c910ef209daf6de826bbe441e7447631254279c8
Author: Kris Jurka <books at ejurka.com>
Date:   Wed Nov 23 21:54:02 2005 +0000

    Correct the display size calculations for numeric data.  Don't add
    precision and scale because scale is just a subset of precision.
---
 org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java b/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java
index 7aa1f7c..56fc4c5 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java,v 1.17 2005/01/11 08:25:46 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSetMetaData.java,v 1.18 2005/09/29 23:04:45 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -256,9 +256,14 @@ public abstract class AbstractJdbc2ResultSetMetaData implements PGResultSetMetaD
         if (type_name.equals( "bpchar" )
                 || type_name.equals( "varchar" ))
             return typmod; // VARHDRSZ=sizeof(int32)=4
-        if (type_name.equals( "numeric" ))
-            return ( (typmod >> 16) & 0xffff )
-                   + 1 + ( typmod & 0xffff ); // DECIMAL(p,s) = (p digits).(s digits)
+        if (type_name.equals( "numeric" )) {
+            if (typmod + 4 == -1)
+                return 1002;
+            int precision = (typmod >> 16) & 0xffff;
+            int scale = typmod & 0xffff;
+            // sign + digits + decimal point if necessary
+            return 1 + precision + (scale != 0 ? 1 : 0);
+        }
 
         // if we don't know better
         return f.getLength();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git



More information about the pkg-java-commits mailing list