Wrapper around the raw connection to the server that implements some basic primitives (reading/writing formatted data, doing string encoding, etc).
In general, instances of PGStream are not threadsafe; the caller must ensure that only one thread at a time is accessing a particular PGStream instance.
| Modifier and Type | Field and Description |
|---|---|
| private Socket | |
| private Encoding | |
| private Writer | |
| pack-priv boolean | |
| private final HostSpec | |
| private final byte[] | |
| private final byte[] | |
| private long | |
| private int | |
| private int | |
| private long | |
| private VisibleBufferedInputStream | |
| private OutputStream | |
| private long | |
| private final SocketFactory | |
| private @Nullable byte[] |
| Access | Constructor and Description |
|---|---|
| public | PGStream(SocketFactory
socket factory to use when creating sockets socketFactory, HostSpec the host and port to connect to hostSpec, int timeout in milliseconds, or 0 if no timeout set timeout)Constructor: Connect to the PostgreSQL back end and return a stream connection. |
| public | |
| public | PGStream(SocketFactory
socket factory socketFactory, HostSpec the host and port to connect to hostSpec)
Deprecated
use
PGStream(SocketFactory, org.
Constructor: Connect to the PostgreSQL back end and return a stream connection. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | |
| public void | |
| private Socket | |
| public void | |
| public Encoding | |
| public Writer | Returns: the shared Writer instanceGet a Writer instance that encodes directly onto the underlying stream. |
| public HostSpec | |
| public long | |
| public int | |
| public int | |
| public Socket | |
| public SocketFactory | |
| public boolean | Returns: true if there is a pending backend messageCheck for pending backend messages without blocking. |
| private void | |
| public boolean | |
| public boolean | |
| public int | Returns: the character receivedReceives a single character from the backend, without advancing the current protocol stream position. |
| public byte[] | Returns: array of bytes receivednumber of bytes to read siz)Reads in a given number of bytes from the backend. |
| public void | receive(byte[]
buffer to store result buf, int offset in buffer off, int number of bytes to read siz)Reads in a given number of bytes from the backend. |
| public String | Returns: string from back endReceives a null-terminated string from the backend and attempts to decode to a
|
| public String | Returns: string from back endReceives a null-terminated string from the backend and attempts to decode to a
|
| public int | |
| public void | |
| public EncodingPredictor. | Returns: the decoded stringthe length of the string to receive, in bytes. len)Receives a fixed-size string from the backend, and tries to avoid "UTF-8 decode failed" errors. |
| public int | Returns: the integer received from the backendReceives a two byte integer from the backend. |
| public int | Returns: the integer received from the backendReceives a four byte integer from the backend. |
| public String | Returns: the decoded stringthe length of the string to receive, in bytes. len)Receives a fixed-size string from the backend. |
| public String | |
| public Tuple | |
| public void | |
| public void | send(byte[]
the array of bytes to be sent buf, int the number of bytes to be sent siz)Send a fixed-size array of bytes to the backend. |
| public void | send(byte[]
the array of bytes to be sent buf, int offset in the array to start sending from off, int the number of bytes to be sent siz)Send a fixed-size array of bytes to the backend. |
| public void | send(ByteStreamWriter
the stream writer to invoke to send the bytes writer)Send a fixed-size array of bytes to the backend. |
| public void | |
| public void | |
| public void | |
| public void | sendStream(InputStream
the stream to read data from inStream, int the number of bytes to copy remaining)Copy data from an input stream to the connection. |
| public void | |
| public void | setMaxResultBuffer(@Nullable String
value of new max result buffer as string (cause we can expect % or chars to use
multiplier) value)Method to set MaxResultBuffer inside PGStream. |
| public void | setMaxRowSizeBytes(int
new value to be set as maxRowSizeBytes rowSizeBytes)The idea behind this method is to keep in maxRowSize the size of biggest read data row. |
| public void | |
| public void | |
| public void | |
| public void |
| connection | back to summary |
|---|---|
| private Socket connection | |
| encoding | back to summary |
|---|---|
| private Encoding encoding | |
| encodingWriter | back to summary |
|---|---|
| private Writer encodingWriter | |
| gssEncrypted | back to summary |
|---|---|
| pack-priv boolean gssEncrypted | |
| hostSpec | back to summary |
|---|---|
| private final HostSpec hostSpec | |
| int2Buf | back to summary |
|---|---|
| private final byte[] int2Buf | |
| int4Buf | back to summary |
|---|---|
| private final byte[] int4Buf | |
| maxResultBuffer | back to summary |
|---|---|
| private long maxResultBuffer | |
| maxRowSizeBytes | back to summary |
|---|---|
| private int maxRowSizeBytes | |
| minStreamAvailableCheckDelay | back to summary |
|---|---|
| private int minStreamAvailableCheckDelay | |
| nextStreamAvailableCheckTime | back to summary |
|---|---|
| private long nextStreamAvailableCheckTime | |
| pgInput | back to summary |
|---|---|
| private VisibleBufferedInputStream pgInput | |
| pgOutput | back to summary |
|---|---|
| private OutputStream pgOutput | |
| resultBufferByteCount | back to summary |
|---|---|
| private long resultBufferByteCount | |
| socketFactory | back to summary |
|---|---|
| private final SocketFactory socketFactory | |
| streamBuffer | back to summary |
|---|---|
| private @Nullable byte[] streamBuffer | |
| PGStream | back to summary |
|---|---|
| public PGStream(SocketFactory socketFactory, HostSpec hostSpec, int timeout) throws IOException Constructor: Connect to the PostgreSQL back end and return a stream connection.
| |
| PGStream | back to summary |
|---|---|
public PGStream(PGStream pgStream, int timeout) throws IOException
| |
| PGStream | back to summary |
|---|---|
| public PGStream(SocketFactory socketFactory, HostSpec hostSpec) throws IOException
Deprecated use Constructor: Connect to the PostgreSQL back end and return a stream connection.
| |
| changeSocket | back to summary |
|---|---|
| public void changeSocket(Socket socket) throws IOException Switch this stream to using a new socket. Any existing socket is not closed; it's assumed that we are changing to a new socket that delegates to the original socket (e.g. SSL).
| |
| clearMaxRowSizeBytes | back to summary |
|---|---|
| public void clearMaxRowSizeBytes() Clear value of max row size noticed so far. | |
| clearResultBufferCount | back to summary |
|---|---|
| public void clearResultBufferCount() Clear count of byte buffer. | |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements java. Closes the connection.
| |
| createSocket | back to summary |
|---|---|
| private Socket createSocket(int timeout) throws IOException | |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Implements java. Flush any pending output to the backend.
| |
| getEncoding | back to summary |
|---|---|
| public Encoding getEncoding() | |
| getEncodingWriter | back to summary |
|---|---|
| public Writer getEncodingWriter() throws IOException Get a Writer instance that encodes directly onto the underlying stream. The returned Writer should not be closed, as it's a shared object. Writer.flush needs to be
called when switching between use of the Writer and use of the PGStream write methods, but it
won't actually flush output all the way out -- call
| |
| getHostSpec | back to summary |
|---|---|
| public HostSpec getHostSpec() | |
| getMaxResultBuffer | back to summary |
|---|---|
| public long getMaxResultBuffer() Get MaxResultBuffer from PGStream.
| |
| getMaxRowSizeBytes | back to summary |
|---|---|
| public int getMaxRowSizeBytes() Get actual max row size noticed so far.
| |
| getNetworkTimeout | back to summary |
|---|---|
| public int getNetworkTimeout() throws IOException | |
| getSocket | back to summary |
|---|---|
| public Socket getSocket() | |
| getSocketFactory | back to summary |
|---|---|
| public SocketFactory getSocketFactory() | |
| hasMessagePending | back to summary |
|---|---|
| public boolean hasMessagePending() throws IOException Check for pending backend messages without blocking. Might return false when there actually are messages waiting, depending on the characteristics of the underlying socket. This is used to detect asynchronous notifies from the backend, when available.
| |
| increaseByteCounter | back to summary |
|---|---|
| private void increaseByteCounter(long value) throws SQLException Increase actual count of buffer. If buffer count is bigger than max result buffer limit, then gonna return an exception.
| |
| isClosed | back to summary |
|---|---|
| public boolean isClosed() | |
| isGssEncrypted | back to summary |
|---|---|
| public boolean isGssEncrypted() | |
| peekChar | back to summary |
|---|---|
| public int peekChar() throws IOException Receives a single character from the backend, without advancing the current protocol stream position.
| |
| receive | back to summary |
|---|---|
| public byte[] receive(int siz) throws IOException Reads in a given number of bytes from the backend.
| |
| receive | back to summary |
|---|---|
| public void receive(byte[] buf, int off, int siz) throws IOException Reads in a given number of bytes from the backend.
| |
| receiveCanonicalString | back to summary |
|---|---|
| public String receiveCanonicalString() throws IOException Receives a null-terminated string from the backend and attempts to decode to a
| |
| receiveCanonicalStringIfPresent | back to summary |
|---|---|
| public String receiveCanonicalStringIfPresent() throws IOException Receives a null-terminated string from the backend and attempts to decode to a
| |
| receiveChar | back to summary |
|---|---|
| public int receiveChar() throws IOException Receives a single character from the backend.
| |
| receiveEOF | back to summary |
|---|---|
| public void receiveEOF() throws SQLException, IOException Consume an expected EOF from the backend.
| |
| receiveErrorString | back to summary |
|---|---|
| public EncodingPredictor. Receives a fixed-size string from the backend, and tries to avoid "UTF-8 decode failed" errors.
| |
| receiveInteger2 | back to summary |
|---|---|
| public int receiveInteger2() throws IOException Receives a two byte integer from the backend.
| |
| receiveInteger4 | back to summary |
|---|---|
| public int receiveInteger4() throws IOException Receives a four byte integer from the backend.
| |
| receiveString | back to summary |
|---|---|
| public String receiveString(int len) throws IOException Receives a fixed-size string from the backend.
| |
| receiveString | back to summary |
|---|---|
| public String receiveString() throws IOException Receives a null-terminated string from the backend. If we don't see a null, then we assume something has gone wrong.
| |
| receiveTupleV3 | back to summary |
|---|---|
| public Tuple receiveTupleV3() throws IOException, OutOfMemoryError, SQLException Read a tuple from the back end. A tuple is a two dimensional array of bytes. This variant reads the V3 protocol's tuple representation.
| |
| send | back to summary |
|---|---|
| public void send(byte[] buf) throws IOException Send an array of bytes to the backend.
| |
| send | back to summary |
|---|---|
| public void send(byte[] buf, int siz) throws IOException Send a fixed-size array of bytes to the backend. If
| |
| send | back to summary |
|---|---|
| public void send(byte[] buf, int off, int siz) throws IOException Send a fixed-size array of bytes to the backend. If
| |
| send | back to summary |
|---|---|
| public void send(ByteStreamWriter writer) throws IOException Send a fixed-size array of bytes to the backend. If
| |
| sendChar | back to summary |
|---|---|
| public void sendChar(int val) throws IOException Sends a single character to the back end.
| |
| sendInteger2 | back to summary |
|---|---|
| public void sendInteger2(int val) throws IOException Sends a 2-byte integer (short) to the back end.
| |
| sendInteger4 | back to summary |
|---|---|
| public void sendInteger4(int val) throws IOException Sends a 4-byte integer to the back end.
| |
| sendStream | back to summary |
|---|---|
| public void sendStream(InputStream inStream, int remaining) throws IOException Copy data from an input stream to the connection.
| |
| setEncoding | back to summary |
|---|---|
| public void setEncoding(Encoding encoding) throws IOException Change the encoding used by this connection.
| |
| setMaxResultBuffer | back to summary |
|---|---|
| public void setMaxResultBuffer(@Nullable String value) throws PSQLException Method to set MaxResultBuffer inside PGStream.
| |
| setMaxRowSizeBytes | back to summary |
|---|---|
| public void setMaxRowSizeBytes(int rowSizeBytes) The idea behind this method is to keep in maxRowSize the size of biggest read data row. As there may be many data rows send after each other for a query, then value in maxRowSize would contain value noticed so far, because next data rows and their sizes are not read for that moment. We want it increasing, because the size of the biggest among data rows will be used during computing new adaptive fetch size for the query.
| |
| setMinStreamAvailableCheckDelay | back to summary |
|---|---|
| public void setMinStreamAvailableCheckDelay(int delay) | |
| setNetworkTimeout | back to summary |
|---|---|
| public void setNetworkTimeout(int milliseconds) throws IOException | |
| setSecContext | back to summary |
|---|---|
| public void setSecContext(GSSContext secContext) | |
| skip | back to summary |
|---|---|
| public void skip(int size) throws IOException | |