ProtocolConnectionImpl protoConnection = new ProtocolConnectionImpl(newStream, user, database, logger); readStartupMessages(newStream, protoConnection, logger);
private void receiveAsyncNotify() throws IOException { int pid = pgStream.ReceiveInteger4(); String msg = pgStream.ReceiveString(); if (logger.logDebug()) logger.debug(" <=BE AsyncNotify(pid=" + pid + ",msg=" + msg + ")"); protoConnection.addNotification(new org.postgresql.core.Notification(msg, pid)); }
public synchronized void processNotifies() throws SQLException { // 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 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 void runInitialQueries(ProtocolConnectionImpl protoConnection, Properties info, Logger logger) throws SQLException, IOException { byte[][] results = SetupQueryRunner.run(protoConnection, "set datestyle = 'ISO'; select version(), case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end", true); String rawDbVersion = protoConnection.getEncoding().decode(results[0]); StringTokenizer versionParts = new StringTokenizer(rawDbVersion); protoConnection.setServerVersion(dbVersion); protoConnection.setEncoding(Encoding.getDatabaseEncoding("UTF8")); String dbEncoding = (results[1] == null ? null : protoConnection.getEncoding().decode(results[1])); if (logger.logDebug()) protoConnection.setEncoding(Encoding.getJVMEncoding(charSet)); protoConnection.setEncoding(Encoding.getDatabaseEncoding(dbEncoding)); protoConnection.setEncoding(Encoding.defaultEncoding()); logger.debug("Connection encoding (using JVM's nomenclature): " + protoConnection.getEncoding()); String value = protoConnection.getEncoding().decode(results[0]); protoConnection.setStandardConformingStrings(value.equalsIgnoreCase("on")); protoConnection.setStandardConformingStrings(false); Utils.appendEscapedLiteral(sb, appName, protoConnection.getStandardConformingStrings()); sb.append("'"); SetupQueryRunner.run(protoConnection, sb.toString(), false);
if (protoConnection.getTransactionState() == ProtocolConnection.TRANSACTION_IDLE && (flags & QueryExecutor.QUERY_SUPPRESS_BEGIN) == 0) protoConnection.close(); handler.handleError(new PSQLException(GT.tr("An I/O error occured while sending to the backend."), PSQLState.CONNECTION_FAILURE, e));
if (logger.logDebug()) logger.debug(" <=BE BackendKeyData(pid=" + pid + ",ckey=" + ckey + ")"); protoConnection.setBackendKeyData(pid, ckey); break; if (logger.logDebug()) logger.debug(" <=BE NoticeResponse(" + warnMsg + ")"); protoConnection.addWarning(new SQLWarning(warnMsg)); break;
protoConnection.addWarning(receiveNotification()); break;
public synchronized byte[] fastpathCall(int fnid, ParameterList parameters, boolean suppressBegin) throws SQLException { if (protoConnection.getTransactionState() == ProtocolConnection.TRANSACTION_IDLE && !suppressBegin)
private void runInitialQueries(ProtocolConnectionImpl protoConnection, String charSet, Logger logger) throws SQLException, IOException { byte[][] results = runSetupQuery(protoConnection, "set datestyle = 'ISO'; select version(), case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end", true); String rawDbVersion = protoConnection.getEncoding().decode(results[0]); StringTokenizer versionParts = new StringTokenizer(rawDbVersion); protoConnection.setServerVersion(dbVersion); protoConnection.setEncoding(Encoding.getDatabaseEncoding("UNICODE")); String dbEncoding = (results[1] == null ? null : protoConnection.getEncoding().decode(results[1])); if (logger.logDebug()) protoConnection.setEncoding(Encoding.getJVMEncoding(charSet)); protoConnection.setEncoding(Encoding.getDatabaseEncoding(dbEncoding)); protoConnection.setEncoding(Encoding.defaultEncoding()); logger.debug("Connection encoding (using JVM's nomenclature): " + protoConnection.getEncoding()); String value = protoConnection.getEncoding().decode(results[0]); protoConnection.setStandardConformingStrings(value.equalsIgnoreCase("on")); protoConnection.setStandardConformingStrings(false);
if (logger.logDebug()) logger.debug(" <=BE BackendKeyData(pid=" + pid + ",ckey=" + ckey + ")"); protoConnection.setBackendKeyData(pid, ckey); break; if (logger.logDebug()) logger.debug(" <=BE NoticeResponse(" + warnMsg + ")"); protoConnection.addWarning(new SQLWarning(warnMsg)); break;
if (protoConnection.getTransactionState() == ProtocolConnection.TRANSACTION_IDLE && (flags & QueryExecutor.QUERY_SUPPRESS_BEGIN) == 0) protoConnection.close(); handler.handleError(new PSQLException(GT.tr("An I/O error occured while sending to the backend."), PSQLState.CONNECTION_FAILURE, e));
public void handleWarning(SQLWarning warning) { protoConnection.addWarning(warning); }
public synchronized byte[] fastpathCall(int fnid, ParameterList parameters, boolean suppressBegin) throws SQLException { if (protoConnection.getTransactionState() == ProtocolConnection.TRANSACTION_IDLE && !suppressBegin)
private void runInitialQueries(ProtocolConnectionImpl protoConnection, Properties info, Logger logger) throws SQLException, IOException { byte[][] results = SetupQueryRunner.run(protoConnection, "set datestyle = 'ISO'; select version(), case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else getdatabaseencoding() end", true); String rawDbVersion = protoConnection.getEncoding().decode(results[0]); StringTokenizer versionParts = new StringTokenizer(rawDbVersion); protoConnection.setServerVersion(dbVersion); protoConnection.setEncoding(Encoding.getDatabaseEncoding("UTF8")); String dbEncoding = (results[1] == null ? null : protoConnection.getEncoding().decode(results[1])); if (logger.logDebug()) protoConnection.setEncoding(Encoding.getJVMEncoding(charSet)); protoConnection.setEncoding(Encoding.getDatabaseEncoding(dbEncoding)); protoConnection.setEncoding(Encoding.defaultEncoding()); logger.debug("Connection encoding (using JVM's nomenclature): " + protoConnection.getEncoding()); String value = protoConnection.getEncoding().decode(results[0]); protoConnection.setStandardConformingStrings(value.equalsIgnoreCase("on")); protoConnection.setStandardConformingStrings(false); Utils.appendEscapedLiteral(sb, appName, protoConnection.getStandardConformingStrings()); sb.append("'"); SetupQueryRunner.run(protoConnection, sb.toString(), false);
public synchronized void processNotifies() throws SQLException { // 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 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); } }
if (logger.logDebug()) logger.debug(" <=BE BackendKeyData(pid=" + pid + ",ckey=" + ckey + ")"); protoConnection.setBackendKeyData(pid, ckey); break; if (logger.logDebug()) logger.debug(" <=BE NoticeResponse(" + warnMsg + ")"); protoConnection.addWarning(new SQLWarning(warnMsg)); break;
if (protoConnection.getTransactionState() == ProtocolConnection.TRANSACTION_IDLE && (flags & QueryExecutor.QUERY_SUPPRESS_BEGIN) == 0) protoConnection.close(); handler.handleError(new PSQLException(GT.tr("An I/O error occured while sending to the backend."), PSQLState.CONNECTION_FAILURE, e));
protoConnection.addWarning(receiveNotification()); break;
private void receiveAsyncNotify() throws IOException { int pid = pgStream.ReceiveInteger4(); String msg = pgStream.ReceiveString(); if (logger.logDebug()) logger.debug(" <=BE AsyncNotify(pid=" + pid + ",msg=" + msg + ")"); protoConnection.addNotification(new org.postgresql.core.Notification(msg, pid)); }
public synchronized byte[] fastpathCall(int fnid, ParameterList parameters, boolean suppressBegin) throws SQLException { if (protoConnection.getTransactionState() == ProtocolConnection.TRANSACTION_IDLE && !suppressBegin)