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

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

Best Java code snippets using org.postgresql.core.PGStream.Send (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

/**
 * Send a fixed-size array of bytes to the backend. If buf.length < siz,
 * pad with zeros. If buf.lengh > siz, truncate the array.
 *
 * @param buf the array of bytes to be sent
 * @param siz the number of bytes to be sent
 * @exception IOException if an I/O error occurs
 */
public void Send(byte buf[], int siz) throws IOException
{
  Send(buf, 0, siz);
}
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 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

for (int i = 0; i < encodedParams.length; ++i)
  pgStream.Send(encodedParams[i]);
  pgStream.SendChar(0);
origin: postgresql/postgresql

private void copyStream(PGStream pgStream, StreamWrapper wrapper) throws IOException {
  byte[] rawData = wrapper.getBytes();
  if (rawData != null)
  {
    pgStream.Send(rawData, wrapper.getOffset(), wrapper.getLength());
    return ;
  }
  pgStream.SendStream(wrapper.getStream(), wrapper.getLength());
}
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 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

pgStream.SendInteger4((int)encodedSize);      // Message size
if (encodedPortalName != null)
  pgStream.Send(encodedPortalName);    // Destination portal name.
pgStream.SendChar(0);                    // End of portal name.
if (encodedStatementName != null)
  pgStream.Send(encodedStatementName); // Source statement name.
pgStream.SendChar(0);                    // End of statement name.
origin: postgresql/postgresql

private static void streamBytea(PGStream pgStream, StreamWrapper wrapper) throws IOException {
  byte[] rawData = wrapper.getBytes();
  if (rawData != null)
  {
    pgStream.Send(rawData, wrapper.getOffset(), wrapper.getLength());
    return ;
  }
  pgStream.SendStream(wrapper.getStream(), wrapper.getLength());
}
origin: postgresql/postgresql

void writeV3Value(int index, PGStream pgStream) throws IOException {
  --index;
  // Null?
  if (paramValues[index] == NULL_OBJECT)
    throw new IllegalArgumentException("can't writeV3Value() on a null parameter");
  // Directly encoded?
  if (paramValues[index] instanceof byte[])
  {
    pgStream.Send((byte[])paramValues[index]);
    return ;
  }
  // Binary-format bytea?
  if (paramValues[index] instanceof StreamWrapper)
  {
    streamBytea(pgStream, (StreamWrapper)paramValues[index]);
    return ;
  }
  // Encoded string.
  if (encoded[index] == null)
    encoded[index] = Utils.encodeUTF8((String)paramValues[index]);
  pgStream.Send(encoded[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

pgStream.SendInteger4(encodedSize);
if (encodedStatementName != null)
  pgStream.Send(encodedStatementName);
pgStream.SendChar(0);   // End of statement name
for (int i = 0; i < parts.length; ++i)
  pgStream.Send(parts[i]);
origin: postgresql/postgresql

    Send(streamBuffer, count);
    remaining -= count;
    count = (remaining > streamBuffer.length ? streamBuffer.length : remaining);
Send(streamBuffer, readCount);
remaining -= readCount;
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

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

/**
 * 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

/**
 * 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

pgStream.SendChar('f'); // CopyFail
pgStream.SendInteger4(5 + msg.length);
pgStream.Send(msg);
pgStream.SendChar(0);
pgStream.flush();
origin: postgresql/postgresql

pgStream.Send(encodedResult);
pgStream.SendChar(0);
pgStream.flush();
pgStream.Send(digest);
pgStream.SendChar(0);
pgStream.flush();
pgStream.Send(encodedPassword);
pgStream.SendChar(0);
pgStream.flush();
origin: postgresql/postgresql

pgStream.Send(outToken);
pgStream.flush();
org.postgresql.corePGStreamSend

Javadoc

Send an array of bytes 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.
  • 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,
  • SendChar,
  • SendInteger2,
  • SendInteger4

Popular in Java

  • Reading from database using SQL prepared statement
  • addToBackStack (FragmentTransaction)
  • getExternalFilesDir (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • BufferedInputStream (java.io)
    Wraps an existing InputStream and buffers the input. Expensive interaction with the underlying input
  • Path (java.nio.file)
  • Timer (java.util)
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be s
  • JLabel (javax.swing)
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
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