Skip to content

Commit 76eeac2

Browse files
committed
Implemented BatchCompletionState interface
1 parent 24ee4c0 commit 76eeac2

File tree

15 files changed

+450
-74
lines changed

15 files changed

+450
-74
lines changed

examples/interfaces/11.batch.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,18 @@ int main()
5858
IAttachment* att = NULL;
5959
ITransaction* tra = NULL;
6060
IBatch* batch = NULL;
61+
IBatchCompletionState* cs = NULL;
6162

6263
try
6364
{
6465
// attach employee db
6566
att = prov->attachDatabase(&status, "employee", 0, NULL);
6667
tra = att->startTransaction(&status, 0, NULL);
6768

69+
// cleanup
70+
att->execute(&status, tra, 0, "delete from country where currency='lim'", SAMPLES_DIALECT,
71+
NULL, NULL, NULL, NULL);
72+
6873
// Message to store in a table
6974
FB_MESSAGE(Msg, ThrowStatusWrapper,
7075
(FB_VARCHAR(15), country)
@@ -81,8 +86,13 @@ int main()
8186
msg->currency.set("lim");
8287
batch->add(&status, 1, msg.getData());
8388

89+
msg->country.set("Banania");
90+
msg->currency.set("lim");
91+
batch->add(&status, 1, msg.getData());
92+
8493
// and execute it
85-
batch->execute(&status, tra);
94+
cs = batch->execute(&status, tra);
95+
printf("upcount=%d\n", cs->getSize(&status));
8696

8797
// cleanup
8898
batch->release();
@@ -100,6 +110,8 @@ int main()
100110
}
101111

102112
// release interfaces after error caught
113+
if (cs)
114+
cs->dispose();
103115
if (batch)
104116
batch->release();
105117
if (tra)

src/common/classes/vector.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ class Vector
8585
return &data[index];
8686
}
8787

88+
T* removeCount(const FB_SIZE_T index, const FB_SIZE_T n) throw()
89+
{
90+
fb_assert(index + n <= count);
91+
memmove(data + index, data + index + n, sizeof(T) * (count - index - n));
92+
count -= n;
93+
return &data[index];
94+
}
95+
8896
void shrink(FB_SIZE_T newCount) throw()
8997
{
9098
fb_assert(newCount <= count);
@@ -118,6 +126,20 @@ class Vector
118126
return data[count];
119127
}
120128

129+
void push(const T* items, const FB_SIZE_T itemsSize)
130+
{
131+
fb_assert(count <= FB_MAX_SIZEOF - itemsSize);
132+
fb_assert(count + itemsSize <= Capacity);
133+
memcpy(data + count, items, sizeof(T) * itemsSize);
134+
count += itemsSize;
135+
}
136+
137+
void append(const T* items, const FB_SIZE_T itemsSize)
138+
{
139+
push(items, itemsSize);
140+
}
141+
142+
121143
// This method only assigns "pos" if the element is found.
122144
// Maybe we should modify it to iterate directy with "pos".
123145
bool find(const T& item, FB_SIZE_T& pos) const

src/common/utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ unsigned int mergeStatus(ISC_STATUS* const dest, unsigned int space,
11691169
return copied;
11701170
}
11711171

1172-
void copyStatus(Firebird::CheckStatusWrapper* to, const Firebird::CheckStatusWrapper* from) throw()
1172+
void copyStatus(Firebird::CheckStatusWrapper* to, const Firebird::IStatus* from) throw()
11731173
{
11741174
to->init();
11751175

src/common/utils_proto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ namespace fb_utils
136136

137137
unsigned int copyStatus(ISC_STATUS* const to, const unsigned int space,
138138
const ISC_STATUS* const from, const unsigned int count) throw();
139-
void copyStatus(Firebird::CheckStatusWrapper* to, const Firebird::CheckStatusWrapper* from) throw();
139+
void copyStatus(Firebird::CheckStatusWrapper* to, const Firebird::IStatus* from) throw();
140140
unsigned int mergeStatus(ISC_STATUS* const to, unsigned int space, const Firebird::IStatus* from) throw();
141141
void setIStatus(Firebird::CheckStatusWrapper* to, const ISC_STATUS* from) throw();
142142
unsigned int statusLength(const ISC_STATUS* const status) throw();

0 commit comments

Comments
 (0)