transactd 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/common/tdclc_32_2_2.dll +0 -0
- data/bin/common/tdclc_64_2_2.dll +0 -0
- data/build/swig/ruby/generate.cmd +45 -0
- data/build/swig/ruby/generate.sh +40 -0
- data/build/swig/ruby/tdclrb_wrap.cpp +406 -969
- data/build/swig/tdcl.i +88 -0
- data/build/tdclc/CMakeLists.txt +5 -1
- data/build/tdclc/tdclc.cbproj +1 -1
- data/build/tdclc/tdclc.rc +4 -4
- data/build/tdclcpp/tdclcpp.rc +4 -4
- data/build/tdclcpp/tdclcpp_bc.cbproj +1 -1
- data/build/tdclrb/tdclrb.rc +4 -4
- data/source/bzs/db/engine/mysql/database.cpp +165 -74
- data/source/bzs/db/engine/mysql/database.h +19 -5
- data/source/bzs/db/engine/mysql/dbManager.cpp +33 -11
- data/source/bzs/db/engine/mysql/dbManager.h +6 -1
- data/source/bzs/db/engine/mysql/mydebuglog.h +12 -0
- data/source/bzs/db/engine/mysql/mysqlInternal.h +10 -3
- data/source/bzs/db/engine/mysql/mysqlThd.cpp +20 -8
- data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +12 -7
- data/source/bzs/db/protocol/hs/hsCommandExecuter.h +1 -1
- data/source/bzs/db/protocol/tdap/client/activeTableImple.h +1 -0
- data/source/bzs/db/protocol/tdap/client/client.cpp +17 -15
- data/source/bzs/db/protocol/tdap/client/client.h +102 -30
- data/source/bzs/db/protocol/tdap/client/connectionPool.cpp +1 -1
- data/source/bzs/db/protocol/tdap/client/database.cpp +32 -10
- data/source/bzs/db/protocol/tdap/client/database.h +1 -0
- data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +0 -2
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +2 -0
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +47 -42
- data/source/bzs/db/protocol/tdap/client/fields.h +3 -1
- data/source/bzs/db/protocol/tdap/client/filter.h +3 -3
- data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +18 -2
- data/source/bzs/db/protocol/tdap/client/nsDatabase.h +3 -2
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +14 -6
- data/source/bzs/db/protocol/tdap/client/nsTable.h +12 -12
- data/source/bzs/db/protocol/tdap/client/recordsetImple.h +6 -3
- data/source/bzs/db/protocol/tdap/client/request.h +1 -0
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +101 -64
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +3 -0
- data/source/bzs/db/protocol/tdap/client/stringConverter.h +9 -13
- data/source/bzs/db/protocol/tdap/client/table.cpp +73 -56
- data/source/bzs/db/protocol/tdap/client/table.h +8 -8
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +52 -100
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +8 -1
- data/source/bzs/db/protocol/tdap/mysql/request.h +6 -0
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +349 -189
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +28 -12
- data/source/bzs/db/protocol/tdap/tdapRequest.h +5 -4
- data/source/bzs/db/protocol/tdap/tdapSchema.h +6 -1
- data/source/bzs/db/protocol/tdap/tdapcapi.h +29 -4
- data/source/bzs/db/protocol/tdap/uri.h +297 -0
- data/source/bzs/db/transactd/appModule.cpp +41 -16
- data/source/bzs/db/transactd/appModule.h +1 -2
- data/source/bzs/db/transactd/transactd.cpp +37 -14
- data/source/bzs/env/crosscompile.h +1 -3
- data/source/bzs/example/queryData.cpp +2 -2
- data/source/bzs/netsvc/client/iconnection.h +3 -1
- data/source/bzs/netsvc/client/tcpClient.cpp +75 -28
- data/source/bzs/netsvc/client/tcpClient.h +94 -62
- data/source/bzs/netsvc/server/IAppModule.h +2 -2
- data/source/bzs/netsvc/server/serverCpt.cpp +17 -10
- data/source/bzs/netsvc/server/serverPipe.cpp +26 -19
- data/source/bzs/netsvc/server/serverTpool.cpp +8 -2
- data/source/bzs/rtl/debuglog.cpp +21 -5
- data/source/bzs/rtl/debuglog.h +1 -1
- data/source/bzs/test/tdclphp/transactd_Test.php +183 -37
- data/source/bzs/test/tdclphp/transactd_pool_Test.php +1 -2
- data/source/bzs/test/tdclrb/transactd_spec.rb +183 -39
- data/source/bzs/test/transactdBench/scaling_bench.cpp +3 -3
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +172 -57
- data/source/global/boost/sha1.hpp +223 -0
- data/source/global/tdclatl/ConnectParams.cpp +2 -2
- data/source/global/tdclatl/ConnectParams.h +1 -1
- data/source/global/tdclatl/Database.cpp +18 -0
- data/source/global/tdclatl/Database.h +5 -0
- data/source/global/tdclatl/tdclatl.idl +23 -1
- data/source/linux/linuxTypes.h +2 -0
- metadata +8 -6
- data/bin/common/tdclc_32_2_1.dll +0 -0
- data/bin/common/tdclc_64_2_1.dll +0 -0
- data/source/bzs/db/protocol/tdap/client/memRecordset.cpp +0 -448
- data/source/bzs/db/protocol/tdap/client/memRecordset.h +0 -159
@@ -1,448 +0,0 @@
|
|
1
|
-
/*=================================================================
|
2
|
-
Copyright (C) 2014 BizStation Corp All rights reserved.
|
3
|
-
|
4
|
-
This program is free software; you can redistribute it and/or
|
5
|
-
modify it under the terms of the GNU General Public License
|
6
|
-
as published by the Free Software Foundation; either version 2
|
7
|
-
of the License, or (at your option) any later version.
|
8
|
-
|
9
|
-
This program is distributed in the hope that it will be useful,
|
10
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
-
GNU General Public License for more details.
|
13
|
-
|
14
|
-
You should have received a copy of the GNU General Public License
|
15
|
-
along with this program; if not, write to the Free Software
|
16
|
-
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
17
|
-
02111-1307, USA.
|
18
|
-
=================================================================*/
|
19
|
-
#pragma hdrstop
|
20
|
-
|
21
|
-
#include "memRecordset.h"
|
22
|
-
|
23
|
-
#ifdef _DEBUG
|
24
|
-
#include <iostream>
|
25
|
-
#endif
|
26
|
-
#pragma package(smart_init)
|
27
|
-
|
28
|
-
namespace bzs
|
29
|
-
{
|
30
|
-
namespace db
|
31
|
-
{
|
32
|
-
namespace protocol
|
33
|
-
{
|
34
|
-
namespace tdap
|
35
|
-
{
|
36
|
-
namespace client
|
37
|
-
{
|
38
|
-
|
39
|
-
// ---------------------------------------------------------------------------
|
40
|
-
// class multiRecordAlocatorImple
|
41
|
-
// ---------------------------------------------------------------------------
|
42
|
-
class multiRecordAlocatorImple : public multiRecordAlocator
|
43
|
-
{
|
44
|
-
class recordset* m_rs;
|
45
|
-
int m_rowOffset;
|
46
|
-
int m_addType;
|
47
|
-
int m_curFirstFiled;
|
48
|
-
const std::vector<std::vector<int> >* m_joinRowMap;
|
49
|
-
|
50
|
-
public:
|
51
|
-
inline multiRecordAlocatorImple(recordset* rs)
|
52
|
-
: m_rs(rs), m_rowOffset(0), m_addType(0), m_curFirstFiled(0),
|
53
|
-
m_joinRowMap(NULL)
|
54
|
-
{
|
55
|
-
}
|
56
|
-
|
57
|
-
inline void init(size_t recordCount, size_t recordLen, int addType,
|
58
|
-
const table* tb)
|
59
|
-
{
|
60
|
-
m_rs->registerMemoryBlock(NULL, recordCount * recordLen, recordLen,
|
61
|
-
addType | m_addType, tb);
|
62
|
-
}
|
63
|
-
|
64
|
-
inline unsigned char* ptr(size_t row, int stat)
|
65
|
-
{
|
66
|
-
int col = (stat == mra_current_block) ? m_curFirstFiled : 0;
|
67
|
-
size_t rowNum = m_joinRowMap ? (*m_joinRowMap)[row + m_rowOffset][0]
|
68
|
-
: row + m_rowOffset;
|
69
|
-
return (*m_rs)[rowNum].ptr(col);
|
70
|
-
}
|
71
|
-
|
72
|
-
inline void setRowOffset(int v) { m_rowOffset = v; }
|
73
|
-
|
74
|
-
inline void setJoinType(int v) { m_addType = v; }
|
75
|
-
|
76
|
-
inline void setInvalidRecord(size_t row, bool v)
|
77
|
-
{
|
78
|
-
(*m_rs)[row + m_rowOffset].setInvalidRecord(v);
|
79
|
-
}
|
80
|
-
|
81
|
-
inline void setCurFirstFiled(int v) { m_curFirstFiled = v; }
|
82
|
-
|
83
|
-
inline void setJoinRowMap(const std::vector<std::vector<int> >* v)
|
84
|
-
{
|
85
|
-
m_joinRowMap = v; /*m_joinMapSize = size;*/
|
86
|
-
}
|
87
|
-
|
88
|
-
inline const std::vector<std::vector<int> >* joinRowMap() const
|
89
|
-
{
|
90
|
-
return m_joinRowMap;
|
91
|
-
}
|
92
|
-
};
|
93
|
-
|
94
|
-
// ---------------------------------------------------------------------------
|
95
|
-
// class recordsetSorter
|
96
|
-
// ---------------------------------------------------------------------------
|
97
|
-
class recordsetSorter
|
98
|
-
{
|
99
|
-
const std::vector<int>& m_fieldNums;
|
100
|
-
|
101
|
-
public:
|
102
|
-
recordsetSorter(const std::vector<int>& fieldNums) : m_fieldNums(fieldNums)
|
103
|
-
{
|
104
|
-
}
|
105
|
-
bool operator()(const row_ptr& l, const row_ptr r) const
|
106
|
-
{
|
107
|
-
std::vector<int>::const_iterator it = m_fieldNums.begin();
|
108
|
-
while (it != m_fieldNums.end())
|
109
|
-
{
|
110
|
-
int ret = (*l)[*it].comp((*r)[*it], 0);
|
111
|
-
if (ret)
|
112
|
-
return (ret < 0);
|
113
|
-
++it;
|
114
|
-
}
|
115
|
-
return false;
|
116
|
-
}
|
117
|
-
};
|
118
|
-
|
119
|
-
// ---------------------------------------------------------------------------
|
120
|
-
// class recordset
|
121
|
-
// ---------------------------------------------------------------------------
|
122
|
-
recordset::recordset()
|
123
|
-
: m_fds(fielddefs::create(), &fielddefs::destroy), m_joinRows(0),
|
124
|
-
m_uniqueReadMaxField(0)
|
125
|
-
{
|
126
|
-
m_mra.reset(new multiRecordAlocatorImple(this));
|
127
|
-
}
|
128
|
-
|
129
|
-
recordset::~recordset()
|
130
|
-
{
|
131
|
-
}
|
132
|
-
|
133
|
-
void recordset::registerMemoryBlock(unsigned char* ptr, size_t size,
|
134
|
-
size_t recordLen, int addtype,
|
135
|
-
const table* tb)
|
136
|
-
{
|
137
|
-
autoMemory* am = new autoMemory(ptr, size, 0, true);
|
138
|
-
m_memblock.push_back(boost::shared_ptr<autoMemory>(am));
|
139
|
-
unsigned char* p = am->ptr;
|
140
|
-
// copy fileds
|
141
|
-
if (addtype & mra_nextrows)
|
142
|
-
{
|
143
|
-
if (addtype == mra_nextrows)
|
144
|
-
m_mra->setRowOffset((int)m_recordset.size()); // no join
|
145
|
-
else
|
146
|
-
m_mra->setRowOffset((int)m_joinRows); // Join
|
147
|
-
}
|
148
|
-
else
|
149
|
-
{
|
150
|
-
// assert(tb);
|
151
|
-
m_joinRows = 0;
|
152
|
-
m_mra->setRowOffset(0);
|
153
|
-
m_mra->setCurFirstFiled((int)m_fds->size());
|
154
|
-
if (tb)
|
155
|
-
m_fds->copyFrom(tb);
|
156
|
-
if (tb && (addtype == mra_nojoin))
|
157
|
-
{
|
158
|
-
const keydef& kd = tb->tableDef()->keyDefs[tb->keyNum()];
|
159
|
-
m_uniqueReadMaxField =
|
160
|
-
(kd.segments[0].flags.bit0 == false) ? (short)m_fds->size() : 0;
|
161
|
-
}
|
162
|
-
}
|
163
|
-
|
164
|
-
*(am->endFieldIndex) = (short)m_fds->size();
|
165
|
-
size_t rows = size / recordLen;
|
166
|
-
|
167
|
-
// set record pointer to each record
|
168
|
-
if ((addtype & mra_innerjoin) || (addtype & mra_outerjoin))
|
169
|
-
{
|
170
|
-
// Join optimazing
|
171
|
-
const std::vector<std::vector<int> >* jmap = m_mra->joinRowMap();
|
172
|
-
|
173
|
-
if (jmap)
|
174
|
-
{
|
175
|
-
// At Join that if some base records reference to a joined record
|
176
|
-
// that the joined record pointer is shared by some base
|
177
|
-
// records.
|
178
|
-
for (int i = 0; i < (int)rows; ++i)
|
179
|
-
{
|
180
|
-
const std::vector<int>& map = (*jmap)[i + m_joinRows];
|
181
|
-
for (int j = 0; j < (int)map.size(); ++j)
|
182
|
-
m_recordset[map[j]]->setRecordData(
|
183
|
-
p + recordLen * i, 0, am->endFieldIndex, false);
|
184
|
-
}
|
185
|
-
}
|
186
|
-
else
|
187
|
-
{
|
188
|
-
for (int i = 0; i < (int)rows; ++i)
|
189
|
-
m_recordset[i + m_joinRows]->setRecordData(
|
190
|
-
p + recordLen * i, 0, am->endFieldIndex, false);
|
191
|
-
}
|
192
|
-
m_joinRows += rows;
|
193
|
-
}
|
194
|
-
else
|
195
|
-
{ // create new record
|
196
|
-
size_t reserveSize = m_recordset.size() + rows;
|
197
|
-
m_recordset.reserve(reserveSize);
|
198
|
-
for (int i = 0; i < (int)rows; ++i)
|
199
|
-
{
|
200
|
-
row_ptr rec(memoryRecord::create(*m_fds), &memoryRecord::release);
|
201
|
-
rec->setRecordData(p + recordLen * i, 0, am->endFieldIndex, false);
|
202
|
-
m_recordset.push_back(rec);
|
203
|
-
}
|
204
|
-
}
|
205
|
-
}
|
206
|
-
|
207
|
-
void recordset::makeSortFields(const _TCHAR* name, std::vector<int>& fieldNums)
|
208
|
-
{
|
209
|
-
int index = m_fds->indexByName(name);
|
210
|
-
if (index == -1)
|
211
|
-
THROW_BZS_ERROR_WITH_MSG(_T("oorderBy:Invalid field name"));
|
212
|
-
fieldNums.push_back(index);
|
213
|
-
}
|
214
|
-
|
215
|
-
int recordset::getMemBlockIndex(unsigned char* ptr) const
|
216
|
-
{
|
217
|
-
for (int i = 0; i < (int)m_memblock.size(); ++i)
|
218
|
-
{
|
219
|
-
const boost::shared_ptr<autoMemory>& am = m_memblock[i];
|
220
|
-
if ((ptr >= am->ptr) && (ptr < am->ptr + am->size))
|
221
|
-
return i;
|
222
|
-
}
|
223
|
-
assert(0);
|
224
|
-
return -1;
|
225
|
-
}
|
226
|
-
|
227
|
-
/* This clone is deep copy.
|
228
|
-
But text and blob field data memory are shared.
|
229
|
-
*/
|
230
|
-
recordset* recordset::clone() const
|
231
|
-
{
|
232
|
-
recordset* p = new recordset();
|
233
|
-
p->m_joinRows = m_joinRows;
|
234
|
-
p->m_uniqueReadMaxField = m_uniqueReadMaxField;
|
235
|
-
p->m_unionFds = m_unionFds;
|
236
|
-
p->m_fds.reset(m_fds->clone(), &fielddefs::destroy);
|
237
|
-
|
238
|
-
std::vector<__int64> offsets;
|
239
|
-
for (int i = 0; i < (int)m_memblock.size(); ++i)
|
240
|
-
{
|
241
|
-
autoMemory* am =
|
242
|
-
new autoMemory(m_memblock[i]->ptr, m_memblock[i]->size, 0, true);
|
243
|
-
*am->endFieldIndex = *m_memblock[i]->endFieldIndex;
|
244
|
-
p->m_memblock.push_back(boost::shared_ptr<autoMemory>(am));
|
245
|
-
offsets.push_back((__int64)(am->ptr - m_memblock[i]->ptr));
|
246
|
-
}
|
247
|
-
|
248
|
-
for (int i = 0; i < (int)m_recordset.size(); ++i)
|
249
|
-
{
|
250
|
-
memoryRecord* row = dynamic_cast<memoryRecord*>(m_recordset[i].get());
|
251
|
-
memoryRecord* mr = memoryRecord::create(*p->m_fds);
|
252
|
-
row_ptr rec(mr, &memoryRecord::release);
|
253
|
-
p->m_recordset.push_back(rec);
|
254
|
-
|
255
|
-
for (int j = 0; j < (int)row->memBlockSize(); ++j)
|
256
|
-
{
|
257
|
-
const autoMemory& mb = row->memBlock(j);
|
258
|
-
int index = getMemBlockIndex(mb.ptr);
|
259
|
-
unsigned char* ptr = mb.ptr + offsets[index];
|
260
|
-
const boost::shared_ptr<autoMemory>& am = p->m_memblock[index];
|
261
|
-
mr->setRecordData(ptr, mb.size, am->endFieldIndex, mb.owner);
|
262
|
-
}
|
263
|
-
}
|
264
|
-
return p;
|
265
|
-
}
|
266
|
-
|
267
|
-
void recordset::clearRecords()
|
268
|
-
{
|
269
|
-
m_recordset.clear();
|
270
|
-
m_uniqueReadMaxField = 0;
|
271
|
-
}
|
272
|
-
|
273
|
-
void recordset::clear()
|
274
|
-
{
|
275
|
-
clearRecords();
|
276
|
-
m_fds->clear();
|
277
|
-
m_unionFds.clear();
|
278
|
-
m_memblock.clear();
|
279
|
-
}
|
280
|
-
|
281
|
-
recordset& recordset::top(recordset& c, int n)
|
282
|
-
{
|
283
|
-
c = *this;
|
284
|
-
c.clearRecords();
|
285
|
-
for (int i = 0; i < n; ++i)
|
286
|
-
c.push_back(m_recordset[i]);
|
287
|
-
return c;
|
288
|
-
}
|
289
|
-
|
290
|
-
recordset::iterator recordset::begin()
|
291
|
-
{
|
292
|
-
return m_recordset.begin();
|
293
|
-
}
|
294
|
-
|
295
|
-
recordset::iterator recordset::end()
|
296
|
-
{
|
297
|
-
return m_recordset.end();
|
298
|
-
}
|
299
|
-
|
300
|
-
recordset::iterator recordset::erase(size_t index)
|
301
|
-
{
|
302
|
-
return m_recordset.erase(m_recordset.begin() + index);
|
303
|
-
}
|
304
|
-
|
305
|
-
recordset::iterator recordset::erase(const iterator& it)
|
306
|
-
{
|
307
|
-
return m_recordset.erase(it);
|
308
|
-
}
|
309
|
-
|
310
|
-
void recordset::push_back(row_ptr r)
|
311
|
-
{
|
312
|
-
m_recordset.push_back(r);
|
313
|
-
};
|
314
|
-
|
315
|
-
void recordset::readBefore(const table_ptr tb, const aliasMap_type* alias)
|
316
|
-
{
|
317
|
-
tb->setMra(m_mra.get());
|
318
|
-
m_fds->setAliases(alias);
|
319
|
-
}
|
320
|
-
|
321
|
-
recordset::key_type recordset::resolvKeyValue(const std::_tstring& name,
|
322
|
-
bool noexception)
|
323
|
-
{
|
324
|
-
int index = m_fds->indexByName(name);
|
325
|
-
if (index != -1)
|
326
|
-
return index;
|
327
|
-
if (!noexception)
|
328
|
-
THROW_BZS_ERROR_WITH_MSG(_T("groupQuery:Invalid key name"));
|
329
|
-
|
330
|
-
return (key_type)m_fds->size();
|
331
|
-
}
|
332
|
-
|
333
|
-
void recordset::removeField(int index)
|
334
|
-
{
|
335
|
-
m_fds->remove(index);
|
336
|
-
for (int i = 0; i < (int)m_unionFds.size(); ++i)
|
337
|
-
m_unionFds[i]->remove(index);
|
338
|
-
|
339
|
-
for (int i = 0; i < (int)m_memblock.size(); ++i)
|
340
|
-
{
|
341
|
-
if (*(m_memblock[i]->endFieldIndex) > index)
|
342
|
-
{
|
343
|
-
short v = *(m_memblock[i]->endFieldIndex) - 1;
|
344
|
-
*(m_memblock[i]->endFieldIndex) = v;
|
345
|
-
}
|
346
|
-
}
|
347
|
-
}
|
348
|
-
|
349
|
-
recordset& recordset::matchBy(recordsetQuery& rq)
|
350
|
-
{
|
351
|
-
rq.init(fieldDefs());
|
352
|
-
for (int i = (int)m_recordset.size() - 1; i >= 0; --i)
|
353
|
-
if (!rq.match(m_recordset[i]))
|
354
|
-
erase(i);
|
355
|
-
return *this;
|
356
|
-
}
|
357
|
-
|
358
|
-
recordset& recordset::groupBy(groupQuery& gq)
|
359
|
-
{
|
360
|
-
gq.grouping(*this);
|
361
|
-
return *this;
|
362
|
-
}
|
363
|
-
|
364
|
-
recordset& recordset::orderBy(const _TCHAR* name1, const _TCHAR* name2,
|
365
|
-
const _TCHAR* name3, const _TCHAR* name4,
|
366
|
-
const _TCHAR* name5, const _TCHAR* name6,
|
367
|
-
const _TCHAR* name7, const _TCHAR* name8)
|
368
|
-
{
|
369
|
-
std::vector<int> fieldNums;
|
370
|
-
makeSortFields(name1, fieldNums);
|
371
|
-
if (name2)
|
372
|
-
makeSortFields(name2, fieldNums);
|
373
|
-
if (name3)
|
374
|
-
makeSortFields(name3, fieldNums);
|
375
|
-
if (name4)
|
376
|
-
makeSortFields(name4, fieldNums);
|
377
|
-
if (name5)
|
378
|
-
makeSortFields(name5, fieldNums);
|
379
|
-
if (name6)
|
380
|
-
makeSortFields(name6, fieldNums);
|
381
|
-
if (name7)
|
382
|
-
makeSortFields(name7, fieldNums);
|
383
|
-
if (name8)
|
384
|
-
makeSortFields(name8, fieldNums);
|
385
|
-
std::sort(begin(), end(), recordsetSorter(fieldNums));
|
386
|
-
return *this;
|
387
|
-
}
|
388
|
-
|
389
|
-
inline recordset& recordset::reverse()
|
390
|
-
{
|
391
|
-
std::reverse(begin(), end());
|
392
|
-
return *this;
|
393
|
-
}
|
394
|
-
|
395
|
-
void recordset::appendCol(const _TCHAR* name, int type, short len)
|
396
|
-
{
|
397
|
-
assert(m_fds->size());
|
398
|
-
fielddef fd((*m_fds)[0]);
|
399
|
-
fd.len = len;
|
400
|
-
fd.pos = 0;
|
401
|
-
fd.type = type;
|
402
|
-
fd.setName(name);
|
403
|
-
m_fds->push_back(&fd);
|
404
|
-
for (int i = 0; i < (int)m_unionFds.size(); ++i)
|
405
|
-
m_unionFds[i]->push_back(&fd);
|
406
|
-
registerMemoryBlock(NULL, fd.len * size(), fd.len, mra_outerjoin);
|
407
|
-
}
|
408
|
-
|
409
|
-
recordset& recordset::operator+=(const recordset& r)
|
410
|
-
{
|
411
|
-
if (!m_fds->canUnion(*r.m_fds))
|
412
|
-
THROW_BZS_ERROR_WITH_MSG(_T("Recordsets are different format"));
|
413
|
-
|
414
|
-
m_recordset.reserve(m_recordset.size() + r.size());
|
415
|
-
m_unionFds.push_back(r.m_fds);
|
416
|
-
for (size_t i = 0; i < r.size(); ++i)
|
417
|
-
m_recordset.push_back(r.m_recordset[i]);
|
418
|
-
for (size_t i = 0; i < r.m_memblock.size(); ++i)
|
419
|
-
m_memblock.push_back(r.m_memblock[i]);
|
420
|
-
return *this;
|
421
|
-
}
|
422
|
-
|
423
|
-
#ifdef _DEBUG
|
424
|
-
void recordset::dump()
|
425
|
-
{
|
426
|
-
const fielddefs& fields = *fieldDefs();
|
427
|
-
for (int j = 0; j < (int)fields.size(); ++j)
|
428
|
-
std::tcout << fields[j].name() << _T("\t");
|
429
|
-
std::tcout << _T("\n");
|
430
|
-
|
431
|
-
for (int i = 0; i < (int)size(); ++i)
|
432
|
-
{
|
433
|
-
row& m = (operator[](i));
|
434
|
-
for (int j = 0; j < (int)m.size(); ++j)
|
435
|
-
{
|
436
|
-
std::tcout << m[(short)j].c_str() << _T("\t");
|
437
|
-
if (j == (int)m.size() - 1)
|
438
|
-
std::tcout << _T("\n");
|
439
|
-
}
|
440
|
-
}
|
441
|
-
}
|
442
|
-
#endif
|
443
|
-
|
444
|
-
} // namespace client
|
445
|
-
} // namespace tdap
|
446
|
-
} // namespace protocol
|
447
|
-
} // namespace db
|
448
|
-
} // namespace bzs
|
@@ -1,159 +0,0 @@
|
|
1
|
-
#ifndef BZS_DB_PROTOCOL_TDAP_CLIENT_MEMRECORDSET_H
|
2
|
-
#define BZS_DB_PROTOCOL_TDAP_CLIENT_MEMRECORDSET_H
|
3
|
-
/*=================================================================
|
4
|
-
Copyright (C) 2014 BizStation Corp All rights reserved.
|
5
|
-
|
6
|
-
This program is free software; you can redistribute it and/or
|
7
|
-
modify it under the terms of the GNU General Public License
|
8
|
-
as published by the Free Software Foundation; either version 2
|
9
|
-
of the License, or (at your option) any later version.
|
10
|
-
|
11
|
-
This program is distributed in the hope that it will be useful,
|
12
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
GNU General Public License for more details.
|
15
|
-
|
16
|
-
You should have received a copy of the GNU General Public License
|
17
|
-
along with this program; if not, write to the Free Software
|
18
|
-
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
19
|
-
02111-1307, USA.
|
20
|
-
=================================================================*/
|
21
|
-
#include "groupQuery.h"
|
22
|
-
|
23
|
-
namespace bzs
|
24
|
-
{
|
25
|
-
namespace db
|
26
|
-
{
|
27
|
-
namespace protocol
|
28
|
-
{
|
29
|
-
namespace tdap
|
30
|
-
{
|
31
|
-
namespace client
|
32
|
-
{
|
33
|
-
|
34
|
-
class AGRPACK recordset
|
35
|
-
{
|
36
|
-
friend class multiRecordAlocatorImple;
|
37
|
-
boost::shared_ptr<fielddefs> m_fds;
|
38
|
-
boost::shared_ptr<class multiRecordAlocatorImple> m_mra;
|
39
|
-
std::vector<row_ptr> m_recordset;
|
40
|
-
std::vector<boost::shared_ptr<autoMemory> > m_memblock;
|
41
|
-
std::vector<boost::shared_ptr<fielddefs> > m_unionFds;
|
42
|
-
|
43
|
-
/* for registerMemoryBlock temp data */
|
44
|
-
size_t m_joinRows;
|
45
|
-
|
46
|
-
/*
|
47
|
-
for optimazing join.
|
48
|
-
If the first reading is using by unique key , set that field count.
|
49
|
-
*/
|
50
|
-
short m_uniqueReadMaxField;
|
51
|
-
|
52
|
-
public:
|
53
|
-
typedef std::vector<row_ptr>::iterator iterator;
|
54
|
-
|
55
|
-
private:
|
56
|
-
void registerMemoryBlock(unsigned char* ptr, size_t size, size_t recordLen,
|
57
|
-
int addtype, const table* tb = NULL);
|
58
|
-
void makeSortFields(const _TCHAR* name, std::vector<int>& fieldNums);
|
59
|
-
int getMemBlockIndex(unsigned char* ptr) const;
|
60
|
-
|
61
|
-
public:
|
62
|
-
typedef fielddefs header_type;
|
63
|
-
typedef int key_type;
|
64
|
-
typedef row_ptr row_type;
|
65
|
-
typedef row row_pure_type;
|
66
|
-
|
67
|
-
recordset();
|
68
|
-
~recordset();
|
69
|
-
/* This clone is deep copy.
|
70
|
-
But text and blob field data memory are shared.
|
71
|
-
*/
|
72
|
-
recordset* clone() const;
|
73
|
-
|
74
|
-
inline short uniqueReadMaxField() const { return m_uniqueReadMaxField; }
|
75
|
-
|
76
|
-
inline row_ptr& getRow(size_t index) { return m_recordset[index]; }
|
77
|
-
|
78
|
-
inline row& operator[](size_t index) { return *m_recordset[index].get(); }
|
79
|
-
|
80
|
-
inline row& first() { return *m_recordset[0].get(); }
|
81
|
-
|
82
|
-
inline row& last() { return *m_recordset[m_recordset.size() - 1].get(); }
|
83
|
-
|
84
|
-
inline size_t size() const { return m_recordset.size(); }
|
85
|
-
|
86
|
-
inline size_t count() const { return m_recordset.size(); }
|
87
|
-
|
88
|
-
void clearRecords();
|
89
|
-
const fielddefs* fieldDefs() const { return m_fds.get(); }
|
90
|
-
void clear();
|
91
|
-
recordset& top(recordset& c, int n);
|
92
|
-
iterator begin();
|
93
|
-
iterator end();
|
94
|
-
iterator erase(size_t index);
|
95
|
-
iterator erase(const iterator& it);
|
96
|
-
void push_back(row_ptr r);
|
97
|
-
void readBefore(const table_ptr tb, const aliasMap_type* alias);
|
98
|
-
|
99
|
-
key_type resolvKeyValue(const std::_tstring& name,
|
100
|
-
bool noexception = false);
|
101
|
-
void removeField(int index);
|
102
|
-
recordset& matchBy(recordsetQuery& rq);
|
103
|
-
recordset& groupBy(groupQuery& gq);
|
104
|
-
recordset& orderBy(const _TCHAR* name1, const _TCHAR* name2 = NULL,
|
105
|
-
const _TCHAR* name3 = NULL, const _TCHAR* name4 = NULL,
|
106
|
-
const _TCHAR* name5 = NULL, const _TCHAR* name6 = NULL,
|
107
|
-
const _TCHAR* name7 = NULL, const _TCHAR* name8 = NULL);
|
108
|
-
recordset& reverse();
|
109
|
-
void appendCol(const _TCHAR* name, int type, short len);
|
110
|
-
recordset& operator+=(const recordset& r);
|
111
|
-
|
112
|
-
#ifdef _DEBUG
|
113
|
-
void dump();
|
114
|
-
|
115
|
-
#endif
|
116
|
-
};
|
117
|
-
|
118
|
-
/** @cond INTERNAL */
|
119
|
-
|
120
|
-
inline recordset::iterator begin(recordset& m)
|
121
|
-
{
|
122
|
-
return m.begin();
|
123
|
-
}
|
124
|
-
inline recordset::iterator end(recordset& m)
|
125
|
-
{
|
126
|
-
return m.end();
|
127
|
-
}
|
128
|
-
inline void push_back(recordset& m, row_ptr c)
|
129
|
-
{
|
130
|
-
}
|
131
|
-
|
132
|
-
/* for groupby */
|
133
|
-
inline void clear(recordset& m)
|
134
|
-
{
|
135
|
-
return m.clearRecords();
|
136
|
-
}
|
137
|
-
|
138
|
-
/* for groupby */
|
139
|
-
inline recordset::key_type resolvKeyValue(recordset& m,
|
140
|
-
const std::_tstring& name,
|
141
|
-
bool noexception = false)
|
142
|
-
{
|
143
|
-
return m.resolvKeyValue(name, noexception);
|
144
|
-
}
|
145
|
-
|
146
|
-
inline row* create(recordset& m, int)
|
147
|
-
{
|
148
|
-
return NULL;
|
149
|
-
}
|
150
|
-
|
151
|
-
/** @endcond */
|
152
|
-
|
153
|
-
} // namespace client
|
154
|
-
} // namespace tdap
|
155
|
-
} // namespace protocol
|
156
|
-
} // namespace db
|
157
|
-
} // namespace bzs
|
158
|
-
|
159
|
-
#endif // BZS_DB_PROTOCOL_TDAP_CLIENT_MEMRECORDSET_H
|