Marmos
v juptune
v asn1
v lang
v ast
v Classes
v Enums
v ir
v parser
v Enums
v Structs
v core
v crypto
v keyexchange
v memory
v data
v alphabet
v buffer
v json
v builder
v parser
v Enums
v Structs
v serialise
v Structs
v Templates
v pem
v Enums
v Structs

Functions PostgresProtocol.simpleQuery

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module juptune.postgres.protocol.connection;

Result simpleQuery(
    const char[] query, 
    Result function(
        ushort columnCount, 
        Result function(
            PostgresColumnDescription desc
        ) nextDescription
    ) onRowDescriptionOrNull, 
    Result function(
        ushort columnCount, 
        Result function(
            MemoryReader valueReader, 
            bool isNull
        ) nextData
    ) onDataRowOrNull
);

Documentation

Public API (querying)

Sends a simple Query message and calls the user-provided callbacks to handle any results.

Simple querying is useful for queries that have more than 1 statement and/or don't require the use of placeholders for their parameters.

Notes

All slices that are passed to onRowDescriptionOrNulland onDataRowNullare slices to the internal buffer of this struct, you must perform a full memory copy of these slices** if you wish to persist any of the data returned to you.

Failure to do this will lead to values being changed under your nose, and in the worst case memory corruption/security exploits.

Under most circumstances, when an error is produced it is safe to continue using an instance of this struct as it will attempt to self-correct. User code should use .isReadyToQueryto double check whether continued use is safe.

Assertions

This function can only be called once .connectsuccesfully executes.

If either onRowDescriptionOrNullor onDataRowOrNullare null, then they both must be null. You're either handling the results, or you're not.

Params

Throws

Anything that onRowDescriptionOrNulland onDataRowOrNullcan throw.

PostgresProtocolError.emptyQueryif the server returned an EmptyQuery response.

PostgresProtocolError.bufferTooSmallif the buffer would exceed PostgresProtocolConfig.maxBufferSizewhen reading or writing.

PostgresProtocolError.unexpectedMessageif an unexpected message was returned by the server.

PostgresProtocolError.invalidMessageif a message returned by the server is in some way malformed.

PostgresProtocolError.notEnoughBytesif the server didn't send enough bytes than expected (more likely a Juptune parsing bug).

PostgresProtocolError.errorResponseif the server returned an ErrorResponse message.

Anything that .putand .receivefor TcpSocketand TlsSocketcan throw.

Returns

An errorful Resultif something went wrong.