ProtocolConnectionImpl protoConnection = new ProtocolConnectionImpl(newStream, user, database, info, logger); readStartupMessages(newStream, protoConnection, logger);
private void receiveAsyncNotify() throws IOException { int msglen = pgStream.ReceiveInteger4(); int pid = pgStream.ReceiveInteger4(); String msg = pgStream.ReceiveString(); String param = pgStream.ReceiveString(); protoConnection.addNotification(new org.postgresql.core.Notification(msg, pid, param)); if (logger.logDebug()) logger.debug(" <=BE AsyncNotify(" + pid + "," + msg + "," + param + ")"); }
protoConnection.setTransactionState(ProtocolConnection.TRANSACTION_IDLE); break; case 'T': protoConnection.setTransactionState(ProtocolConnection.TRANSACTION_OPEN); break; case 'E': protoConnection.setTransactionState(ProtocolConnection.TRANSACTION_FAILED); break; default: logger.debug(" <=BE BackendKeyData(pid=" + pid + ",ckey=" + ckey + ")"); protoConnection.setBackendKeyData(pid, ckey); break; logger.debug(" <=BE NoticeResponse(" + l_warnMsg + ")"); protoConnection.addWarning(new PSQLWarning(l_warnMsg)); break; protoConnection.setServerVersion(value); else if (name.equals("client_encoding")) protoConnection.setStandardConformingStrings(true); else if (value.equals("off")) protoConnection.setStandardConformingStrings(false); else throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION);
boolean supportsEStringSyntax = false; if (protoConnection != null) { standardConformingStrings = protoConnection.getStandardConformingStrings(); supportsEStringSyntax = protoConnection.getServerVersion().compareTo("8.1") >= 0;
public synchronized void processNotifies() throws SQLException { waitOnLock(); // Asynchronous notifies only arrive when we are not in a transaction if (protoConnection.getTransactionState() != ProtocolConnection.TRANSACTION_IDLE) return; 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); } }
public synchronized byte[] fastpathCall(int fnid, ParameterList parameters, boolean suppressBegin) throws SQLException { waitOnLock(); if (!suppressBegin) { doSubprotocolBegin(); } try { sendFastpathCall(fnid, (SimpleParameterList)parameters); return receiveFastpathResult(); } catch (IOException ioe) { protoConnection.close(); throw new PSQLException(GT.tr("An I/O error occured while sending to the backend."), PSQLState.CONNECTION_FAILURE, ioe); } }
protoConnection.close(); // we're screwed now; we can't trust any subsequent string. 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; protoConnection.close(); // we're screwed now; we can't trust any subsequent date. 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; protoConnection.setStandardConformingStrings(true); else if (value.equals("off")) protoConnection.setStandardConformingStrings(false); else protoConnection.close(); // we're screwed now; we don't know how to escape string literals handler.handleError(new PSQLException(GT.tr("The server''s standard_conforming_strings parameter was reported as {0}. The JDBC driver expected on or off.", value), PSQLState.CONNECTION_FAILURE)); endQuery = true;
protoConnection.getTransactionState() != ProtocolConnection.TRANSACTION_IDLE) return delegateHandler;
protoConnection.addWarning(warning); break;
protoConnection.sendQueryCancel();
int inParen = 0; boolean standardConformingStrings = protoConnection.getStandardConformingStrings();
protoConnection.close(); handler.handleError(new PSQLException(GT.tr("An I/O error occured while sending to the backend."), PSQLState.CONNECTION_FAILURE, e));
public synchronized void processNotifies() throws SQLException { waitOnLock(); // Asynchronous notifies only arrive when we are not in a transaction if (protoConnection.getTransactionState() != ProtocolConnection.TRANSACTION_IDLE) return; 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); } }
boolean supportsEStringSyntax = false; if (protoConnection != null) { standardConformingStrings = protoConnection.getStandardConformingStrings(); supportsEStringSyntax = protoConnection.getServerVersion().compareTo("8.1") >= 0;
protoConnection.close(); // we're screwed now; we can't trust any subsequent string. 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; protoConnection.close(); // we're screwed now; we can't trust any subsequent date. 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; protoConnection.setStandardConformingStrings(true); else if (value.equals("off")) protoConnection.setStandardConformingStrings(false); else protoConnection.close(); // we're screwed now; we don't know how to escape string literals handler.handleError(new PSQLException(GT.tr("The server''s standard_conforming_strings parameter was reported as {0}. The JDBC driver expected on or off.", value), PSQLState.CONNECTION_FAILURE)); endQuery = true;
public void doSubprotocolBegin() throws SQLException { if (protoConnection.getTransactionState() == ProtocolConnection.TRANSACTION_IDLE)
logger.debug(" <=BE Notification while copying"); protoConnection.addWarning(receiveNoticeResponse()); break;
protoConnection.sendQueryCancel();
int inParen = 0; boolean standardConformingStrings = protoConnection.getStandardConformingStrings();
protoConnection.setTransactionState(ProtocolConnection.TRANSACTION_IDLE); break; case 'T': protoConnection.setTransactionState(ProtocolConnection.TRANSACTION_OPEN); break; case 'E': protoConnection.setTransactionState(ProtocolConnection.TRANSACTION_FAILED); break; default: logger.debug(" <=BE BackendKeyData(pid=" + pid + ",ckey=" + ckey + ")"); protoConnection.setBackendKeyData(pid, ckey); break; logger.debug(" <=BE NoticeResponse(" + l_warnMsg + ")"); protoConnection.addWarning(new PSQLWarning(l_warnMsg)); break; protoConnection.setServerVersion(value); else if (name.equals("client_encoding")) protoConnection.setStandardConformingStrings(true); else if (value.equals("off")) protoConnection.setStandardConformingStrings(false); else throw new PSQLException(GT.tr("Protocol error. Session setup failed."), PSQLState.PROTOCOL_VIOLATION);