Allocate reuired memory, build socket and authorize the connection.
When this callback returns true, pollMessages will exit it's loop. Interceptor should set err to true if it has encountered some kind of error and wants it to be rethrown as PsqlClientException at the end of pollMessages call. errMsg should be appended with error description.
Open new socket and connect it to the same backend as this connection is bound to, send CancelRequest and close the temporary socket.
discard write buffer content
Flush writeBuffer into the socket. Blocks/yields (according to socket implementation).
Generate next connection-unique portal name.
Generate next connection-unique prepared statement name.
Read messages from the socket in loop until: 1). if finishOnError is set and ErrorResponse is received, function throws PsqlErrorResponseException immediately. 2). ReadyForQuery message is received. 3). interceptor delegate returns true. 4). NotificationResponse received and notificationCallback returned 'true'. Interceptor delegate is used to customize the logic. If the message is not ReadyForQuery, ErrorResponse or Notice\Notification, it is passed to interceptor.
Same as above, but throws only on serious protocol or socket-level errors.
Put Bind message into write buffer.
putBindMessage overload for parameterless portals
putBindMessage overload for already serialized parameters
put Close message into write buffer. closeWhat is 'S' for prepared statement and 'P' for portal.
put Close message into write buffer. closeWhat is 'S' for prepared statement and 'P' for portal.
non-zero maxRows will generate PortalSuspended messages, wich are currently not handled by dpeq commands
Quote: "The Flush message does not cause any specific output to be generated, but forces the backend to deliver any data pending in its output buffers. A Flush must be sent after any extended-query command except Sync, if the frontend wishes to examine the results of that command before issuing more commands. Without Flush, messages returned by the backend will be combined into the minimum possible number of packets to minimize network overhead."
put Query message (simple query protocol) into the write buffer
Put Sync message into write buffer. Usually you should call this after every portal execute message. Every postSimpleQuery or PSQLConnection.sync MUST be accompanied by getQueryResults call.
Read from socket to buffer buf exactly buf.length bytes. Blocks and throws.
read exactly one message from the socket
Reserve space in write buffer for length prefix and return struct that automatically fills it from current buffer offset position.
Save write buffer cursor in order to be able to restore it in case of errors. Use it to prevent sending junk to backend when something goes wrong during serialization or message creation.
Notify backend and close socket.
reads and discards messages from socket until all expected ReadyForQuery messages are received
extends writeBuffer if serializer 'm' is lacking space (returns -2)
write numeric type T to write buffer
Backend parameters this connection was constructed from
Cancellation secret. Used in CancelRequest message.
Number of ReadyForQuery messages that are yet to be received from the backend. May be useful for checking wether getQueryResults would block forever.
Connection is open when it is authorized and socket was alive last time it was checked.
Backend process ID. Used in CancelRequest message.
Socket getter.
Transaction status, reported by the last received ReadyForQuery message. For a new connection TransactionStatus.IDLE is returned.
backend params this connection was created with
NoticeResponse messages will be parsed and passed to this callback during 'pollMessages' call.
NotificationResponse messages will be parsed and passed to this callback during 'pollMessages' call. https://www.postgresql.org/docs/9.5/static/sql-notify.html
counters to generate unique prepared statement and portal ids
Connection object.