Index: org/postgresql/Connection.java =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v retrieving revision 1.11 diff -u -3 -r1.11 Connection.java --- org/postgresql/Connection.java 2000/12/22 03:08:52 1.11 +++ org/postgresql/Connection.java 2001/01/17 19:21:59 @@ -868,10 +868,34 @@ } /** - * This is an attempt to implement SQL Escape clauses + * Implement SQL Escape clauses. + * + *

This only implements the date escape clause correctly right now. */ public String EscapeSQL(String sql) { - return sql; + boolean DEBUG = false; + if (DEBUG) { System.out.println ("parseSQLEscapes called"); } + + // If we find a "{d", assume we have a date escape. + // + // Since the date escape syntax is very close to the + // native Postgres date format, we just remove the escape + // delimiters. + // + // This implementation could use some optimization, but it has + // worked in practice for two years of solid use. + int index = sql.indexOf("{d"); + while (index != -1) { + if (DEBUG) { System.out.println ("escape found at index: " + index);} + StringBuffer buf = new StringBuffer(sql); + buf.setCharAt(index, ' '); + buf.setCharAt(index + 1, ' '); + buf.setCharAt(sql.indexOf('}', index), ' '); + sql = new String(buf); + index = sql.indexOf("{d"); + } + if (DEBUG) { System.out.println ("modified SQL: " + sql); } + return sql; } } Index: org/postgresql/PG_Stream.java =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/PG_Stream.java,v retrieving revision 1.5 diff -u -3 -r1.5 PG_Stream.java --- org/postgresql/PG_Stream.java 2000/10/12 08:55:24 1.5 +++ org/postgresql/PG_Stream.java 2001/01/17 19:22:00 @@ -494,13 +494,11 @@ */ class BytePoolDim1 { int maxsize = 256; - ObjectPool notusemap[] = new ObjectPool[maxsize]; - ObjectPool inusemap[] = new ObjectPool[maxsize]; - byte binit[][] = new byte[maxsize][0]; + ObjectPool notusemap[] = new ObjectPool[maxsize + 1]; + ObjectPool inusemap[] = new ObjectPool[maxsize + 1]; public BytePoolDim1(){ - for(int i = 0; i < maxsize; i++){ - binit[i] = new byte[i]; + for(int i = 0; i <= maxsize; i++){ inusemap[i] = new ObjectPool(); notusemap[i] = new ObjectPool(); } @@ -526,7 +524,7 @@ } public void deallocate(){ - for(int i = 0; i < maxsize; i++){ + for(int i = 0; i <= maxsize; i++){ notusemap[i].addAll(inusemap[i]); inusemap[i].clear(); } @@ -542,11 +540,11 @@ */ class BytePoolDim2 { int maxsize = 32; - ObjectPool notusemap[] = new ObjectPool[maxsize]; - ObjectPool inusemap[] = new ObjectPool[maxsize]; + ObjectPool notusemap[] = new ObjectPool[maxsize + 1]; + ObjectPool inusemap[] = new ObjectPool[maxsize + 1]; public BytePoolDim2(){ - for(int i = 0; i < maxsize; i++){ + for(int i = 0; i <= maxsize; i++){ inusemap[i] = new ObjectPool(); notusemap[i] = new ObjectPool(); } @@ -571,7 +569,7 @@ } public void deallocate(){ - for(int i = 0; i < maxsize; i++){ + for(int i = 0; i <= maxsize; i++){ notusemap[i].addAll(inusemap[i]); inusemap[i].clear(); } Index: org/postgresql/jdbc1/ResultSet.java =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java,v retrieving revision 1.8 diff -u -3 -r1.8 ResultSet.java --- org/postgresql/jdbc1/ResultSet.java 2001/01/13 18:52:42 1.8 +++ org/postgresql/jdbc1/ResultSet.java 2001/01/17 19:22:00 @@ -471,12 +471,12 @@ SimpleDateFormat df = null; if (s.length()>21 && s.indexOf('.') != -1) { df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSzzz"); - } else if (s.length()>19 && s.indexOf('.') == -1) { - df = new SimpleDateFormat("yyyy-MM-dd HH:MM:sszzz"); - } else if (s.length()>19 && s.indexOf('.') != -1) { - df = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss.SS"); - } else if (s.length()>10 && s.length()<=18) { - df = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss"); + } else if (s.length()>19 && s.indexOf('.') == -1) { + df = new SimpleDateFormat("yyyy-MM-dd HH:mm:sszzz"); + } else if (s.length()>19 && s.indexOf('.') != -1) { + df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SS"); + } else if (s.length()>10) { + df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } else { df = new SimpleDateFormat("yyyy-MM-dd"); } Index: org/postgresql/jdbc1/Statement.java =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Statement.java,v retrieving revision 1.3 diff -u -3 -r1.3 Statement.java --- org/postgresql/jdbc1/Statement.java 2000/10/09 16:48:17 1.3 +++ org/postgresql/jdbc1/Statement.java 2001/01/17 19:22:00 @@ -266,6 +266,8 @@ */ public boolean execute(String sql) throws SQLException { + if (escapeProcessing) + sql = connection.EscapeSQL(sql); result = connection.ExecSQL(sql); return (result != null && ((org.postgresql.ResultSet)result).reallyResultSet()); } Index: org/postgresql/jdbc2/ResultSet.java =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java,v retrieving revision 1.15 diff -u -3 -r1.15 ResultSet.java --- org/postgresql/jdbc2/ResultSet.java 2001/01/13 18:52:42 1.15 +++ org/postgresql/jdbc2/ResultSet.java 2001/01/17 19:22:02 @@ -486,11 +486,11 @@ if (s.length()>21 && s.indexOf('.') != -1) { df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSzzz"); } else if (s.length()>19 && s.indexOf('.') == -1) { - df = new SimpleDateFormat("yyyy-MM-dd HH:MM:sszzz"); + df = new SimpleDateFormat("yyyy-MM-dd HH:mm:sszzz"); } else if (s.length()>19 && s.indexOf('.') != -1) { - df = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss.SS"); + df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SS"); } else if (s.length()>10 && s.length()<=18) { - df = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss"); + df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); } else { df = new SimpleDateFormat("yyyy-MM-dd"); } Index: org/postgresql/util/PSQLException.java =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/util/PSQLException.java,v retrieving revision 1.2 diff -u -3 -r1.2 PSQLException.java --- org/postgresql/util/PSQLException.java 2000/09/12 05:18:25 1.2 +++ org/postgresql/util/PSQLException.java 2001/01/17 19:22:02 @@ -83,7 +83,7 @@ } // Expand any arguments - if(args!=null) + if(args != null && message != null) message = MessageFormat.format(message,args); } Index: utils/CheckVersion.java =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/utils/CheckVersion.java,v retrieving revision 1.2 diff -u -3 -r1.2 CheckVersion.java --- utils/CheckVersion.java 2000/12/19 17:33:39 1.2 +++ utils/CheckVersion.java 2001/01/17 19:22:02 @@ -1,5 +1,7 @@ package utils; +import java.util.Properties; + /** * This little app checks to see what version of JVM is being used. * It does this by checking first the java.vm.version property, and @@ -41,28 +43,30 @@ { String vmversion = System.getProperty("java.vm.version"); - System.out.println("postgresql.jdbc="+System.getProperty("postgresql.jdbc")); - - // We are running a 1.1 JVM - if(vmversion.startsWith("1.1")) { + // We might be running a 1.1 JDK that does not define + // vmversion, such as the IBM JDK 1.1.8 + if(vmversion == null && checkClass("java.lang.Byte")) { System.out.println("jdbc1"); - //System.exit(0); - } - else - // We are running a 1.2 or 1.3 JVM - if(vmversion.startsWith("1.2") || - vmversion.startsWith("1.3") || - checkClass("java.lang.Byte") - ) { - + } + // We are running a 1.1 JDK + else if (vmversion.startsWith("1.1")) { + System.out.println("jdbc1"); + } + // We are running a 1.2 or 1.3 JDK, or maybe another + // compatible JDK that has java.lang.Byte support. + else if(vmversion.startsWith("1.2") || + vmversion.startsWith("1.3") || + checkClass("java.lang.Byte") + ) { // Check to see if we have the standard extensions. If so, then // we want the enterprise edition, otherwise the jdbc2 driver. if(checkClass("javax.sql.DataSource")) - System.out.println("enterprise"); + System.out.println("enterprise"); else - System.out.println("jdbc2"); - //System.exit(0); + System.out.println("jdbc2"); } - System.setProperty("postgresql.jdbc","yoyo"); + // If we have not detected a supported JDK version, + // exit with an error status to stop the make process early. + else System.exit(1); } }