30#include "Descriptor.h"
60 NONE = fb::IBatch::BLOB_NONE,
70 ID_USER = fb::IBatch::BLOB_ID_USER,
75 STREAM = fb::IBatch::BLOB_STREAM,
117 recordCounts = value;
126 return bufferBytesSize;
134 bufferBytesSize = value;
160 return detailedErrors;
168 detailedErrors = value;
173 bool multiError =
false;
174 bool recordCounts =
false;
175 std::optional<unsigned> bufferBytesSize;
177 unsigned detailedErrors = 64;
242 std::optional<unsigned>
findError(
unsigned pos);
249 std::vector<std::intptr_t>
getStatus(
unsigned pos);
254 impl::StatusWrapper statusWrapper;
334 return handle !=
nullptr;
347 void add(
unsigned count,
const void* inBuffer);
415 BatchCompletionState
execute();
442 std::vector<std::uint8_t> buildParametersBlock(Client& client,
const BatchOptions& options);
443 std::vector<std::uint8_t> prepareBpb(Client& client,
const BlobOptions& bpb);
444 void buildInputDescriptors();
448 Transaction* transaction;
449 Statement* statement =
nullptr;
450 FbUniquePtr<fb::IStatus> status;
451 impl::StatusWrapper statusWrapper;
452 FbRef<fb::IBatch> handle;
453 std::vector<Descriptor> inputDescriptors;
Represents a connection to a Firebird database.
Wraps IBatchCompletionState to provide RAII-safe access to batch execution results.
BatchCompletionState & operator=(BatchCompletionState &&)=delete
Move assignment is not supported.
BatchCompletionState & operator=(const BatchCompletionState &)=delete
Copy assignment is not supported.
BatchCompletionState(const BatchCompletionState &)=delete
Copy construction is not supported.
std::optional< unsigned > findError(unsigned pos)
Finds the next error at or after the given position.
static constexpr int EXECUTE_FAILED
Per-message state value indicating the message failed to execute.
int getState(unsigned pos)
Returns the per-message result at the given position.
std::vector< std::intptr_t > getStatus(unsigned pos)
Returns the detailed error status vector for the given position.
static constexpr int SUCCESS_NO_INFO
Per-message state value indicating success with no row-count information.
unsigned getSize()
Returns the number of messages processed.
Configuration options for creating a Batch.
BatchOptions & setRecordCounts(bool value)
Enables or disables per-message affected row counts.
std::optional< unsigned > getBufferBytesSize() const
Returns the batch buffer size in bytes, or nullopt for the server default.
BatchOptions & setBlobPolicy(BlobPolicy value)
Sets the blob handling policy.
bool getRecordCounts() const
Returns whether per-message affected row counts are reported.
unsigned getDetailedErrors() const
Returns the maximum number of detailed error statuses to collect.
BatchOptions & setDetailedErrors(unsigned value)
Sets the maximum number of detailed error statuses to collect.
BlobPolicy getBlobPolicy() const
Returns the blob handling policy.
BatchOptions & setMultiError(bool value)
Enables or disables collection of multiple errors per execution.
bool getMultiError() const
Returns whether multiple errors are collected per execution.
BatchOptions & setBufferBytesSize(unsigned value)
Sets the batch buffer size in bytes.
Wraps the Firebird IBatch interface for bulk DML operations.
Batch & operator=(const Batch &)=delete
Copy assignment is not supported.
void close()
Closes the batch handle and releases resources.
void addBlobStream(std::span< const std::byte > data)
Adds blob data in stream mode (BlobPolicy::STREAM only).
Batch(const Batch &)=delete
Copy construction is not supported.
bool isValid() const noexcept
Returns whether the batch handle is valid.
void appendBlobData(std::span< const std::byte > data)
Appends more data to the last blob added with addBlob().
void addMessage()
Adds the Statement's current input-message buffer as one message.
Batch & operator=(Batch &&)=delete
Move assignment is not supported.
void add(unsigned count, const void *inBuffer)
Adds one or more raw messages to the batch buffer.
const std::vector< Descriptor > & getInputDescriptors()
Returns cached input parameter descriptors for this batch.
FbRef< fb::IMessageMetadata > getInputMetadata()
Returns the input metadata for this batch.
BlobId registerBlob(const BlobId &existingBlob)
Registers an existing blob (created via the normal Blob class) for use in the batch,...
void setDefaultBpb(const BlobOptions &bpb)
Sets the default BPB (Blob Parameter Block) for blobs in this batch.
BlobId addBlob(std::span< const std::byte > data, const BlobOptions &bpb={})
Adds an inline blob and returns its batch-local ID.
BatchCompletionState execute()
Executes all queued messages and returns the completion state.
void cancel()
Cancels the batch, discarding all queued messages.
unsigned getBlobAlignment()
Returns the blob alignment requirement for this batch.
~Batch() noexcept
Closes the batch handle if still valid.
Represents a Firebird blob identifier.
Additional options used when creating or opening blobs.
Represents a Firebird client library instance.
Prepares, executes, and fetches SQL statements against a Firebird attachment.
Represents a transaction in one or more Firebird databases.
BlobPolicy
Selects the blob handling policy for a Batch.
@ ID_ENGINE
Batch-local blob IDs are generated by the Firebird engine.
@ STREAM
Blobs are sent inline as a stream.
@ NONE
Blobs are not allowed in the batch.
@ ID_USER
Batch-local blob IDs are generated by the caller.
std::unique_ptr< T, impl::FbDisposeDeleter > FbUniquePtr
Unique pointer type for Firebird disposable objects.