mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-12 18:34:36 +08:00
Attempt to fix setMaxFieldSize() logic that was checked in yesterday.
I think this should fix the problem, but since I don't have a reproducable test case, I can't be sure. This problem is reported by Kim Ho of redhat, who will test this fix. This also includes a test case for the original functionality. Modified Files: jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java jdbc/org/postgresql/test/jdbc2/ResultSetTest.java
This commit is contained in:
parent
3e51c1553c
commit
06bbd98a15
@ -25,7 +25,7 @@ import java.sql.Timestamp;
|
|||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.32 2003/08/24 22:10:09 barry Exp $
|
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.33 2003/08/26 06:50:39 barry Exp $
|
||||||
* This class defines methods of the jdbc1 specification. This class is
|
* This class defines methods of the jdbc1 specification. This class is
|
||||||
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
|
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
|
||||||
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
|
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
|
||||||
@ -87,7 +87,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
|
|||||||
// returnTypeSet is true when a proper call to registerOutParameter has been made
|
// returnTypeSet is true when a proper call to registerOutParameter has been made
|
||||||
private boolean returnTypeSet;
|
private boolean returnTypeSet;
|
||||||
protected Object callResult;
|
protected Object callResult;
|
||||||
protected static int maxfieldSize = 0;
|
protected int maxfieldSize = 0;
|
||||||
|
|
||||||
public abstract BaseResultSet createResultSet(Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException;
|
public abstract BaseResultSet createResultSet(Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException;
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import org.postgresql.test.TestUtil;
|
|||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
@ -33,12 +34,20 @@ public class ResultSetTest extends TestCase
|
|||||||
stmt.executeUpdate("INSERT INTO testrs VALUES (6)");
|
stmt.executeUpdate("INSERT INTO testrs VALUES (6)");
|
||||||
stmt.executeUpdate("INSERT INTO testrs VALUES (9)");
|
stmt.executeUpdate("INSERT INTO testrs VALUES (9)");
|
||||||
|
|
||||||
|
TestUtil.createTable(con, "teststring", "a text");
|
||||||
|
stmt.executeUpdate("INSERT INTO teststring VALUES ('12345')");
|
||||||
|
|
||||||
|
TestUtil.createTable(con, "testint", "a int");
|
||||||
|
stmt.executeUpdate("INSERT INTO testint VALUES (12345)");
|
||||||
|
|
||||||
stmt.close();
|
stmt.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() throws Exception
|
protected void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
TestUtil.dropTable(con, "testrs");
|
TestUtil.dropTable(con, "testrs");
|
||||||
|
TestUtil.dropTable(con, "teststring");
|
||||||
|
TestUtil.dropTable(con, "testint");
|
||||||
TestUtil.closeDB(con);
|
TestUtil.closeDB(con);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,4 +94,25 @@ public class ResultSetTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testMaxFieldSize() throws Exception
|
||||||
|
{
|
||||||
|
Statement stmt = con.createStatement();
|
||||||
|
stmt.setMaxFieldSize(2);
|
||||||
|
|
||||||
|
ResultSet rs = stmt.executeQuery("select * from testint");
|
||||||
|
|
||||||
|
//max should not apply to the following since per the spec
|
||||||
|
//it should apply only to binary and char/varchar columns
|
||||||
|
rs.next();
|
||||||
|
assertEquals(rs.getString(1),"12345");
|
||||||
|
assertEquals(new String(rs.getBytes(1)), "12345");
|
||||||
|
|
||||||
|
//max should apply to the following since the column is
|
||||||
|
//a varchar column
|
||||||
|
rs = stmt.executeQuery("select * from teststring");
|
||||||
|
rs.next();
|
||||||
|
assertEquals(rs.getString(1), "12");
|
||||||
|
assertEquals(new String(rs.getBytes(1)), "12");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user