mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
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
This commit is contained in:
@ -98,7 +98,9 @@ public class Fastpath
|
|||||||
|
|
||||||
// Now loop, reading the results
|
// Now loop, reading the results
|
||||||
Object result = null; // our result
|
Object result = null; // our result
|
||||||
while (true)
|
StringBuffer errorMessage = null;
|
||||||
|
boolean loop = true;
|
||||||
|
while (loop)
|
||||||
{
|
{
|
||||||
int in = stream.ReceiveChar();
|
int in = stream.ReceiveChar();
|
||||||
//DriverManager.println("ReceiveChar() = "+in+" '"+((char)in)+"'");
|
//DriverManager.println("ReceiveChar() = "+in+" '"+((char)in)+"'");
|
||||||
@ -128,8 +130,10 @@ public class Fastpath
|
|||||||
//------------------------------
|
//------------------------------
|
||||||
// Error message returned
|
// Error message returned
|
||||||
case 'E':
|
case 'E':
|
||||||
throw new PSQLException("postgresql.fp.error", stream.ReceiveString(conn.getEncoding()));
|
if ( errorMessage == null )
|
||||||
|
errorMessage = new StringBuffer();
|
||||||
|
errorMessage.append(stream.ReceiveString(conn.getEncoding()));
|
||||||
|
break;
|
||||||
//------------------------------
|
//------------------------------
|
||||||
// Notice from backend
|
// Notice from backend
|
||||||
case 'N':
|
case 'N':
|
||||||
@ -143,15 +147,22 @@ public class Fastpath
|
|||||||
// processed earlier. If no result, this already contains null
|
// processed earlier. If no result, this already contains null
|
||||||
case '0':
|
case '0':
|
||||||
//DriverManager.println("returning "+result);
|
//DriverManager.println("returning "+result);
|
||||||
return result;
|
// return result;
|
||||||
|
break;
|
||||||
case 'Z':
|
case 'Z':
|
||||||
|
// cause the loop to exit
|
||||||
|
loop = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new PSQLException("postgresql.fp.protocol", new Character((char)in));
|
throw new PSQLException("postgresql.fp.protocol", new Character((char)in));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( errorMessage != null )
|
||||||
|
throw new PSQLException("postgresql.fp.error", errorMessage.toString());
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user