| 369 | } |
| 370 | |
| 371 | class Batch final : public RefCntIface<IBatchImpl<Batch, CheckStatusWrapper> > |
| 372 | { |
| 373 | public: |
| 374 | static const ULONG DEFER_BATCH_LIMIT = 64; |
| 375 | |
| 376 | Batch(Statement* s, IMessageMetadata* inFmt, unsigned parLength, const unsigned char* par); |
| 377 | |
| 378 | // IBatch implementation |
| 379 | int release() override; |
| 380 | void add(CheckStatusWrapper* status, unsigned count, const void* inBuffer) override; |
| 381 | void addBlob(CheckStatusWrapper* status, unsigned length, const void* inBuffer, ISC_QUAD* blobId, |
| 382 | unsigned parLength, const unsigned char* par) override; |
| 383 | void appendBlobData(CheckStatusWrapper* status, unsigned length, const void* inBuffer) override; |
| 384 | void addBlobStream(CheckStatusWrapper* status, unsigned length, const void* inBuffer) override; |
| 385 | void registerBlob(CheckStatusWrapper* status, const ISC_QUAD* existingBlob, ISC_QUAD* blobId) override; |
| 386 | IBatchCompletionState* execute(CheckStatusWrapper* status, ITransaction* transaction) override; |
| 387 | void cancel(CheckStatusWrapper* status) override; |
| 388 | unsigned getBlobAlignment(CheckStatusWrapper* status) override; |
| 389 | void setDefaultBpb(CheckStatusWrapper* status, unsigned parLength, const unsigned char* par) override; |
| 390 | IMessageMetadata* getMetadata(CheckStatusWrapper* status) override; |
| 391 | void close(CheckStatusWrapper* status) override; |
| 392 | void deprecatedClose(CheckStatusWrapper* status) override; |
| 393 | void getInfo(CheckStatusWrapper* status, |
| 394 | unsigned int itemsLength, const unsigned char* items, |
| 395 | unsigned int bufferLength, unsigned char* buffer) override; |
| 396 | |
| 397 | private: |
| 398 | void freeClientData(CheckStatusWrapper* status, bool force = false); |
| 399 | void internalClose(CheckStatusWrapper* status); |
| 400 | void releaseStatement(); |
| 401 | void setServerInfo(); |
| 402 | |
| 403 | void cleanup() |
| 404 | { |
| 405 | if (blobPolicy != BLOB_NONE) |
| 406 | blobStream = blobStreamBuffer; |
| 407 | sizePointer = nullptr; |
| 408 | messageStream = 0; |
| 409 | } |
| 410 | |
| 411 | void genBlobId(ISC_QUAD* blobId) |
| 412 | { |
| 413 | if (++genId.gds_quad_low == 0) |
| 414 | ++genId.gds_quad_high; |
| 415 | memcpy(blobId, &genId, sizeof(genId)); |
| 416 | } |
| 417 | |
| 418 | bool batchHasData() |
| 419 | { |
| 420 | return batchActive; |
| 421 | } |
| 422 | |
| 423 | // working with message stream buffer |
| 424 | void putMessageData(ULONG count, const void* p) |
| 425 | { |
| 426 | fb_assert(messageStreamBuffer); |
| 427 | |
| 428 | const UCHAR* ptr = reinterpret_cast<const UCHAR*>(p); |