| 46 | class Attachment; |
| 47 | |
| 48 | class DsqlBatch |
| 49 | { |
| 50 | public: |
| 51 | DsqlBatch(DsqlDmlRequest* req, const dsql_msg* message, Firebird::IMessageMetadata* inMetadata, |
| 52 | Firebird::ClumpletReader& pb); |
| 53 | ~DsqlBatch(); |
| 54 | |
| 55 | static const ULONG RAM_BATCH = 128 * 1024; |
| 56 | static const ULONG BUFFER_LIMIT = 16 * 1024 * 1024; |
| 57 | static const ULONG HARD_BUFFER_LIMIT = 256 * 1024 * 1024; |
| 58 | static const ULONG DETAILED_LIMIT = 64; |
| 59 | static const ULONG SIZEOF_BLOB_HEAD = sizeof(ISC_QUAD) + 2 * sizeof(ULONG); |
| 60 | static const unsigned BLOB_STREAM_ALIGN = 4; |
| 61 | |
| 62 | static DsqlBatch* open(thread_db* tdbb, DsqlDmlRequest* req, Firebird::IMessageMetadata* inMetadata, |
| 63 | unsigned parLength, const UCHAR* par); |
| 64 | |
| 65 | Attachment* getAttachment() const; |
| 66 | void setInterfacePtr(JBatch* interfacePtr) throw(); |
| 67 | |
| 68 | void add(thread_db* tdbb, ULONG count, const void* inBuffer); |
| 69 | void addBlob(thread_db* tdbb, ULONG length, const void* inBuffer, ISC_QUAD* blobId, unsigned parLength, const unsigned char* par); |
| 70 | void appendBlobData(thread_db* tdbb, ULONG length, const void* inBuffer); |
| 71 | void addBlobStream(thread_db* tdbb, unsigned length, const void* inBuffer); |
| 72 | void registerBlob(thread_db* tdbb, const ISC_QUAD* existingBlob, ISC_QUAD* blobId); |
| 73 | Firebird::IBatchCompletionState* execute(thread_db* tdbb); |
| 74 | Firebird::IMessageMetadata* getMetadata(thread_db* tdbb); |
| 75 | void cancel(thread_db* tdbb); |
| 76 | void setDefaultBpb(thread_db* tdbb, unsigned parLength, const unsigned char* par); |
| 77 | void info(thread_db* tdbb, unsigned int itemsLength, const unsigned char* items, |
| 78 | unsigned int bufferLength, unsigned char* buffer); |
| 79 | |
| 80 | // Additional flags - start from the maximum one |
| 81 | static const UCHAR FLAG_DEFAULT_SEGMENTED = 31; |
| 82 | static const UCHAR FLAG_CURRENT_SEGMENTED = 30; |
| 83 | |
| 84 | private: |
| 85 | void genBlobId(ISC_QUAD* blobId); |
| 86 | void blobPrepare(); |
| 87 | void blobSetSize(); |
| 88 | void blobCheckMode(bool stream, const char* fname); |
| 89 | void blobCheckMeta(); |
| 90 | void registerBlob(const ISC_QUAD* engineBlob, const ISC_QUAD* batchBlob); |
| 91 | void setDefBpb(unsigned parLength, const unsigned char* par); |
| 92 | void putSegment(ULONG length, const void* inBuffer); |
| 93 | |
| 94 | void setFlag(UCHAR bit, bool value) |
| 95 | { |
| 96 | if (value) |
| 97 | m_flags |= (1 << bit); |
| 98 | else |
| 99 | m_flags &= ~(1 << bit); |
| 100 | } |
| 101 | |
| 102 | DsqlDmlRequest* const m_dsqlRequest; |
| 103 | JBatch* m_batch; |
| 104 | Firebird::IMessageMetadata* m_meta; |
| 105 | |