transactd 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. checksums.yaml +7 -0
  2. data/BUILD_UNIX-JA +174 -0
  3. data/BUILD_WIN-JA +256 -0
  4. data/CMakeLists.txt +96 -0
  5. data/COPYING +339 -0
  6. data/README +406 -0
  7. data/README-JA +424 -0
  8. data/bin/common/tdclc_32_1_0.dll +0 -0
  9. data/bin/common/tdclc_64_1_0.dll +0 -0
  10. data/build/common/check_for_link_iconv.cmake +73 -0
  11. data/build/common/copyifgreater.cmd +30 -0
  12. data/build/common/copyifgreater.js +290 -0
  13. data/build/common/get_boost_libs.cmake +106 -0
  14. data/build/common/get_ruby_path.cmake +115 -0
  15. data/build/common/options.cmake +127 -0
  16. data/build/common/smart_install.cmake +263 -0
  17. data/build/common/system.cmake +122 -0
  18. data/build/common/transactd.rc.in +52 -0
  19. data/build/common/transactd_cl_common.cmake +101 -0
  20. data/build/common/transactd_cl_output.cmake +93 -0
  21. data/build/common/transactd_common.cmake +237 -0
  22. data/build/common/transactd_required.cmake +28 -0
  23. data/build/swig/ruby/generate.cmake.in +35 -0
  24. data/build/swig/ruby/generate.cmd.in +19 -0
  25. data/build/swig/ruby/ruby.swg +101 -0
  26. data/build/swig/tdcl.i +188 -0
  27. data/build/tdclc/BUILDNUMBER.txt +1 -0
  28. data/build/tdclc/CMakeLists.txt +170 -0
  29. data/build/tdclc/tdclc_32.cbproj +181 -0
  30. data/build/tdclc/tdclc_64.cbproj +205 -0
  31. data/build/tdclcpp/BUILDNUMBER.txt +1 -0
  32. data/build/tdclcpp/CMakeLists.txt +142 -0
  33. data/build/tdclcpp/tdclcpp_bcb_32.cbproj +239 -0
  34. data/build/tdclcpp/tdclcpp_bcb_64.cbproj +304 -0
  35. data/build/tdclrb/BUILDNUMBER.txt +1 -0
  36. data/build/tdclrb/CMakeLists.txt +258 -0
  37. data/build/tdclrb/GEM_VERSION +3 -0
  38. data/build/tdclrb/bldgem/extconf.rb +123 -0
  39. data/build/tdclrb/gem/INSTALLLOG.win32 +9 -0
  40. data/build/tdclrb/gem/Makefile.win32-VS +65 -0
  41. data/build/tdclrb/gem/Makefile.win32-prebuilt +48 -0
  42. data/build/tdclrb/gem/detect.rb +31 -0
  43. data/build/tdclrb/gem/helper.rb +113 -0
  44. data/build/tdclrb/gem/transactd.rb +22 -0
  45. data/build/tdclrb/gem_output.cmake +44 -0
  46. data/source/bzs/db/IBlobBuffer.h +51 -0
  47. data/source/bzs/db/blobBuffer.h +177 -0
  48. data/source/bzs/db/blobStructs.h +85 -0
  49. data/source/bzs/db/engine/mysql/IReadRecords.h +52 -0
  50. data/source/bzs/db/engine/mysql/bookmark.h +195 -0
  51. data/source/bzs/db/engine/mysql/database.cpp +1882 -0
  52. data/source/bzs/db/engine/mysql/database.h +465 -0
  53. data/source/bzs/db/engine/mysql/dbManager.cpp +303 -0
  54. data/source/bzs/db/engine/mysql/dbManager.h +143 -0
  55. data/source/bzs/db/engine/mysql/errorMessage.cpp +75 -0
  56. data/source/bzs/db/engine/mysql/errorMessage.h +43 -0
  57. data/source/bzs/db/engine/mysql/fieldAccess.h +158 -0
  58. data/source/bzs/db/engine/mysql/mydebuglog.cpp +349 -0
  59. data/source/bzs/db/engine/mysql/mydebuglog.h +89 -0
  60. data/source/bzs/db/engine/mysql/mysqlInternal.h +171 -0
  61. data/source/bzs/db/engine/mysql/mysqlThd.cpp +169 -0
  62. data/source/bzs/db/engine/mysql/mysqlThd.h +35 -0
  63. data/source/bzs/db/engine/mysql/percentageKey.h +260 -0
  64. data/source/bzs/db/protocol/ICommandExecuter.h +49 -0
  65. data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +689 -0
  66. data/source/bzs/db/protocol/hs/hsCommandExecuter.h +228 -0
  67. data/source/bzs/db/protocol/tdap/btrDate.cpp +437 -0
  68. data/source/bzs/db/protocol/tdap/btrDate.h +227 -0
  69. data/source/bzs/db/protocol/tdap/client/bulkInsert.h +127 -0
  70. data/source/bzs/db/protocol/tdap/client/client.cpp +106 -0
  71. data/source/bzs/db/protocol/tdap/client/client.h +292 -0
  72. data/source/bzs/db/protocol/tdap/client/connMgr.cpp +144 -0
  73. data/source/bzs/db/protocol/tdap/client/connMgr.h +82 -0
  74. data/source/bzs/db/protocol/tdap/client/database.cpp +863 -0
  75. data/source/bzs/db/protocol/tdap/client/database.h +118 -0
  76. data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +100 -0
  77. data/source/bzs/db/protocol/tdap/client/dbDef.cpp +1640 -0
  78. data/source/bzs/db/protocol/tdap/client/dbDef.h +135 -0
  79. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +434 -0
  80. data/source/bzs/db/protocol/tdap/client/errorMessage.cpp +92 -0
  81. data/source/bzs/db/protocol/tdap/client/errorMessage_ja.cpp +98 -0
  82. data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +174 -0
  83. data/source/bzs/db/protocol/tdap/client/fieldDDF.h +91 -0
  84. data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +140 -0
  85. data/source/bzs/db/protocol/tdap/client/fileDDF.h +86 -0
  86. data/source/bzs/db/protocol/tdap/client/filter.cpp +527 -0
  87. data/source/bzs/db/protocol/tdap/client/filter.h +154 -0
  88. data/source/bzs/db/protocol/tdap/client/indexDDF.cpp +137 -0
  89. data/source/bzs/db/protocol/tdap/client/indexDDF.h +84 -0
  90. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +724 -0
  91. data/source/bzs/db/protocol/tdap/client/nsDatabase.h +123 -0
  92. data/source/bzs/db/protocol/tdap/client/nsTable.cpp +899 -0
  93. data/source/bzs/db/protocol/tdap/client/nsTable.h +199 -0
  94. data/source/bzs/db/protocol/tdap/client/request.h +198 -0
  95. data/source/bzs/db/protocol/tdap/client/sharedData.cpp +58 -0
  96. data/source/bzs/db/protocol/tdap/client/sharedData.h +56 -0
  97. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +574 -0
  98. data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +53 -0
  99. data/source/bzs/db/protocol/tdap/client/stringConverter.h +627 -0
  100. data/source/bzs/db/protocol/tdap/client/table.cpp +2613 -0
  101. data/source/bzs/db/protocol/tdap/client/table.h +221 -0
  102. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +1096 -0
  103. data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +179 -0
  104. data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +40 -0
  105. data/source/bzs/db/protocol/tdap/client/trnsctcl.def +11 -0
  106. data/source/bzs/db/protocol/tdap/myDateTime.cpp +500 -0
  107. data/source/bzs/db/protocol/tdap/mysql/characterset.cpp +184 -0
  108. data/source/bzs/db/protocol/tdap/mysql/characterset.h +60 -0
  109. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +284 -0
  110. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +53 -0
  111. data/source/bzs/db/protocol/tdap/mysql/debuglog.cpp +383 -0
  112. data/source/bzs/db/protocol/tdap/mysql/debuglog.h +106 -0
  113. data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +680 -0
  114. data/source/bzs/db/protocol/tdap/mysql/request.h +202 -0
  115. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +1020 -0
  116. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +141 -0
  117. data/source/bzs/db/protocol/tdap/tdapRequest.h +190 -0
  118. data/source/bzs/db/protocol/tdap/tdapSchema.cpp +295 -0
  119. data/source/bzs/db/protocol/tdap/tdapSchema.h +558 -0
  120. data/source/bzs/db/protocol/tdap/tdapcapi.h +423 -0
  121. data/source/bzs/db/transactd/appBuilderImple.h +55 -0
  122. data/source/bzs/db/transactd/appModule.cpp +183 -0
  123. data/source/bzs/db/transactd/appModule.h +80 -0
  124. data/source/bzs/db/transactd/connManager.cpp +201 -0
  125. data/source/bzs/db/transactd/connManager.h +60 -0
  126. data/source/bzs/db/transactd/connectionRecord.h +69 -0
  127. data/source/bzs/db/transactd/transactd.cpp +325 -0
  128. data/source/bzs/env/compiler.h +135 -0
  129. data/source/bzs/env/crosscompile.cpp +130 -0
  130. data/source/bzs/env/crosscompile.h +150 -0
  131. data/source/bzs/env/fileopen.h +36 -0
  132. data/source/bzs/env/mbcswchrLinux.cpp +40 -0
  133. data/source/bzs/env/mbcswchrLinux.h +88 -0
  134. data/source/bzs/env/tstring.h +183 -0
  135. data/source/bzs/example/changeSchema.cpp +117 -0
  136. data/source/bzs/example/changeSchema_c.cpp +78 -0
  137. data/source/bzs/example/connection_pool_c.cpp +171 -0
  138. data/source/bzs/example/createDatabase.cpp +305 -0
  139. data/source/bzs/example/createDatabase_c.cpp +202 -0
  140. data/source/bzs/example/deleteRecords.cpp +87 -0
  141. data/source/bzs/example/deleteRecords_c.cpp +57 -0
  142. data/source/bzs/example/dropDatabase.cpp +59 -0
  143. data/source/bzs/example/dropDatabase_c.cpp +34 -0
  144. data/source/bzs/example/insertRecords.cpp +212 -0
  145. data/source/bzs/example/insertRecords_c.cpp +153 -0
  146. data/source/bzs/example/readRecords.cpp +141 -0
  147. data/source/bzs/example/readRecords_c.cpp +107 -0
  148. data/source/bzs/example/updateRecords.cpp +99 -0
  149. data/source/bzs/example/updateRecords_c.cpp +71 -0
  150. data/source/bzs/example/update_with_transaction.cpp +104 -0
  151. data/source/bzs/example/update_with_transaction_c.cpp +80 -0
  152. data/source/bzs/netsvc/client/tcpClient.cpp +226 -0
  153. data/source/bzs/netsvc/client/tcpClient.h +489 -0
  154. data/source/bzs/netsvc/server/IAppModule.h +94 -0
  155. data/source/bzs/netsvc/server/iserver.h +65 -0
  156. data/source/bzs/netsvc/server/serverCpt.cpp +522 -0
  157. data/source/bzs/netsvc/server/serverCpt.h +88 -0
  158. data/source/bzs/netsvc/server/serverPipe.cpp +705 -0
  159. data/source/bzs/netsvc/server/serverPipe.h +96 -0
  160. data/source/bzs/netsvc/server/serverTpool.cpp +416 -0
  161. data/source/bzs/netsvc/server/serverTpool.h +84 -0
  162. data/source/bzs/rtl/benchmark.cpp +96 -0
  163. data/source/bzs/rtl/benchmark.h +65 -0
  164. data/source/bzs/rtl/datetime.cpp +375 -0
  165. data/source/bzs/rtl/datetime.h +53 -0
  166. data/source/bzs/rtl/debuglog.cpp +106 -0
  167. data/source/bzs/rtl/debuglog.h +97 -0
  168. data/source/bzs/rtl/exception.h +116 -0
  169. data/source/bzs/rtl/stl_uty.cpp +35 -0
  170. data/source/bzs/rtl/stl_uty.h +29 -0
  171. data/source/bzs/rtl/stringBuffers.cpp +101 -0
  172. data/source/bzs/rtl/stringBuffers.h +58 -0
  173. data/source/bzs/rtl/strtrim.cpp +135 -0
  174. data/source/bzs/rtl/strtrim.h +46 -0
  175. data/source/bzs/test/tdclatl/bench_tdclatl.js +445 -0
  176. data/source/bzs/test/tdclrb/bench_tdclcpp.rb +375 -0
  177. data/source/bzs/test/tdclrb/prepare.rb +226 -0
  178. data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +172 -0
  179. data/source/bzs/test/tdclrb/transactd_kanjischema_spec.rb +208 -0
  180. data/source/bzs/test/tdclrb/transactd_spec.rb +1536 -0
  181. data/source/bzs/test/transactdBench/transactdBench.cpp +430 -0
  182. data/source/bzs/test/transactdBench/transactdBench2.cpp +342 -0
  183. data/source/bzs/test/trdclengn/test_trdclengn.cpp +2030 -0
  184. data/source/global/tdclatl/Database.cpp +503 -0
  185. data/source/global/tdclatl/Database.h +139 -0
  186. data/source/global/tdclatl/DbDef.cpp +242 -0
  187. data/source/global/tdclatl/DbDef.h +79 -0
  188. data/source/global/tdclatl/Field.cpp +92 -0
  189. data/source/global/tdclatl/Field.h +59 -0
  190. data/source/global/tdclatl/FieldDef.cpp +238 -0
  191. data/source/global/tdclatl/FieldDef.h +87 -0
  192. data/source/global/tdclatl/Flags.cpp +111 -0
  193. data/source/global/tdclatl/Flags.h +55 -0
  194. data/source/global/tdclatl/KeyDef.cpp +51 -0
  195. data/source/global/tdclatl/KeyDef.h +55 -0
  196. data/source/global/tdclatl/KeySegment.cpp +55 -0
  197. data/source/global/tdclatl/Table.cpp +600 -0
  198. data/source/global/tdclatl/Table.h +144 -0
  199. data/source/global/tdclatl/TableDef.cpp +291 -0
  200. data/source/global/tdclatl/TableDef.h +86 -0
  201. data/source/global/tdclatl/TdVersion.cpp +74 -0
  202. data/source/global/tdclatl/TdVersion.h +54 -0
  203. data/source/global/tdclatl/_IDatabaseEvents_CP.h +113 -0
  204. data/source/global/tdclatl/dllmain.cpp +30 -0
  205. data/source/global/tdclatl/dllmain.h +27 -0
  206. data/source/global/tdclatl/keySegment.h +57 -0
  207. data/source/global/tdclatl/resource.h +0 -0
  208. data/source/global/tdclatl/stdafx.cpp +2 -0
  209. data/source/global/tdclatl/stdafx.h +25 -0
  210. data/source/global/tdclatl/targetver.h +4 -0
  211. data/source/global/tdclatl/tdclatl.cpp +68 -0
  212. data/source/global/tdclatl/tdclatl.def +10 -0
  213. data/source/global/tdclatl/tdclatl.idl +1035 -0
  214. data/source/linux/charsetConvert.h +112 -0
  215. data/source/linux/linuxTypes.h +33 -0
  216. data/source/linux/tchar.h +428 -0
  217. data/transactd.gemspec +97 -0
  218. metadata +267 -0
@@ -0,0 +1,342 @@
1
+ /*=================================================================
2
+ Copyright (C) 2013 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
+
20
+ #pragma hdrstop
21
+
22
+ #include <tchar.h>
23
+ #include <bzs/db/protocol/tdap/client/trdboostapi.h>
24
+ #include <time.h>
25
+ #include <bzs/rtl/benchmark.h>
26
+ #include <boost/bind.hpp>
27
+ #include <stdio.h>
28
+
29
+ #define _CRT_SECURE_NO_WARNINGS
30
+
31
+
32
+ static const char keynum_id = 0;
33
+ static const short fn_id = 0;
34
+ static const short fn_name = 1;
35
+
36
+ static const int USE_NORMAL = 0;
37
+ static const int USE_TRANS = 1;
38
+ static const int USE_BALKINS = 2;
39
+ static const int USE_SNAPSHOT = 4;
40
+
41
+ using namespace bzs::rtl;
42
+ using namespace bzs::db::protocol::tdap;
43
+ using namespace bzs::db::protocol::tdap::client;
44
+
45
+
46
+ /* -------------------------------------------------------------------------------- */
47
+ void write(fields& fds, int start, int end)
48
+ {
49
+ for (int i = start; i < end; i++)
50
+ {
51
+ fds.clearValues();
52
+ fds[fn_id] = i;
53
+ fds[fn_name] = i;
54
+ insertRecord(fds);
55
+ }
56
+ }
57
+
58
+ /* -------------------------------------------------------------------------------- */
59
+ bool deleteAll(database_ptr db, table_ptr tb, int start, int end)
60
+ {
61
+ transaction trn(db);
62
+ trn.begin();
63
+
64
+ for (int i = start; i < end; i++)
65
+ {
66
+ indexIterator it = readIndex_v(tb, eSeekEqual, keynum_id, i);
67
+ if (it != indexIterator::eos)
68
+ deleteRecord(it);
69
+ }
70
+ trn.end();
71
+ return true;
72
+ }
73
+
74
+ /* -------------------------------------------------------------------------------- */
75
+ void inserts(database_ptr db, table_ptr tb, int start, int end, int mode, int unit)
76
+ {
77
+ int total = end - start;
78
+ int count = total / unit;
79
+ int st = start;
80
+ int en = st;
81
+ fields fds(tb);
82
+ while (en != end)
83
+ {
84
+ en = st + unit;
85
+ if (mode == USE_TRANS)
86
+ {
87
+ transaction trn(db);
88
+ trn.begin();
89
+ write(fds, st, en);
90
+ trn.end();
91
+ }else if (mode == USE_BALKINS)
92
+ {
93
+ autoBulkinsert bi(tb);
94
+ write(fds, st, en);
95
+ }else
96
+ write(fds, st, en);
97
+ st = en;
98
+ }
99
+ }
100
+
101
+ /* -------------------------------------------------------------------------------- */
102
+ template <class T>
103
+ void checkFldIdValue(T it, int value)
104
+ {
105
+ const fields& fds = *it;
106
+ if ((it == T::eos) || fds[fn_id] != value)
107
+ {
108
+ _TCHAR buf[256];
109
+ _stprintf_s(buf, 256, _T("read error.Can not found value %d = %d\r\n"), value, fds[fn_id].i());
110
+ THROW_BZS_ERROR_WITH_MSG(buf);
111
+ }
112
+ }
113
+
114
+ /* -------------------------------------------------------------------------------- */
115
+ void doRead( database_ptr db, table_ptr tb, int start, int end, int shapshot)
116
+ {
117
+ for (int i = start; i < end; i++)
118
+ {
119
+ indexIterator it = readIndex_v(tb, eSeekEqual, keynum_id, i);
120
+ checkFldIdValue(it, i);
121
+ }
122
+ }
123
+
124
+ /* -------------------------------------------------------------------------------- */
125
+ void read( database_ptr db, table_ptr tb, int start, int end, int shapshot)
126
+ {
127
+ if (shapshot == USE_SNAPSHOT)
128
+ {
129
+ autoSnapshot sn(db);
130
+ doRead(db, tb, start, end, shapshot);
131
+ }else
132
+ doRead(db, tb, start, end, shapshot);
133
+ }
134
+
135
+ /* -------------------------------------------------------------------------------- */
136
+ void doRreads(database_ptr db, table_ptr tb, int start, int end, int unit)
137
+ {
138
+ int total = end - start;
139
+ int count = total / unit;
140
+ int st = start;
141
+ int en = st;
142
+ filterParams fp( _T("*"), 1 , 20);
143
+ findIterator itsf = find(tb, keynum_id, fp, st);
144
+ while (en != end)
145
+ {
146
+ en = st + unit;
147
+ for (int i = st; i < en; i++)
148
+ {
149
+ checkFldIdValue(itsf, i);
150
+ ++itsf;
151
+ }
152
+ st = en;
153
+ }
154
+ }
155
+ /* -------------------------------------------------------------------------------- */
156
+ void reads(database_ptr db, table_ptr tb, int start, int end, int unit, int shapshot)
157
+ {
158
+ if (shapshot == USE_SNAPSHOT)
159
+ {
160
+ autoSnapshot sn(db);
161
+ doRreads(db, tb, start, end, unit);
162
+ }else
163
+ doRreads(db, tb, start, end, unit);
164
+ }
165
+ /* -------------------------------------------------------------------------------- */
166
+ void doUupdates(table_ptr tb, int st, int en, int tran)
167
+ {
168
+ _TCHAR buf[256];
169
+ for (int i = st; i < en; i++)
170
+ {
171
+ fields fd(tb);
172
+ fd[fn_id] = i;
173
+ _ltot_s(i + 1 + tran, buf, 30, 10);
174
+ fd[fn_name] = buf;
175
+ updateRecord(fd, keynum_id);
176
+ }
177
+ }
178
+ /* -------------------------------------------------------------------------------- */
179
+ void updates(database_ptr db, table_ptr tb, int start, int end, int tran, int unit)
180
+ {
181
+ int total = end - start;
182
+ int count = total / unit;
183
+ int st = start;
184
+ int en = st;
185
+ while (en != end)
186
+ {
187
+ en = st + unit;
188
+ if (tran == USE_TRANS)
189
+ {
190
+ transaction trn(db);
191
+ trn.begin();
192
+ doUupdates(tb, st, en, 1);
193
+ trn.end();
194
+ }else
195
+ doUupdates(tb, st, en, 0);
196
+ st = en;
197
+ }
198
+ }
199
+
200
+ /* -------------------------------------------------------------------------------- */
201
+ void createUserTableSchema(dbdef* def)
202
+ {
203
+ static const short tableid = 1;
204
+ insertTable(def, tableid, _T("user"), CHARSET_LATIN1);
205
+
206
+ short fieldNum = 0;
207
+ insertField(def, tableid, fieldNum, _T("id"), ft_integer, 4);
208
+ insertField(def, tableid, ++fieldNum, _T("name"), ft_myvarchar, 100);
209
+ updateTableDef(def, tableid);
210
+
211
+ short keyNum = 0;
212
+ keydef* kd = insertKey(def, tableid, keyNum);
213
+ kd->segments[0].fieldNum = 0;
214
+ kd->segments[0].flags.bit8 = 1; // extend key type
215
+ kd->segments[0].flags.bit1 = 1; // changeable
216
+ kd->segmentCount = 1;
217
+ updateTableDef(def, tableid);
218
+
219
+ }
220
+
221
+ /* -------------------------------------------------------------------------------- */
222
+ void createTestDataBase(database_ptr db, connectParams& params)
223
+ {
224
+ params.setMode(TD_OPEN_EXCLUSIVE);
225
+ createDatabase(db, params);
226
+ openDatabase(db, params);
227
+ createUserTableSchema(db->dbDef());
228
+ }
229
+
230
+ /* -------------------------------------------------------------------------------- */
231
+ void printHeader(const _TCHAR* uri, int count)
232
+ {
233
+ printf("Start Bench mark Insert Items = %d\r\n", count);
234
+ time_t timer;
235
+ #ifdef LINUX
236
+ time(&timer);
237
+ #else
238
+ timer = time(NULL);
239
+ #endif
240
+ #pragma warning( disable : 4996 )
241
+ printf("%s", ctime(&timer));
242
+ #pragma warning( default : 4996 )
243
+
244
+ _tprintf(_T("%s\r\n"), uri);
245
+ printf("BOOST_VERSION = %s\r\n", BOOST_LIB_VERSION );
246
+ printf("----------------------------------------\r\n");
247
+ }
248
+
249
+ /* -------------------------------------------------------------------------------- */
250
+ void printTail()
251
+ {
252
+ printf("----------------------------------------\r\n");
253
+ }
254
+
255
+ /* -------------------------------------------------------------------------------- */
256
+ void showUsage()
257
+ {
258
+ printf("usage: transactdBench databaseUri processNumber functionNumber\n "
259
+ "\t --- Below is list of functionNumber ---\n"
260
+ "\t-1: all function\n"
261
+ "\t 0: Insert\n"
262
+ "\t 1: Insert in transaction. 20rec x 1000times\n"
263
+ "\t 2: Insert by bulkmode. 20rec x 1000times\n"
264
+ "\t 3: read each record\n"
265
+ "\t 4: read each record with snapshpot\n"
266
+ "\t 5: read range. 20rec x 1000times\n"
267
+ "\t 6: read range with snapshpot. 20rec x 1000times\n"
268
+ "\t 7: update\n"
269
+ "\t 8: update in transaction. 20rec x 1000times\n"
270
+ "exsample : transactdBench \"tdap://localhost/test?dbfile=test.bdf\" 0 -1\n");
271
+ }
272
+
273
+ /* -------------------------------------------------------------------------------- */
274
+ #pragma argsused
275
+ int _tmain(int argc, _TCHAR* argv[])
276
+ {
277
+ if (argc < 4)
278
+ {
279
+ showUsage();
280
+ return 0;
281
+ }
282
+ int procID = _ttol(argv[2]); // 0
283
+ int count = 20000;
284
+ int start = procID * count + 1;
285
+ int end = start + count;
286
+ int exeType = _ttol(argv[3]);// -1
287
+ bool insertBeforeNoDelete = 0;
288
+ if (argc > 4)
289
+ insertBeforeNoDelete = (_ttol(argv[4])!=0);
290
+
291
+ try
292
+ {
293
+ database_ptr db = createDatadaseObject();
294
+ connectParams param(argv[1]);
295
+
296
+ if (!db->open(param.uri(), param.type(), param.mode()))
297
+ createTestDataBase(db, param);
298
+ printHeader(param.uri(), count);
299
+ openDatabase(db, param);
300
+ table_ptr tb = openTable(db, _T("user"));
301
+
302
+
303
+ if ((exeType == -1) || (exeType == 0))
304
+ {
305
+ if (insertBeforeNoDelete || deleteAll(db, tb, start, end))
306
+ benchmark::report2(boost::bind(inserts, db, tb, start, end, USE_NORMAL, 1), ": Insert");
307
+ }
308
+ if ((exeType == -1) || (exeType == 1))
309
+ {
310
+ if (insertBeforeNoDelete || deleteAll(db, tb, start, end))
311
+ benchmark::report2(boost::bind(inserts, db, tb, start, end, USE_TRANS, 20)
312
+ , ": Insert in transaction. 20rec x 1000times.");
313
+ }
314
+ if ((exeType == -1) || (exeType == 2))
315
+ {
316
+ if (insertBeforeNoDelete || deleteAll(db, tb, start, end))
317
+ benchmark::report2(boost::bind(inserts, db, tb, start, end, USE_BALKINS, 20)
318
+ , ": Insert by bulkmode. 20rec x 1000times.");
319
+ }
320
+ if ((exeType == -1) || (exeType == 3))
321
+ benchmark::report2(boost::bind( read, db, tb, start, end, USE_NORMAL), ": read each record.");
322
+ if ((exeType == -1) || (exeType == 4))
323
+ benchmark::report2(boost::bind( read, db, tb, start, end, USE_SNAPSHOT), ": read each record with snapshpot.");
324
+ if ((exeType == -1) || (exeType == 5))
325
+ benchmark::report2(boost::bind( reads, db, tb, start, end, 20, USE_NORMAL), ": read range. 20rec x 1000times.");
326
+ if ((exeType == -1) || (exeType == 6))
327
+ benchmark::report2(boost::bind( reads, db, tb, start, end, 20, USE_SNAPSHOT), ": read range with snapshot. 20rec x 1000times.");
328
+ if ((exeType == -1) || (exeType == 7))
329
+ benchmark::report2(boost::bind( updates, db, tb, start, end, USE_NORMAL, 1), ": update.");
330
+ if ((exeType == -1) || (exeType == 8))
331
+ benchmark::report2(boost::bind( updates, db, tb, start, end, USE_TRANS, 20), ": update in transaction. 20rec x 1000times.");
332
+
333
+ printTail();
334
+ return 0;
335
+ }
336
+ catch(bzs::rtl::exception &e)
337
+ {
338
+ _tprintf(_T("Error ! %s\n"), getMsg(e)->c_str());
339
+
340
+ }
341
+ return 1;
342
+ }