transactd 1.2.0 → 2.0.0

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 (306) hide show
  1. checksums.yaml +4 -4
  2. data/BUILD_UNIX-JA +46 -67
  3. data/BUILD_WIN-JA +106 -63
  4. data/CMakeLists.txt +40 -15
  5. data/README +219 -75
  6. data/README-JA +207 -76
  7. data/README_ORMSRCGEN +118 -0
  8. data/README_ORMSRCGEN-JA +115 -0
  9. data/bin/common/tdclc_32_2_0.dll +0 -0
  10. data/bin/common/tdclc_64_2_0.dll +0 -0
  11. data/build/common/check_for_link_iconv.cmake +18 -14
  12. data/build/common/create_symlink.cmake.in +25 -0
  13. data/build/common/get_boost_libs.cmake +23 -23
  14. data/build/common/options.cmake +0 -66
  15. data/build/common/smart_install.cmake +3 -3
  16. data/build/common/transactd.rc.in +15 -5
  17. data/build/common/transactd_cl_common.cmake +37 -18
  18. data/build/common/transactd_cl_output.cmake +55 -13
  19. data/build/common/transactd_common.cmake +108 -31
  20. data/build/swig/php/generate.cmake.in +15 -17
  21. data/build/swig/php/generate.cmd.in +15 -9
  22. data/build/swig/php/php.swg +124 -82
  23. data/build/swig/php/transactd.no_yield.php +4494 -0
  24. data/build/swig/php/transactd.no_yield.php.git.patch +685 -0
  25. data/build/swig/php/transactd.no_yield.php.patch +685 -0
  26. data/build/swig/php/transactd.yield.php +4461 -0
  27. data/build/swig/php/transactd.yield.php.git.patch +652 -0
  28. data/build/swig/php/transactd.yield.php.patch +652 -0
  29. data/build/swig/referencecounter.h +79 -0
  30. data/build/swig/ruby/ruby.swg +226 -76
  31. data/build/swig/ruby/threadBlockRegionWrapper.h +71 -0
  32. data/build/swig/ruby/without_gvl.swg +87 -0
  33. data/build/swig/tdcl.i +659 -170
  34. data/build/swig/validatablepointer.h +91 -0
  35. data/build/tdclc/CMakeLists.txt +49 -34
  36. data/build/tdclc/{tdclc_64.cbproj → tdclc.cbproj} +65 -20
  37. data/build/tdclc/tdclc.rc +0 -0
  38. data/build/tdclcpp/CMakeLists.txt +84 -20
  39. data/build/tdclcpp/tdclcpp.rc +0 -0
  40. data/build/tdclcpp/{tdclcpp_bcb_64.cbproj → tdclcpp_bc.cbproj} +168 -44
  41. data/build/tdclrb/CMakeLists.txt +84 -66
  42. data/build/tdclrb/bldgem/extconf.rb +28 -3
  43. data/build/tdclrb/gem/helper.rb +11 -1
  44. data/build/tdclrb/gem_output.cmake +20 -16
  45. data/index_ja.html +15 -0
  46. data/source/bzs/db/IBlobBuffer.h +15 -17
  47. data/source/bzs/db/blobBuffer.h +186 -140
  48. data/source/bzs/db/blobStructs.h +37 -37
  49. data/source/bzs/db/engine/mysql/IReadRecords.h +34 -34
  50. data/source/bzs/db/engine/mysql/bookmark.h +150 -147
  51. data/source/bzs/db/engine/mysql/database.cpp +1721 -1526
  52. data/source/bzs/db/engine/mysql/database.h +608 -370
  53. data/source/bzs/db/engine/mysql/dbManager.cpp +213 -201
  54. data/source/bzs/db/engine/mysql/dbManager.h +115 -104
  55. data/source/bzs/db/engine/mysql/errorMessage.cpp +49 -50
  56. data/source/bzs/db/engine/mysql/errorMessage.h +25 -26
  57. data/source/bzs/db/engine/mysql/fieldAccess.h +55 -61
  58. data/source/bzs/db/engine/mysql/mydebuglog.cpp +326 -292
  59. data/source/bzs/db/engine/mysql/mydebuglog.h +63 -55
  60. data/source/bzs/db/engine/mysql/mysqlInternal.h +182 -125
  61. data/source/bzs/db/engine/mysql/mysqlThd.cpp +121 -121
  62. data/source/bzs/db/engine/mysql/mysqlThd.h +20 -20
  63. data/source/bzs/db/engine/mysql/percentageKey.h +241 -228
  64. data/source/bzs/db/protocol/ICommandExecuter.h +18 -17
  65. data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +543 -514
  66. data/source/bzs/db/protocol/hs/hsCommandExecuter.h +155 -158
  67. data/source/bzs/db/protocol/tdap/btrDate.cpp +213 -180
  68. data/source/bzs/db/protocol/tdap/btrDate.h +39 -37
  69. data/source/bzs/db/protocol/tdap/client/activeTable.cpp +173 -0
  70. data/source/bzs/db/protocol/tdap/client/activeTable.h +165 -0
  71. data/source/bzs/db/protocol/tdap/client/activeTableImple.h +370 -0
  72. data/source/bzs/db/protocol/tdap/client/bulkInsert.h +13 -23
  73. data/source/bzs/db/protocol/tdap/client/client.cpp +81 -68
  74. data/source/bzs/db/protocol/tdap/client/client.h +361 -320
  75. data/source/bzs/db/protocol/tdap/client/connMgr.cpp +17 -22
  76. data/source/bzs/db/protocol/tdap/client/connMgr.h +17 -19
  77. data/source/bzs/db/protocol/tdap/client/connectionPool.cpp +243 -0
  78. data/source/bzs/db/protocol/tdap/client/connectionPool.h +109 -0
  79. data/source/bzs/db/protocol/tdap/client/database.cpp +327 -219
  80. data/source/bzs/db/protocol/tdap/client/database.h +141 -118
  81. data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +60 -62
  82. data/source/bzs/db/protocol/tdap/client/databaseManager.h +255 -0
  83. data/source/bzs/db/protocol/tdap/client/dbDef.cpp +315 -202
  84. data/source/bzs/db/protocol/tdap/client/dbDef.h +40 -32
  85. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +390 -371
  86. data/source/bzs/db/protocol/tdap/client/errorMessage.cpp +148 -56
  87. data/source/bzs/db/protocol/tdap/client/errorMessage_ja.cpp +149 -57
  88. data/source/bzs/db/protocol/tdap/client/export.h +35 -0
  89. data/source/bzs/db/protocol/tdap/client/field.cpp +1985 -0
  90. data/source/bzs/db/protocol/tdap/client/field.h +393 -0
  91. data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +14 -14
  92. data/source/bzs/db/protocol/tdap/client/fieldDDF.h +11 -14
  93. data/source/bzs/db/protocol/tdap/client/fieldNameAlias.cpp +123 -0
  94. data/source/bzs/db/protocol/tdap/client/fieldNameAlias.h +58 -0
  95. data/source/bzs/db/protocol/tdap/client/fields.h +178 -0
  96. data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +13 -16
  97. data/source/bzs/db/protocol/tdap/client/fileDDF.h +11 -17
  98. data/source/bzs/db/protocol/tdap/client/filter.h +423 -259
  99. data/source/bzs/db/protocol/tdap/client/groupComp.h +117 -0
  100. data/source/bzs/db/protocol/tdap/client/groupQuery.cpp +818 -0
  101. data/source/bzs/db/protocol/tdap/client/groupQuery.h +281 -0
  102. data/source/bzs/db/protocol/tdap/client/indexDDF.cpp +14 -17
  103. data/source/bzs/db/protocol/tdap/client/indexDDF.h +11 -14
  104. data/source/bzs/db/protocol/tdap/client/memRecord.cpp +231 -0
  105. data/source/bzs/db/protocol/tdap/client/memRecord.h +145 -0
  106. data/source/bzs/db/protocol/tdap/client/memRecordset.cpp +448 -0
  107. data/source/bzs/db/protocol/tdap/client/memRecordset.h +159 -0
  108. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +300 -173
  109. data/source/bzs/db/protocol/tdap/client/nsDatabase.h +53 -36
  110. data/source/bzs/db/protocol/tdap/client/nsTable.cpp +171 -128
  111. data/source/bzs/db/protocol/tdap/client/nsTable.h +121 -87
  112. data/source/bzs/db/protocol/tdap/client/pooledDatabaseManager.h +173 -0
  113. data/source/bzs/db/protocol/tdap/client/recordset.cpp +209 -0
  114. data/source/bzs/db/protocol/tdap/client/recordset.h +86 -0
  115. data/source/bzs/db/protocol/tdap/client/recordsetImple.h +596 -0
  116. data/source/bzs/db/protocol/tdap/client/request.h +227 -170
  117. data/source/bzs/db/protocol/tdap/client/serializer.cpp +1288 -0
  118. data/source/bzs/db/protocol/tdap/client/serializer.h +295 -0
  119. data/source/bzs/db/protocol/tdap/client/sharedData.cpp +9 -12
  120. data/source/bzs/db/protocol/tdap/client/sharedData.h +18 -16
  121. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +494 -473
  122. data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +51 -53
  123. data/source/bzs/db/protocol/tdap/client/stringConverter.h +214 -148
  124. data/source/bzs/db/protocol/tdap/client/table.cpp +929 -1665
  125. data/source/bzs/db/protocol/tdap/client/table.h +413 -87
  126. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +642 -534
  127. data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +25 -40
  128. data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +11 -15
  129. data/source/bzs/db/protocol/tdap/client/trdormapi.h +378 -437
  130. data/source/bzs/db/protocol/tdap/client/trnsctcl.def +1 -1
  131. data/source/bzs/db/protocol/tdap/fieldComp.h +127 -0
  132. data/source/bzs/db/protocol/tdap/myDateTime.cpp +352 -345
  133. data/source/bzs/db/protocol/tdap/mysql/characterset.cpp +75 -78
  134. data/source/bzs/db/protocol/tdap/mysql/characterset.h +18 -19
  135. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +216 -199
  136. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +23 -14
  137. data/source/bzs/db/protocol/tdap/mysql/debuglog.cpp +354 -314
  138. data/source/bzs/db/protocol/tdap/mysql/debuglog.h +57 -47
  139. data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +905 -739
  140. data/source/bzs/db/protocol/tdap/mysql/request.h +152 -159
  141. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +1044 -879
  142. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +87 -81
  143. data/source/bzs/db/protocol/tdap/tdapRequest.h +162 -130
  144. data/source/bzs/db/protocol/tdap/tdapSchema.cpp +368 -166
  145. data/source/bzs/db/protocol/tdap/tdapSchema.h +702 -566
  146. data/source/bzs/db/protocol/tdap/tdapcapi.h +387 -353
  147. data/source/bzs/db/transactd/appBuilderImple.h +21 -20
  148. data/source/bzs/db/transactd/appModule.cpp +350 -98
  149. data/source/bzs/db/transactd/appModule.h +31 -37
  150. data/source/bzs/db/transactd/connManager.cpp +138 -135
  151. data/source/bzs/db/transactd/connManager.h +28 -21
  152. data/source/bzs/db/transactd/connectionRecord.h +39 -39
  153. data/source/bzs/db/transactd/transactd.cpp +217 -203
  154. data/source/bzs/env/boost_bcb_link.h +131 -0
  155. data/source/bzs/env/compiler.h +136 -79
  156. data/source/bzs/env/crosscompile.cpp +57 -57
  157. data/source/bzs/env/crosscompile.h +130 -115
  158. data/source/bzs/env/fileopen.h +7 -8
  159. data/source/bzs/env/mbcswchrLinux.cpp +4 -9
  160. data/source/bzs/env/mbcswchrLinux.h +37 -34
  161. data/source/bzs/env/tcharMinGW.h +59 -0
  162. data/source/bzs/env/tstring.h +90 -95
  163. data/source/bzs/example/changeSchema.cpp +22 -23
  164. data/source/bzs/example/changeSchema_c.cpp +22 -24
  165. data/source/bzs/example/connection_pool_c.cpp +49 -104
  166. data/source/bzs/example/createDatabase.cpp +40 -47
  167. data/source/bzs/example/createDatabase_c.cpp +38 -43
  168. data/source/bzs/example/deleteRecords.cpp +10 -15
  169. data/source/bzs/example/deleteRecords_c.cpp +10 -14
  170. data/source/bzs/example/dropDatabase.cpp +3 -9
  171. data/source/bzs/example/dropDatabase_c.cpp +5 -6
  172. data/source/bzs/example/insertRecords.cpp +37 -29
  173. data/source/bzs/example/insertRecords_c.cpp +19 -25
  174. data/source/bzs/example/ormap_c.cpp +621 -0
  175. data/source/bzs/example/queryData.cpp +371 -0
  176. data/source/bzs/example/queryData.h +16 -0
  177. data/source/bzs/example/query_c.cpp +109 -0
  178. data/source/bzs/example/readRecords.cpp +27 -27
  179. data/source/bzs/example/readRecords_c.cpp +25 -23
  180. data/source/bzs/example/updateRecords.cpp +16 -21
  181. data/source/bzs/example/updateRecords_c.cpp +8 -12
  182. data/source/bzs/example/update_with_transaction.cpp +21 -24
  183. data/source/bzs/example/update_with_transaction_c.cpp +12 -15
  184. data/source/bzs/example/useORMRecord.cpp +177 -0
  185. data/source/bzs/netsvc/client/tcpClient.cpp +167 -156
  186. data/source/bzs/netsvc/client/tcpClient.h +541 -489
  187. data/source/bzs/netsvc/server/IAppModule.h +119 -32
  188. data/source/bzs/netsvc/server/iserver.h +21 -23
  189. data/source/bzs/netsvc/server/serverCpt.cpp +421 -391
  190. data/source/bzs/netsvc/server/serverCpt.h +41 -43
  191. data/source/bzs/netsvc/server/serverPipe.cpp +580 -565
  192. data/source/bzs/netsvc/server/serverPipe.h +44 -45
  193. data/source/bzs/netsvc/server/serverTpool.cpp +333 -303
  194. data/source/bzs/netsvc/server/serverTpool.h +38 -43
  195. data/source/bzs/rtl/benchmark.cpp +91 -31
  196. data/source/bzs/rtl/benchmark.h +76 -22
  197. data/source/bzs/rtl/datetime.cpp +231 -233
  198. data/source/bzs/rtl/datetime.h +16 -16
  199. data/source/bzs/rtl/debuglog.cpp +48 -51
  200. data/source/bzs/rtl/debuglog.h +55 -44
  201. data/source/bzs/rtl/exception.h +55 -48
  202. data/source/bzs/rtl/stl_uty.cpp +27 -28
  203. data/source/bzs/rtl/stl_uty.h +28 -29
  204. data/source/bzs/rtl/stringBuffers.cpp +8 -6
  205. data/source/bzs/rtl/stringBuffers.h +16 -9
  206. data/source/bzs/rtl/strtrim.cpp +90 -91
  207. data/source/bzs/rtl/strtrim.h +14 -16
  208. data/source/bzs/test/tdclatl/bench_query_atl.js +647 -0
  209. data/source/bzs/test/tdclatl/bench_tdclatl.js +303 -303
  210. data/source/bzs/test/tdclatl/test_query_atl.js +669 -0
  211. data/source/bzs/test/tdclphp/bench.php +357 -0
  212. data/source/bzs/test/tdclphp/transactd_Test.php +907 -303
  213. data/source/bzs/test/tdclphp/transactd_blob_Test.php +21 -49
  214. data/source/bzs/test/tdclphp/transactd_datetime_Test.php +41 -75
  215. data/source/bzs/test/tdclphp/transactd_kanjischema_Test.php +23 -37
  216. data/source/bzs/test/tdclphp/transactd_pool_Test.php +120 -0
  217. data/source/bzs/test/tdclrb/bench_tdclcpp.rb +4 -6
  218. data/source/bzs/test/tdclrb/prepare.rb +15 -12
  219. data/source/bzs/test/tdclrb/transactd_blob_spec.rb +29 -32
  220. data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +0 -29
  221. data/source/bzs/test/tdclrb/transactd_kanjischema_spec.rb +18 -19
  222. data/source/bzs/test/tdclrb/transactd_pool_spec.rb +107 -0
  223. data/source/bzs/test/tdclrb/transactd_spec.rb +734 -142
  224. data/source/bzs/test/transactdBench/query_bench.cpp +156 -0
  225. data/source/bzs/test/transactdBench/scaling_bench.cpp +265 -0
  226. data/source/bzs/test/transactdBench/transactdBench.cpp +107 -83
  227. data/source/bzs/test/transactdBench/transactdBench2.cpp +122 -83
  228. data/source/bzs/test/transactdBench/workerBase.cpp +5 -0
  229. data/source/bzs/test/transactdBench/workerBase.h +88 -0
  230. data/source/bzs/test/transactdBench/workerMySQLImple.h +333 -0
  231. data/source/bzs/test/transactdBench/workerTransactdImple.h +201 -0
  232. data/source/bzs/test/trdclengn/test_blob.cpp +121 -73
  233. data/source/bzs/test/trdclengn/test_trdclengn.cpp +1244 -426
  234. data/source/global/ormsrcgen/confParam.h +80 -0
  235. data/source/global/ormsrcgen/fieldName.cpp +77 -0
  236. data/source/global/ormsrcgen/fieldName.h +43 -0
  237. data/source/global/ormsrcgen/main.cpp +196 -0
  238. data/source/global/ormsrcgen/srcgen.cpp +763 -0
  239. data/source/global/ormsrcgen/srcgen.h +72 -0
  240. data/source/global/ormsrcgen/template/fieldNameList_sample.txt +2 -0
  241. data/source/global/ormsrcgen/template/ormDataClass_template.cpp +48 -0
  242. data/source/global/ormsrcgen/template/ormDataClass_template.h +34 -0
  243. data/source/global/ormsrcgen/template/ormMapClass_template.cpp +51 -0
  244. data/source/global/ormsrcgen/template/ormMapClass_template.h +62 -0
  245. data/source/global/ormsrcgen/template/template.cnf +38 -0
  246. data/source/global/querystmts/querystmts.cpp +237 -0
  247. data/source/global/tdclatl/ConnectParams.cpp +77 -0
  248. data/source/global/tdclatl/ConnectParams.h +70 -0
  249. data/source/global/tdclatl/Database.cpp +132 -128
  250. data/source/global/tdclatl/Database.h +60 -49
  251. data/source/global/tdclatl/DbDef.cpp +68 -64
  252. data/source/global/tdclatl/DbDef.h +36 -36
  253. data/source/global/tdclatl/Field.cpp +12 -17
  254. data/source/global/tdclatl/Field.h +15 -12
  255. data/source/global/tdclatl/FieldDef.cpp +75 -36
  256. data/source/global/tdclatl/FieldDef.h +38 -19
  257. data/source/global/tdclatl/FieldDefs.cpp +74 -0
  258. data/source/global/tdclatl/FieldDefs.h +56 -0
  259. data/source/global/tdclatl/FieldNames.cpp +99 -0
  260. data/source/global/tdclatl/FieldNames.h +66 -0
  261. data/source/global/tdclatl/Flags.cpp +75 -37
  262. data/source/global/tdclatl/Flags.h +13 -12
  263. data/source/global/tdclatl/GroupQuery.cpp +119 -0
  264. data/source/global/tdclatl/GroupQuery.h +65 -0
  265. data/source/global/tdclatl/KeyDef.cpp +15 -14
  266. data/source/global/tdclatl/KeyDef.h +20 -17
  267. data/source/global/tdclatl/KeySegment.cpp +13 -12
  268. data/source/global/tdclatl/PooledDbManager.cpp +223 -0
  269. data/source/global/tdclatl/PooledDbManager.h +76 -0
  270. data/source/global/tdclatl/QueryBase.cpp +206 -127
  271. data/source/global/tdclatl/QueryBase.h +55 -59
  272. data/source/global/tdclatl/Record.cpp +214 -0
  273. data/source/global/tdclatl/Record.h +96 -0
  274. data/source/global/tdclatl/Recordset.cpp +278 -0
  275. data/source/global/tdclatl/Recordset.h +83 -0
  276. data/source/global/tdclatl/RecordsetQuery.cpp +118 -0
  277. data/source/global/tdclatl/RecordsetQuery.h +126 -0
  278. data/source/global/tdclatl/Table.cpp +57 -60
  279. data/source/global/tdclatl/Table.h +32 -29
  280. data/source/global/tdclatl/TableDef.cpp +63 -62
  281. data/source/global/tdclatl/TableDef.h +20 -22
  282. data/source/global/tdclatl/TdVersion.cpp +3 -3
  283. data/source/global/tdclatl/TdVersion.h +15 -11
  284. data/source/global/tdclatl/_IDatabaseEvents_CP.h +99 -92
  285. data/source/global/tdclatl/activeTable.cpp +355 -0
  286. data/source/global/tdclatl/activeTable.h +79 -0
  287. data/source/global/tdclatl/dllmain.cpp +4 -3
  288. data/source/global/tdclatl/dllmain.h +7 -6
  289. data/source/global/tdclatl/keySegment.h +22 -18
  290. data/source/global/tdclatl/resource.h +0 -0
  291. data/source/global/tdclatl/stdafx.h +6 -4
  292. data/source/global/tdclatl/targetver.h +0 -1
  293. data/source/global/tdclatl/tdclatl.cpp +10 -5
  294. data/source/global/tdclatl/tdclatl.idl +530 -14
  295. data/source/linux/charsetConvert.h +78 -79
  296. data/source/linux/linuxTypes.h +9 -12
  297. data/source/linux/tchar.h +168 -166
  298. data/transactd.gemspec +24 -16
  299. metadata +98 -12
  300. data/bin/common/tdclc_32_1_2.dll +0 -0
  301. data/bin/common/tdclc_64_1_2.dll +0 -0
  302. data/build/tdclc/tdclc_32.cbproj +0 -173
  303. data/build/tdclcpp/tdclcpp_bcb_32.cbproj +0 -232
  304. data/build/tdclrb/GEM_VERSION +0 -3
  305. data/source/bzs/db/protocol/tdap/client/filter.cpp +0 -43
  306. data/source/bzs/example/useORM.cpp +0 -585
@@ -0,0 +1,370 @@
1
+ #ifndef BZS_DB_PROTOCOL_TDAP_CLIENT_ACTIVETABLEIMPLE_H
2
+ #define BZS_DB_PROTOCOL_TDAP_CLIENT_ACTIVETABLEIMPLE_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 "trdboostapi.h"
22
+ #include "trdormapi.h"
23
+ #include "recordsetImple.h"
24
+ #include "memRecord.h"
25
+
26
+ namespace bzs
27
+ {
28
+ namespace db
29
+ {
30
+ namespace protocol
31
+ {
32
+ namespace tdap
33
+ {
34
+ namespace client
35
+ {
36
+
37
+ class map_orm_fdi
38
+ {
39
+ friend class map_orm;
40
+ const table* m_tb;
41
+
42
+ public:
43
+ void init(table* tb) { m_tb = tb; }
44
+ };
45
+
46
+ inline map_orm_fdi* createFdi(map_orm_fdi*)
47
+ {
48
+ return new map_orm_fdi();
49
+ }
50
+ inline void destroyFdi(map_orm_fdi* p)
51
+ {
52
+ delete p;
53
+ }
54
+ inline void initFdi(map_orm_fdi* fdi, table* tb)
55
+ {
56
+ fdi->init(tb);
57
+ }
58
+
59
+ class map_orm
60
+ {
61
+ const map_orm_fdi& m_fdi;
62
+ short m_autoIncFiled;
63
+
64
+ int comp(row& lm, row& rm, const _TCHAR* name, int index) const
65
+ {
66
+ return lm[index].comp(rm[index], 0);
67
+ }
68
+
69
+ public:
70
+ map_orm(const map_orm_fdi& fdi) : m_fdi(fdi), m_autoIncFiled(-2) {}
71
+
72
+ bool compKeyValue(row& l, row& r, int keyNum) const
73
+ {
74
+ const tabledef* def = m_fdi.m_tb->tableDef();
75
+ const keydef* kd = &def->keyDefs[keyNum];
76
+ for (int i = 0; i < kd->segmentCount; ++i)
77
+ {
78
+ short n = kd->segments[i].fieldNum;
79
+ const fielddef* fd = &def->fieldDefs[n];
80
+ int ret = comp(l, r, fd->name(), n);
81
+ if (ret)
82
+ return (ret < 0);
83
+ }
84
+ return 0;
85
+ }
86
+
87
+ template <class T> void readMap(T& m, const fields& fds, int optipn)
88
+ {
89
+ // needlessness
90
+ }
91
+
92
+ typedef row mdl_typename;
93
+ typedef map_orm_fdi fdi_typename;
94
+ typedef mdlsHandler<map_orm, recordsetImple> collection_orm_typename;
95
+ };
96
+
97
+ struct joinInfo
98
+ {
99
+ std::_tstring fixedValue;
100
+ ushort_td len;
101
+ ushort_td type;
102
+ };
103
+
104
+ #define JOIN_KEYVALUE_TYPE_PTR 0
105
+ #define JOIN_KEYVALUE_TYPE_STR 1
106
+
107
+ class activeTableImple : public activeObject<map_orm>
108
+ {
109
+
110
+ typedef recordsetImple Container;
111
+ typedef boost::shared_ptr<writableRecord> record;
112
+ typedef activeObject<map_orm> baseClass_type;
113
+ typedef std::vector<std::vector<int> > joinmap_type;
114
+ record m_record;
115
+
116
+ // return can memcpy
117
+ uchar_td convertFieldType(uchar_td v)
118
+ {
119
+ if (v == ft_autoinc)
120
+ v = ft_integer;
121
+ else if (v == ft_autoIncUnsigned)
122
+ v = ft_integer;
123
+ else if (v == ft_uinteger)
124
+ v = ft_integer;
125
+ else if (v == ft_logical)
126
+ v = ft_integer;
127
+ else if (v == ft_bit)
128
+ v = ft_integer;
129
+ return v;
130
+ }
131
+
132
+ template <class Container>
133
+ inline void
134
+ makeJoinFieldInfo(Container& mdls, const fielddefs* fds,
135
+ const fieldNames& fns,
136
+ std::vector<typename Container::key_type>& fieldIndexes,
137
+ std::vector<joinInfo>& joinFields)
138
+ {
139
+ joinFields.resize(fns.count());
140
+ fieldIndexes.resize(fns.count());
141
+ const tabledef* td = table()->tableDef();
142
+ const keydef* kd = &td->keyDefs[table()->keyNum()];
143
+ if (kd->segmentCount < fns.count())
144
+ THROW_BZS_ERROR_WITH_MSG(_T("Join key fields are too many.\n ")
145
+ _T("Check index number and field count."));
146
+
147
+ for (int i = 0; i < fns.count(); ++i)
148
+ {
149
+ std::_tstring s = fns.getValue(i);
150
+ if (s[0] == '[')
151
+ {
152
+ fieldIndexes[i] = -1;
153
+ joinFields[i].type = JOIN_KEYVALUE_TYPE_PTR;
154
+ joinFields[i].len = (ushort_td)(s.size() - 2);
155
+ joinFields[i].fixedValue = s.substr(1, s.size() - 2);
156
+ }
157
+ else
158
+ {
159
+ ushort_td index = resolvKeyValue(mdls, s, false);
160
+ fieldIndexes[i] = index;
161
+ const fielddef& fd = (*fds)[index];
162
+ // Check the fieldType
163
+ if (convertFieldType(fd.type) ==
164
+ convertFieldType(
165
+ td->fieldDefs[kd->segments[i].fieldNum].type))
166
+ {
167
+ joinFields[i].len = fd.len;
168
+ joinFields[i].type = JOIN_KEYVALUE_TYPE_PTR;
169
+ }
170
+ else
171
+ {
172
+ joinFields[i].len = 0;
173
+ joinFields[i].type = JOIN_KEYVALUE_TYPE_STR;
174
+ }
175
+ }
176
+ }
177
+ }
178
+
179
+ template <class Container>
180
+ inline void
181
+ addSeekValues(row& mdl, queryBase& q,
182
+ std::vector<typename Container::key_type>& fieldIndexes,
183
+ std::vector<joinInfo>& joinFields)
184
+ {
185
+ for (int i = 0; i < (int)fieldIndexes.size(); ++i)
186
+ {
187
+ if (fieldIndexes[i] == -1)
188
+ q.addSeekKeyValuePtr(joinFields[i].fixedValue.c_str(),
189
+ joinFields[i].len, KEYVALUE_STR);
190
+ else if (joinFields[i].type == JOIN_KEYVALUE_TYPE_PTR)
191
+ q.addSeekKeyValuePtr(mdl[fieldIndexes[i]].ptr(),
192
+ joinFields[i].len, KEYVALUE_PTR);
193
+ else
194
+ {
195
+ const _TCHAR* p = mdl[fieldIndexes[i]].c_str();
196
+ q.addSeekKeyValuePtr(p, (ushort_td)_tcslen(p),
197
+ KEYVALUE_STR_NEED_COPY);
198
+ }
199
+ }
200
+ }
201
+
202
+ template <class Container>
203
+ void makeJoinMap(Container& mdls, joinmap_type& joinRowMap,
204
+ std::vector<typename Container::key_type>& keyFields)
205
+ {
206
+ grouping_comp<Container> groupingComp(mdls, keyFields);
207
+ std::vector<int> index;
208
+ std::vector<int> tmp;
209
+ for (int n = 0; n < (int)mdls.size(); ++n)
210
+ {
211
+ bool found = false;
212
+ int i = binary_search(n, index, 0, (int)index.size(), groupingComp,
213
+ found);
214
+ if (!found)
215
+ {
216
+ index.insert(index.begin() + i, n);
217
+ joinRowMap.insert(joinRowMap.begin() + i, tmp);
218
+ }
219
+ joinRowMap[i].push_back(n);
220
+ }
221
+ }
222
+
223
+ template <class Container>
224
+ void doJoin(bool innner, Container& mdls, queryBase& q, const _TCHAR* name1,
225
+ const _TCHAR* name2 = NULL, const _TCHAR* name3 = NULL,
226
+ const _TCHAR* name4 = NULL, const _TCHAR* name5 = NULL,
227
+ const _TCHAR* name6 = NULL, const _TCHAR* name7 = NULL,
228
+ const _TCHAR* name8 = NULL)
229
+ {
230
+ if (mdls.size() == 0)
231
+ return;
232
+ m_alias.reverseAliasNamesQuery(q);
233
+ q.clearSeekKeyValues();
234
+
235
+ mraResetter mras(m_tb);
236
+ typename Container::iterator it = mdls.begin(), ite = mdls.end();
237
+
238
+ bool optimize = !(q.getOptimize() & queryBase::joinHasOneOrHasMany);
239
+ joinmap_type joinRowMap;
240
+
241
+ fieldNames fns;
242
+ fns.keyField(name1, name2, name3, name4, name5, name6, name7, name8);
243
+
244
+ std::vector<typename Container::key_type> fieldIndexes;
245
+ std::vector<joinInfo> joinFields;
246
+
247
+ const fielddefs* fds = mdls.fieldDefs();
248
+ makeJoinFieldInfo<Container>(mdls, fds, fns, fieldIndexes, joinFields);
249
+
250
+ // optimizing join
251
+ // if base recordsetImple is made by unique key and join by uniqe field,
252
+ // that can not opitimize.
253
+ //
254
+ q.joinKeySize(fns.count());
255
+ if (optimize)
256
+ {
257
+ makeJoinMap(mdls, joinRowMap, fieldIndexes);
258
+ q.reserveSeekKeyValuePtrSize(joinRowMap.size() *
259
+ fieldIndexes.size());
260
+ std::vector<std::vector<int> >::iterator it1 = joinRowMap.begin(),
261
+ ite1 = joinRowMap.end();
262
+ while (it1 != ite1)
263
+ {
264
+ row& mdl = *(mdls.getRow((*it1)[0]));
265
+ addSeekValues<Container>(mdl, q, fieldIndexes, joinFields);
266
+ ++it1;
267
+ }
268
+ }
269
+ else
270
+ {
271
+ q.reserveSeekKeyValuePtrSize(mdls.size() * fieldIndexes.size());
272
+ while (it != ite)
273
+ {
274
+ row& mdl = *(*it);
275
+ addSeekValues<Container>(mdl, q, fieldIndexes, joinFields);
276
+ ++it;
277
+ }
278
+ }
279
+
280
+ m_tb->setQuery(&q);
281
+ if (m_tb->stat() != 0)
282
+ nstable::throwError(_T("activeObject Join Query"), &(*m_tb));
283
+
284
+ typename map_orm::collection_orm_typename map(mdls);
285
+
286
+ // std::vector<typename Container::iterator> ignores;
287
+ it = mdls.begin();
288
+ map.init(m_option, m_fdi, m_map, m_tb, &m_alias);
289
+ if (m_tb->mra())
290
+ {
291
+ m_tb->mra()->setJoinType(innner ? mra_innerjoin : mra_outerjoin);
292
+ if (optimize)
293
+ m_tb->mra()->setJoinRowMap(&joinRowMap);
294
+ }
295
+ m_tb->find();
296
+ while (1)
297
+ {
298
+ if (m_tb->stat())
299
+ {
300
+ if ((m_tb->stat() == STATUS_EOF) ||
301
+ ((m_tb->stat() != STATUS_SUCCESS) &&
302
+ (m_tb->stat() != STATUS_NOT_FOUND_TI)))
303
+ break;
304
+ }
305
+ ++it;
306
+ m_tb->findNext(); // mra copy value to memrecord
307
+ }
308
+
309
+ readStatusCheck(*m_tb, _T("join"));
310
+ m_tb->mra()->setJoinRowMap(NULL);
311
+
312
+ // remove record see ignore list for inner join
313
+ if (innner)
314
+ {
315
+ for (int i = (int)mdls.size() - 1; i >= 0; --i)
316
+ {
317
+ if (mdls[i].isInvalidRecord())
318
+ mdls.erase(i);
319
+ }
320
+ }
321
+ }
322
+
323
+ public:
324
+ explicit activeTableImple(idatabaseManager* mgr, const _TCHAR* tableName)
325
+ : baseClass_type(mgr, tableName){};
326
+
327
+ explicit activeTableImple(database_ptr& db, const _TCHAR* tableName)
328
+ : baseClass_type(db, tableName){};
329
+
330
+ explicit activeTableImple(database* db, const _TCHAR* tableName)
331
+ : baseClass_type(db, tableName){};
332
+
333
+ inline writableRecord& getWritableRecord()
334
+ {
335
+ m_record.reset(writableRecord::create(m_tb.get(), &m_alias),
336
+ &writableRecord::release);
337
+ return *m_record.get();
338
+ }
339
+
340
+ inline void join(Container& mdls, queryBase& q, const _TCHAR* name1,
341
+ const _TCHAR* name2 = NULL, const _TCHAR* name3 = NULL,
342
+ const _TCHAR* name4 = NULL, const _TCHAR* name5 = NULL,
343
+ const _TCHAR* name6 = NULL, const _TCHAR* name7 = NULL,
344
+ const _TCHAR* name8 = NULL)
345
+ {
346
+ doJoin(true, mdls, q, name1, name2, name3, name4, name5, name6, name7,
347
+ name8);
348
+ }
349
+
350
+ inline void
351
+ outerJoin(Container& mdls, queryBase& q, const _TCHAR* name1,
352
+ const _TCHAR* name2 = NULL, const _TCHAR* name3 = NULL,
353
+ const _TCHAR* name4 = NULL, const _TCHAR* name5 = NULL,
354
+ const _TCHAR* name6 = NULL, const _TCHAR* name7 = NULL,
355
+ const _TCHAR* name8 = NULL)
356
+ {
357
+ doJoin(false, mdls, q, name1, name2, name3, name4, name5, name6, name7,
358
+ name8);
359
+ }
360
+
361
+ void releaseTable() { m_tb.reset(); }
362
+ };
363
+
364
+ } // namespace client
365
+ } // namespace tdap
366
+ } // namespace protocol
367
+ } // namespace db
368
+ } // namespace bzs
369
+
370
+ #endif // BZS_DB_PROTOCOL_TDAP_CLIENT_ACTIVETABLEIMPLE_H
@@ -49,22 +49,17 @@ public:
49
49
  m_ptr = m_buf + sizeof(ushort_td);
50
50
  m_count = 0;
51
51
  m_buflen = BULKBUFSIZE;
52
-
53
52
  }
54
53
 
55
- ~bulkInsert()
56
- {
57
- delete [] m_buf;
58
- }
54
+ ~bulkInsert() { delete[] m_buf; }
59
55
 
60
56
  char* reallocBuffer(char* buf, int oldsize, int newSize)
61
57
  {
62
58
  char* p = new char[newSize];
63
59
  memcpy(p, buf, oldsize);
64
- delete [] buf;
60
+ delete[] buf;
65
61
 
66
62
  return p;
67
-
68
63
  }
69
64
 
70
65
  ushort_td insert(const char* p, ushort_td size, nstable* tb)
@@ -73,17 +68,17 @@ public:
73
68
  if (m_count == (int)(USHRT_MAX - 3))
74
69
  {
75
70
  ins_rows = tb->commitBulkInsert(true /* auto */);
76
- m_ptr = m_buf +sizeof(ushort_td);
71
+ m_ptr = m_buf + sizeof(ushort_td);
77
72
  m_count = 0;
78
73
  }
79
74
 
80
75
  // check over run. current size + need size
81
- if ((m_ptr - m_buf )+ size + sizeof(ushort_td) > (uint_td)m_buflen)
76
+ if ((m_ptr - m_buf) + size + sizeof(ushort_td) > (uint_td)m_buflen)
82
77
  {
83
78
  if ((int)(m_buflen + BULKBUFSIZE) > m_maxBuflen)
84
79
  {
85
80
  ins_rows = tb->commitBulkInsert(true /* auto */);
86
- m_ptr = m_buf +sizeof(ushort_td);
81
+ m_ptr = m_buf + sizeof(ushort_td);
87
82
  m_count = 0;
88
83
  }
89
84
  else
@@ -100,7 +95,6 @@ public:
100
95
  m_ptr += size;
101
96
  m_count++;
102
97
  return ins_rows;
103
-
104
98
  }
105
99
 
106
100
  void* data()
@@ -109,19 +103,15 @@ public:
109
103
  return m_buf;
110
104
  }
111
105
 
112
- uint_td dataLen()
113
- {
114
- return (uint_td)(m_ptr - m_buf);
115
- }
116
-
117
- int count() {return m_count;}
106
+ uint_td dataLen() { return (uint_td)(m_ptr - m_buf); }
118
107
 
108
+ int count() { return m_count; }
119
109
  };
120
110
 
121
- }//namespace client
122
- }//namespace tdap
123
- }//namespace protocol
124
- }//namespace db
125
- }//namespace bzs
111
+ } // namespace client
112
+ } // namespace tdap
113
+ } // namespace protocol
114
+ } // namespace db
115
+ } // namespace bzs
126
116
 
127
- #endif//BZS_DB_PROTOCOL_TDAP_CLIENT_BULKINSERT_H
117
+ #endif // BZS_DB_PROTOCOL_TDAP_CLIENT_BULKINSERT_H
@@ -1,21 +1,21 @@
1
- /*=================================================================
2
- Copyright (C) 2012 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
- =================================================================*/
1
+ /* =================================================================
2
+ Copyright (C) 2012 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
19
  #include "client.h"
20
20
  #include "sqlBuilder.h"
21
21
  #include "stringConverter.h"
@@ -24,7 +24,6 @@ using namespace bzs::db::protocol::tdap::client;
24
24
 
25
25
  bzs::netsvc::client::connections* m_cons = NULL;
26
26
 
27
-
28
27
  namespace bzs
29
28
  {
30
29
  namespace db
@@ -39,68 +38,82 @@ namespace client
39
38
  #ifdef USETLS
40
39
  tls_key g_tlsiID;
41
40
  #else
42
- __THREAD client* __THREAD_BCB g_client=NULL;
41
+ __THREAD client* __THREAD_BCB g_client = NULL;
43
42
  #endif
44
43
 
44
+ bool checkVersion(trdVersiton& ver)
45
+ {
46
+ if ((ver.srvMajor < 1) || ((ver.srvMajor == 1) && (ver.srvMinor < 3)))
47
+ return false;
48
+ return true;
49
+ }
45
50
 
46
51
  bool client::readServerCharsetIndex()
47
52
  {
48
- if (m_charsetIndexServer == -1)
49
- {
50
- request req = m_req;
51
- uint_td len = 256;
52
- char tmp[256]={0x00};
53
- req.op = TD_GETSERVER_CHARSET;
54
- req.data = tmp;
55
- req.datalen = &len;
56
-
57
- mutex::scoped_lock lck(m_mutex);
58
- char* p = con()->sendBuffer();
59
- unsigned int size = req.serialize(p);
60
- p = con()->asyncWriteRead(size);
61
- req.parse(p);
62
- if (req.result==0)
63
- {
64
- m_charsetIndexServer = mysql::charsetIndex((const char*)req.data);
65
- return true;
66
- }
67
- return false;
68
- }
69
- return true;
53
+ if (m_charsetIndexServer == -1)
54
+ {
55
+ request req = m_req;
56
+ req.paramMask = P_MASK_POSBLK | P_MASK_DATA | P_MASK_DATALEN;
57
+ trdVersiton ver;
58
+ memset(&ver, 0, sizeof(trdVersiton));
59
+ ver.cherserServer[0] = 0x00;
60
+ ver.clMajor = (ushort_td)atoi(C_INTERFACE_VER_MAJOR);
61
+ ver.clMinor = (ushort_td)atoi(C_INTERFACE_VER_MINOR);
62
+ ver.clRelease = (ushort_td)atoi(C_INTERFACE_VER_RELEASE);
63
+
64
+ uint_td len = sizeof(trdVersiton);
65
+ req.op = TD_GETSERVER_CHARSET;
66
+ req.data = &ver;
67
+ req.datalen = &len;
68
+
69
+ mutex::scoped_lock lck(m_mutex);
70
+ char* p = con()->sendBuffer(m_req.sendLenEstimate());
71
+ unsigned int size = req.serialize(p);
72
+ p = con()->asyncWriteRead(size);
73
+ req.parse(p, 0, 0);
74
+ if (req.result == 0)
75
+ {
76
+ if (!checkVersion(ver))
77
+ return false;
78
+ m_charsetIndexServer = mysql::charsetIndex(ver.cherserServer);
79
+ return true;
80
+ }
81
+ return false;
82
+ }
83
+ return true;
70
84
  }
71
85
 
72
86
  void client::addSecondCharsetData(unsigned int destCodePage, std::string& src)
73
87
  {
74
- stringConverter cv(destCodePage, CP_UTF8);
75
- int osize = (int)src.size()*3;
76
- char* srvchar = new char[osize];
77
-
78
- size_t len = cv.convert(srvchar, osize, src.c_str(), src.size());
79
- srvchar[len] = 0x00;
80
- src += std::string("\t") + srvchar;
81
- delete [] srvchar;
88
+ stringConverter cv(destCodePage, CP_UTF8);
89
+ int osize = (int)src.size() * 3;
90
+ char* srvchar = new char[osize];
91
+
92
+ size_t len = cv.convert(srvchar, osize, src.c_str(), src.size());
93
+ srvchar[len] = 0x00;
94
+ src += std::string("\t") + srvchar;
95
+ delete[] srvchar;
82
96
  }
83
97
 
84
98
  bool client::buildDualChasetKeybuf()
85
99
  {
86
- if (!readServerCharsetIndex())
87
- return false;
88
- //m_serverCharData = std::string((char*)m_req.keybuf, m_req.keylen);
89
- m_serverCharData = (char*)m_req.keybuf;
90
- if (CHARSET_UTF8 != m_charsetIndexServer)
91
- addSecondCharsetData(mysql::codePage(m_charsetIndexServer), m_serverCharData);
92
- else
93
- m_serverCharData += std::string("\t") + (char*)m_req.keybuf;
94
-
95
- m_req.keybuf = (void_td*)m_serverCharData.c_str();
96
- m_req.keylen = (keylen_td)m_serverCharData.size() + 1;
100
+ if (!readServerCharsetIndex())
101
+ return false;
102
+ // m_serverCharData = std::string((char*)m_req.keybuf, m_req.keylen);
103
+ m_serverCharData = (char*)m_req.keybuf;
104
+ if (CHARSET_UTF8 != m_charsetIndexServer)
105
+ addSecondCharsetData(mysql::codePage(m_charsetIndexServer),
106
+ m_serverCharData);
107
+ else
108
+ m_serverCharData += std::string("\t") + (char*)m_req.keybuf;
109
+
110
+ m_req.keybuf = (void_td*)m_serverCharData.c_str();
111
+ m_req.keylen = (keylen_td)m_serverCharData.size() + 1;
97
112
  return true;
98
113
  }
99
114
 
100
- }//namespace client
101
- }//namespace tdap
102
- }//namespace protocol
103
- }//namespace db
104
- }//namespace bzs
105
-
106
-
115
+ } // namespace client
116
+ } // namespace tdap
117
+ } // namespace protocol
118
+ } // namespace db
119
+ } // namespace bzs