Tabnine Logo
PGStream.flush
Code IndexAdd Tabnine to your IDE (free)

How to use
flush
method
in
org.postgresql.core.PGStream

Best Java code snippets using org.postgresql.core.PGStream.flush (Showing top 20 results out of 315)

origin: org.postgresql/postgresql

@Override
public void close() {
 if (closed) {
  return;
 }
 try {
  LOGGER.log(Level.FINEST, " FE=> Terminate");
  sendCloseMessage();
  pgStream.flush();
  pgStream.close();
 } catch (IOException ioe) {
  LOGGER.log(Level.FINEST, "Discarding IOException on close:", ioe);
 }
 closed = true;
}
origin: org.postgresql/postgresql

private void sendSync() throws IOException {
 LOGGER.log(Level.FINEST, " FE=> Sync");
 pgStream.sendChar('S'); // Sync
 pgStream.sendInteger4(4); // Length
 pgStream.flush();
 // Below "add queues" are likely not required at all
 pendingExecuteQueue.add(new ExecuteRequest(sync, null, true));
 pendingDescribePortalQueue.add(sync);
}
origin: org.postgresql/postgresql

pgStream.flush();
origin: org.postgresql/postgresql

private void sendAuthenticationMessage(int bodyLength, BodySender bodySender)
  throws IOException {
 pgStream.sendChar('p');
 pgStream.sendInteger4(Integer.BYTES + bodyLength);
 bodySender.sendBody(pgStream);
 pgStream.flush();
}
origin: org.postgresql/postgresql

private void sendSSPIResponse(byte[] outToken) throws IOException {
 /*
  * The sspiContext now contains a token we can send to the server to start the handshake. Send a
  * 'password' message containing the required data; the server knows we're doing SSPI
  * negotiation and will deal with it appropriately.
  */
 pgStream.sendChar('p');
 pgStream.sendInteger4(4 + outToken.length);
 pgStream.send(outToken);
 pgStream.flush();
}
origin: org.postgresql/postgresql

private void sendSimpleQuery(SimpleQuery query, SimpleParameterList params) throws IOException {
 String nativeSql = query.toString(params);
 LOGGER.log(Level.FINEST, " FE=> SimpleQuery(query=\"{0}\")", nativeSql);
 Encoding encoding = pgStream.getEncoding();
 byte[] encoded = encoding.encode(nativeSql);
 pgStream.sendChar('Q');
 pgStream.sendInteger4(encoded.length + 4 + 1);
 pgStream.send(encoded);
 pgStream.sendChar(0);
 pgStream.flush();
 pendingExecuteQueue.add(new ExecuteRequest(query, null, true));
 pendingDescribePortalQueue.add(query);
}
origin: postgresql/postgresql

private void sendSync() throws IOException {
  if (logger.logDebug())
    logger.debug(" FE=> Sync");
  pgStream.SendChar('S');     // Sync
  pgStream.SendInteger4(4); // Length
  pgStream.flush();
}
origin: postgresql/postgresql

protected void sendQuery(V2Query query, SimpleParameterList params, String queryPrefix) throws IOException {
  if (logger.logDebug())
    logger.debug(" FE=> Query(\"" + (queryPrefix == null ? "" : queryPrefix) + query.toString(params) + "\")");
  pgStream.SendChar('Q');
  Writer encodingWriter = pgStream.getEncodingWriter();
  if (queryPrefix != null)
    encodingWriter.write(queryPrefix);
  String[] fragments = query.getFragments();
  for (int i = 0 ; i < fragments.length; ++i)
  {
    encodingWriter.write(fragments[i]);
    if (i < params.getParameterCount())
      params.writeV2Value(i + 1, encodingWriter);
  }
  encodingWriter.write(0);
  pgStream.flush();
}
origin: postgresql/postgresql

public synchronized void flushCopy(CopyInImpl op) throws SQLException {
  if(!hasLock(op))
    throw new PSQLException(GT.tr("Tried to write to an inactive copy operation"), PSQLState.OBJECT_NOT_IN_STATE);
  try {
    pgStream.flush();
    processCopyResults(op, false); // collect any pending notifications without blocking
  } catch(IOException ioe) {
    throw new PSQLException(GT.tr("Database connection failed when writing to copy"), PSQLState.CONNECTION_FAILURE, ioe);
  }
}
origin: org.postgresql/postgresql

public synchronized void flushCopy(CopyOperationImpl op) throws SQLException {
 if (!hasLock(op)) {
  throw new PSQLException(GT.tr("Tried to write to an inactive copy operation"),
    PSQLState.OBJECT_NOT_IN_STATE);
 }
 try {
  pgStream.flush();
  processCopyResults(op, false); // collect any pending notifications without blocking
 } catch (IOException ioe) {
  throw new PSQLException(GT.tr("Database connection failed when writing to copy"),
    PSQLState.CONNECTION_FAILURE, ioe);
 }
}
origin: org.postgresql/postgresql

 cancelStream.sendInteger4(cancelPid);
 cancelStream.sendInteger4(cancelKey);
 cancelStream.flush();
 cancelStream.receiveEOF();
} catch (IOException e) {
origin: postgresql/postgresql

private void sendStartupPacket(PGStream pgStream, String user, String database, Logger logger) throws IOException {
  //  4: total size including self
  //  2: protocol major
  //  2: protocol minor
  // 64: database name
  // 32: user name
  // 64: options
  // 64: unused
  // 64: tty
  if (logger.logDebug())
    logger.debug(" FE=> StartupPacket(user=" + user + ",database=" + database + ")");
  pgStream.SendInteger4(4 + 4 + 64 + 32 + 64 + 64 + 64);
  pgStream.SendInteger2(2); // protocol major
  pgStream.SendInteger2(0); // protocol minor
  pgStream.Send(database.getBytes("UTF-8"), 64);
  pgStream.Send(user.getBytes("UTF-8"), 32);
  pgStream.Send(new byte[64]);  // options
  pgStream.Send(new byte[64]);  // unused
  pgStream.Send(new byte[64]);  // tty
  pgStream.flush();
}
origin: postgresql/postgresql

public void close() {
  if (closed)
    return ;
  try
  {
    if (logger.logDebug())
      logger.debug(" FE=> Terminate");
    pgStream.SendChar('X');
    pgStream.flush();
    pgStream.close();
  }
  catch (IOException ioe)
  {
    // Forget it.
    if (logger.logDebug())
      logger.debug("Discarding IOException on close:", ioe);
  }
  closed = true;
}
origin: postgresql/postgresql

private void sendFastpathCall(int fnid, FastpathParameterList params) throws IOException {
  // Send call.
  int count = params.getParameterCount();
  if (logger.logDebug())
    logger.debug(" FE=> FastpathCall(fnid=" + fnid + ",paramCount=" + count + ")");
  pgStream.SendChar('F');
  pgStream.SendChar(0);
  pgStream.SendInteger4(fnid);
  pgStream.SendInteger4(count);
  for (int i = 1; i <= count; ++i)
    params.writeV2FastpathValue(i, pgStream);
  pgStream.flush();
}
origin: postgresql/postgresql

public void close() {
  if (closed)
    return ;
  try
  {
    if (logger.logDebug())
      logger.debug(" FE=> Terminate");
    pgStream.SendChar('X');
    pgStream.SendInteger4(4);
    pgStream.flush();
    pgStream.close();
  }
  catch (IOException ioe)
  {
    // Forget it.
    if (logger.logDebug())
      logger.debug("Discarding IOException on close:", ioe);
  }
  closed = true;
}
origin: org.postgresql/postgresql

/**
 * Finishes writing to copy and unlocks connection.
 *
 * @param op the copy operation presumably currently holding lock on this connection
 * @return number of rows updated for server versions 8.2 or newer
 * @throws SQLException on failure
 */
public synchronized long endCopy(CopyOperationImpl op) throws SQLException {
 if (!hasLock(op)) {
  throw new PSQLException(GT.tr("Tried to end inactive copy"), PSQLState.OBJECT_NOT_IN_STATE);
 }
 try {
  LOGGER.log(Level.FINEST, " FE=> CopyDone");
  pgStream.sendChar('c'); // CopyDone
  pgStream.sendInteger4(4);
  pgStream.flush();
  do {
   processCopyResults(op, true);
  } while (hasLock(op));
  return op.getHandledRowCount();
 } catch (IOException ioe) {
  throw new PSQLException(GT.tr("Database connection failed when ending copy"),
    PSQLState.CONNECTION_FAILURE, ioe);
 }
}
origin: org.postgresql/postgresql

/**
 * Sends given query to BE to start, initialize and lock connection for a CopyOperation.
 *
 * @param sql COPY FROM STDIN / COPY TO STDOUT statement
 * @return CopyIn or CopyOut operation object
 * @throws SQLException on failure
 */
public synchronized CopyOperation startCopy(String sql, boolean suppressBegin)
  throws SQLException {
 waitOnLock();
 if (!suppressBegin) {
  doSubprotocolBegin();
 }
 byte[] buf = Utils.encodeUTF8(sql);
 try {
  LOGGER.log(Level.FINEST, " FE=> Query(CopyStart)");
  pgStream.sendChar('Q');
  pgStream.sendInteger4(buf.length + 4 + 1);
  pgStream.send(buf);
  pgStream.sendChar(0);
  pgStream.flush();
  return processCopyResults(null, true);
  // expect a CopyInResponse or CopyOutResponse to our query above
 } catch (IOException ioe) {
  throw new PSQLException(GT.tr("Database connection failed when starting copy"),
    PSQLState.CONNECTION_FAILURE, ioe);
 }
}
origin: postgresql/postgresql

/**
 * Finishes writing to copy and unlocks connection
 * @param op the copy operation presumably currently holding lock on this connection
 * @return number of rows updated for server versions 8.2 or newer
 * @throws SQLException on failure
 */
public synchronized long endCopy(CopyInImpl op) throws SQLException {
  if(!hasLock(op))
      throw new PSQLException(GT.tr("Tried to end inactive copy"), PSQLState.OBJECT_NOT_IN_STATE);
  try {
    if (logger.logDebug())
      logger.debug(" FE=> CopyDone");
    pgStream.SendChar('c'); // CopyDone
    pgStream.SendInteger4(4);
    pgStream.flush();
    processCopyResults(op, true);
    return op.getHandledRowCount();
  } catch(IOException ioe) {
    throw new PSQLException(GT.tr("Database connection failed when ending copy"), PSQLState.CONNECTION_FAILURE, ioe);
  }
}
origin: postgresql/postgresql

/**
 * Sends given query to BE to start, initialize and lock connection for a CopyOperation.
 * @param sql COPY FROM STDIN / COPY TO STDOUT statement
 * @return CopyIn or CopyOut operation object
 * @throws SQLException on failure
 */
public synchronized CopyOperation startCopy(String sql, boolean suppressBegin) throws SQLException {
  waitOnLock();
  if (!suppressBegin) {
    doSubprotocolBegin();
  }
  byte buf[] = Utils.encodeUTF8(sql);
  try {
    if (logger.logDebug())
      logger.debug(" FE=> Query(CopyStart)");
    pgStream.SendChar('Q');
    pgStream.SendInteger4(buf.length + 4 + 1);
    pgStream.Send(buf);
    pgStream.SendChar(0);
    pgStream.flush();
    return processCopyResults(null, true); // expect a CopyInResponse or CopyOutResponse to our query above
  } catch(IOException ioe) {
    throw new PSQLException(GT.tr("Database connection failed when starting copy"), PSQLState.CONNECTION_FAILURE, ioe);
  }
}
origin: postgresql/postgresql

pgStream.SendInteger2(1234);
pgStream.SendInteger2(5679);
pgStream.flush();
org.postgresql.corePGStreamflush

Javadoc

Flush any pending output to the backend.

Popular methods of PGStream

  • <init>
    Constructor: Connect to the PostgreSQL back end and return a stream connection.
  • changeSocket
    Switch this stream to using a new socket. Any existing socket is not closed; it's assumed that we ar
  • close
    Closes the connection.
  • getEncoding
  • getSocket
  • hasMessagePending
    Check for pending backend messages without blocking. Might return false when there actually are mess
  • setEncoding
    Change the encoding used by this connection.
  • Receive
    Reads in a given number of bytes from the backend
  • ReceiveChar
    Receives a single character from the backend
  • ReceiveEOF
    Consume an expected EOF from the backend
  • ReceiveInteger2
    Receives a two byte integer from the backend
  • ReceiveInteger4
    Receives a four byte integer from the backend
  • ReceiveInteger2,
  • ReceiveInteger4,
  • ReceiveString,
  • ReceiveTupleV2,
  • ReceiveTupleV3,
  • Send,
  • SendChar,
  • SendInteger2,
  • SendInteger4

Popular in Java

  • Updating database using SQL prepared statement
  • scheduleAtFixedRate (Timer)
  • getExternalFilesDir (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • Path (java.nio.file)
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • Notification (javax.management)
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now