transactd 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/CMakeLists.txt +37 -4
  3. data/bin/common/tdclc_32_1_2.dll +0 -0
  4. data/bin/common/tdclc_64_1_2.dll +0 -0
  5. data/build/common/transactd_cl_common.cmake +0 -1
  6. data/build/common/transactd_common.cmake +26 -6
  7. data/build/swig/php/generate.cmake.in +58 -0
  8. data/build/swig/php/generate.cmd.in +41 -0
  9. data/build/swig/php/php.swg +155 -0
  10. data/build/swig/ruby/ruby.swg +38 -0
  11. data/build/swig/tdcl.i +133 -3
  12. data/build/tdclc/CMakeLists.txt +4 -1
  13. data/build/tdclc/tdclc_32.cbproj +1 -1
  14. data/build/tdclc/tdclc_64.cbproj +1 -1
  15. data/build/tdclcpp/CMakeLists.txt +1 -1
  16. data/build/tdclcpp/tdclcpp_bcb_32.cbproj +1 -4
  17. data/build/tdclcpp/tdclcpp_bcb_64.cbproj +0 -3
  18. data/build/tdclrb/CMakeLists.txt +1 -1
  19. data/build/tdclrb/GEM_VERSION +2 -2
  20. data/source/bzs/db/engine/mysql/IReadRecords.h +1 -1
  21. data/source/bzs/db/engine/mysql/bookmark.h +3 -3
  22. data/source/bzs/db/engine/mysql/database.cpp +95 -19
  23. data/source/bzs/db/engine/mysql/database.h +6 -6
  24. data/source/bzs/db/engine/mysql/mysqlInternal.h +43 -1
  25. data/source/bzs/db/engine/mysql/mysqlThd.cpp +10 -8
  26. data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +1 -1
  27. data/source/bzs/db/protocol/tdap/btrDate.h +2 -2
  28. data/source/bzs/db/protocol/tdap/client/dbDef.cpp +15 -8
  29. data/source/bzs/db/protocol/tdap/client/dbDef.h +2 -2
  30. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +4 -0
  31. data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +0 -5
  32. data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +0 -4
  33. data/source/bzs/db/protocol/tdap/client/filter.cpp +0 -484
  34. data/source/bzs/db/protocol/tdap/client/filter.h +696 -84
  35. data/source/bzs/db/protocol/tdap/client/nsTable.cpp +13 -3
  36. data/source/bzs/db/protocol/tdap/client/nsTable.h +12 -6
  37. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +2 -1
  38. data/source/bzs/db/protocol/tdap/client/stringConverter.h +1 -0
  39. data/source/bzs/db/protocol/tdap/client/table.cpp +519 -75
  40. data/source/bzs/db/protocol/tdap/client/table.h +49 -7
  41. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +145 -124
  42. data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +39 -0
  43. data/source/bzs/db/protocol/tdap/client/trdormapi.h +872 -0
  44. data/source/bzs/db/protocol/tdap/myDateTime.cpp +8 -8
  45. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +7 -9
  46. data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +406 -195
  47. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +64 -13
  48. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +2 -1
  49. data/source/bzs/db/protocol/tdap/tdapSchema.cpp +35 -3
  50. data/source/bzs/db/protocol/tdap/tdapSchema.h +11 -3
  51. data/source/bzs/db/protocol/tdap/tdapcapi.h +63 -53
  52. data/source/bzs/env/crosscompile.h +8 -3
  53. data/source/bzs/example/connection_pool_c.cpp +1 -7
  54. data/source/bzs/example/useORM.cpp +585 -0
  55. data/source/bzs/rtl/exception.h +6 -0
  56. data/source/bzs/test/tdclatl/bench_tdclatl.js +12 -7
  57. data/source/bzs/test/tdclphp/transactd_Test.php +1845 -0
  58. data/source/bzs/test/tdclphp/transactd_blob_Test.php +325 -0
  59. data/source/bzs/test/tdclphp/transactd_datetime_Test.php +183 -0
  60. data/source/bzs/test/tdclphp/transactd_kanjischema_Test.php +212 -0
  61. data/source/bzs/test/tdclrb/transactd_blob_spec.rb +332 -0
  62. data/source/bzs/test/tdclrb/transactd_spec.rb +256 -1
  63. data/source/bzs/test/trdclengn/test_blob.cpp +327 -0
  64. data/source/bzs/test/trdclengn/test_trdclengn.cpp +485 -5
  65. data/source/global/tdclatl/QueryBase.cpp +231 -0
  66. data/source/global/tdclatl/QueryBase.h +96 -0
  67. data/source/global/tdclatl/Table.cpp +24 -0
  68. data/source/global/tdclatl/Table.h +2 -1
  69. data/source/global/tdclatl/resource.h +0 -0
  70. data/source/global/tdclatl/tdclatl.idl +88 -2
  71. metadata +16 -3
  72. data/bin/common/tdclc_32_1_1.dll +0 -0
  73. data/bin/common/tdclc_64_1_1.dll +0 -0
@@ -0,0 +1,585 @@
1
+ #include <bzs/db/protocol/tdap/client/trdboostapi.h>
2
+ #include <iostream>
3
+ #include <vector>
4
+ #include <bzs/db/protocol/tdap/client/trdormapi.h>
5
+ #include <boost/iterator/iterator_facade.hpp>
6
+
7
+ using namespace bzs::db::protocol::tdap::client;
8
+ using namespace bzs::db::protocol::tdap;
9
+
10
+ /**
11
+ @brief Read records and manual O/R mapping example
12
+
13
+ This program read records of the "user" table where group = 3.
14
+ And O/R mapping to the user class.
15
+ This program use the filter operation on server side.
16
+
17
+ Please execute "create database" , "change schema" and "insert records" example
18
+ before execute this example.
19
+
20
+ */
21
+
22
+
23
+ static const char_td keynum_group = 1;
24
+ static const char_td primary_key = 0;
25
+
26
+ class group
27
+ {
28
+ int m_id;
29
+ std::string m_name;
30
+ protected:
31
+ group(void* owner):m_id(0){}
32
+ public:
33
+
34
+ int id() const {return m_id;}
35
+ const std::string& name() const {return m_name;}
36
+ void setId(int v){m_id = v;}
37
+ void setName(const char* v){m_name = v;}
38
+ static group* create(void* owner){return new group(owner);};
39
+
40
+
41
+ };
42
+
43
+ typedef boost::shared_ptr<group> group_ptr;
44
+ typedef std::vector<group_ptr> group_ptr_list;
45
+ typedef std::vector<group*> group_list;
46
+ typedef boost::shared_ptr<group_list> group_list_ptr;
47
+
48
+
49
+
50
+ group* create(group_ptr_list& m, int){return group::create(&m);}
51
+
52
+ class group_fdi
53
+ {
54
+
55
+ public:
56
+ short id;
57
+ short name;
58
+
59
+ //table*�������ɂƂ�init�֐����Ȃ���΂Ȃ�Ȃ�
60
+ void init(table* tb)
61
+ {
62
+ id = tb->fieldNumByName(_T("id"));
63
+ name = tb->fieldNumByName(_T("name"));
64
+ }
65
+ //�C���X�^���X��Ԃ�static �� create�֐����Ȃ���΂Ȃ�Ȃ�
66
+ //static group_fdi* create(){return new group_fdi();};
67
+ };
68
+
69
+ group_fdi* createFdi(group_fdi *){return new group_fdi();}
70
+ void destroyFdi(group_fdi * p){delete p;}
71
+ void initFdi(group_fdi * fdi, table* tb){fdi->init(tb);}
72
+
73
+ class group_orm
74
+ {
75
+ const group_fdi& m_fdi;
76
+
77
+ public:
78
+
79
+ /* mdl_typename���`���Ȃ���΂Ȃ�Ȃ�*/
80
+ typedef group mdl_typename;
81
+
82
+ /* fdi_typename���`���Ȃ���΂Ȃ�Ȃ�
83
+ fdi���g�p���Ȃ��ꍇ�̓f�t�H���g��typedef fdibase fdi_typename; �Ƃ��邱��
84
+ ���ƂȂ�FDI���g�p����ꍇ��activeTable<group, group_fdi>�̂悤��
85
+ activeTable�̃C���X�^���X�쐬����fdi�̌^���w�肷�� */
86
+ typedef group_fdi fdi_typename;
87
+
88
+ /* fdi_typename fdi&�������Ɏ��R���X�g���N�^���K�{ */
89
+ group_orm(const fdi_typename& fdi):m_fdi(fdi){}
90
+
91
+ /* ���j�[�N�L�[�����Ă΂�Ȃ��Ȃ��̂ł��̑��̃L�[���͒�`���Ȃ��Ă悢*/
92
+ bool compKeyValue(group& l, group& r, int keyNum) const
93
+ {
94
+ return l.id() < r.id();
95
+ }
96
+
97
+ void setKeyValues(group& g, const fields& fds, int keyNum)
98
+ {
99
+ fds[m_fdi.id] = g.id();
100
+ }
101
+
102
+ void writeMap(group& g, const fields& fds, int optipn)
103
+ {
104
+ fds[m_fdi.id] = g.id();
105
+ fds[m_fdi.name] = g.name();
106
+ }
107
+
108
+ void readMap(group& g, const fields& fds, int optipn)
109
+ {
110
+ g.setId(fds[m_fdi.id].i());
111
+ g.setName(fds[m_fdi.name].a_str()); //get by ansi string
112
+ }
113
+
114
+ void readAuntoincValue(group& g, const fields& fds, int optipn)
115
+ {
116
+ g.setId(fds[m_fdi.id].i());
117
+ }
118
+
119
+ /* �N���X������e�[�u�������������߂̊֐�getTableName���K�{ */
120
+ const _TCHAR* getTableName(){return _T("group1");}
121
+
122
+
123
+
124
+ };
125
+
126
+ /** User class */
127
+ class user
128
+ {
129
+ mutable group* m_grp;
130
+ int m_id;
131
+ std::string m_name;
132
+ std::string m_tel;
133
+ protected:
134
+ user(void* owner):m_grp(NULL),m_id(0){}
135
+ public:
136
+
137
+
138
+ group* grp()const
139
+ {
140
+ if (m_grp == NULL)
141
+ m_grp = group::create(0);
142
+ return m_grp;
143
+ }
144
+ int id() const {return m_id;}
145
+ const std::string& name() const {return m_name;}
146
+ const std::string& tel() const {return m_tel;}
147
+ void setId(int v){m_id = v;}
148
+ void setName(const char* v){m_name = v;}
149
+ void setTel(const char* v){m_tel = v;}
150
+
151
+ //�R���N�V��������ŕK�{�̊֐��@owner�ɂ̓R���N�V�����̃|�C���^���n����܂��B
152
+
153
+ static user* create(void* owner){return new user(owner);};
154
+
155
+
156
+ };
157
+
158
+ typedef boost::shared_ptr<user> user_ptr;
159
+ typedef std::vector<user_ptr> user_ptr_list;
160
+ typedef std::vector<user*> user_list;
161
+ typedef boost::shared_ptr<user_list> user_list_ptr;
162
+
163
+ /* �C�e���[�^���‚���͖̂ʓ|������ǂ��A���܂��܂ȃA���S���Y�����g�����Ƃ��l�����
164
+ �쐬����̂��x�^�[
165
+ */
166
+ /*class mdls;
167
+ class mdlsIterator : public std::iterator<std::random_access_iterator_tag, user*>
168
+ {
169
+ int m_index;
170
+ mdls& m_mdls;
171
+ public:
172
+ //mdlsIterator():m_mdls(*((mdls*)0)){};
173
+ mdlsIterator(mdls& m, int index=0);
174
+ //mdlsIterator& operator=(const mdlsIterator &r) ;
175
+ user* operator*() const;
176
+ mdlsIterator &operator++();
177
+ bool operator!=(const mdlsIterator &r) const;
178
+ //mdlsIterator& operator-(const mdlsIterator &r);
179
+ //mdlsIterator& operator+(const mdlsIterator &r);
180
+ };*/
181
+
182
+ class mdls;
183
+
184
+ /*user* mdlsIterator::operator*() const{return m_mdls[m_index];}
185
+ mdlsIterator& mdlsIterator::operator++() {++m_index; return *this;}
186
+ bool mdlsIterator::operator!=(const mdlsIterator &r) const {return m_index != r.m_index;}
187
+ */
188
+
189
+
190
+ class mdlsIterator
191
+ : public boost::iterator_facade<mdlsIterator, user*
192
+ , boost::random_access_traversal_tag>
193
+ {
194
+ friend class boost::iterator_core_access;
195
+ size_t m_index;
196
+ mdls* m_mdls;
197
+ user*& dereference() const;
198
+ void increment();
199
+ void decrement();
200
+ void advance(size_t n);
201
+ size_t distance_to(const mdlsIterator &r)const;
202
+ bool equal(const mdlsIterator &r) const;
203
+
204
+ public:
205
+ mdlsIterator(mdls* m, int index=0);
206
+
207
+
208
+ };
209
+
210
+ class mdls
211
+ {
212
+ mutable std::vector<user*> m_users;
213
+ public:
214
+ void clear(){m_users.clear();}
215
+ user* add(user* u)
216
+ {
217
+ m_users.push_back(u);
218
+ return u;
219
+ }
220
+ user*& item(int index)const {return m_users[index];}
221
+ //user** item_ptr(int index)const {return &(m_users[index]);}
222
+ /** �I���W�i���R���N�V�����̏ꍇ�͈ȉ��̂R�‚̊֐���
223
+ �A�C�e���̊i�[�^������item_type����������
224
+ �֐��̒lj�������ȏꍇ��adapter������Ă��������B
225
+ */
226
+
227
+ size_t size(){return m_users.size();}
228
+ user* operator[](unsigned int index)const{return item(index);}
229
+
230
+ /*
231
+ �ȉ��̂Q�‚�typedef��������K�v������
232
+ typedef�̓C���^�t�F�[�X�ɉe�����Ȃ��̂ŁA�ˑ��R�[�h�̍ăR���p�C���͕s�v�ł�
233
+ */
234
+ typedef user* item_type; //�ێ�����^���w��ł��邪 vector�Ő��̏ꍇ�͎w�肷����@���Ȃ�
235
+ typedef mdlsIterator iterator;//�K�{
236
+ /*
237
+ push_back() begin() end()��(�C���^�t�F�[�X�̕ύX�𔺂��̂�����ꍇ)
238
+ �������Ă����Ȃ��Ă��ǂ��B���Ȃ��ꍇ�� bzs::db::protocol::tdap::client���O��Ԃ�
239
+ ���ꉻ����
240
+ template <>
241
+ mdlsIterator push_back(mdls& m);
242
+ mdlsIterator begin(mdls& m);
243
+ mdlsIterator end(mdls& m);
244
+ �̂R�‚̊֐����쐬����B
245
+ */
246
+ //void push_back(user* u){add(u);}
247
+ //mdlsIterator begin(){return mdlsIterator(*this, 0);}
248
+ //mdlsIterator end(){return mdlsIterator(*this, size());}
249
+
250
+ };
251
+
252
+ /* mdlsIterator�̎��� */
253
+ /*mdlsIterator::mdlsIterator(mdls& m, int index):m_index(index),m_mdls(m){};
254
+ user* mdlsIterator::operator*() const{return m_mdls[m_index];}
255
+ mdlsIterator& mdlsIterator::operator++() {++m_index; return *this;}
256
+ bool mdlsIterator::operator!=(const mdlsIterator &r) const {return m_index != r.m_index;}
257
+ */
258
+ void dumpUser2(const user* user)
259
+ {
260
+ std::cout << " id " << user->id() << std::endl;
261
+ std::cout << " name " << user->name() << std::endl;
262
+ std::cout << " group " << user->grp()->name() << std::endl;
263
+ std::cout << " tel " << user->tel() << std::endl << std::endl;
264
+
265
+ }
266
+
267
+
268
+ user*& mdlsIterator::dereference() const
269
+ {
270
+ //for (int i=0;i<m_mdls->size();++i)
271
+ // dumpUser2((*m_mdls)[i]);
272
+
273
+ return m_mdls->item(m_index);
274
+ //return p;
275
+ }
276
+ void mdlsIterator::increment() {++m_index;}
277
+ void mdlsIterator::decrement() {--m_index;}
278
+ void mdlsIterator::advance(size_t n){m_index+=n;}
279
+ size_t mdlsIterator::distance_to(const mdlsIterator &r)const{return r.m_index - m_index;}
280
+ bool mdlsIterator::equal(const mdlsIterator &r) const {return m_index == r.m_index;}
281
+ mdlsIterator::mdlsIterator(mdls* m, int index):m_index(index),m_mdls(m){}
282
+
283
+
284
+
285
+ //�I���W�i���R���N�V������push_back begin end�@���������Ȃ��ꍇ�͈ȉ��̖��O
286
+ //��Ԃɂ��ꂼ��̊֐����쐬����
287
+ namespace bzs{namespace db{namespace protocol{namespace tdap{namespace client
288
+ {
289
+
290
+ inline mdlsIterator begin(mdls& m){return mdlsIterator(&m, 0);}
291
+
292
+ inline mdlsIterator end(mdls& m){return mdlsIterator(&m, m.size());}
293
+
294
+ inline void push_back(mdls& m, user* u){m.add(u);}
295
+ }}}}}
296
+
297
+
298
+ user* create(mdls& m, int){return user::create(&m);}
299
+ user* create(user_ptr_list& m, int){return user::create(&m);}
300
+
301
+
302
+
303
+ class user_fdi //: public fdibase
304
+ {
305
+
306
+ public:
307
+ short id;
308
+ short name;
309
+ short tel;
310
+ short group;
311
+ void init(table* tb)
312
+ {
313
+ id = tb->fieldNumByName(_T("id"));
314
+ name = tb->fieldNumByName(_T("name"));
315
+ tel = tb->fieldNumByName(_T("tel"));
316
+ group = tb->fieldNumByName(_T("group"));
317
+ }
318
+
319
+ //static user_fdi* create(){return new user_fdi();}
320
+ };
321
+
322
+ user_fdi* createFdi(user_fdi *){return new user_fdi();}
323
+ void destroyFdi(user_fdi * p){delete p;}
324
+ void initFdi(user_fdi * fdi, table* tb){fdi->init(tb);}
325
+
326
+
327
+ class user_orm
328
+ {
329
+ const user_fdi& m_fdi;
330
+
331
+ public:
332
+ user_orm(const user_fdi& fdi):m_fdi(fdi){}
333
+
334
+ bool compKeyValue(user& l, user& r, int keyNum) const
335
+ {
336
+ if (keyNum==0)
337
+ return l.id() < r.id();
338
+ return 1;
339
+ }
340
+
341
+ void setKeyValues(user& u, const fields& fds, int keyNum)
342
+ {
343
+ fds[m_fdi.id] = u.id();
344
+ }
345
+
346
+ void writeMap(user& u, const fields& fds, int optipn)
347
+ {
348
+ fds[m_fdi.id] = u.id();
349
+ fds[m_fdi.name] = u.name();
350
+ fds[m_fdi.tel] = u.tel();
351
+ fds[m_fdi.group] = u.grp()->id();
352
+ }
353
+
354
+ void readMap(user& u, const fields& fds, int optipn)
355
+ {
356
+ u.setId(fds[m_fdi.id].i());
357
+ u.setName(fds[m_fdi.name].a_str()); //get by ansi string
358
+ u.setTel(fds[m_fdi.tel].a_str()); //get by ansi string
359
+ u.grp()->setId(fds[m_fdi.group].i());
360
+ }
361
+
362
+ void readAuntoincValue(user& u, const fields& fds, int optipn)
363
+ {
364
+ u.setId(fds[m_fdi.id].i());
365
+ }
366
+
367
+ /* �N���X������e�[�u�������������߂̊֐�getTableName���K�{ */
368
+ const _TCHAR* getTableName(){return _T("user");}
369
+
370
+ typedef user mdl_typename;
371
+ typedef user_fdi fdi_typename;
372
+
373
+ /* �I���W�i���R���N�V�������‚����Ƃ��ɒ�`����
374
+ �ŏ��̌^�͂��̃}�b�v�N���X�A2�Ԗڂ̌^�̓R���N�V�����N���X
375
+ ���ꂪ��`����Ă��Ă�vector<shared_ptr<T>>�̃R���N�V������
376
+ �������Ɏg���܂��B
377
+ */
378
+ typedef mdlsHandler<user_orm, mdls> collection_orm_typename;
379
+
380
+ };
381
+
382
+ typedef user_orm::collection_orm_typename users_orm;
383
+
384
+
385
+ int isMatch(const fields& fds)
386
+ {
387
+ return filter_validate_value;
388
+ }
389
+
390
+ /** dump user to screen */
391
+ void dumpUser(const user_ptr& user)
392
+ {
393
+ std::cout << " id " << user->id() << std::endl;
394
+ std::cout << " name " << user->name() << std::endl;
395
+ std::cout << " group " << user->grp()->name() << std::endl;
396
+ std::cout << " tel " << user->tel() << std::endl << std::endl;
397
+
398
+ }
399
+
400
+ bool sortFunc2(const user* l, const user* r)
401
+ {
402
+
403
+ return l->name() < r->name();
404
+ }
405
+
406
+ void readUsers(databaseManager& db, std::vector<user_ptr>& users)
407
+ {
408
+ int id = 12;
409
+ int find_group_id = 3;
410
+ bool readMyKeyValue = false;
411
+ // user_orm��activeTable�̃C���X�^���X���쐬���܂��B
412
+ activeTable<user_orm> ut(db);
413
+
414
+ //id=12�̃��[�U�[���쐬���܂��B
415
+ user_ptr u(user::create(0));
416
+ u->setId(id);
417
+ u->setName("moriwaki");
418
+ u->setTel("81-999-9999");
419
+ u->grp()->setId(1);
420
+ ut.index(primary_key);
421
+ ut.save(*u);
422
+
423
+ //id=12�̃��[�U�[��ǂݎ��
424
+ ut.read(*u);
425
+
426
+ //id=12�̃��[�U�[�̓d�b�ԍ��̕ύX
427
+ u->setTel("81-999-8888");
428
+ ut.update(*u);
429
+
430
+ //�L�[�l��ς���Ƃ���
431
+ ut.index(primary_key).keyValue(u->id());
432
+ u->setId(13);
433
+ ut.update(*u, readMyKeyValue);
434
+
435
+ //id=13�̃��[�U�[�폜
436
+ ut.del(*u);
437
+
438
+ //�폜�̓L�[�l�����ł�OK
439
+ ut.index(primary_key).keyValue(12).del(); //�G���[�@���R�[�h�Ȃ�
440
+
441
+
442
+
443
+ //�J�[�\����index�ƃL�[�ʒu���w�肵�܂��B
444
+ //�������烌�R�[�h�̌������J�n���܂��B
445
+ ut.index(keynum_group).keyValue(find_group_id);
446
+
447
+ //�����������w�肵�܂��B�T�[�o�[�t�B���^�[�ł��B
448
+ //reject�Ŏw�肵���A���}�b�`���R�[�h���ɂȂ�ƌ����𒆎~���܂��B
449
+ query q;
450
+ q.select(_T("*")).where(_T("group"), _T("=") , find_group_id)//.or(_T("group"), _T("=") , _T("a"))
451
+ .reject(1);
452
+
453
+ //�ǂݎ������s�B�@���ʂ��󂯎��R���N�V�����ƃN�G���[��n���܂��B
454
+ ut.read(users, q);
455
+
456
+
457
+ /*
458
+ �O���reads�Ŏg�p�����R���N�V������vector�ł����B�������I���W�i����
459
+ �R���N�V�������g�p���Ă���ꍇ������ł��傤
460
+ user_orm�ɃI���W�i���R���N�V�����}�b�v�̌^collection_orm_typename��
461
+ �m�点�Ă����Ύ����ŃC���X�^���X���쐬���n���h�����Ă���܂�*/
462
+
463
+ mdls m;
464
+ ut.index(keynum_group).keyValue(find_group_id).read(m, q);
465
+
466
+
467
+ /*
468
+ �I���W�i���R���N�V�����}�b�v�������ō쐬�łȂ������ŏ���������
469
+ �g���������Ƃ�����ł��傤���̎���readsBy���g�p���܂�*/
470
+
471
+ users_orm users_hdr(m);
472
+ ut.readRange(users_hdr, q);
473
+
474
+
475
+ /* �N���C�A���g���t�B���^�[���ȒP�Ɏg���܂��B
476
+ isMatch�֐��̂悤�ȁ@const fields&�������Ɏ����int��Ԃ��֐��Ȃ牽�ł�
477
+ OK�ł��B
478
+ */
479
+ ut.index(keynum_group).keyValue(find_group_id).read(users, q, isMatch);
480
+
481
+
482
+
483
+ //group�̓ǂݎ��
484
+ group_ptr grp(group::create(0));
485
+
486
+ activeTable<group_orm> gt(db);
487
+ //shared_ptr<group>�̃C���X�^���X��*���‚��ēn���܂��B
488
+ gt.index(0).keyValue(2).read(*grp);
489
+
490
+
491
+
492
+ /*
493
+ ���|�C���^�̃|�C���^�̎��� *���‚��ēn���܂��B
494
+ shared_ptr�ł����|�C���^�ł�*���‚��ē����悤�ɓn���܂��B
495
+ */
496
+ group* g = group::create(0);
497
+ gt.read(*g);
498
+ delete g;
499
+
500
+
501
+ //--------------------------------------------------------
502
+ // Join�̂悤�ȏ���
503
+ //--------------------------------------------------------
504
+ /*
505
+ users����O���[�v�̃��X�g���쐬����user�Ɋ֘A�t�����O���[�v
506
+ ��ǂݎ��܂��B
507
+ list�֐��ɃR���N�V������user->grp()�֐��̃A�h���X��n���܂��B
508
+ activeTable<group_orm>��readEach�֐��ɂ��̃��X�g��n���܂��B
509
+ */
510
+ query qe;
511
+ group_list_ptr grps(listup(users, &user::grp));
512
+ gt.index(primary_key).readEach(*grps, qe.select(_T("id"), _T("name")));
513
+
514
+
515
+ //�I���W�i���̃O���[�v���X�g�ł�listup�֐��͎g���܂��B
516
+ group_list_ptr grps2(listup(m, &user::grp));
517
+ gt.index(primary_key).readEach(*grps2, qe);
518
+
519
+
520
+ //listup���������Ď����ōs��
521
+ gt.index(primary_key);
522
+ gt.readEach(users, &user::grp, qe.select(_T("id"), _T("name")));
523
+ gt.readEach(m, &user::grp, qe);
524
+
525
+ //IN
526
+ gt.index(primary_key);
527
+ qe.reset();
528
+ std::vector<group_ptr> gmdls;
529
+ gt.read(gmdls, qe.select(_T("id"), _T("name")).in(1, 2, 3));
530
+
531
+ //orderby
532
+ users.clear();
533
+ ut.index(0).keyValue(0).read(users, q.all());
534
+ sort(users, &user::name, &user::id);
535
+
536
+ //groupby
537
+ //����l�����o����
538
+
539
+ //�\�[�g�Ή��̃C�e���[�^�͑�ςł��B
540
+ m.clear();
541
+ ut.index(0).keyValue(0).read(m, q);
542
+
543
+ sort(m, &user::name);
544
+ std::sort(begin(m), end(m), &sortFunc2);
545
+
546
+ std::for_each(begin(m), end(m), dumpUser2);
547
+
548
+ //�e�[�u�������̑���
549
+ table_ptr tb = ut.table();
550
+ tb->clearOwnerName();
551
+ }
552
+
553
+
554
+ #pragma argsused
555
+ int _tmain(int argc, _TCHAR* argv[])
556
+ {
557
+ database_ptr db = createDatadaseObject();
558
+ try
559
+ {
560
+ connectParams param(_T("tdap"), _T("localhost"), _T("test"), _T("test"));
561
+ openDatabase(db, param);
562
+
563
+ databaseManager mgr(db);
564
+ std::vector<user_ptr> users;
565
+
566
+ readUsers(mgr, users);
567
+ std::cout << "Read records success.\nRecord count = " << users.size() << std::endl;
568
+
569
+ //dump users to screen.
570
+ std::for_each(users.begin(), users.end(), dumpUser);
571
+
572
+ return 0;
573
+ }
574
+
575
+ catch(bzs::rtl::exception& e)
576
+ {
577
+ std::tcout << *bzs::rtl::getMsg(e) << std::endl;
578
+ }
579
+ return 1;
580
+ }
581
+
582
+
583
+
584
+
585
+
@@ -44,12 +44,16 @@ class exception : public std::exception
44
44
 
45
45
 
46
46
  public:
47
+ exception(): std::exception(),m_error(0){};
47
48
  exception(int error, const std::_tstring& message): std::exception()
48
49
  ,m_error(error),m_message(message){};
49
50
  explicit exception(int error):std::exception(),m_error(error){};
50
51
  explicit exception(const std::_tstring& message): std::exception(),m_message(message){};
51
52
  const std::_tstring& getMessage(){return m_message;}
52
53
  const int& getErrorCode(){return m_error;}
54
+ exception& operator<<(int error){m_error = error;return *this;}
55
+ exception& operator<<(const _TCHAR* msg){m_message += msg;return *this;}
56
+
53
57
 
54
58
  };
55
59
 
@@ -67,6 +71,8 @@ inline const int* getCode(bzs::rtl::exception &e)
67
71
  return &e.getErrorCode();
68
72
  }
69
73
 
74
+ inline int errnoCode(int code){return code;}
75
+ inline const _TCHAR* errMessage(const _TCHAR* msg){return msg;}
70
76
 
71
77
 
72
78
 
@@ -217,6 +217,7 @@ function Reads(db, tb, start, end, name, shapshot)
217
217
  /*--------------------------------------------------------------------------------*/
218
218
  function ReadRange(db, tb, start, end, name, unit, shapshot)
219
219
  {
220
+ var qb = new ActiveXObject('transactd.query');
220
221
  var ret = true;
221
222
  var now = new Date();
222
223
  var ticks = now.getTime();
@@ -229,9 +230,9 @@ function ReadRange(db, tb, start, end, name, unit, shapshot)
229
230
  while (en != end)
230
231
  {
231
232
  en = st + unit;
232
- tb.Filter = "id >= " + st + " and id < " + en;
233
- tb.FilterRejectCount = 1;
234
233
  tb.ClearBuffer();
234
+ qb.Where("id", ">=", st).And("id", "<", en);
235
+ tb.SetQuery(qb);
235
236
  tb.Vlng(fn_id) = st;
236
237
  tb.SeekGreater(true/*orEqual*/);
237
238
  for(var i=st;i<en;i++)
@@ -243,7 +244,6 @@ function ReadRange(db, tb, start, end, name, unit, shapshot)
243
244
  break;
244
245
  }
245
246
  tb.FindNext();
246
-
247
247
  }
248
248
  if (ret==false) break;
249
249
  st = en;
@@ -391,15 +391,20 @@ function main()
391
391
  var end = start + count;
392
392
 
393
393
  if (db.Open(URI, TYPE_BDF, OPEN_NORMAL, "", ""))
394
- db.Drop();
394
+ {
395
+ if (execType < 3)
396
+ db.Drop();
397
+ }
395
398
  if (db.Stat == 3106)
396
399
  {
397
400
  WScript.Echo("Error! Maybe MySQL or Tranasactd is stopping! ");
398
401
  return 1;
399
402
  }
400
- if (!createTestDataBase(db, URI))
401
- return 1;
402
-
403
+ if (execType < 3)
404
+ {
405
+ if (!createTestDataBase(db, URI))
406
+ return 1;
407
+ }
403
408
  var now = new Date();
404
409
  WScript.Echo("Start Bench mark Insert Items = " + count);
405
410
  WScript.Echo(now);