diff -urb postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/core/PGStream.java postgresql-jdbc-8.0-310.src/org/postgresql/core/PGStream.java --- postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/core/PGStream.java 2005-01-11 09:25:43.000000000 +0100 +++ postgresql-jdbc-8.0-310.src/org/postgresql/core/PGStream.java 2005-04-11 07:00:42.000000000 +0200 @@ -71,6 +71,10 @@ return connection; } + public boolean hasMessagePending() throws IOException { + return connection.getInputStream().available()>0; + } + /** * Switch this stream to using a new socket. Any existing socket * is not closed; it's assumed that we are changing to diff -urb postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/core/ProtocolConnection.java postgresql-jdbc-8.0-310.src/org/postgresql/core/ProtocolConnection.java --- postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/core/ProtocolConnection.java 2005-01-11 09:25:43.000000000 +0100 +++ postgresql-jdbc-8.0-310.src/org/postgresql/core/ProtocolConnection.java 2005-04-11 07:01:26.000000000 +0200 @@ -82,7 +82,7 @@ * @return an array of notifications; if there are no notifications, an empty * array is returned. */ - PGNotification[] getNotifications(); + PGNotification[] getNotifications() throws SQLException; /** * Retrieve and clear the chain of warnings accumulated on this connection. diff -urb postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/core/v2/ProtocolConnectionImpl.java postgresql-jdbc-8.0-310.src/org/postgresql/core/v2/ProtocolConnectionImpl.java --- postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/core/v2/ProtocolConnectionImpl.java 2005-01-11 09:25:43.000000000 +0100 +++ postgresql-jdbc-8.0-310.src/org/postgresql/core/v2/ProtocolConnectionImpl.java 2005-04-11 06:58:48.000000000 +0200 @@ -57,7 +57,8 @@ } public synchronized PGNotification[] - getNotifications() { + getNotifications() throws SQLException { + executor.processNotifies(); PGNotification[] array = (PGNotification[])notifications.toArray(new PGNotification[notifications.size()]); notifications.clear(); return array; diff -urb postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/core/v2/QueryExecutorImpl.java postgresql-jdbc-8.0-310.src/org/postgresql/core/v2/QueryExecutorImpl.java --- postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/core/v2/QueryExecutorImpl.java 2005-02-01 08:27:54.000000000 +0100 +++ postgresql-jdbc-8.0-310.src/org/postgresql/core/v2/QueryExecutorImpl.java 2005-04-11 07:11:26.000000000 +0200 @@ -148,6 +148,31 @@ pgStream.flush(); } + public synchronized void processNotifies() throws SQLException { + if (protoConnection.getTransactionState() == ProtocolConnection.TRANSACTION_IDLE) { + try { + while (pgStream.hasMessagePending()) { + int c = pgStream.ReceiveChar(); + switch (c) { + case 'A': // Asynchronous Notify + receiveAsyncNotify(); + break; + case 'E': // Error Message + throw receiveErrorMessage(); + // break; + case 'N': // Error Notification + protoConnection.addWarning(receiveNotification()); + break; + default: + throw new PSQLException(GT.tr("Unknown Response Type {0}.", new Character((char) c)), PSQLState.CONNECTION_FAILURE); + } + } + } catch (IOException ioe) { + throw new PSQLException(GT.tr("An I/O error occured while sending to the backend."), PSQLState.CONNECTION_FAILURE, ioe); + } + } + } + private byte[] receiveFastpathResult() throws IOException, SQLException { SQLException error = null; boolean endQuery = false; diff -urb postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/core/v3/ProtocolConnectionImpl.java postgresql-jdbc-8.0-310.src/org/postgresql/core/v3/ProtocolConnectionImpl.java --- postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/core/v3/ProtocolConnectionImpl.java 2005-01-11 09:25:44.000000000 +0100 +++ postgresql-jdbc-8.0-310.src/org/postgresql/core/v3/ProtocolConnectionImpl.java 2005-04-11 06:59:26.000000000 +0200 @@ -58,7 +58,8 @@ } public synchronized PGNotification[] - getNotifications() { + getNotifications() throws SQLException { + executor.processNotifies(); PGNotification[] array = (PGNotification[])notifications.toArray(new PGNotification[notifications.size()]); notifications.clear(); return array; diff -urb postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/core/v3/QueryExecutorImpl.java postgresql-jdbc-8.0-310.src/org/postgresql/core/v3/QueryExecutorImpl.java --- postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/core/v3/QueryExecutorImpl.java 2005-02-01 08:27:54.000000000 +0100 +++ postgresql-jdbc-8.0-310.src/org/postgresql/core/v3/QueryExecutorImpl.java 2005-04-11 07:11:56.000000000 +0200 @@ -524,6 +524,32 @@ pgStream.flush(); } + public synchronized void processNotifies() throws SQLException { + if (protoConnection.getTransactionState() == ProtocolConnection.TRANSACTION_IDLE) { + try { + while (pgStream.hasMessagePending()) { + int c = pgStream.ReceiveChar(); + switch (c) { + case 'A': // Asynchronous Notify + receiveAsyncNotify(); + break; + case 'E': // Error Response (response to pretty much everything; backend then skips until Sync) + throw receiveErrorResponse(); + // break; + case 'N': // Notice Response (warnings / info) + SQLWarning warning = receiveNoticeResponse(); + protoConnection.addWarning(warning); + break; + default: + throw new PSQLException(GT.tr("Unknown Response Type {0}.", new Character((char) c)), PSQLState.CONNECTION_FAILURE); + } + } + } catch (IOException ioe) { + throw new PSQLException(GT.tr("An I/O error occured while sending to the backend."), PSQLState.CONNECTION_FAILURE, ioe); + } + } + } + private byte[] receiveFastpathResult() throws IOException, SQLException { boolean endQuery = false; SQLException error = null; diff -urb postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/jdbc2/AbstractJdbc2Connection.java postgresql-jdbc-8.0-310.src/org/postgresql/jdbc2/AbstractJdbc2Connection.java --- postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/jdbc2/AbstractJdbc2Connection.java 2005-01-25 07:21:21.000000000 +0100 +++ postgresql-jdbc-8.0-310.src/org/postgresql/jdbc2/AbstractJdbc2Connection.java 2005-04-11 07:02:04.000000000 +0200 @@ -1023,7 +1023,7 @@ protoConnection.sendQueryCancel(); } - public PGNotification[] getNotifications() + public PGNotification[] getNotifications() throws SQLException { // Backwards-compatibility hand-holding. PGNotification[] notifications = protoConnection.getNotifications(); diff -urb postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/PGConnection.java postgresql-jdbc-8.0-310.src/org/postgresql/PGConnection.java --- postgresql-jdbc-8.0-310.src-vanilla/org/postgresql/PGConnection.java 2005-01-17 10:51:40.000000000 +0100 +++ postgresql-jdbc-8.0-310.src/org/postgresql/PGConnection.java 2005-04-11 07:03:00.000000000 +0200 @@ -27,7 +27,7 @@ * Returns null if there have been no notifications. * @since 7.3 */ - public PGNotification[] getNotifications(); + public PGNotification[] getNotifications() throws SQLException; /** * This returns the LargeObject API for the current connection.