]> granicus.if.org Git - postgresql/commitdiff
patches by Kim Ho to fix
authorDave Cramer <davec@fastcrypt.com>
Mon, 30 Jun 2003 21:10:55 +0000 (21:10 +0000)
committerDave Cramer <davec@fastcrypt.com>
Mon, 30 Jun 2003 21:10:55 +0000 (21:10 +0000)
getByte, getSort if input has decimal or whitespace
setObject if object is a BIT
boolean not on list of SQLKeywords

src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
src/interfaces/jdbc/org/postgresql/jdbc2/AbstractJdbc2Connection.java
src/interfaces/jdbc/org/postgresql/jdbc3/AbstractJdbc3Connection.java

index ff465164a1208d10555a6340f96186f138c924cc..cfb8e4e89757aa646d50a3ad60d616886709b849 100644 (file)
@@ -9,7 +9,7 @@
  * Copyright (c) 2003, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.20 2003/05/29 21:44:47 barry Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.21 2003/06/30 21:10:55 davec Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1740,6 +1740,7 @@ public abstract class AbstractJdbc1Connection implements BaseConnection
                                "varchar", "text", "name", "filename",
                                "bytea",
                                "bool",
+                               "bit",
                                "date",
                                "time",
                                "abstime", "timestamp", "timestamptz"
@@ -1764,6 +1765,7 @@ public abstract class AbstractJdbc1Connection implements BaseConnection
                Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
                Types.BINARY,
                Types.BIT,
+               Types.BIT,
                Types.DATE,
                Types.TIME,
                Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP
index f0b50c1f62dbc6fbdc9f033e6847694a16ce474d..6afee490f06003a6f570a0d5eb676ec7fdc9a508 100644 (file)
@@ -12,7 +12,7 @@ public abstract class AbstractJdbc1DatabaseMetaData
 {
 
        private static final String keywords = "abort,acl,add,aggregate,append,archive," +
-                                                                                  "arch_store,backward,binary,change,cluster," +
+                                                                                  "arch_store,backward,binary,boolean,change,cluster," +
                                                                                   "copy,database,delimiter,delimiters,do,extend," +
                                                                                   "explain,forward,heavy,index,inherits,isnull," +
                                                                                   "light,listen,load,merge,nothing,notify," +
index ee1db017cf9d30b1ccc1cecc8d79cbb27b2bfbb8..5f10f110461da06f376d4b5507a825968a92f98e 100644 (file)
@@ -9,7 +9,7 @@
  * Copyright (c) 2003, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.12 2003/05/03 20:40:45 barry Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.13 2003/06/30 21:10:55 davec Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -189,6 +189,19 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
                {
                        try
                        {
+                               switch(fields[columnIndex-1].getSQLType())
+                               {
+                                       case Types.NUMERIC:
+                                       case Types.REAL:
+                                       case Types.DOUBLE:
+                                       case Types.FLOAT:
+                                       case Types.DECIMAL:
+                                               s = (s.indexOf(".")==-1) ? s : s.substring(0,s.indexOf("."));
+                                               break;
+                                       case Types.CHAR:
+                                               s = s.trim();
+                                               break;
+                               }
                                return Byte.parseByte(s);
                        }
                        catch (NumberFormatException e)
@@ -207,6 +220,19 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
                {
                        try
                        {
+                               switch(fields[columnIndex-1].getSQLType())
+                               {
+                                       case Types.NUMERIC:
+                                       case Types.REAL:
+                                       case Types.DOUBLE:
+                                       case Types.FLOAT:
+                                       case Types.DECIMAL:
+                                               s = (s.indexOf(".")==-1) ? s : s.substring(0,s.indexOf("."));
+                                               break;
+                                       case Types.CHAR:
+                                               s = s.trim();
+                                               break;
+                               }
                                return Short.parseShort(s);
                        }
                        catch (NumberFormatException e)
@@ -778,6 +804,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
                {
                        try
                        {
+                               s = s.trim();
                                return Integer.parseInt(s);
                        }
                        catch (NumberFormatException e)
@@ -794,6 +821,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
                {
                        try
                        {
+                               s = s.trim();           
                                return Long.parseLong(s);
                        }
                        catch (NumberFormatException e)
@@ -811,6 +839,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
                {
                        try
                        {
+                               s = s.trim();
                                val = new BigDecimal(s);
                        }
                        catch (NumberFormatException e)
@@ -837,6 +866,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
                {
                        try
                        {
+                               s = s.trim();
                                return Float.valueOf(s).floatValue();
                        }
                        catch (NumberFormatException e)
@@ -853,6 +883,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
                {
                        try
                        {
+                               s = s.trim();
                                return Double.valueOf(s).doubleValue();
                        }
                        catch (NumberFormatException e)
@@ -871,6 +902,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
                // length >  10: SQL Timestamp, assumes PGDATESTYLE=ISO
                try
                {
+                       s = s.trim();
                        return java.sql.Date.valueOf((s.length() == 10) ? s : s.substring(0, 10));
                }
                catch (NumberFormatException e)
@@ -885,6 +917,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
                        return null; // SQL NULL
                try
                {
+                       s = s.trim();
                        if (s.length() == 8)
                        {
                                //value is a time value
@@ -952,6 +985,7 @@ public abstract class AbstractJdbc1ResultSet implements BaseResultSet
                if (s == null)
                        return null;
 
+               s = s.trim();
                // We must be synchronized here incase more theads access the ResultSet
                // bad practice but possible. Anyhow this is to protect sbuf and
                // SimpleDateFormat objects
index c3d7af25137d4de28f124c22e06a9a1e0385955a..b76bad557822ec10135db007075f24401b986342 100644 (file)
@@ -25,7 +25,7 @@ import java.sql.Timestamp;
 import java.sql.Types;
 import java.util.Vector;
 
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.25 2003/06/30 16:38:30 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.26 2003/06/30 21:10:55 davec Exp $
  * This class defines methods of the jdbc1 specification.  This class is
  * extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
  * methods.  The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
@@ -1464,7 +1464,10 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
                switch (targetSqlType)
                {
                        case Types.INTEGER:
-                               bind(parameterIndex, x.toString(), PG_INTEGER);
+                               if (x instanceof Boolean)
+                                       bind(parameterIndex,((Boolean)x).booleanValue() ? "1" :"0", PG_BOOLEAN);
+                               else
+                                       bind(parameterIndex, x.toString(), PG_INTEGER);
                                break;
                        case Types.TINYINT:
                        case Types.SMALLINT:
@@ -1498,6 +1501,10 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
                                {
                                        bind(parameterIndex, ((Boolean)x).booleanValue() ? "TRUE" : "FALSE", PG_TEXT);
                                }
+                               else if (x instanceof Number)
+                               {
+                                       bind(parameterIndex, ((Number)x).intValue()==1 ? "TRUE" : "FALSE", PG_TEXT);
+                               }
                                else
                                {
                                        throw new PSQLException("postgresql.prep.type");
index 2e896c6f1a2a972cd978030037d8a25db44a25c2..0f5150c1f272b93b6be6a392537a10e62f8fccdd 100644 (file)
@@ -7,7 +7,7 @@ import java.sql.SQLData;
 import java.sql.SQLException;
 import java.sql.Types;
 
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Connection.java,v 1.5 2003/05/29 04:39:48 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2Connection.java,v 1.6 2003/06/30 21:10:55 davec Exp $
  * This class defines methods of the jdbc2 specification.  This class extends
  * org.postgresql.jdbc1.AbstractJdbc1Connection which provides the jdbc1
  * methods.  The real Connection class (for jdbc2) is org.postgresql.jdbc2.Jdbc2Connection
@@ -126,6 +126,7 @@ public abstract class AbstractJdbc2Connection extends org.postgresql.jdbc1.Abstr
                                "varchar", "text", "name", "filename",
                                "bytea",
                                "bool",
+                               "bit",
                                "date",
                                "time",
                                "abstime", "timestamp", "timestamptz",
@@ -154,6 +155,7 @@ public abstract class AbstractJdbc2Connection extends org.postgresql.jdbc1.Abstr
                                                                                                Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
                                                                                                Types.BINARY,
                                                                                                Types.BIT,
+                                                                                               Types.BIT,
                                                                                                Types.DATE,
                                                                                                Types.TIME,
                                                                                                Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP,
index f76eeb6cc49b7872212447dc6383b6f337a65179..fd2f62ff059717db814790dbc83034a2eac29503 100644 (file)
@@ -2,7 +2,7 @@ package org.postgresql.jdbc3;
 
 import java.sql.*;
 
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Connection.java,v 1.3 2003/05/07 03:03:30 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3Connection.java,v 1.4 2003/06/30 21:10:55 davec Exp $
  * This class defines methods of the jdbc3 specification.  This class extends
  * org.postgresql.jdbc2.AbstractJdbc2Connection which provides the jdbc2
  * methods.  The real Connection class (for jdbc3) is org.postgresql.jdbc3.Jdbc3Connection
@@ -415,6 +415,7 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
                                "varchar", "text", "name", "filename",
                                "bytea",
                                "bool",
+                               "bit",
                                "date",
                                "time",
                                "abstime", "timestamp", "timestamptz",
@@ -443,6 +444,7 @@ public abstract class AbstractJdbc3Connection extends org.postgresql.jdbc2.Abstr
                        Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
                        Types.BINARY,
                        Types.BIT,
+                       Types.BIT,
                        Types.DATE,
                        Types.TIME,
                        Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP,