private void interpretCommandStatus(String status, ResultHandler handler) { int update_count = 0; long insert_oid = 0; if (status.startsWith("INSERT") || status.startsWith("UPDATE") || status.startsWith("DELETE") || status.startsWith("MOVE")) { try { update_count = Integer.parseInt(status.substring(1 + status.lastIndexOf(' '))); if (status.startsWith("INSERT")) insert_oid = Long.parseLong(status.substring(1 + status.indexOf(' '), status.lastIndexOf(' '))); } catch (NumberFormatException nfe) { handler.handleError(new PSQLException(GT.tr("Unable to interpret the update count in command completion tag: {0}.", status), PSQLState.CONNECTION_FAILURE)); return ; } } handler.handleCommandStatus(status, update_count, insert_oid); }
@Override public void handleCompletion() throws SQLException { if (delegate != null) { delegate.handleCompletion(); } }
@Override public void handleResultRows(Query fromQuery, Field[] fields, List<byte[][]> tuples, ResultCursor cursor) { if (delegate != null) { delegate.handleResultRows(fromQuery, fields, tuples, cursor); } }
handler.handleResultRows(currentQuery, fields, tuples, null); tuples = null; handler.handleResultRows(currentQuery, fields, tuples, currentPortal); tuples = null; break; handler.handleResultRows(currentQuery, fields, tuples, null); tuples = null; } catch (OutOfMemoryError oome) { if (!noResults) { handler.handleError( new PSQLException(GT.tr("Ran out of memory retrieving query results."), PSQLState.OUT_OF_MEMORY, oome)); handler.handleError(error); if (willHealViaReparse(error)) { handler.handleCommandStatus("EMPTY", 0, 0); if (currentPortal != null) { currentPortal.close(); handler.handleWarning(warning); break; receiveParameterStatus(); } catch (SQLException e) { handler.handleError(e);
handler.handleError(new PSQLException(GT.tr("An I/O error occured while sending to the backend."), PSQLState.CONNECTION_FAILURE, e)); handler.handleCompletion();
} catch(OutOfMemoryError oome) { if (maxRows == 0 || tuples.size() < maxRows) { handler.handleError(new PSQLException(GT.tr("Ran out of memory retrieving query results."), PSQLState.OUT_OF_MEMORY, oome)); handler.handleResultRows(originalQuery, fields, tuples, null); fields = null; } catch(OutOfMemoryError oome) { if (maxRows == 0 || tuples.size() < maxRows) handler.handleError(new PSQLException(GT.tr("Ran out of memory retrieving query results."), PSQLState.OUT_OF_MEMORY, oome)); handler.handleError(receiveErrorMessage()); handler.handleWarning(receiveNotification()); break;
@Override public void handleWarning(SQLWarning warning) { if (delegate != null) { delegate.handleWarning(warning); } }
@Override public void handleCommandStatus(String status, int updateCount, long insertOID) { if (delegate != null) { delegate.handleCommandStatus(status, updateCount, insertOID); } }
@Override public void handleError(SQLException error) { if (delegate != null) { delegate.handleError(error); } }
if (handler.getException() != null) { break; if (handler.getException() == null) { if ((flags & QueryExecutor.QUERY_EXECUTE_AS_SIMPLE) != 0) { handler.handleError( new PSQLException(GT.tr("An I/O error occurred while sending to the backend."), PSQLState.CONNECTION_FAILURE, e)); handler.handleCompletion(); } catch (SQLException e) { rollbackIfRequired(autosave, e);
@Override public SQLException getException() { if (delegate != null) { return delegate.getException(); } return null; }
@Override public SQLWarning getWarning() { if (delegate != null) { return delegate.getWarning(); } return null; } }
handler.handleResultRows(currentQuery, fields, tuples, null); tuples = null; handler.handleResultRows(currentQuery, fields, tuples, currentPortal); handler.handleResultRows(currentQuery, fields, tuples, null); tuples = null; } catch(OutOfMemoryError oome) { if (!noResults) { handler.handleError(new PSQLException(GT.tr("Ran out of memory retrieving query results."), PSQLState.OUT_OF_MEMORY, oome)); handler.handleError(error); Query currentQuery = (Query)executeData[0]; Portal currentPortal = (Portal)executeData[1]; handler.handleCommandStatus("EMPTY", 0, 0); if (currentPortal != null) currentPortal.close(); handler.handleWarning(warning); break; handler.handleError(new PSQLException(GT.tr("The server''s client_encoding parameter was changed to {0}. The JDBC driver requires client_encoding to be UTF8 for correct operation.", value), PSQLState.CONNECTION_FAILURE)); endQuery = true; handler.handleError(new PSQLException(GT.tr("The server''s DateStyle parameter was changed to {0}. The JDBC driver requires DateStyle to begin with ISO for correct operation.", value), PSQLState.CONNECTION_FAILURE)); endQuery = true;
public synchronized void fetch(ResultCursor cursor, ResultHandler handler, int fetchSize) throws SQLException { waitOnLock(); final Portal portal = (Portal) cursor; // Insert a ResultHandler that turns bare command statuses into empty datasets // (if the fetch returns no rows, we see just a CommandStatus..) final ResultHandler delegateHandler = handler; handler = new ResultHandlerDelegate(delegateHandler) { public void handleCommandStatus(String status, int updateCount, long insertOID) { handleResultRows(portal.getQuery(), null, new ArrayList<byte[][]>(), null); } }; // Now actually run it. try { processDeadParsedQueries(); processDeadPortals(); sendExecute(portal.getQuery(), portal, fetchSize); sendSync(); processResults(handler, 0); estimatedReceiveBufferBytes = 0; } catch (IOException e) { abort(); handler.handleError( new PSQLException(GT.tr("An I/O error occurred while sending to the backend."), PSQLState.CONNECTION_FAILURE, e)); } handler.handleCompletion(); }
} catch(OutOfMemoryError oome) { if (maxRows == 0 || tuples.size() < maxRows) { handler.handleError(new PSQLException(GT.tr("Ran out of memory retrieving query results."), PSQLState.OUT_OF_MEMORY, oome)); handler.handleResultRows(originalQuery, fields, tuples, null); fields = null; } catch(OutOfMemoryError oome) { if (maxRows == 0 || tuples.size() < maxRows) handler.handleError(new PSQLException(GT.tr("Ran out of memory retrieving query results."), PSQLState.OUT_OF_MEMORY, oome)); handler.handleError(receiveErrorMessage()); handler.handleWarning(receiveNotification()); break;
public void handleWarning(SQLWarning warning) { delegateHandler.handleWarning(warning); }
public void handleCommandStatus(String status, int updateCount, long insertOID) { delegateHandler.handleCommandStatus(status, updateCount, insertOID); }
public void handleError(SQLException error) { sawError = true; delegateHandler.handleError(error); }
if (resultHandler.getException() == null) { sendOneQuery((SimpleQuery) query, (SimpleParameterList) parameters, maxRows, fetchSize, flags); if (resultHandler.getException() != null) { break;
handler.handleResultRows(currentQuery, fields, tuples, null); tuples = null; handler.handleResultRows(currentQuery, fields, tuples, currentPortal); handler.handleResultRows(currentQuery, fields, tuples, null); tuples = null; } catch(OutOfMemoryError oome) { if (!noResults) { handler.handleError(new PSQLException(GT.tr("Ran out of memory retrieving query results."), PSQLState.OUT_OF_MEMORY, oome)); handler.handleError(error); Query currentQuery = (Query)executeData[0]; Portal currentPortal = (Portal)executeData[1]; handler.handleCommandStatus("EMPTY", 0, 0); if (currentPortal != null) currentPortal.close(); handler.handleWarning(warning); break; handler.handleError(new PSQLException(GT.tr("The server''s client_encoding parameter was changed to {0}. The JDBC driver requires client_encoding to be UNICODE for correct operation.", value), PSQLState.CONNECTION_FAILURE)); endQuery = true; handler.handleError(new PSQLException(GT.tr("The server''s DateStyle parameter was changed to {0}. The JDBC driver requires DateStyle to begin with ISO for correct operation.", value), PSQLState.CONNECTION_FAILURE)); endQuery = true;