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

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

commit 5d2899d04633cd014e36d61b61b667dfcb50b847
Author: Barry Lind <[email protected]>
Date:   Sun Feb 9 23:41:46 2003 +0000

    Merge changes from head to 7.3 branch: better error message on character 
set conversion problems and patch from Kris Jurka for numeric scale
     Modified Files:
      Tag: REL7_3_STABLE
        jdbc/org/postgresql/errors.properties
        jdbc/org/postgresql/core/Encoding.java
        jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
---
 org/postgresql/core/Encoding.java                  | 62 ++++++++++++----------
 org/postgresql/errors.properties                   |  1 +
 .../jdbc1/AbstractJdbc1DatabaseMetaData.java       |  2 +-
 3 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/org/postgresql/core/Encoding.java 
b/org/postgresql/core/Encoding.java
index 417306a..00afd1d 100644
--- a/org/postgresql/core/Encoding.java
+++ b/org/postgresql/core/Encoding.java
@@ -235,36 +235,40 @@ public class Encoding
        private static final int pow2_12 = 4096;        // 212
        private char[] cdata = new char[50];
 
-       private synchronized String decodeUTF8(byte data[], int offset, int 
length) {
-               char[] l_cdata = cdata;
-               if (l_cdata.length < (length)) {
-                       l_cdata = new char[length];
-               }
-               int i = offset;
-               int j = 0;
-               int k = length + offset;
-               int z, y, x, val;
-               while (i < k) {
-                       z = data[i] & 0xFF;
-                       if (z < 0x80) {
-                               l_cdata[j++] = (char)data[i];
-                               i++;
-                       } else if (z >= 0xE0) {         // length == 3
-                               y = data[i+1] & 0xFF;
-                               x = data[i+2] & 0xFF;
-                               val = (z-0xE0)*pow2_12 + (y-0x80)*pow2_6 + 
(x-0x80);
-                               l_cdata[j++] = (char) val;
-                               i+= 3;
-                       } else {                // length == 2 (maybe add 
checking for length > 3, throw exception if it is
-                               y = data[i+1] & 0xFF;
-                               val = (z - 0xC0)* (pow2_6)+(y-0x80);
-                               l_cdata[j++] = (char) val;
-                               i+=2;
-                       } 
-               }
+       private synchronized String decodeUTF8(byte data[], int offset, int 
length) throws SQLException {
+               try {
+                       char[] l_cdata = cdata;
+                       if (l_cdata.length < (length)) {
+                               l_cdata = new char[length];
+                       }
+                       int i = offset;
+                       int j = 0;
+                       int k = length + offset;
+                       int z, y, x, val;
+                       while (i < k) {
+                               z = data[i] & 0xFF;
+                               if (z < 0x80) {
+                                       l_cdata[j++] = (char)data[i];
+                                       i++;
+                               } else if (z >= 0xE0) {         // length == 3
+                                       y = data[i+1] & 0xFF;
+                                       x = data[i+2] & 0xFF;
+                                       val = (z-0xE0)*pow2_12 + 
(y-0x80)*pow2_6 + (x-0x80);
+                                       l_cdata[j++] = (char) val;
+                                       i+= 3;
+                               } else {                // length == 2 (maybe 
add checking for length > 3, throw exception if it is
+                                       y = data[i+1] & 0xFF;
+                                       val = (z - 0xC0)* (pow2_6)+(y-0x80);
+                                       l_cdata[j++] = (char) val;
+                                       i+=2;
+                               } 
+                       }
        
-               String s = new String(l_cdata, 0, j);
-               return s;
+                       String s = new String(l_cdata, 0, j);
+                       return s;
+               } catch (Exception l_e) {
+                       throw new PSQLException("postgresql.con.invalidchar", 
l_e);
+               }
        }
 
 }
diff --git a/org/postgresql/errors.properties b/org/postgresql/errors.properties
index ff87266..ca649b0 100644
--- a/org/postgresql/errors.properties
+++ b/org/postgresql/errors.properties
@@ -5,6 +5,7 @@ postgresql.con.auth:The authentication type {0} is not 
supported. Check that you
 postgresql.con.authfail:An error occured while getting the authentication 
request.
 postgresql.con.backend:Backend start-up failed: {0}
 postgresql.con.call:Callable Statements are not supported at this time.
+postgresql.con.invalidchar:Invalid character data was found.  This is most 
likely caused by stored data containing characters that are invalid for the 
character set the database was created in.  The most common example of this is 
storing 8bit data in a SQL_ASCII database.
 postgresql.con.closed:Connection is closed.  Operation is not permitted.
 postgresql.con.creobj:Failed to create object for {0} {1}
 postgresql.con.failed:The connection attempt failed because {0}
diff --git a/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java 
b/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
index 1027d3f..794b9ae 100644
--- a/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
+++ b/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
@@ -2337,7 +2337,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
                        }
                        else if (pgType.equals("numeric") || 
pgType.equals("decimal")) 
                        {
-                               int attypmod = rs.getInt(8) - VARHDRSZ;
+                               int attypmod = rs.getInt("atttypmod") - 
VARHDRSZ;
                                tuple[6] = Integer.toString( ( attypmod >> 16 ) 
& 0xffff ).getBytes();
                                tuple[8] = Integer.toString(attypmod & 
0xffff).getBytes();
                                tuple[9] = "10".getBytes();

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

_______________________________________________
pkg-java-commits mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

Reply via email to