Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 06bbd98

Browse files
author
Barry Lind
committed
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
1 parent 3e51c15 commit 06bbd98

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import java.sql.Types;
2626
import java.util.Vector;
2727

28-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.32 2003/08/24 22:10:09 barry Exp $
28+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.33 2003/08/26 06:50:39 barry Exp $
2929
* This class defines methods of the jdbc1 specification. This class is
3030
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
3131
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
@@ -87,7 +87,7 @@ public abstract class AbstractJdbc1Statement implements BaseStatement
8787
// returnTypeSet is true when a proper call to registerOutParameter has been made
8888
private boolean returnTypeSet;
8989
protected Object callResult;
90-
protected static int maxfieldSize = 0;
90+
protected int maxfieldSize = 0;
9191

9292
public abstract BaseResultSet createResultSet(Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException;
9393

src/interfaces/jdbc/org/postgresql/test/jdbc2/ResultSetTest.java

+30
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.sql.Connection;
55
import java.sql.ResultSet;
66
import java.sql.Statement;
7+
import java.sql.SQLException;
78

89
import junit.framework.TestCase;
910

@@ -32,13 +33,21 @@ protected void setUp() throws Exception
3233
stmt.executeUpdate("INSERT INTO testrs VALUES (4)");
3334
stmt.executeUpdate("INSERT INTO testrs VALUES (6)");
3435
stmt.executeUpdate("INSERT INTO testrs VALUES (9)");
36+
37+
TestUtil.createTable(con, "teststring", "a text");
38+
stmt.executeUpdate("INSERT INTO teststring VALUES ('12345')");
39+
40+
TestUtil.createTable(con, "testint", "a int");
41+
stmt.executeUpdate("INSERT INTO testint VALUES (12345)");
3542

3643
stmt.close();
3744
}
3845

3946
protected void tearDown() throws Exception
4047
{
4148
TestUtil.dropTable(con, "testrs");
49+
TestUtil.dropTable(con, "teststring");
50+
TestUtil.dropTable(con, "testint");
4251
TestUtil.closeDB(con);
4352
}
4453

@@ -85,4 +94,25 @@ public void testEmptyResult()
8594
}
8695

8796
}
97+
98+
public void testMaxFieldSize() throws Exception
99+
{
100+
Statement stmt = con.createStatement();
101+
stmt.setMaxFieldSize(2);
102+
103+
ResultSet rs = stmt.executeQuery("select * from testint");
104+
105+
//max should not apply to the following since per the spec
106+
//it should apply only to binary and char/varchar columns
107+
rs.next();
108+
assertEquals(rs.getString(1),"12345");
109+
assertEquals(new String(rs.getBytes(1)), "12345");
110+
111+
//max should apply to the following since the column is
112+
//a varchar column
113+
rs = stmt.executeQuery("select * from teststring");
114+
rs.next();
115+
assertEquals(rs.getString(1), "12");
116+
assertEquals(new String(rs.getBytes(1)), "12");
117+
}
88118
}

0 commit comments

Comments
 (0)