From a676d61b726b11fcb094ef4e353e621798cbd1b5 Mon Sep 17 00:00:00 2001
From: AlexPeshkoff
It’s supposed that all components of blob stream in a batch should be aligned at least at alignment boundary, including size of stream -potions passed to addBlobStream() which should be a multiple of this +portions passed to addBlobStream() which should be a multiple of this alignment. Header contains 3 fields – 8-byte blob ID (must be non-zero), 4-byte total blob size and 4 byte BPB size. Total blob size includes BPB inside, i.e. one will always find next blob in the @@ -1145,6 +1145,17 @@ correct (from batch POV) ID to msg->desc.
Almost all mentioned methods are used in 11.batch.cpp – please use it to see an alive sample of batching in firebird. +
+
+
+
+Two words about access to +batches from ISC API - one can execute prepared ISC statement in +batch mode. Main support for it is present in Util interface, namely +getTransactionByHandle & getStatementByHandle methods, which make +it possible to access appropriate interfaces identical to existing +ISC handles. An example of it is present in 12.batch_isc.cpp.
-
-
Dtc
-interface – distributed transactions coordinator. Used to start
-distributed (working with 2 or more attachments) transaction. Unlike
-pre-FB3 approach where distributed transaction must be started in
-this way from the most beginning FB3's distributed transactions
+
+DecFloat16 / DecFloat34 –
+interfaces that help to work with DECFLOAT (16 & 34 respectively)
+datatypes. They have almost same set of methods with FB_DEC16
+parameter replaced by FB_DEC34 for DecFloat34: void
+ toBcd(const FB_DEC16* from, int* sign, unsigned char* bcd, int* exp)
+ – convert decimal float value to BCD. void
+ toString(StatusType* status, const FB_DEC16* from, unsigned
+ bufferLength, char* buffer) – convert decimal float value to
+ string. void
+ fromBcd(int sign, const unsigned char* bcd, int exp, FB_DEC16* to) –
+ make decimal float value from BCD. void
+ fromString(StatusType* status, const char* from, FB_DEC16* to) –
+ make decimal float value from string. Dtc
+interface – distributed transactions coordinator. Used to
+start distributed (working with 2 or more attachments) transaction.
+Unlike pre-FB3 approach where distributed transaction must be started
+in this way from the most beginning FB3's distributed transactions
coordinator makes it also possible to join already started
transactions into single distributed transaction.
+
+
+
@@ -3107,18 +3140,60 @@ interface – various helper methods required here or there.
IXpbBuilder*
+ IXpbBuilder*
getXpbBuilder(StatusType* status, unsigned kind, const unsigned
char* buf, unsigned len) – returns XpbBuilder
interface. Valid kinds are
- enumerated in XpbBuilder.
unsigned
+ unsigned
setOffsets(StatusType* status, IMessageMetadata* metadata,
IOffsetsCallback* callback) – sets valid offsets in
MessageMetadata. Performs calls to
callback in OffsetsCallback for each
- field/parameter.
IDecFloat16* + getDecFloat16(StatusType* status) – access DecFloat16 + interface.
+ +IDecFloat34* + getDecFloat34(StatusType* status) – access DecFloat34 + interface.
+ +ITransaction* + getTransactionByHandle(StatusType* status, isc_tr_handle* hndlPtr) – + access Transaction interface by ISC API + hndl.
+ +IStatement* + getStatementByHandle(StatusType* status, isc_stmt_handle* hndlPtr) – + access Statement interface by ISC API hndl.
+ +void + decodeTimeTz(StatusType* status, const ISC_TIME_TZ* timeTz, + unsigned* hours, unsigned* minutes, unsigned* seconds, unsigned*
+fractions, + unsigned timeZoneBufferLength, char* timeZoneBuffer) + – decode time taking time zone into an account.
+ +void + decodeTimeStampTz(StatusType* status, const ISC_TIMESTAMP_TZ* + timeStampTz, unsigned* year, unsigned* month, unsigned* day, + unsigned* hours, unsigned* minutes, unsigned* seconds, unsigned* + fractions, unsigned timeZoneBufferLength, char* timeZoneBuffer) - + decode timestamp taking time zone into an account.
+ +void + encodeTimeTz(StatusType* status, ISC_TIME_TZ* timeTz, unsigned + hours, unsigned minutes, unsigned seconds, unsigned fractions, const + char* timeZone) – encode time taking time zone into an account.
+ +void + encodeTimeStampTz(StatusType* status, ISC_TIMESTAMP_TZ* timeStampTz, + unsigned year, unsigned month, unsigned day, unsigned hours, + unsigned minutes, unsigned seconds, unsigned fractions, const char* + timeZone) – encode timestamp taking time zone into an account.
@@ -3756,9 +3831,8 @@ interface is main interface of database crypt key holder plugin.
ICryptKeyCallback* keyHandle(StatusType* status, const char* keyName) – is intended diff --git a/examples/interfaces/11.batch.cpp b/examples/interfaces/11.batch.cpp index 47667b463e..741ac5e807 100644 --- a/examples/interfaces/11.batch.cpp +++ b/examples/interfaces/11.batch.cpp @@ -418,6 +418,22 @@ int main() batch->addBlobStream(&status, stream - streamStart, streamStart); + // Continue last blob + stream = streamStart; + ISC_QUAD nullId = {0,0}; + unsigned* size = putBlobHdr(stream, blobAlign, &nullId, 0, NULL); + + const char* d4 = " 444444444444444444444444"; + unsigned ld4 = strlen(d4); + + memcpy(stream, d4, ld4); + *size += ld4; + stream += ld4; + stream = align(stream, blobAlign); + + stream = align(stream, blobAlign); + batch->addBlobStream(&status, stream - streamStart, streamStart); + // Put segmented Blob in the stream // add message @@ -435,7 +451,7 @@ int main() // make stream stream = streamStart; - unsigned* size = putBlobHdr(stream, blobAlign, &vSeg, pb->getBufferLength(&status), pb->getBuffer(&status)); + size = putBlobHdr(stream, blobAlign, &vSeg, pb->getBufferLength(&status), pb->getBuffer(&status)); *size += putSegment(stream, d1); *size += putSegment(stream, "\n"); *size += putSegment(stream, d2);