pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
patch for getXXX methods
11+ messages / 2 participants
[nested] [flat]

* patch for getXXX methods
@ 2004-07-09 21:09 Dave Cramer <pg@fastcrypt.com>
  2004-07-09 22:34 ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Dave Cramer @ 2004-07-09 21:09 UTC (permalink / raw)
  To: pgsql-jdbc

this patch addresses the issue of using getXXX recommended and secondary
methods

Please review and comment.

Dave
-- 
Dave Cramer
519 939 0336
ICQ # 14675561

Attachments:

getxxx.patch (text/x-patch, 21.6K) download Index: org/postgresql/test/jdbc2/ResultSetTest.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc2/ResultSetTest.java,v retrieving revision 1.18 diff -c -r1.18 ResultSetTest.java *** org/postgresql/test/jdbc2/ResultSetTest.java 29 Jun 2004 06:43:28 -0000 1.18 --- org/postgresql/test/jdbc2/ResultSetTest.java 9 Jul 2004 21:06:30 -0000 *************** *** 61,72 **** stmt.executeUpdate("INSERT INTO testnumeric VALUES('0.0')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('-1.0')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('1.2')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('99999.2')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('99999')"); - stmt.executeUpdate("INSERT INTO testnumeric VALUES('-2.5')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('-99999.2')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('-99999')"); stmt.close(); --- 61,90 ---- stmt.executeUpdate("INSERT INTO testnumeric VALUES('0.0')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('-1.0')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('1.2')"); + stmt.executeUpdate("INSERT INTO testnumeric VALUES('-2.5')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('99999.2')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('99999')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('-99999.2')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('-99999')"); + // Integer.MaxValue + stmt.execute("INSERT INTO testnumeric VALUES('2147483647')"); + + // Integer.MinValue + stmt.execute("INSERT INTO testnumeric VALUES('-2147483648')"); + + stmt.executeUpdate("INSERT INTO testnumeric VALUES('2147483648')"); + stmt.executeUpdate("INSERT INTO testnumeric VALUES('-2147483649')"); + + // Long.MaxValue + stmt.executeUpdate("INSERT INTO testnumeric VALUES('9223372036854775807')"); + + // Long.MinValue + stmt.executeUpdate("INSERT INTO testnumeric VALUES('-9223372036854775808')"); + + stmt.executeUpdate("INSERT INTO testnumeric VALUES('9223372036854775808')"); + stmt.executeUpdate("INSERT INTO testnumeric VALUES('-9223372036854775809')"); + stmt.close(); *************** *** 225,287 **** public void testgetByte() throws SQLException { ! ResultSet rs = con.createStatement().executeQuery("select * from testnumeric"); ! boolean thrown = false; ! assertTrue(rs.next()); ! assertEquals(1,rs.getByte(1)); ! assertTrue(rs.next()); ! assertEquals(0,rs.getByte(1)); ! assertTrue(rs.next()); ! assertEquals(-1,rs.getByte(1)); ! while (rs.next()) ! { ! thrown = false; ! try ! { ! rs.getByte(1); ! } ! catch (Exception e) ! { ! thrown = true; ! } ! if (!thrown) ! fail("Exception expected."); ! } ! } ! public void testgetShort() throws SQLException ! { ! ResultSet rs = con.createStatement().executeQuery("select * from testnumeric"); ! boolean thrown = false; ! assertTrue(rs.next()); ! assertEquals(1,rs.getShort(1)); ! assertTrue(rs.next()); ! assertEquals(0,rs.getShort(1)); ! assertTrue(rs.next()); ! assertEquals(-1,rs.getShort(1)); ! while (rs.next()) ! { ! thrown = false; ! try ! { ! rs.getShort(1); ! } ! catch (Exception e) ! { ! thrown = true; ! } ! if (!thrown) ! fail("Exception expected."); ! } ! } public void testParameters() throws SQLException { --- 243,445 ---- public void testgetByte() throws SQLException { ! ResultSet rs = con.createStatement().executeQuery( ! "select * from testnumeric"); ! boolean thrown = false; ! ! assertTrue(rs.next()); ! assertEquals(1, rs.getByte(1)); ! ! assertTrue(rs.next()); ! assertEquals(0, rs.getByte(1)); ! ! assertTrue(rs.next()); ! assertEquals( -1, rs.getByte(1)); ! ! assertTrue(rs.next()); ! assertEquals(1, rs.getByte(1)); ! ! assertTrue(rs.next()); ! assertEquals(-2, rs.getByte(1)); ! ! while (rs.next()) ! { ! thrown = false; ! try ! { ! rs.getByte(1); ! } ! catch (Exception e) ! { ! thrown = true; ! } ! if (!thrown) ! fail("Exception expected."); ! } ! rs.close(); ! } ! public void testgetShort() throws SQLException ! { ! ResultSet rs = con.createStatement().executeQuery( ! "select * from testnumeric"); ! boolean thrown = false; ! ! assertTrue(rs.next()); ! assertEquals(1, rs.getShort(1)); ! ! assertTrue(rs.next()); ! assertEquals(0, rs.getShort(1)); ! ! assertTrue(rs.next()); ! assertEquals( -1, rs.getShort(1)); ! ! assertTrue(rs.next()); ! assertEquals(1, rs.getShort(1)); ! ! assertTrue(rs.next()); ! assertEquals(-2, rs.getShort(1)); ! ! while (rs.next()) ! { ! thrown = false; ! try ! { ! rs.getShort(1); ! } ! catch (Exception e) ! { ! thrown = true; ! } ! if (!thrown) ! fail("Exception expected."); ! } ! rs.close(); ! } ! public void testgetInt() throws SQLException ! { ! ResultSet rs = con.createStatement().executeQuery( ! "select * from testnumeric"); ! boolean thrown = false; ! assertTrue(rs.next()); ! assertEquals(1, rs.getInt(1)); ! assertTrue(rs.next()); ! assertEquals(0, rs.getInt(1)); ! assertTrue(rs.next()); ! assertEquals( -1, rs.getInt(1)); ! assertTrue(rs.next()); ! assertEquals(1, rs.getInt(1)); ! assertTrue(rs.next()); ! assertEquals( -2, rs.getInt(1)); ! assertTrue(rs.next()); ! assertEquals(99999, rs.getInt(1)); ! assertTrue(rs.next()); ! assertEquals(99999, rs.getInt(1)); ! ! assertTrue(rs.next()); ! assertEquals(-99999, rs.getInt(1)); ! ! assertTrue(rs.next()); ! assertEquals(-99999, rs.getInt(1)); ! ! assertTrue(rs.next()); ! assertEquals(Integer.MAX_VALUE, rs.getInt(1)); ! ! assertTrue(rs.next()); ! assertEquals(Integer.MIN_VALUE, rs.getInt(1)); ! ! while (rs.next()) ! { ! thrown = false; ! try ! { ! rs.getInt(1); ! } ! catch (Exception e) ! { ! thrown = true; ! } ! if (!thrown) ! fail("Exception expected." + rs.getString(1)); ! } ! rs.close(); ! } ! ! public void testgetLong() throws SQLException ! { ! ResultSet rs = con.createStatement().executeQuery( ! "select * from testnumeric"); ! boolean thrown = false; ! ! assertTrue(rs.next()); ! assertEquals(1, rs.getLong(1)); ! ! assertTrue(rs.next()); ! assertEquals(0, rs.getLong(1)); ! ! assertTrue(rs.next()); ! assertEquals( -1, rs.getLong(1)); ! ! assertTrue(rs.next()); ! assertEquals(1, rs.getLong(1)); ! ! assertTrue(rs.next()); ! assertEquals( -2, rs.getLong(1)); ! ! assertTrue(rs.next()); ! assertEquals(99999, rs.getLong(1)); ! ! assertTrue(rs.next()); ! assertEquals(99999, rs.getLong(1)); ! ! assertTrue(rs.next()); ! assertEquals(-99999, rs.getLong(1)); ! ! assertTrue(rs.next()); ! assertEquals(-99999, rs.getLong(1)); ! ! assertTrue(rs.next()); ! assertEquals( ((long)Integer.MAX_VALUE), rs.getLong(1)); ! ! assertTrue(rs.next()); ! assertEquals( ((long)Integer.MIN_VALUE), rs.getLong(1)); ! ! assertTrue(rs.next()); ! assertEquals( ((long)Integer.MAX_VALUE)+1, rs.getLong(1)); ! ! assertTrue(rs.next()); ! assertEquals( ((long)Integer.MIN_VALUE)-1, rs.getLong(1)); ! ! assertTrue(rs.next()); ! assertEquals( Long.MAX_VALUE, rs.getLong(1)); ! ! assertTrue(rs.next()); ! assertEquals( Long.MIN_VALUE, rs.getLong(1)); ! ! while (rs.next()) ! { ! thrown = false; ! try ! { ! rs.getLong(1); ! } ! catch (Exception e) ! { ! thrown = true; ! } ! if (!thrown) ! fail("Exception expected." + rs.getString(1) ); ! } ! rs.close(); ! } public void testParameters() throws SQLException { Index: org/postgresql/jdbc1/AbstractJdbc1ResultSet.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java,v retrieving revision 1.35 diff -c -r1.35 AbstractJdbc1ResultSet.java *** org/postgresql/jdbc1/AbstractJdbc1ResultSet.java 29 Jun 2004 06:43:26 -0000 1.35 --- org/postgresql/jdbc1/AbstractJdbc1ResultSet.java 9 Jul 2004 21:06:30 -0000 *************** *** 28,33 **** --- 28,34 ---- import org.postgresql.util.PGtokenizer; import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLState; + import java.math.BigInteger; public abstract class AbstractJdbc1ResultSet implements BaseResultSet, org.postgresql.PGRefCursorResultSet { *************** *** 61,92 **** public class CursorResultHandler implements ResultHandler { private SQLException error; ! public void handleResultRows(Query fromQuery, Field[] fields, Vector tuples, ResultCursor cursor) { AbstractJdbc1ResultSet.this.rows = tuples; AbstractJdbc1ResultSet.this.cursor = cursor; } ! public void handleCommandStatus(String status, int updateCount, long insertOID) { handleError(new SQLException("unexpected command status")); } ! public void handleWarning(SQLWarning warning) { AbstractJdbc1ResultSet.this.addWarning(warning); } ! public void handleError(SQLException newError) { if (error == null) error = newError; else error.setNextException(newError); } ! public void handleCompletion() throws SQLException { if (error != null) throw error; } ! }; public AbstractJdbc1ResultSet(Query originalQuery, BaseStatement statement, --- 62,93 ---- public class CursorResultHandler implements ResultHandler { private SQLException error; ! public void handleResultRows(Query fromQuery, Field[] fields, Vector tuples, ResultCursor cursor) { AbstractJdbc1ResultSet.this.rows = tuples; AbstractJdbc1ResultSet.this.cursor = cursor; } ! public void handleCommandStatus(String status, int updateCount, long insertOID) { handleError(new SQLException("unexpected command status")); } ! public void handleWarning(SQLWarning warning) { AbstractJdbc1ResultSet.this.addWarning(warning); } ! public void handleError(SQLException newError) { if (error == null) error = newError; else error.setNextException(newError); } ! public void handleCompletion() throws SQLException { if (error != null) throw error; } ! }; public AbstractJdbc1ResultSet(Query originalQuery, BaseStatement statement, *************** *** 146,152 **** { if (rows == null) throw new PSQLException("postgresql.con.closed", PSQLState.CONNECTION_DOES_NOT_EXIST); ! if (onInsertRow) throw new PSQLException("postgresql.res.oninsertrow"); --- 147,153 ---- { if (rows == null) throw new PSQLException("postgresql.con.closed", PSQLState.CONNECTION_DOES_NOT_EXIST); ! if (onInsertRow) throw new PSQLException("postgresql.res.oninsertrow"); *************** *** 231,261 **** if (s != null ) { try { ! switch(getSQLType(columnIndex)) ! { ! case Types.NUMERIC: ! case Types.REAL: ! case Types.DOUBLE: ! case Types.FLOAT: ! case Types.DECIMAL: ! int loc = s.indexOf("."); ! if (loc!=-1 && Integer.parseInt(s.substring(loc+1,s.length()))==0) ! { ! s = s.substring(0,loc); ! } ! break; ! case Types.CHAR: ! s = s.trim(); ! break; ! } ! if ( s.length() == 0 ) return 0; ! return Byte.parseByte(s); } catch (NumberFormatException e) { ! throw new PSQLException("postgresql.res.badbyte", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL --- 232,268 ---- if (s != null ) { + s= s.trim(); + if ( s.length() == 0 ) return 0; try { ! // try the optimal parse ! return Byte.parseByte(s); } catch (NumberFormatException e) { ! // didn't work, assume the column is not a byte ! try ! { ! double d = Double.parseDouble(s); ! // check the size ! if (d > Byte.MAX_VALUE || d < Byte.MIN_VALUE) ! { ! throw new PSQLException("postgresql.res.badbyte", ! PSQLState. ! NUMERIC_VALUE_OUT_OF_RANGE, s); ! } ! else ! { ! return (byte)d; ! } ! } ! catch( NumberFormatException ex ) ! { ! throw new PSQLException("postgresql.res.badbyte", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, ! s); ! } } } return 0; // SQL NULL *************** *** 267,296 **** if (s != null) { try { - switch(getSQLType(columnIndex)) - { - case Types.NUMERIC: - case Types.REAL: - case Types.DOUBLE: - case Types.FLOAT: - case Types.DECIMAL: - int loc = s.indexOf("."); - if (loc!=-1 && Integer.parseInt(s.substring(loc+1,s.length()))==0) - { - s = s.substring(0,loc); - } - break; - case Types.CHAR: - s = s.trim(); - break; - } return Short.parseShort(s); } catch (NumberFormatException e) { ! throw new PSQLException("postgresql.res.badshort", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL --- 274,308 ---- if (s != null) { + s = s.trim(); try { return Short.parseShort(s); } catch (NumberFormatException e) { ! try ! { ! double d = Double.parseDouble(s); ! // check the size ! if (d > Short.MAX_VALUE || d < Short.MIN_VALUE) ! { ! throw new PSQLException("postgresql.res.badshort", ! PSQLState. ! NUMERIC_VALUE_OUT_OF_RANGE, s); ! } ! else ! { ! return (short)d; ! } ! ! } ! catch ( NumberFormatException ne ) ! { ! throw new PSQLException("postgresql.res.badshort", ! PSQLState. ! NUMERIC_VALUE_OUT_OF_RANGE, s); ! } } } return 0; // SQL NULL *************** *** 634,647 **** wasNullFlag = true; return null; } ! Object result = internalGetObject(columnIndex, field); if (result != null) return result; return connection.getObject(getPGType(columnIndex), getString(columnIndex)); } ! protected Object internalGetObject(int columnIndex, Field field) throws SQLException { switch (getSQLType(columnIndex)) { --- 646,659 ---- wasNullFlag = true; return null; } ! Object result = internalGetObject(columnIndex, field); if (result != null) return result; return connection.getObject(getPGType(columnIndex), getString(columnIndex)); } ! protected Object internalGetObject(int columnIndex, Field field) throws SQLException { switch (getSQLType(columnIndex)) { *************** *** 811,821 **** } catch (NumberFormatException e) { ! throw new PSQLException ("postgresql.res.badint", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL } public static long toLong(String s) throws SQLException { --- 823,854 ---- } catch (NumberFormatException e) { ! try ! { ! double d = Double.parseDouble(s); ! if( d > Integer.MAX_VALUE || d < Integer.MIN_VALUE ) ! { ! throw new PSQLException("postgresql.res.badint", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, ! s); ! } ! else ! { ! return (int)d; ! } ! } ! catch( NumberFormatException ne ) ! { ! throw new PSQLException("postgresql.res.badint", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, ! s); ! } } } return 0; // SQL NULL } + private static BigInteger LONGMAX = new BigInteger(Long.toString(Long.MAX_VALUE)); + private static BigInteger LONGMIN = new BigInteger(Long.toString(Long.MIN_VALUE)); public static long toLong(String s) throws SQLException { *************** *** 828,834 **** } catch (NumberFormatException e) { ! throw new PSQLException ("postgresql.res.badlong", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL --- 861,888 ---- } catch (NumberFormatException e) { ! try ! { ! BigDecimal n = new BigDecimal(s); ! BigInteger i = n.toBigInteger(); ! int gt = i.compareTo(LONGMAX); ! int lt = i.compareTo(LONGMIN); ! ! if ( gt > 0 || lt < 0 ) ! { ! throw new PSQLException("postgresql.res.badint", ! PSQLState. ! NUMERIC_VALUE_OUT_OF_RANGE, ! s); ! } ! return i.longValue(); ! } ! catch( NumberFormatException ne ) ! { ! throw new PSQLException("postgresql.res.badint", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, ! s); ! } } } return 0; // SQL NULL *************** *** 846,852 **** } catch (NumberFormatException e) { ! throw new PSQLException ("postgresql.res.badbigdec", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } if (scale == -1) return val; --- 900,907 ---- } catch (NumberFormatException e) { ! throw new PSQLException("postgresql.res.badbigdec", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } if (scale == -1) return val; *************** *** 856,862 **** } catch (ArithmeticException e) { ! throw new PSQLException ("postgresql.res.badbigdec", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return null; // SQL NULL --- 911,918 ---- } catch (ArithmeticException e) { ! throw new PSQLException("postgresql.res.badbigdec", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return null; // SQL NULL *************** *** 873,879 **** } catch (NumberFormatException e) { ! throw new PSQLException ("postgresql.res.badfloat", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL --- 929,936 ---- } catch (NumberFormatException e) { ! throw new PSQLException("postgresql.res.badfloat", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL *************** *** 890,896 **** } catch (NumberFormatException e) { ! throw new PSQLException ("postgresql.res.baddouble", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL --- 947,954 ---- } catch (NumberFormatException e) { ! throw new PSQLException("postgresql.res.baddouble", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL
^ permalink raw reply [nested|flat] 11+ messages in thread

* Re: patch for getXXX methods
  2004-07-09 21:09 patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
@ 2004-07-09 22:34 ` Oliver Jowett <oliver@opencloud.com>
  2004-07-09 23:47   ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Oliver Jowett @ 2004-07-09 22:34 UTC (permalink / raw)
  To: pg@fastcrypt.com; +Cc: pgsql-jdbc

Dave Cramer wrote:
> this patch addresses the issue of using getXXX recommended and secondary
> methods
> 
> Please review and comment.

There are lots of whitespace-only changes which makes it harder to see 
the real changes.

-O



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: patch for getXXX methods
  2004-07-09 21:09 patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-09 22:34 ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
@ 2004-07-09 23:47   ` Dave Cramer <pg@fastcrypt.com>
  2004-07-11 15:04     ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Dave Cramer @ 2004-07-09 23:47 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc

Attached, with -cb this time
On Fri, 2004-07-09 at 18:34, Oliver Jowett wrote:
> Dave Cramer wrote:
> > this patch addresses the issue of using getXXX recommended and secondary
> > methods
> > 
> > Please review and comment.
> 
> There are lots of whitespace-only changes which makes it harder to see 
> the real changes.
> 
> -O
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
> 
> 
> 
> !DSPAM:40ef1f6e143178639810363!
> 
> 
-- 
Dave Cramer
519 939 0336
ICQ # 14675561

Attachments:

getxxx.patch (text/x-patch, 17.7K) download Index: org/postgresql/test/jdbc2/ResultSetTest.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc2/ResultSetTest.java,v retrieving revision 1.18 diff -c -b -r1.18 ResultSetTest.java *** org/postgresql/test/jdbc2/ResultSetTest.java 29 Jun 2004 06:43:28 -0000 1.18 --- org/postgresql/test/jdbc2/ResultSetTest.java 9 Jul 2004 23:44:48 -0000 *************** *** 61,72 **** stmt.executeUpdate("INSERT INTO testnumeric VALUES('0.0')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('-1.0')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('1.2')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('99999.2')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('99999')"); - stmt.executeUpdate("INSERT INTO testnumeric VALUES('-2.5')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('-99999.2')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('-99999')"); stmt.close(); --- 61,90 ---- stmt.executeUpdate("INSERT INTO testnumeric VALUES('0.0')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('-1.0')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('1.2')"); + stmt.executeUpdate("INSERT INTO testnumeric VALUES('-2.5')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('99999.2')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('99999')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('-99999.2')"); stmt.executeUpdate("INSERT INTO testnumeric VALUES('-99999')"); + // Integer.MaxValue + stmt.execute("INSERT INTO testnumeric VALUES('2147483647')"); + + // Integer.MinValue + stmt.execute("INSERT INTO testnumeric VALUES('-2147483648')"); + + stmt.executeUpdate("INSERT INTO testnumeric VALUES('2147483648')"); + stmt.executeUpdate("INSERT INTO testnumeric VALUES('-2147483649')"); + + // Long.MaxValue + stmt.executeUpdate("INSERT INTO testnumeric VALUES('9223372036854775807')"); + + // Long.MinValue + stmt.executeUpdate("INSERT INTO testnumeric VALUES('-9223372036854775808')"); + + stmt.executeUpdate("INSERT INTO testnumeric VALUES('9223372036854775808')"); + stmt.executeUpdate("INSERT INTO testnumeric VALUES('-9223372036854775809')"); + stmt.close(); *************** *** 225,241 **** public void testgetByte() throws SQLException { ! ResultSet rs = con.createStatement().executeQuery("select * from testnumeric"); boolean thrown = false; assertTrue(rs.next()); ! assertEquals(1,rs.getByte(1)); assertTrue(rs.next()); ! assertEquals(0,rs.getByte(1)); assertTrue(rs.next()); ! assertEquals(-1,rs.getByte(1)); while (rs.next()) { --- 243,266 ---- public void testgetByte() throws SQLException { ! ResultSet rs = con.createStatement().executeQuery( ! "select * from testnumeric"); boolean thrown = false; assertTrue(rs.next()); ! assertEquals(1, rs.getByte(1)); ! ! assertTrue(rs.next()); ! assertEquals(0, rs.getByte(1)); assertTrue(rs.next()); ! assertEquals( -1, rs.getByte(1)); assertTrue(rs.next()); ! assertEquals(1, rs.getByte(1)); ! ! assertTrue(rs.next()); ! assertEquals(-2, rs.getByte(1)); while (rs.next()) { *************** *** 251,271 **** if (!thrown) fail("Exception expected."); } } public void testgetShort() throws SQLException { ! ResultSet rs = con.createStatement().executeQuery("select * from testnumeric"); boolean thrown = false; assertTrue(rs.next()); ! assertEquals(1,rs.getShort(1)); assertTrue(rs.next()); ! assertEquals(0,rs.getShort(1)); assertTrue(rs.next()); ! assertEquals(-1,rs.getShort(1)); while (rs.next()) { --- 276,304 ---- if (!thrown) fail("Exception expected."); } + rs.close(); } public void testgetShort() throws SQLException { ! ResultSet rs = con.createStatement().executeQuery( ! "select * from testnumeric"); boolean thrown = false; assertTrue(rs.next()); ! assertEquals(1, rs.getShort(1)); assertTrue(rs.next()); ! assertEquals(0, rs.getShort(1)); assertTrue(rs.next()); ! assertEquals( -1, rs.getShort(1)); ! ! assertTrue(rs.next()); ! assertEquals(1, rs.getShort(1)); ! ! assertTrue(rs.next()); ! assertEquals(-2, rs.getShort(1)); while (rs.next()) { *************** *** 281,286 **** --- 314,444 ---- if (!thrown) fail("Exception expected."); } + rs.close(); + } + + public void testgetInt() throws SQLException + { + ResultSet rs = con.createStatement().executeQuery( + "select * from testnumeric"); + boolean thrown = false; + + assertTrue(rs.next()); + assertEquals(1, rs.getInt(1)); + + assertTrue(rs.next()); + assertEquals(0, rs.getInt(1)); + + assertTrue(rs.next()); + assertEquals( -1, rs.getInt(1)); + + assertTrue(rs.next()); + assertEquals(1, rs.getInt(1)); + + assertTrue(rs.next()); + assertEquals( -2, rs.getInt(1)); + + assertTrue(rs.next()); + assertEquals(99999, rs.getInt(1)); + + assertTrue(rs.next()); + assertEquals(99999, rs.getInt(1)); + + assertTrue(rs.next()); + assertEquals(-99999, rs.getInt(1)); + + assertTrue(rs.next()); + assertEquals(-99999, rs.getInt(1)); + + assertTrue(rs.next()); + assertEquals(Integer.MAX_VALUE, rs.getInt(1)); + + assertTrue(rs.next()); + assertEquals(Integer.MIN_VALUE, rs.getInt(1)); + + while (rs.next()) + { + thrown = false; + try + { + rs.getInt(1); + } + catch (Exception e) + { + thrown = true; + } + if (!thrown) + fail("Exception expected." + rs.getString(1)); + } + rs.close(); + } + + public void testgetLong() throws SQLException + { + ResultSet rs = con.createStatement().executeQuery( + "select * from testnumeric"); + boolean thrown = false; + + assertTrue(rs.next()); + assertEquals(1, rs.getLong(1)); + + assertTrue(rs.next()); + assertEquals(0, rs.getLong(1)); + + assertTrue(rs.next()); + assertEquals( -1, rs.getLong(1)); + + assertTrue(rs.next()); + assertEquals(1, rs.getLong(1)); + + assertTrue(rs.next()); + assertEquals( -2, rs.getLong(1)); + + assertTrue(rs.next()); + assertEquals(99999, rs.getLong(1)); + + assertTrue(rs.next()); + assertEquals(99999, rs.getLong(1)); + + assertTrue(rs.next()); + assertEquals(-99999, rs.getLong(1)); + + assertTrue(rs.next()); + assertEquals(-99999, rs.getLong(1)); + + assertTrue(rs.next()); + assertEquals( ((long)Integer.MAX_VALUE), rs.getLong(1)); + + assertTrue(rs.next()); + assertEquals( ((long)Integer.MIN_VALUE), rs.getLong(1)); + + assertTrue(rs.next()); + assertEquals( ((long)Integer.MAX_VALUE)+1, rs.getLong(1)); + + assertTrue(rs.next()); + assertEquals( ((long)Integer.MIN_VALUE)-1, rs.getLong(1)); + + assertTrue(rs.next()); + assertEquals( Long.MAX_VALUE, rs.getLong(1)); + + assertTrue(rs.next()); + assertEquals( Long.MIN_VALUE, rs.getLong(1)); + + while (rs.next()) + { + thrown = false; + try + { + rs.getLong(1); + } + catch (Exception e) + { + thrown = true; + } + if (!thrown) + fail("Exception expected." + rs.getString(1) ); + } + rs.close(); } public void testParameters() throws SQLException Index: org/postgresql/jdbc1/AbstractJdbc1ResultSet.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java,v retrieving revision 1.35 diff -c -b -r1.35 AbstractJdbc1ResultSet.java *** org/postgresql/jdbc1/AbstractJdbc1ResultSet.java 29 Jun 2004 06:43:26 -0000 1.35 --- org/postgresql/jdbc1/AbstractJdbc1ResultSet.java 9 Jul 2004 23:44:49 -0000 *************** *** 28,33 **** --- 28,34 ---- import org.postgresql.util.PGtokenizer; import org.postgresql.util.PSQLException; import org.postgresql.util.PSQLState; + import java.math.BigInteger; public abstract class AbstractJdbc1ResultSet implements BaseResultSet, org.postgresql.PGRefCursorResultSet { *************** *** 231,261 **** if (s != null ) { try { ! switch(getSQLType(columnIndex)) { ! case Types.NUMERIC: ! case Types.REAL: ! case Types.DOUBLE: ! case Types.FLOAT: ! case Types.DECIMAL: ! int loc = s.indexOf("."); ! if (loc!=-1 && Integer.parseInt(s.substring(loc+1,s.length()))==0) { ! s = s.substring(0,loc); } ! break; ! case Types.CHAR: ! s = s.trim(); ! break; } - if ( s.length() == 0 ) return 0; - return Byte.parseByte(s); } ! catch (NumberFormatException e) { ! throw new PSQLException("postgresql.res.badbyte", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL --- 232,268 ---- if (s != null ) { + s= s.trim(); + if ( s.length() == 0 ) return 0; try { ! // try the optimal parse ! return Byte.parseByte(s); ! } ! catch (NumberFormatException e) { ! // didn't work, assume the column is not a byte ! try ! { ! double d = Double.parseDouble(s); ! // check the size ! if (d > Byte.MAX_VALUE || d < Byte.MIN_VALUE) { ! throw new PSQLException("postgresql.res.badbyte", ! PSQLState. ! NUMERIC_VALUE_OUT_OF_RANGE, s); } ! else ! { ! return (byte)d; } } ! catch( NumberFormatException ex ) { ! throw new PSQLException("postgresql.res.badbyte", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, ! s); ! } } } return 0; // SQL NULL *************** *** 267,296 **** if (s != null) { try { ! switch(getSQLType(columnIndex)) { ! case Types.NUMERIC: ! case Types.REAL: ! case Types.DOUBLE: ! case Types.FLOAT: ! case Types.DECIMAL: ! int loc = s.indexOf("."); ! if (loc!=-1 && Integer.parseInt(s.substring(loc+1,s.length()))==0) { ! s = s.substring(0,loc); } ! break; ! case Types.CHAR: ! s = s.trim(); ! break; } ! return Short.parseShort(s); } ! catch (NumberFormatException e) { ! throw new PSQLException("postgresql.res.badshort", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL --- 274,308 ---- if (s != null) { + s = s.trim(); try { ! return Short.parseShort(s); ! } ! catch (NumberFormatException e) { ! try { ! double d = Double.parseDouble(s); ! // check the size ! if (d > Short.MAX_VALUE || d < Short.MIN_VALUE) ! { ! throw new PSQLException("postgresql.res.badshort", ! PSQLState. ! NUMERIC_VALUE_OUT_OF_RANGE, s); } ! else ! { ! return (short)d; } ! } ! catch ( NumberFormatException ne ) { ! throw new PSQLException("postgresql.res.badshort", ! PSQLState. ! NUMERIC_VALUE_OUT_OF_RANGE, s); ! } } } return 0; // SQL NULL *************** *** 811,821 **** } catch (NumberFormatException e) { ! throw new PSQLException ("postgresql.res.badint", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL } public static long toLong(String s) throws SQLException { --- 823,854 ---- } catch (NumberFormatException e) { ! try ! { ! double d = Double.parseDouble(s); ! if( d > Integer.MAX_VALUE || d < Integer.MIN_VALUE ) ! { ! throw new PSQLException("postgresql.res.badint", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, ! s); ! } ! else ! { ! return (int)d; ! } ! } ! catch( NumberFormatException ne ) ! { ! throw new PSQLException("postgresql.res.badint", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, ! s); ! } } } return 0; // SQL NULL } + private static BigInteger LONGMAX = new BigInteger(Long.toString(Long.MAX_VALUE)); + private static BigInteger LONGMIN = new BigInteger(Long.toString(Long.MIN_VALUE)); public static long toLong(String s) throws SQLException { *************** *** 828,834 **** } catch (NumberFormatException e) { ! throw new PSQLException ("postgresql.res.badlong", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL --- 861,888 ---- } catch (NumberFormatException e) { ! try ! { ! BigDecimal n = new BigDecimal(s); ! BigInteger i = n.toBigInteger(); ! int gt = i.compareTo(LONGMAX); ! int lt = i.compareTo(LONGMIN); ! ! if ( gt > 0 || lt < 0 ) ! { ! throw new PSQLException("postgresql.res.badint", ! PSQLState. ! NUMERIC_VALUE_OUT_OF_RANGE, ! s); ! } ! return i.longValue(); ! } ! catch( NumberFormatException ne ) ! { ! throw new PSQLException("postgresql.res.badint", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, ! s); ! } } } return 0; // SQL NULL *************** *** 846,852 **** } catch (NumberFormatException e) { ! throw new PSQLException ("postgresql.res.badbigdec", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } if (scale == -1) return val; --- 900,907 ---- } catch (NumberFormatException e) { ! throw new PSQLException("postgresql.res.badbigdec", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } if (scale == -1) return val; *************** *** 856,862 **** } catch (ArithmeticException e) { ! throw new PSQLException ("postgresql.res.badbigdec", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return null; // SQL NULL --- 911,918 ---- } catch (ArithmeticException e) { ! throw new PSQLException("postgresql.res.badbigdec", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return null; // SQL NULL *************** *** 873,879 **** } catch (NumberFormatException e) { ! throw new PSQLException ("postgresql.res.badfloat", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL --- 929,936 ---- } catch (NumberFormatException e) { ! throw new PSQLException("postgresql.res.badfloat", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL *************** *** 890,896 **** } catch (NumberFormatException e) { ! throw new PSQLException ("postgresql.res.baddouble", PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL --- 947,954 ---- } catch (NumberFormatException e) { ! throw new PSQLException("postgresql.res.baddouble", ! PSQLState.NUMERIC_VALUE_OUT_OF_RANGE, s); } } return 0; // SQL NULL
^ permalink raw reply [nested|flat] 11+ messages in thread

* Re: patch for getXXX methods
  2004-07-09 21:09 patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-09 22:34 ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-09 23:47   ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
@ 2004-07-11 15:04     ` Oliver Jowett <oliver@opencloud.com>
  2004-07-11 20:24       ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Oliver Jowett @ 2004-07-11 15:04 UTC (permalink / raw)
  To: pg@fastcrypt.com; +Cc: pgsql-jdbc

Dave Cramer wrote:
> Attached, with -cb this time

Thanks. Comments:

How you handle bytes and shorts is inconsistent with how you handle 
longs; we should consistently do it one way or the other. Since you lose 
precision going via a double, that probably means the BigInteger approach.

The shared conversion/rangecheck logic should be done once in a helper 
function rather than duplicated -- call the helper with appropriate 
range info and cast the result.

I still don't like silently discarding any fractional portion of the value.

-O



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: patch for getXXX methods
  2004-07-09 21:09 patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-09 22:34 ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-09 23:47   ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-11 15:04     ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
@ 2004-07-11 20:24       ` Dave Cramer <pg@fastcrypt.com>
  2004-07-11 23:37         ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Dave Cramer @ 2004-07-11 20:24 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc

Oliver,

I don't believe you will lose precision if the number is below MAX_LONG
? When I tested it on my system, I was able to retrieve a double that
was equal to MAX_LONG without losing precision.

I understand your concern about silently discarding the fractional
portion, but I also believe if the user is using this, then they know
what they are doing. Time will tell.

Dave


On Sun, 2004-07-11 at 11:04, Oliver Jowett wrote:
> Dave Cramer wrote:
> > Attached, with -cb this time
> 
> Thanks. Comments:
> 
> How you handle bytes and shorts is inconsistent with how you handle 
> longs; we should consistently do it one way or the other. Since you lose 
> precision going via a double, that probably means the BigInteger approach.
> 
> The shared conversion/rangecheck logic should be done once in a helper 
> function rather than duplicated -- call the helper with appropriate 
> range info and cast the result.
> 
> I still don't like silently discarding any fractional portion of the value.
> 
> -O
> 
> 
> 
> !DSPAM:40f15727282821451612596!
> 
> 
-- 
Dave Cramer
519 939 0336
ICQ # 14675561




^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: patch for getXXX methods
  2004-07-09 21:09 patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-09 22:34 ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-09 23:47   ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-11 15:04     ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-11 20:24       ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
@ 2004-07-11 23:37         ` Oliver Jowett <oliver@opencloud.com>
  2004-07-12 11:58           ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Oliver Jowett @ 2004-07-11 23:37 UTC (permalink / raw)
  To: pg@fastcrypt.com; +Cc: pgsql-jdbc

Dave Cramer wrote:
> Oliver,
> 
> I don't believe you will lose precision if the number is below MAX_LONG
> ? When I tested it on my system, I was able to retrieve a double that
> was equal to MAX_LONG without losing precision.

The attached testcase says otherwise. It produces this output:

> Mismatch: 9223372036854775806 => 9.223372036854776E18 => 9223372036854775807
> Mismatch: 9223372036854775805 => 9.223372036854776E18 => 9223372036854775807
> Mismatch: 9223372036854775804 => 9.223372036854776E18 => 9223372036854775807
> Mismatch: 9223372036854775803 => 9.223372036854776E18 => 9223372036854775807
> Mismatch: 9223372036854775802 => 9.223372036854776E18 => 9223372036854775807
> Mismatch: 9223372036854775801 => 9.223372036854776E18 => 9223372036854775807
> Mismatch: 9223372036854775800 => 9.223372036854776E18 => 9223372036854775807
> Mismatch: 9223372036854775799 => 9.223372036854776E18 => 9223372036854775807
[...]
> Mismatch: 9223372036854775296 => 9.223372036854776E18 => 9223372036854775807
> Mismatch: 9223372036854775295 => 9.2233720368547748E18 => 9223372036854774784
> Mismatch: 9223372036854775294 => 9.2233720368547748E18 => 9223372036854774784

and so on.

The problem is that near MAX_LONG you need almost 64 bits of mantissa to 
exactly represent the value -- but a double is only a 64-bit value 
including space for the exponent. I can't remember the exact split but 
from the above it looks like there is around 10 bits of exponent so you 
only have ~54 bits for the mantissa -- so you only get a precision of 
about +/- 512 when you're dealing with numbers of a magnitude around 
MAX_LONG.

-O

Attachments:

TestDoublePrecision.java (text/x-java, 295B) download public class TestDoublePrecision { public static void main(String[] args) { for (long l = Long.MAX_VALUE; l != Long.MIN_VALUE; --l) { double d = (double)l; long check = (long)d; if (check != l) System.out.println("Mismatch: " + l + " => " + d + " => " + check); } } }
^ permalink raw reply [nested|flat] 11+ messages in thread

* Re: patch for getXXX methods
  2004-07-09 21:09 patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-09 22:34 ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-09 23:47   ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-11 15:04     ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-11 20:24       ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-11 23:37         ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
@ 2004-07-12 11:58           ` Dave Cramer <pg@fastcrypt.com>
  2004-07-12 14:36             ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Dave Cramer @ 2004-07-12 11:58 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc

Oliver,

Yes, and this is why I needed to do it for getLong, but I don't think
it's necessary for getInt, getByte, as it is really just to test to see
if it is greater than the max allowed value.

Dave
On Sun, 2004-07-11 at 19:37, Oliver Jowett wrote:
> Dave Cramer wrote:
> > Oliver,
> > 
> > I don't believe you will lose precision if the number is below MAX_LONG
> > ? When I tested it on my system, I was able to retrieve a double that
> > was equal to MAX_LONG without losing precision.
> 
> The attached testcase says otherwise. It produces this output:
> 
> > Mismatch: 9223372036854775806 => 9.223372036854776E18 => 9223372036854775807
> > Mismatch: 9223372036854775805 => 9.223372036854776E18 => 9223372036854775807
> > Mismatch: 9223372036854775804 => 9.223372036854776E18 => 9223372036854775807
> > Mismatch: 9223372036854775803 => 9.223372036854776E18 => 9223372036854775807
> > Mismatch: 9223372036854775802 => 9.223372036854776E18 => 9223372036854775807
> > Mismatch: 9223372036854775801 => 9.223372036854776E18 => 9223372036854775807
> > Mismatch: 9223372036854775800 => 9.223372036854776E18 => 9223372036854775807
> > Mismatch: 9223372036854775799 => 9.223372036854776E18 => 9223372036854775807
> [...]
> > Mismatch: 9223372036854775296 => 9.223372036854776E18 => 9223372036854775807
> > Mismatch: 9223372036854775295 => 9.2233720368547748E18 => 9223372036854774784
> > Mismatch: 9223372036854775294 => 9.2233720368547748E18 => 9223372036854774784
> 
> and so on.
> 
> The problem is that near MAX_LONG you need almost 64 bits of mantissa to 
> exactly represent the value -- but a double is only a 64-bit value 
> including space for the exponent. I can't remember the exact split but 
> from the above it looks like there is around 10 bits of exponent so you 
> only have ~54 bits for the mantissa -- so you only get a precision of 
> about +/- 512 when you're dealing with numbers of a magnitude around 
> MAX_LONG.
> 
> -O
> 
> 
> !DSPAM:40f1cf8080747915514021!
> 
> ______________________________________________________________________
> public class TestDoublePrecision {
>     public static void main(String[] args) {
> 	for (long l = Long.MAX_VALUE; l != Long.MIN_VALUE; --l) {
> 	    double d = (double)l;
> 	    long check = (long)d;
> 
> 	    if (check != l)
> 		System.out.println("Mismatch: " + l + " => " + d + " => " + check);
> 	}
>     }
> }
> 
> 
> !DSPAM:40f1cf8080747915514021!
-- 
Dave Cramer
519 939 0336
ICQ # 14675561




^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: patch for getXXX methods
  2004-07-09 21:09 patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-09 22:34 ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-09 23:47   ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-11 15:04     ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-11 20:24       ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-11 23:37         ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-12 11:58           ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
@ 2004-07-12 14:36             ` Oliver Jowett <oliver@opencloud.com>
  2004-07-12 14:50               ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Oliver Jowett @ 2004-07-12 14:36 UTC (permalink / raw)
  To: pg@fastcrypt.com; +Cc: pgsql-jdbc

Dave Cramer wrote:
> Oliver,
> 
> Yes, and this is why I needed to do it for getLong, but I don't think
> it's necessary for getInt, getByte, as it is really just to test to see
> if it is greater than the max allowed value.

Sure, but my original comment was that I would like to see a consistent 
approach for all conversions, not one approach for longs and another for 
the other types.

-O



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: patch for getXXX methods
  2004-07-09 21:09 patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-09 22:34 ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-09 23:47   ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-11 15:04     ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-11 20:24       ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-11 23:37         ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-12 11:58           ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-12 14:36             ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
@ 2004-07-12 14:50               ` Dave Cramer <pg@fastcrypt.com>
  2004-07-12 15:06                 ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Dave Cramer @ 2004-07-12 14:50 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc

The reason I use the Double.... is because I am assuming it is faster,
if this is not true, then there is no reason to use your suggestion.

Dave
On Mon, 2004-07-12 at 10:36, Oliver Jowett wrote:
> Dave Cramer wrote:
> > Oliver,
> > 
> > Yes, and this is why I needed to do it for getLong, but I don't think
> > it's necessary for getInt, getByte, as it is really just to test to see
> > if it is greater than the max allowed value.
> 
> Sure, but my original comment was that I would like to see a consistent 
> approach for all conversions, not one approach for longs and another for 
> the other types.
> 
> -O
> 
> 
> 
> !DSPAM:40f2a228268032766713856!
> 
> 
-- 
Dave Cramer
519 939 0336
ICQ # 14675561




^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: patch for getXXX methods
  2004-07-09 21:09 patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-09 22:34 ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-09 23:47   ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-11 15:04     ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-11 20:24       ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-11 23:37         ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-12 11:58           ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-12 14:36             ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-12 14:50               ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
@ 2004-07-12 15:06                 ` Oliver Jowett <oliver@opencloud.com>
  2004-07-12 15:14                   ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Oliver Jowett @ 2004-07-12 15:06 UTC (permalink / raw)
  To: pg@fastcrypt.com; +Cc: pgsql-jdbc

Dave Cramer wrote:
> The reason I use the Double.... is because I am assuming it is faster,
> if this is not true, then there is no reason to use your suggestion.

I'd take code clarity over performance benefit -- it's an uncommon case 
and the cost of parsing a BigDecimal is likely to be trivial compared to 
the other work the driver does.

-O



^ permalink  raw  reply  [nested|flat] 11+ messages in thread

* Re: patch for getXXX methods
  2004-07-09 21:09 patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-09 22:34 ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-09 23:47   ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-11 15:04     ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-11 20:24       ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-11 23:37         ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-12 11:58           ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-12 14:36             ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
  2004-07-12 14:50               ` Re: patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
  2004-07-12 15:06                 ` Re: patch for getXXX methods Oliver Jowett <oliver@opencloud.com>
@ 2004-07-12 15:14                   ` Dave Cramer <pg@fastcrypt.com>
  0 siblings, 0 replies; 11+ messages in thread

From: Dave Cramer @ 2004-07-12 15:14 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc

Ok, I'll buy that argument.

--dc--
On Mon, 2004-07-12 at 11:06, Oliver Jowett wrote:
> Dave Cramer wrote:
> > The reason I use the Double.... is because I am assuming it is faster,
> > if this is not true, then there is no reason to use your suggestion.
> 
> I'd take code clarity over performance benefit -- it's an uncommon case 
> and the cost of parsing a BigDecimal is likely to be trivial compared to 
> the other work the driver does.
> 
> -O
> 
> 
> 
> !DSPAM:40f2a91b11386775011984!
> 
> 
-- 
Dave Cramer
519 939 0336
ICQ # 14675561




^ permalink  raw  reply  [nested|flat] 11+ messages in thread


end of thread, other threads:[~2004-07-12 15:14 UTC | newest]

Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-07-09 21:09 patch for getXXX methods Dave Cramer <pg@fastcrypt.com>
2004-07-09 22:34 ` Oliver Jowett <oliver@opencloud.com>
2004-07-09 23:47   ` Dave Cramer <pg@fastcrypt.com>
2004-07-11 15:04     ` Oliver Jowett <oliver@opencloud.com>
2004-07-11 20:24       ` Dave Cramer <pg@fastcrypt.com>
2004-07-11 23:37         ` Oliver Jowett <oliver@opencloud.com>
2004-07-12 11:58           ` Dave Cramer <pg@fastcrypt.com>
2004-07-12 14:36             ` Oliver Jowett <oliver@opencloud.com>
2004-07-12 14:50               ` Dave Cramer <pg@fastcrypt.com>
2004-07-12 15:06                 ` Oliver Jowett <oliver@opencloud.com>
2004-07-12 15:14                   ` Dave Cramer <pg@fastcrypt.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox