Codota Logo
PGStream.SendInteger4
Code IndexAdd Codota to your IDE (free)

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

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

  • Common ways to obtain PGStream
private void myMethod () {
PGStream p =
  • Codota IconString host;new PGStream(host, port)
  • Smart code suggestions by Codota
}
origin: postgresql/postgresql

void writeV2FastpathValue(int index, PGStream pgStream) throws IOException {
  --index;
  if (paramValues[index] instanceof StreamWrapper)
  {
    StreamWrapper wrapper = (StreamWrapper)paramValues[index];
    pgStream.SendInteger4(wrapper.getLength());
    copyStream(pgStream, wrapper);
  }
  else if (paramValues[index] instanceof byte[])
  {
    byte[] data = (byte[])paramValues[index];
    pgStream.SendInteger4(data.length);
    pgStream.Send(data);
  }
  else if (paramValues[index] instanceof String)
  {
    byte[] data = pgStream.getEncoding().encode((String)paramValues[index]);
    pgStream.SendInteger4(data.length);
    pgStream.Send(data);
  }
  else
  {
    throw new IllegalArgumentException("don't know how to stream parameter " + index);
  }
}
origin: postgresql/postgresql

private void sendExecute(SimpleQuery query, Portal portal, int limit) throws IOException {
  //
  // Send Execute.
  //
  if (logger.logDebug())
  {
    logger.debug(" FE=> Execute(portal=" + portal + ",limit=" + limit + ")");
  }
  byte[] encodedPortalName = (portal == null ? null : portal.getEncodedPortalName());
  int encodedSize = (encodedPortalName == null ? 0 : encodedPortalName.length);
  // Total size = 4 (size field) + 1 + N (source portal) + 4 (max rows)
  pgStream.SendChar('E');              // Execute
  pgStream.SendInteger4(4 + 1 + encodedSize + 4);  // message size
  if (encodedPortalName != null)
    pgStream.Send(encodedPortalName); // portal name
  pgStream.SendChar(0);                 // portal name terminator
  pgStream.SendInteger4(limit);       // row limit
  pendingExecuteQueue.add(new Object[] { query, portal });
}
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

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

private void sendDescribeStatement(SimpleQuery query, SimpleParameterList params, boolean describeOnly) throws IOException {
  // Send Statement Describe
  if (logger.logDebug())
  {
    logger.debug(" FE=> Describe(statement=" + query.getStatementName()+")");
  }
  byte[] encodedStatementName = query.getEncodedStatementName();
  // Total size = 4 (size field) + 1 (describe type, 'S') + N + 1 (portal name)
  int encodedSize = 4 + 1 + (encodedStatementName == null ? 0 : encodedStatementName.length) + 1;
  pgStream.SendChar('D');                     // Describe
  pgStream.SendInteger4(encodedSize);         // Message size
  pgStream.SendChar('S');                     // Describe (Statement);
  if (encodedStatementName != null)
    pgStream.Send(encodedStatementName);    // Statement name
  pgStream.SendChar(0);                       // end message
  pendingDescribeStatementQueue.add(new Object[]{query, params, new Boolean(describeOnly), query.getStatementName()});
  pendingDescribePortalQueue.add(query);
  query.setStatementDescribed(true);
  query.setPortalDescribed(true);
}
origin: postgresql/postgresql

pgStream.SendInteger4(4 + 4 + 2 + 2 * paramCount + 2 + encodedSize + 2);
pgStream.SendInteger4(fnid);
pgStream.SendInteger2(paramCount);
for (int i = 1; i <= paramCount; ++i)
    pgStream.SendInteger4( -1);
    pgStream.SendInteger4(params.getV3Length(i));   // Parameter size
    params.writeV3Value(i, pgStream);
origin: postgresql/postgresql

cancelStream.SendInteger4(16);
cancelStream.SendInteger2(1234);
cancelStream.SendInteger2(5678);
cancelStream.SendInteger4(cancelPid);
cancelStream.SendInteger4(cancelKey);
cancelStream.flush();
cancelStream.ReceiveEOF();
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

cancelStream.SendInteger4(16);
cancelStream.SendInteger2(1234);
cancelStream.SendInteger2(5678);
cancelStream.SendInteger4(cancelPid);
cancelStream.SendInteger4(cancelKey);
cancelStream.flush();
cancelStream.ReceiveEOF();
origin: postgresql/postgresql

private void sendDescribePortal(SimpleQuery query, Portal portal) throws IOException {
  //
  // Send Describe.
  //
  if (logger.logDebug())
  {
    logger.debug(" FE=> Describe(portal=" + portal + ")");
  }
  byte[] encodedPortalName = (portal == null ? null : portal.getEncodedPortalName());
  // Total size = 4 (size field) + 1 (describe type, 'P') + N + 1 (portal name)
  int encodedSize = 4 + 1 + (encodedPortalName == null ? 0 : encodedPortalName.length) + 1;
  pgStream.SendChar('D');               // Describe
  pgStream.SendInteger4(encodedSize); // message size
  pgStream.SendChar('P');               // Describe (Portal)
  if (encodedPortalName != null)
    pgStream.Send(encodedPortalName); // portal name to close
  pgStream.SendChar(0);                 // end of portal name
  pendingDescribePortalQueue.add(query);
  query.setPortalDescribed(true);
}
origin: postgresql/postgresql

pgStream.SendInteger4(length);
pgStream.SendInteger2(3); // protocol major
pgStream.SendInteger2(0); // protocol minor
origin: postgresql/postgresql

private void sendCloseStatement(String statementName) throws IOException {
  //
  // Send Close.
  //
  if (logger.logDebug())
  {
    logger.debug(" FE=> CloseStatement(" + statementName + ")");
  }
  byte[] encodedStatementName = Utils.encodeUTF8(statementName);
  // Total size = 4 (size field) + 1 (close type, 'S') + N + 1 (statement name)
  pgStream.SendChar('C');              // Close
  pgStream.SendInteger4(4 + 1 + encodedStatementName.length + 1);  // message size
  pgStream.SendChar('S');              // Close (Statement)
  pgStream.Send(encodedStatementName); // statement to close
  pgStream.SendChar(0);                // statement name terminator
}
origin: postgresql/postgresql

private void sendClosePortal(String portalName) throws IOException {
  //
  // Send Close.
  //
  if (logger.logDebug())
  {
    logger.debug(" FE=> ClosePortal(" + portalName + ")");
  }
  byte[] encodedPortalName = (portalName == null ? null : Utils.encodeUTF8(portalName));
  int encodedSize = (encodedPortalName == null ? 0 : encodedPortalName.length);
  // Total size = 4 (size field) + 1 (close type, 'P') + 1 + N (portal name)
  pgStream.SendChar('C');              // Close
  pgStream.SendInteger4(4 + 1 + 1 + encodedSize);  // message size
  pgStream.SendChar('P');              // Close (Portal)
  if (encodedPortalName != null)
    pgStream.Send(encodedPortalName);
  pgStream.SendChar(0);                // unnamed portal
}
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: postgresql/postgresql

/**
 * Sends data during a live COPY IN operation. Only unlocks the connection if server
 * suddenly returns CommandComplete, which should not happen
 * @param op the CopyIn operation presumably currently holding lock on this connection
 * @param data bytes to send
 * @param off index of first byte to send (usually 0)
 * @param siz number of bytes to send (usually data.length)
 * @throws SQLException on failure
 */
public synchronized void writeToCopy(CopyInImpl op, byte[] data, int off, int siz) throws SQLException {
  if(!hasLock(op))
    throw new PSQLException(GT.tr("Tried to write to an inactive copy operation"), PSQLState.OBJECT_NOT_IN_STATE);
  if (logger.logDebug())
    logger.debug(" FE=> CopyData(" + siz + ")");
  try {
    pgStream.SendChar('d');
    pgStream.SendInteger4(siz + 4);
    pgStream.Send(data, off, siz);
    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: 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.SendInteger4(5 + msg.length);
pgStream.Send(msg);
pgStream.SendChar(0);
origin: postgresql/postgresql

pgStream.SendInteger4(8);
pgStream.SendInteger2(1234);
pgStream.SendInteger2(5679);
origin: postgresql/postgresql

pgStream.SendInteger4(8);
pgStream.SendInteger2(1234);
pgStream.SendInteger2(5679);
org.postgresql.corePGStreamSendInteger4

Javadoc

Sends a 4-byte integer to the back end

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.
  • flush
    Flush any pending output to the backend.
  • 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
  • ReceiveEOF,
  • ReceiveInteger2,
  • ReceiveInteger4,
  • ReceiveString,
  • ReceiveTupleV2,
  • ReceiveTupleV3,
  • Send,
  • SendChar,
  • SendInteger2

Popular in Java

  • Start an intent from android
  • getSupportFragmentManager (FragmentActivity)
  • getExternalFilesDir (Context)
  • setContentView (Activity)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • DataSource (javax.sql)
    A factory for connections to the physical data source that this DataSource object represents. An alt
  • JComboBox (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now