From b08e86d557538c16e482ad10a9bdbc474893d07e Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sun, 15 Jul 2001 04:21:26 +0000 Subject: The attached patch fixes problems with the JDBC driver handling long null terminated strings. The FE/BE protocol sends in some cases null terminated strings to the client. The docs for the FE/BE protocol state that there is no limit on the size of a null terminated string sent to the client and a client should be coded using an expanding buffer to deal with large strings. The old code did not do this and gave an error if a null terminated string was greater than either 4 or 8K. It appears that with the advent of TOAST very long SQL statements are becoming more common, and apparently some error messages from the backend include the SQL statement thus easily exceeding the 8K limit in the old code. In fixing I also cleaned up some calls in the JDBC fastpath code that were not doing character set conversion under multibyte, and removed some methods that were no longer needed. I also removed a potential threading problem with a shared variable that was being used in Connection.java. Thanks to Steve Wampler for discovering the problem and sending the initial diffs that were the basis of this patch. thanks, --Barry --- src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java') diff --git a/src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java b/src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java index 4566f562d2..a99bd0c0d1 100644 --- a/src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java +++ b/src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java @@ -89,7 +89,7 @@ public class Fastpath //DriverManager.println("ReceiveChar() = "+in+" '"+((char)in)+"'"); //if(in!='V') { //if(in=='E') - //throw new SQLException(stream.ReceiveString(4096)); + //throw new SQLException(stream.ReceiveString(conn.getEncoding())); //throw new SQLException("Fastpath: expected 'V' from backend, got "+((char)in)); //} @@ -123,12 +123,12 @@ public class Fastpath //------------------------------ // Error message returned case 'E': - throw new PSQLException("postgresql.fp.error",stream.ReceiveString(4096)); + throw new PSQLException("postgresql.fp.error",stream.ReceiveString(conn.getEncoding())); //------------------------------ // Notice from backend case 'N': - conn.addWarning(stream.ReceiveString(4096)); + conn.addWarning(stream.ReceiveString(conn.getEncoding())); break; //------------------------------ -- cgit v1.2.1