Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 54cc549

Browse files
author
Dave Cramer
committed
modifications to the way the protocol is handled to be consistent with
QueryExecutor. This includes: 1) only exit after we receive a 'Z' packet 2) append error messages to a buffer and throw the exception at the end
1 parent 0092322 commit 54cc549

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/interfaces/jdbc/org/postgresql/fastpath/Fastpath.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ public Object fastpath(int fnid, boolean resulttype, FastpathArg[] args) throws
9898

9999
// Now loop, reading the results
100100
Object result = null; // our result
101-
while (true)
101+
StringBuffer errorMessage = null;
102+
boolean loop = true;
103+
while (loop)
102104
{
103105
int in = stream.ReceiveChar();
104106
//DriverManager.println("ReceiveChar() = "+in+" '"+((char)in)+"'");
@@ -128,8 +130,10 @@ public Object fastpath(int fnid, boolean resulttype, FastpathArg[] args) throws
128130
//------------------------------
129131
// Error message returned
130132
case 'E':
131-
throw new PSQLException("postgresql.fp.error", stream.ReceiveString(conn.getEncoding()));
132-
133+
if ( errorMessage == null )
134+
errorMessage = new StringBuffer();
135+
errorMessage.append(stream.ReceiveString(conn.getEncoding()));
136+
break;
133137
//------------------------------
134138
// Notice from backend
135139
case 'N':
@@ -143,15 +147,22 @@ public Object fastpath(int fnid, boolean resulttype, FastpathArg[] args) throws
143147
// processed earlier. If no result, this already contains null
144148
case '0':
145149
//DriverManager.println("returning "+result);
146-
return result;
147-
150+
// return result;
151+
break;
148152
case 'Z':
153+
// cause the loop to exit
154+
loop = false;
149155
break;
150156

151157
default:
152158
throw new PSQLException("postgresql.fp.protocol", new Character((char)in));
153159
}
154160
}
161+
162+
if ( errorMessage != null )
163+
throw new PSQLException("postgresql.fp.error", errorMessage.toString());
164+
165+
return result;
155166
}
156167
}
157168

0 commit comments

Comments
 (0)