Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit06bbd98

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 testcase, I can't be sure. This problem is reported by Kim Ho of redhat, who willtest 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 parent3e51c15 commit06bbd98

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
importjava.sql.Types;
2626
importjava.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
privatebooleanreturnTypeSet;
8989
protectedObjectcallResult;
90-
protectedstaticintmaxfieldSize =0;
90+
protectedintmaxfieldSize =0;
9191

9292
publicabstractBaseResultSetcreateResultSet(Field[]fields,Vectortuples,Stringstatus,intupdateCount,longinsertOID,booleanbinaryCursor)throwsSQLException;
9393

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
importjava.sql.Connection;
55
importjava.sql.ResultSet;
66
importjava.sql.Statement;
7+
importjava.sql.SQLException;
78

89
importjunit.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
protectedvoidtearDown()throwsException
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+
publicvoidtestMaxFieldSize()throwsException
99+
{
100+
Statementstmt =con.createStatement();
101+
stmt.setMaxFieldSize(2);
102+
103+
ResultSetrs =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(newString(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(newString(rs.getBytes(1)),"12");
117+
}
88118
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp