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
@@ -1,566 +1,702 @@
1
- #ifndef BZS_DB_PROTOCOL_TDAP_TDAPSCHEMA_H
2
- #define BZS_DB_PROTOCOL_TDAP_TDAPSCHEMA_H
3
- /* =================================================================
4
- Copyright (C) 2000-2013 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
-
22
- #include <bzs/db/protocol/tdap/tdapcapi.h>
23
- #include <string.h>
24
- #include <algorithm>
25
- #include <wchar.h>
26
- #include <bzs/env/compiler.h>
27
- #include <bzs/env/crosscompile.h>
28
- #include <bzs/db/protocol/tdap/mysql/characterset.h>
29
-
30
- namespace bzs
31
- {
32
- namespace db
33
- {
34
- namespace protocol
35
- {
36
- namespace tdap
37
- {
38
-
39
- namespace client{class dbdef;}
40
-
41
- #pragma option -a1
42
- pragma_pack1
43
-
44
- using std::min;
45
- using std::max;
46
-
47
- #ifdef SWIG
48
- /* For swig interface
49
- Export names .
50
- */
51
- union FLAGS
52
- {
53
- unsigned short all;
54
- unsigned short bit0 : 1;
55
- unsigned short bit1 : 1;
56
- unsigned short bit2 : 1;
57
- unsigned short bit3 : 1;
58
- unsigned short bit4 : 1;
59
- unsigned short bit5 : 1;
60
- unsigned short bit6 : 1;
61
- unsigned short bit7 : 1;
62
- unsigned short bit8 : 1;
63
- unsigned short bit9 : 1;
64
- unsigned short bitA : 1;
65
- unsigned short bitB : 1;
66
- unsigned short bitC : 1;
67
- unsigned short bitD : 1;
68
- unsigned short bitE : 1;
69
- unsigned short bitF : 1;
70
- };
71
- #else
72
- union FLAGS
73
- {
74
- unsigned short all;
75
-
76
- struct
77
- {
78
- unsigned short bit0 : 1;
79
- unsigned short bit1 : 1;
80
- unsigned short bit2 : 1;
81
- unsigned short bit3 : 1;
82
- unsigned short bit4 : 1;
83
- unsigned short bit5 : 1;
84
- unsigned short bit6 : 1;
85
- unsigned short bit7 : 1;
86
- unsigned short bit8 : 1;
87
- unsigned short bit9 : 1;
88
- unsigned short bitA : 1;
89
- unsigned short bitB : 1;
90
- unsigned short bitC : 1;
91
- unsigned short bitD : 1;
92
- unsigned short bitE : 1;
93
- unsigned short bitF : 1;
94
- };
95
- };
96
- #endif
97
- /* brief Key infomation for create table operation
98
- */
99
- struct keySpec
100
- {
101
- ushort_td keyPos; /* key position */
102
- ushort_td keyLen; /* key length */
103
- FLAGS keyFlag; /* key flag */
104
- uint_td keyCount; /* key count */
105
- uchar_td keyType; /* key type of extended */
106
- uchar_td nullValue; /* value of null */
107
- uchar_td reserve2[2]; /* reserved */
108
- uchar_td keyNo; /* fixed key number */
109
- uchar_td acsNo; /* no acs */
110
- }; /* total 16 byte */
111
-
112
- /* brief File infomation for create table operation
113
- */
114
- struct fileSpec
115
- {
116
- ushort_td recLen; /* record length */
117
- ushort_td pageSize; /* page sise */
118
- ushort_td indexCount; /* index count */
119
- uint_td recCount; /* record count for stat */
120
- FLAGS fileFlag; /* file flags */
121
- uchar_td reserve1[2]; /* reserved */
122
- ushort_td preAlloc; /* page allocation count */
123
- keySpec keySpecs[1]; /* key specs */
124
- }; /* total ? byte */
125
-
126
- /* brief A key segment infomation
127
- */
128
- struct keySegment
129
- {
130
- uchar_td fieldNum; // Refarence field buymber
131
- FLAGS flags; // key flags. 11 to 15bit is not use.
132
-
133
- };
134
-
135
- /* brief A key infomation
136
- */
137
- #define MAX_KEY_SEGMENT 8
138
- struct keydef
139
- {
140
- uchar_td segmentCount; // Number of segment
141
- keySegment segments[MAX_KEY_SEGMENT]; // key segments . max 8 segments
142
- uchar_td keyNumber; // key number
143
- };
144
- // 26byte
145
-
146
- static const int MYSQL_FDNAME_SIZE = 64;
147
- static const int MYSQL_TBNAME_SIZE = 64;
148
- static const int PERVASIVE_FDNAME_SIZE = 20;
149
- static const int FIELD_NAME_SIZE = MYSQL_FDNAME_SIZE;
150
- static const int TABLE_NAME_SIZE = 32;
151
- static const int FILE_NAME_SIZE = 266;
152
-
153
-
154
- #ifdef __x86_32__
155
- static const int TABLEDEF_FILLER_SIZE = 21;//25-4;
156
- #else
157
- static const int TABLEDEF_FILLER_SIZE = 9;//17-8;
158
- #endif
159
-
160
- #ifndef MYSQL_DYNAMIC_PLUGIN
161
-
162
- /* A field type name that specified by a type is returned.
163
- */
164
- PACKAGE const _TCHAR* getTypeName(short type);
165
-
166
- /* A field alignment that specified by a type is returned.
167
- */
168
- PACKAGE int getTypeAlign(short type);
169
-
170
- /* calcurate byts of char type by charctor number.
171
- */
172
- PACKAGE ushort_td lenByCharnum(uchar_td type, uchar_td charsetIndex
173
- , ushort_td charnum);
174
-
175
- #endif
176
-
177
- /* Is field type string ?*/
178
- PACKAGE bool isStringType(uchar_td type);
179
-
180
- /* Mark of ** that BizStation Corp internal use only.
181
- */
182
- template <int N>
183
- struct fielddef_t
184
- {
185
- protected:
186
- char m_name[N];
187
-
188
- public:
189
- uchar_td type; // type (zstring integer)
190
- ushort_td len; // length
191
- uchar_td decimals; // ** decimals
192
- char viewNum; // ** An order of a list view column
193
- ushort_td viewWidth; // ** view width pix
194
- double max; // ** max value
195
- double min; // ** min value
196
- double defValue; // ** default value
197
- uchar_td lookTable; // ** reference table number
198
- uchar_td lookField; // ** field number of reference table
199
- uchar_td lookFields[3]; // ** View fields of reference bit567
200
- ushort_td pos; // Field offset position from record image
201
- ushort_td defViewWidth; // ** default view wifth
202
-
203
- protected:
204
- char m_chainChar[2];
205
-
206
- public:
207
- ushort_td ddfid; // ddf field id
208
- ushort_td filterId; // ** filter id for reference
209
- uchar_td filterKeynum; // ** key number for reference
210
- uchar_td nullValue; // null value
211
- ushort_td userOption; // ** option
212
- uchar_td lookDBNum; // ** database number of reference bitD
213
- ushort_td keylen; // key length for mysql of part key
214
-
215
- protected:
216
- uchar_td m_charsetIndex; // charctor set index of this field data
217
- uint_td m_schemaCodePage;
218
-
219
- public:
220
- FLAGS enableFlags; // ** enable flags. see below
221
-
222
- private:
223
- inline void setSchemaCodePage(uint_td v){m_schemaCodePage = v;};
224
- friend class client::dbdef;
225
- };
226
-
227
- /* This is only for BizStation Corp internal.
228
- enableFlags
229
- bit0 show list view
230
- bit1 enable max value
231
- bit2 enable min value
232
- bit3 enable default value
233
- bit4 enable lookTable
234
- bit5 enable lookFields[0]
235
- bit6 enable lookFields[1]
236
- bit7 enable lookFields[2]
237
- bit8 It append to a front column.
238
- bit9 enable reference filter
239
- bitA call field name rename function.
240
- bitB disbale export this field data.
241
- bitC not show list view but add select field list
242
- bitD enable lookDBNum
243
- */
244
-
245
- typedef fielddef_t<MYSQL_FDNAME_SIZE> fielddef_t_my;
246
- typedef fielddef_t<PERVASIVE_FDNAME_SIZE> fielddef_t_pv;
247
-
248
-
249
- #ifdef SWIG
250
- %template(fielddef_t_my) fielddef_t<MYSQL_FDNAME_SIZE>;
251
- #endif
252
-
253
-
254
- struct PACKAGE fielddef : public fielddef_t_my
255
- {
256
- #ifdef _UNICODE
257
- const wchar_t* name() const ; // Return a field name.
258
- const wchar_t* name(wchar_t* buf) const ; // Return a field name to bufffer .
259
- const wchar_t* chainChar() const ; // ** internal use only.
260
- void setName(const wchar_t* s);
261
- void setChainChar(const wchar_t* s); // ** internal use only.
262
- #else
263
-
264
- inline const char* name() const {return m_name;};
265
-
266
- inline const char* chainChar() const {return m_chainChar;};
267
-
268
- inline void setName(const char* s) {strncpy_s(m_name, FIELD_NAME_SIZE, s, sizeof(m_name) - 1);};
269
-
270
- inline void setChainChar(const char* s) {strncpy_s(m_chainChar, 2, s, sizeof(m_chainChar) - 1);};
271
- #endif
272
-
273
- inline const char* nameA() const {return m_name;};
274
-
275
- inline void setNameA(const char* s) {strncpy_s(m_name, FIELD_NAME_SIZE, s, sizeof(m_name) - 1);};
276
- #ifndef MYSQL_DYNAMIC_PLUGIN
277
-
278
- inline const _TCHAR* typeName() const {return getTypeName(type);};
279
-
280
- inline int align() const {return getTypeAlign(type);};
281
-
282
- inline void setLenByCharnum(ushort_td charnum)
283
- {
284
- len = lenByCharnum(type, m_charsetIndex, charnum);
285
- }
286
-
287
- #endif
288
-
289
- private:
290
-
291
- /* Is variable key type
292
- */
293
- inline bool isKeyVarType() const
294
- {
295
- return (((type >= ft_myvarchar) && (type <= ft_mywvarbinary)) || (type == ft_myblob) ||
296
- (type == ft_mytext));
297
- }
298
-
299
- /* max key segment length. not include sizeBytes.
300
- */
301
- inline ushort_td maxKeylen() const {return keylen ? keylen : len;};
302
-
303
- inline ushort_td keyFromVarlen() const
304
- {
305
- if ((type >= ft_myvarchar) && (type <= ft_mywvarbinary))
306
- return len < 256 ? 1 : 2;
307
- else if ((type == ft_myblob) || (type == ft_mytext))
308
- return len - 8;
309
- return 0;
310
- }
311
-
312
- public:
313
-
314
- inline unsigned int codePage() const {return mysql::codePage((unsigned short)m_charsetIndex);}
315
-
316
- /* data image for key
317
- * param ptr address of record buffer
318
- */
319
- inline const uchar_td* keyData(const uchar_td* ptr) const
320
- {
321
- if ((type == ft_myblob) || (type == ft_mytext))
322
- return blobDataPtr(ptr);
323
- int sizeByte = varLenBytes();
324
- return ptr + sizeByte;
325
- }
326
-
327
- inline uint_td keyDataLen(const uchar_td* ptr) const
328
- {
329
- if ((type == ft_myblob) || (type == ft_mytext))
330
- return blobDataLen(ptr);
331
- return dataLen(ptr);
332
- }
333
-
334
- /* copy key data for send to mysql
335
- * return next copy address.
336
- */
337
- inline uchar_td* keyCopy(uchar_td* to, const uchar_td* from)
338
- {
339
-
340
- ushort_td kl = maxKeylen(); // size of max key segmnet for mysql
341
- ushort_td copylen = kl;
342
- memset(to, 0x00, kl);
343
- ushort_td keyVarlen = keyFromVarlen(); // size of var sizeByte for record.
344
- if (keyVarlen)
345
- {
346
- copylen = (ushort_td)std::min<uint_td>((uint_td)copylen, keyDataLen(from));
347
- memcpy(to, &copylen, 2);
348
- to += 2;
349
- from = keyData(from);
350
- }
351
- memcpy(to, from, copylen);
352
- return to + kl - keyVarlen;
353
- }
354
-
355
- /* length bytes of var field
356
- */
357
- inline int varLenBytes() const
358
- {
359
- if (((type >= ft_myvarchar) && (type <= ft_mywvarbinary)) || type == ft_lstring)
360
- return len < 256 ? 1 : 2;
361
- return 0;
362
- }
363
-
364
- inline uint_td blobLenBytes() const
365
- {
366
- if ((type == ft_myblob) || (type == ft_mytext))
367
- return len - 8;
368
- return 0;
369
- }
370
-
371
- /* data length
372
- */
373
- inline uint_td dataLen(const uchar_td* ptr) const
374
- {
375
- int blen = varLenBytes();
376
- if (blen == 0)
377
- return len;
378
- else if (blen == 1)
379
- return*((unsigned char*)ptr);
380
- return *((unsigned short*)ptr);
381
-
382
- }
383
-
384
- inline uint_td blobDataLen(const uchar_td* ptr) const
385
- {
386
- int blen = blobLenBytes();
387
- if (blen == 0)
388
- return len;
389
- uint_td v = 0;
390
- memcpy(&v, ptr, blen);
391
- return v;
392
- }
393
-
394
- inline const uchar_td* blobDataPtr(const uchar_td* ptr) const
395
- {
396
- int blen = blobLenBytes();
397
- if (blen == 0)
398
- return NULL;
399
- const uchar_td** p = (const uchar_td * *)(ptr + blen);
400
- return *p;
401
- }
402
-
403
- /* Is string type or not.
404
- */
405
- bool isStringType() const ;
406
-
407
- /* Charctor numbers from charset.
408
- */
409
- unsigned int charNum() const ;
410
-
411
- inline void setCharsetIndex(uchar_td index)
412
- {
413
- m_charsetIndex = index;
414
- if ((type == ft_wstring) || (type == ft_wzstring) || (type == ft_mywvarchar) ||
415
- (type == ft_mywvarbinary) || (type == ft_mywchar))
416
- m_charsetIndex = CHARSET_UTF16LE;
417
- }
418
-
419
- inline uchar_td charsetIndex()const {return m_charsetIndex;};
420
-
421
-
422
- };
423
-
424
-
425
-
426
- namespace client{class dbdef;}
427
-
428
- /* Mark of ** that BizStation Corp internal use only.
429
- */
430
- struct PACKAGE tabledef
431
- {
432
- friend class client::dbdef; //for formatVersion
433
-
434
- tabledef()
435
- {
436
- cleanup();
437
- }
438
-
439
- void cleanup()
440
- {
441
- memset(this, 0, sizeof(tabledef));
442
- formatVersion = 1;
443
- primaryKeyNum = -1;
444
- parentKeyNum = -1;
445
- replicaKeyNum = -1;
446
- pageSize = 2048;
447
- }
448
-
449
- #ifdef _UNICODE
450
- const wchar_t* fileName() const ; // file name
451
- const wchar_t* tableName() const ; // table name
452
- void setFileName(const wchar_t* s);
453
- void setTableName(const wchar_t* s);
454
- const char* toChar(char* buf, const wchar_t* s, int size);
455
-
456
- #else
457
-
458
- const char* fileName() const {return m_fileName;};
459
-
460
- const char* tableName() const {return m_tableName;};
461
-
462
- inline void setFileName(const char* s) {setFileNameA(s);};
463
-
464
- inline void setTableName(const char* s) {setTableNameA(s);};
465
-
466
- inline const char* toChar(char* buf, const char* s, int size){strncpy_s(buf, size, s, size-1);return buf;};
467
-
468
- #endif
469
-
470
- const char* fileNameA() const {return m_fileName;};
471
-
472
- const char* tableNameA() const {return m_tableName;};
473
-
474
- inline void setFileNameA(const char* s)
475
- {
476
- strncpy_s(m_fileName, FILE_NAME_SIZE, s, FILE_NAME_SIZE - 1);
477
- }
478
-
479
- inline void setTableNameA(const char* s)
480
- {
481
- strncpy_s(m_tableName, TABLE_NAME_SIZE, s, sizeof(m_tableName) - 1);
482
- }
483
-
484
- ushort_td id; // table id
485
- ushort_td pageSize; // page size
486
- ushort_td preAlloc; // pre alloc page seize
487
- ushort_td fieldCount; // Number of field
488
- uchar_td keyCount; // Number of key
489
-
490
- private:
491
- char m_fileName[FILE_NAME_SIZE];
492
- char m_tableName[TABLE_NAME_SIZE];
493
-
494
- public:
495
- short version; // table version
496
- uchar_td charsetIndex; // SCHARSET_INFO vector index;
497
- uchar_td filler0[17]; // reserved
498
- FLAGS flags; // file flags
499
- uchar_td primaryKeyNum; // Primary key number. -1 is no primary.
500
- uchar_td parentKeyNum; // ** Key number for listview. -1 is no use.
501
- uchar_td replicaKeyNum; // ** Key number for repdata. -1 is no use.
502
- FLAGS optionFlags; // ** optional flags
503
- ushort_td convertFileNum; // ** not use
504
- ushort_td maxRecordLen; // max record length of var size table.
505
- uchar_td treeIndex; // ** View index for listview.
506
- uchar_td iconIndex; // ** Icon index for listview.
507
- ushort_td ddfid;
508
- ushort_td fixedRecordLen; // Fixed record length for var size table.
509
- int autoIncExSpace; //
510
- uchar_td iconIndex2; //
511
- uchar_td iconIndex3; //
512
- uint_td schemaCodePage; // Code page of this schema stirng data.
513
- private:
514
- char formatVersion; //
515
- public:
516
- client::dbdef* parent;
517
- uchar_td reserved[TABLEDEF_FILLER_SIZE]; // reserved
518
-
519
- fielddef* fieldDefs; // Pointer cahche of first field.
520
- keydef* keyDefs; // Pointer cahche of first key.
521
- };
522
-
523
- /* optionFlags BizStation internal use only.
524
-
525
- Bit0 send windows messege.
526
- Bit1 show tree view.
527
- Bit2 is master table or not
528
- Bit3 is replicate or not
529
- Bit4 is backup target or not.
530
- Bit5 is encript or not
531
- Bit6 is this table destination of convert .
532
- Bit7 is support short cut in listveiw.
533
- Bit8 is call validate function at delete record.
534
- Bit9 Can export this table.
535
- BitA is this table include valiable fields (varchar or varbinary is used)
536
- BitB is this table include blob field (Blob is used)
537
-
538
- */
539
-
540
- struct PACKAGE btrVersion
541
- {
542
- ushort_td majorVersion;
543
- ushort_td minorVersion;
544
- unsigned char type;
545
- const _TCHAR* moduleVersionShortString(_TCHAR* buf);
546
- const _TCHAR* moduleTypeString();
547
- };
548
-
549
- struct btrVersions
550
- {
551
- btrVersion versions[4];
552
- };
553
-
554
- #pragma option -a.
555
- pragma_pop
556
-
557
- /*filter cobine type*/
558
- enum combineType{eCend, eCand, eCor};
559
-
560
- PACKAGE uchar_td getFilterLogicTypeCode(const _TCHAR* cmpstr);
561
-
562
- }// namespace tdap
563
- }// namespace protocol
564
- }// namespace db
565
- }// namespace bzs
566
- #endif //BZS_DB_PROTOCOL_TDAP_TDAPSCHEMA_H
1
+ #ifndef BZS_DB_PROTOCOL_TDAP_TDAPSCHEMA_H
2
+ #define BZS_DB_PROTOCOL_TDAP_TDAPSCHEMA_H
3
+ /* =================================================================
4
+ Copyright (C) 2000-2013 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
+
22
+ #include <bzs/db/protocol/tdap/tdapcapi.h>
23
+ #include <string.h>
24
+ #include <algorithm>
25
+ #include <wchar.h>
26
+ #include <bzs/env/compiler.h>
27
+ #include <bzs/env/crosscompile.h>
28
+ #include <bzs/db/protocol/tdap/mysql/characterset.h>
29
+
30
+ namespace bzs
31
+ {
32
+ namespace db
33
+ {
34
+ namespace protocol
35
+ {
36
+ namespace tdap
37
+ {
38
+
39
+ namespace client
40
+ {
41
+ class dbdef;
42
+ }
43
+
44
+ #pragma pack(push, 1)
45
+ pragma_pack1;
46
+
47
+ using std::min;
48
+ using std::max;
49
+
50
+ #ifdef SWIG
51
+
52
+ /* For swig interface
53
+ Export names .
54
+ */
55
+ union FLAGS
56
+ {
57
+ unsigned short all;
58
+
59
+ unsigned short bit0 : 1;
60
+ unsigned short bit1 : 1;
61
+ unsigned short bit2 : 1;
62
+ unsigned short bit3 : 1;
63
+ unsigned short bit4 : 1;
64
+ unsigned short bit5 : 1;
65
+ unsigned short bit6 : 1;
66
+ unsigned short bit7 : 1;
67
+ unsigned short bit8 : 1;
68
+ unsigned short bit9 : 1;
69
+ unsigned short bitA : 1;
70
+ unsigned short bitB : 1;
71
+ unsigned short bitC : 1;
72
+ unsigned short bitD : 1;
73
+ unsigned short bitE : 1;
74
+ unsigned short bitF : 1;
75
+ };
76
+ #else // NOT SWIG
77
+
78
+ union FLAGS
79
+ {
80
+ unsigned short all;
81
+
82
+ struct
83
+ {
84
+ unsigned short bit0 : 1;
85
+ unsigned short bit1 : 1;
86
+ unsigned short bit2 : 1;
87
+ unsigned short bit3 : 1;
88
+ unsigned short bit4 : 1;
89
+ unsigned short bit5 : 1;
90
+ unsigned short bit6 : 1;
91
+ unsigned short bit7 : 1;
92
+ unsigned short bit8 : 1;
93
+ unsigned short bit9 : 1;
94
+ unsigned short bitA : 1;
95
+ unsigned short bitB : 1;
96
+ unsigned short bitC : 1;
97
+ unsigned short bitD : 1;
98
+ unsigned short bitE : 1;
99
+ unsigned short bitF : 1;
100
+ };
101
+ };
102
+ #endif // NOT SWIG
103
+
104
+ /* brief Key infomation for create table operation
105
+ */
106
+ struct keySpec
107
+ {
108
+ ushort_td keyPos; /* key position */
109
+ ushort_td keyLen; /* key length */
110
+ FLAGS keyFlag; /* key flag */
111
+ uint_td keyCount; /* key count */
112
+ uchar_td keyType; /* key type of extended */
113
+ uchar_td nullValue; /* value of null */
114
+ uchar_td reserve2[2]; /* reserved */
115
+ uchar_td keyNo; /* fixed key number */
116
+ uchar_td acsNo; /* no acs */
117
+ }; /* total 16 byte */
118
+
119
+ /* brief File infomation for create table operation
120
+ */
121
+ struct fileSpec
122
+ {
123
+ ushort_td recLen; /* record length */
124
+ ushort_td pageSize; /* page sise */
125
+ ushort_td indexCount; /* index count */
126
+ uint_td recCount; /* record count for stat */
127
+ FLAGS fileFlag; /* file flags */
128
+ uchar_td reserve1[2]; /* reserved */
129
+ ushort_td preAlloc; /* page allocation count */
130
+ keySpec keySpecs[1]; /* key specs */
131
+ }; /* total ? byte */
132
+
133
+ /* brief A key segment infomation
134
+ */
135
+ struct keySegment
136
+ {
137
+ uchar_td fieldNum; // Refarence field buymber
138
+ FLAGS flags; // key flags. 11 to 15bit is not use.
139
+ };
140
+
141
+ /* brief A key infomation
142
+ */
143
+ #define MAX_KEY_SEGMENT 8
144
+
145
+ struct keydef
146
+ {
147
+ uchar_td segmentCount; // Number of segment
148
+ keySegment segments[MAX_KEY_SEGMENT]; // key segments . max 8 segments
149
+ uchar_td keyNumber; // key number
150
+ };
151
+
152
+ static const int MYSQL_FDNAME_SIZE = 64;
153
+ static const int MYSQL_TBNAME_SIZE = 64;
154
+ static const int PERVASIVE_FDNAME_SIZE = 20;
155
+ static const int FIELD_NAME_SIZE = MYSQL_FDNAME_SIZE;
156
+ static const int TABLE_NAME_SIZE = 32;
157
+ static const int FILE_NAME_SIZE = 266;
158
+
159
+ #if (defined(__x86_32__) || __APPLE_32__)
160
+ static const int TABLEDEF_FILLER_SIZE = 21; // 25-4;
161
+ #else
162
+ static const int TABLEDEF_FILLER_SIZE = 9; // 17-8;
163
+ #endif
164
+
165
+ #ifndef MYSQL_DYNAMIC_PLUGIN
166
+
167
+ /* A field type name that specified by a type is returned.
168
+ */
169
+ PACKAGE const _TCHAR* getTypeName(short type);
170
+
171
+ /* A field alignment that specified by a type is returned.
172
+ */
173
+ PACKAGE int getTypeAlign(short type);
174
+
175
+ /* calcurate byts of char type by charctor number.
176
+ */
177
+ PACKAGE ushort_td
178
+ lenByCharnum(uchar_td type, uchar_td charsetIndex, ushort_td charnum);
179
+
180
+ #endif // MYSQL_DYNAMIC_PLUGIN
181
+
182
+ /* Is field type string ? */
183
+ PACKAGE bool isStringType(uchar_td type);
184
+
185
+ /* Mark of ** that BizStation Corp internal use only.
186
+ */
187
+ template <int N> struct fielddef_t
188
+ {
189
+ protected:
190
+ char m_name[N];
191
+
192
+ public:
193
+ uchar_td type; // type (zstring integer)
194
+ ushort_td len; // length
195
+ uchar_td decimals; // ** decimals
196
+ char viewNum; // ** An order of a list view column
197
+ ushort_td viewWidth; // ** view width pix
198
+ double max; // ** max value
199
+ double min; // ** min value
200
+ double defValue; // ** default value
201
+ uchar_td lookTable; // ** reference table number
202
+ uchar_td lookField; // ** field number of reference table
203
+ uchar_td lookFields[3]; // ** View fields of reference bit567
204
+ ushort_td pos; // Field offset position from record image
205
+ ushort_td defViewWidth; // ** default view wifth
206
+
207
+ protected:
208
+ char m_chainChar[2];
209
+
210
+ public:
211
+ ushort_td ddfid; // ddf field id
212
+ ushort_td filterId; // ** filter id for reference
213
+ uchar_td filterKeynum; // ** key number for reference
214
+ uchar_td nullValue; // null value
215
+ ushort_td userOption; // ** option
216
+ uchar_td lookDBNum; // ** database number of reference bitD
217
+ ushort_td keylen; // key length for mysql of part key
218
+
219
+ protected:
220
+ uchar_td m_charsetIndex; // charctor set index of this field data
221
+ uint_td m_schemaCodePage;
222
+
223
+ public:
224
+ FLAGS enableFlags; // ** enable flags. see below
225
+
226
+ private:
227
+ inline void setSchemaCodePage(uint_td v) { m_schemaCodePage = v; };
228
+ friend class client::dbdef;
229
+ };
230
+
231
+ /* This is only for BizStation Corp internal.
232
+ enableFlags
233
+ bit0 show list view
234
+ bit1 enable max value
235
+ bit2 enable min value
236
+ bit3 enable default value
237
+ bit4 enable lookTable
238
+ bit5 enable lookFields[0]
239
+ bit6 enable lookFields[1]
240
+ bit7 enable lookFields[2]
241
+ bit8 It append to a front column.
242
+ bit9 enable reference filter
243
+ bitA call field name rename function.
244
+ bitB disbale export this field data.
245
+ bitC not show list view but add select field list
246
+ bitD enable lookDBNum
247
+ bitE field value is changed
248
+ */
249
+
250
+ typedef fielddef_t<MYSQL_FDNAME_SIZE> fielddef_t_my;
251
+ typedef fielddef_t<PERVASIVE_FDNAME_SIZE> fielddef_t_pv;
252
+
253
+ #ifdef SWIG
254
+ %template(fielddef_t_my) fielddef_t<MYSQL_FDNAME_SIZE>;
255
+ #endif // SWIG
256
+
257
+ struct PACKAGE fielddef : public fielddef_t_my
258
+ {
259
+ #ifdef _UNICODE
260
+ const wchar_t* name() const; // Return a field name.
261
+ const wchar_t* name(wchar_t* buf) const; // Return a field name to bufffer .
262
+ const wchar_t* chainChar() const; // ** internal use only.
263
+ void setName(const wchar_t* s);
264
+ void setChainChar(const wchar_t* s); // ** internal use only.
265
+ #else // NOT _UNICODE
266
+
267
+ #ifdef MYSQL_DYNAMIC_PLUGIN
268
+
269
+ inline const char* name() const { return m_name; };
270
+
271
+ inline const char* chainChar() const { return m_chainChar; };
272
+
273
+ inline void setName(const char* s)
274
+ {
275
+ strncpy_s(m_name, FIELD_NAME_SIZE, s, sizeof(m_name) - 1);
276
+ };
277
+
278
+ inline void setChainChar(const char* s)
279
+ {
280
+ strncpy_s(m_chainChar, 2, s, sizeof(m_chainChar) - 1);
281
+ };
282
+
283
+ #else // NOT MYSQL_DYNAMIC_PLUGIN
284
+ const char* name() const;
285
+ const char* name(char* buf) const;
286
+ const char* chainChar() const;
287
+ void setName(const char* s);
288
+ void setChainChar(const char* s);
289
+ #endif // NOT MYSQL_DYNAMIC_PLUGIN
290
+ #endif // NOT _UNICODE
291
+
292
+ inline const char* nameA() const { return m_name; };
293
+
294
+ inline void setNameA(const char* s)
295
+ {
296
+ strncpy_s(m_name, FIELD_NAME_SIZE, s, sizeof(m_name) - 1);
297
+ };
298
+ #ifndef MYSQL_DYNAMIC_PLUGIN
299
+
300
+ inline const _TCHAR* typeName() const { return getTypeName(type); };
301
+
302
+ inline int align() const { return getTypeAlign(type); };
303
+
304
+ inline void setLenByCharnum(ushort_td charnum)
305
+ {
306
+ len = lenByCharnum(type, m_charsetIndex, charnum);
307
+ }
308
+
309
+ #endif // MYSQL_DYNAMIC_PLUGIN
310
+
311
+ private:
312
+ /* Is variable key type
313
+ */
314
+ inline bool isKeyVarType() const
315
+ {
316
+ return (((type >= ft_myvarchar) && (type <= ft_mywvarbinary)) ||
317
+ (type == ft_myblob) || (type == ft_mytext));
318
+ }
319
+
320
+ /* max key segment length. not include sizeBytes.
321
+ */
322
+ inline ushort_td maxKeylen() const { return keylen ? keylen : len; };
323
+
324
+ inline ushort_td keyFromVarlen() const
325
+ {
326
+ if ((type >= ft_myvarchar) && (type <= ft_mywvarbinary))
327
+ return len < 256 ? 1 : 2;
328
+ else if ((type == ft_myblob) || (type == ft_mytext))
329
+ return len - 8;
330
+ return 0;
331
+ }
332
+
333
+ public:
334
+ inline unsigned int codePage() const
335
+ {
336
+ return mysql::codePage((unsigned short)m_charsetIndex);
337
+ }
338
+
339
+ /* data image for key
340
+ * param ptr address of record buffer
341
+ */
342
+ inline const uchar_td* keyData(const uchar_td* ptr) const
343
+ {
344
+ if ((type == ft_myblob) || (type == ft_mytext))
345
+ return blobDataPtr(ptr);
346
+ int sizeByte = varLenBytes();
347
+ return ptr + sizeByte;
348
+ }
349
+
350
+ inline uint_td keyDataLen(const uchar_td* ptr) const
351
+ {
352
+ if ((type == ft_myblob) || (type == ft_mytext))
353
+ return blobDataLen(ptr);
354
+ return dataLen(ptr);
355
+ }
356
+
357
+ /* copy key data for send to mysql
358
+ * return next copy address.
359
+ */
360
+ inline uchar_td* keyCopy(uchar_td* to, const uchar_td* from)
361
+ {
362
+
363
+ ushort_td kl = maxKeylen(); // size of max key segmnet for mysql
364
+ ushort_td copylen = kl;
365
+ memset(to, 0x00, kl);
366
+ ushort_td keyVarlen =
367
+ keyFromVarlen(); // size of var sizeByte for record.
368
+ if (keyVarlen)
369
+ {
370
+ copylen = (ushort_td)std::min<uint_td>((uint_td)copylen,
371
+ keyDataLen(from));
372
+ memcpy(to, &copylen, 2);
373
+ to += 2;
374
+ from = keyData(from);
375
+ }
376
+ memcpy(to, from, copylen);
377
+ return to + kl - keyVarlen;
378
+ }
379
+
380
+ /* Get keyValue from keybuf for seek mode error description
381
+ * return next copy key address.
382
+ */
383
+ inline const uchar_td* getKeyValueFromKeybuf(const uchar_td* from,
384
+ const uchar_td** data,
385
+ ushort_td& size)
386
+ {
387
+ ushort_td keyVarlen =
388
+ keyFromVarlen(); // size of var sizeByte for record.
389
+ if (keyVarlen)
390
+ {
391
+ size = *((ushort_td*)from);
392
+ *data = from + 2;
393
+ }
394
+ else
395
+ {
396
+ size = maxKeylen();
397
+ *data = from;
398
+ }
399
+ return *data + size;
400
+ }
401
+
402
+ /* length bytes of var field
403
+ */
404
+ inline int varLenBytes() const
405
+ {
406
+ if (((type >= ft_myvarchar) && (type <= ft_mywvarbinary)) ||
407
+ type == ft_lstring)
408
+ return len < 256 ? 1 : 2;
409
+ return 0;
410
+ }
411
+
412
+ inline uint_td blobLenBytes() const
413
+ {
414
+ if ((type == ft_myblob) || (type == ft_mytext))
415
+ return len - 8;
416
+ return 0;
417
+ }
418
+
419
+ inline int maxVarDatalen() const
420
+ {
421
+ if (((type >= ft_myvarchar) && (type <= ft_mywvarbinary)) ||
422
+ type == ft_lstring)
423
+ return (len < 256) ? len - 1 : len - 2;
424
+ else if (type == ft_lvar)
425
+ return len - 4;
426
+ else if ((type == ft_myblob) || (type == ft_mytext))
427
+ {
428
+ switch (len - 8)
429
+ {
430
+ case 1:
431
+ return 0xFF;
432
+ case 2:
433
+ return 0xFFFF;
434
+ case 3:
435
+ return 0xFFFFFF;
436
+ case 4:
437
+ return 0xFFFFFFFF;
438
+ }
439
+ return 0;
440
+ }
441
+ return 0;
442
+ }
443
+
444
+ /* data length
445
+ */
446
+ inline uint_td dataLen(const uchar_td* ptr) const
447
+ {
448
+ int blen = varLenBytes();
449
+ if (blen == 0)
450
+ return len;
451
+ else if (blen == 1)
452
+ return *((unsigned char*)ptr);
453
+ return *((unsigned short*)ptr);
454
+ }
455
+
456
+ inline uint_td blobDataLen(const uchar_td* ptr) const
457
+ {
458
+ int blen = blobLenBytes();
459
+ if (blen == 0)
460
+ return len;
461
+ uint_td v = 0;
462
+ memcpy(&v, ptr, blen);
463
+ return v;
464
+ }
465
+
466
+ inline const uchar_td* blobDataPtr(const uchar_td* ptr) const
467
+ {
468
+ int blen = blobLenBytes();
469
+ if (blen == 0)
470
+ return NULL;
471
+ const uchar_td** p = (const uchar_td**)(ptr + blen);
472
+ return *p;
473
+ }
474
+
475
+ /* Is string type or not.
476
+ */
477
+ bool isStringType() const;
478
+
479
+ inline bool isNumericType() const
480
+ {
481
+ return ((type == ft_integer) || (type == ft_decimal) ||
482
+ (type == ft_money) || (type == ft_logical) ||
483
+ (type == ft_numeric) || (type == ft_bfloat) ||
484
+ (type == ft_uinteger) || (type == ft_autoinc) ||
485
+ (type == ft_bit) || (type == ft_numericsts) ||
486
+ (type == ft_numericsa) || (type == ft_autoIncUnsigned));
487
+ }
488
+
489
+ /* Charctor numbers from charset.
490
+ */
491
+ unsigned int charNum() const;
492
+
493
+ inline void setCharsetIndex(uchar_td index)
494
+ {
495
+ m_charsetIndex = index;
496
+ if ((type == ft_wstring) || (type == ft_wzstring) ||
497
+ (type == ft_mywvarchar) || (type == ft_mywvarbinary) ||
498
+ (type == ft_mywchar))
499
+ m_charsetIndex = CHARSET_UTF16LE;
500
+ }
501
+
502
+ inline uchar_td charsetIndex() const { return m_charsetIndex; };
503
+
504
+ inline uint_td unPackCopy(uchar_td* dest, const uchar_td* src) const
505
+ {
506
+ int clen = varLenBytes();
507
+ if (clen == 0)
508
+ clen = len;
509
+ else if (clen == 1)
510
+ clen += *((unsigned char*)src);
511
+ else
512
+ clen += *((unsigned short*)src);
513
+ memcpy(dest, src, clen);
514
+ return clen;
515
+ }
516
+ };
517
+
518
+ namespace client
519
+ {
520
+ class dbdef;
521
+ }
522
+
523
+ /* Mark of ** that BizStation Corp internal use only.
524
+ */
525
+ struct PACKAGE tabledef
526
+ {
527
+ friend class client::dbdef; // for formatVersion
528
+
529
+ tabledef() { cleanup(); }
530
+
531
+ void cleanup()
532
+ {
533
+ memset(this, 0, sizeof(tabledef));
534
+ formatVersion = 1;
535
+ primaryKeyNum = -1;
536
+ parentKeyNum = -1;
537
+ replicaKeyNum = -1;
538
+ pageSize = 2048;
539
+ }
540
+
541
+ #ifdef _UNICODE
542
+ const wchar_t* fileName() const; // file name
543
+ const wchar_t* tableName() const; // table name
544
+ void setFileName(const wchar_t* s);
545
+ void setTableName(const wchar_t* s);
546
+ const char* toChar(char* buf, const wchar_t* s, int size);
547
+
548
+ #else
549
+ #ifdef MYSQL_DYNAMIC_PLUGIN
550
+
551
+ const char* fileName() const { return m_fileName; };
552
+
553
+ const char* tableName() const { return m_tableName; };
554
+
555
+ inline void setFileName(const char* s) { setFileNameA(s); };
556
+
557
+ inline void setTableName(const char* s) { setTableNameA(s); };
558
+
559
+ inline const char* toChar(char* buf, const char* s, int size)
560
+ {
561
+ strncpy_s(buf, size, s, size - 1);
562
+ return buf;
563
+ };
564
+ #else
565
+ const char* fileName() const;
566
+ const char* tableName() const;
567
+ void setFileName(const char* s);
568
+ void setTableName(const char* s);
569
+ const char* toChar(char* buf, const char* s, int size);
570
+ #endif // MYSQL_DYNAMIC_PLUGIN
571
+ #endif
572
+
573
+ const char* fileNameA() const { return m_fileName; };
574
+
575
+ const char* tableNameA() const { return m_tableName; };
576
+
577
+ inline void setFileNameA(const char* s)
578
+ {
579
+ strncpy_s(m_fileName, FILE_NAME_SIZE, s, FILE_NAME_SIZE - 1);
580
+ }
581
+
582
+ inline void setTableNameA(const char* s)
583
+ {
584
+ strncpy_s(m_tableName, TABLE_NAME_SIZE, s, sizeof(m_tableName) - 1);
585
+ }
586
+
587
+ ushort_td id; // table id
588
+
589
+ #ifdef SWIG
590
+ /* For swig interface
591
+ export field names.
592
+ */
593
+ ushort_td pageSize; // page size
594
+ ushort_td varSize; // second field length
595
+ #else
596
+
597
+ union
598
+ {
599
+ ushort_td pageSize; // page size
600
+ ushort_td varSize; // second field length
601
+ };
602
+ #endif
603
+
604
+ ushort_td preAlloc; // pre alloc page seize
605
+ ushort_td fieldCount; // Number of field
606
+ uchar_td keyCount; // Number of key
607
+
608
+ private:
609
+ char m_fileName[FILE_NAME_SIZE];
610
+ char m_tableName[TABLE_NAME_SIZE];
611
+
612
+ public:
613
+ short version; // table version
614
+ uchar_td charsetIndex; // SCHARSET_INFO vector index;
615
+ uchar_td filler0[17]; // reserved
616
+ FLAGS flags; // file flags
617
+ uchar_td primaryKeyNum; // Primary key number. -1 is no primary.
618
+ uchar_td parentKeyNum; // ** Key number for listview. -1 is no use.
619
+ uchar_td replicaKeyNum; // ** Key number for repdata. -1 is no use.
620
+ FLAGS optionFlags; // ** optional flags
621
+ ushort_td convertFileNum; // ** not use
622
+ ushort_td maxRecordLen; // max record length of var size table.
623
+ uchar_td treeIndex; // ** View index for listview.
624
+ uchar_td iconIndex; // ** Icon index for listview.
625
+ ushort_td ddfid;
626
+ ushort_td fixedRecordLen; // Fixed record length for var size table.
627
+ int autoIncExSpace;
628
+ uchar_td iconIndex2;
629
+ uchar_td iconIndex3;
630
+ uint_td schemaCodePage; // Code page of this schema stirng data.
631
+
632
+ private:
633
+ char formatVersion;
634
+
635
+ public:
636
+ client::dbdef* parent;
637
+ uchar_td reserved[TABLEDEF_FILLER_SIZE]; // reserved
638
+
639
+ fielddef* fieldDefs; // Pointer cahche of first field.
640
+ keydef* keyDefs; // Pointer cahche of first key.
641
+ };
642
+
643
+ /* optionFlags BizStation internal use only.
644
+ Bit0 send windows messege.
645
+ Bit1 show tree view.
646
+ Bit2 is master table or not
647
+ Bit3 is replicate or not
648
+ Bit4 is backup target or not.
649
+ Bit5 is encript or not
650
+ Bit6 is this table destination of convert .
651
+ Bit7 is support short cut in listveiw.
652
+ Bit8 is call validate function at delete record.
653
+ Bit9 Can export this table.
654
+ BitA is this table include valiable fields (varchar or varbinary is used)
655
+ BitB is this table include blob field (Blob is used)
656
+ */
657
+
658
+ struct PACKAGE btrVersion
659
+ {
660
+ ushort_td majorVersion;
661
+ ushort_td minorVersion;
662
+ unsigned char type;
663
+
664
+ const _TCHAR* moduleVersionShortString(_TCHAR* buf);
665
+ const _TCHAR* moduleTypeString();
666
+ };
667
+
668
+ struct btrVersions
669
+ {
670
+ btrVersion versions[4];
671
+ };
672
+
673
+ #pragma pack(pop)
674
+ pragma_pop;
675
+
676
+ /* filter cobine type */
677
+ enum combineType
678
+ {
679
+ eCend,
680
+ eCand,
681
+ eCor
682
+ };
683
+
684
+ /* compair types */
685
+ enum eCompType
686
+ {
687
+ eEqual = 1,
688
+ eGreater = 2,
689
+ eLess = 3,
690
+ eNotEq = 4,
691
+ eGreaterEq = 5,
692
+ eLessEq = 6
693
+ };
694
+
695
+ PACKAGE uchar_td getFilterLogicTypeCode(const _TCHAR* cmpstr);
696
+
697
+ } // namespace tdap
698
+ } // namespace protocol
699
+ } // namespace db
700
+ } // namespace bzs
701
+
702
+ #endif // BZS_DB_PROTOCOL_TDAP_TDAPSCHEMA_H