transactd 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. checksums.yaml +7 -0
  2. data/BUILD_UNIX-JA +174 -0
  3. data/BUILD_WIN-JA +256 -0
  4. data/CMakeLists.txt +96 -0
  5. data/COPYING +339 -0
  6. data/README +406 -0
  7. data/README-JA +424 -0
  8. data/bin/common/tdclc_32_1_0.dll +0 -0
  9. data/bin/common/tdclc_64_1_0.dll +0 -0
  10. data/build/common/check_for_link_iconv.cmake +73 -0
  11. data/build/common/copyifgreater.cmd +30 -0
  12. data/build/common/copyifgreater.js +290 -0
  13. data/build/common/get_boost_libs.cmake +106 -0
  14. data/build/common/get_ruby_path.cmake +115 -0
  15. data/build/common/options.cmake +127 -0
  16. data/build/common/smart_install.cmake +263 -0
  17. data/build/common/system.cmake +122 -0
  18. data/build/common/transactd.rc.in +52 -0
  19. data/build/common/transactd_cl_common.cmake +101 -0
  20. data/build/common/transactd_cl_output.cmake +93 -0
  21. data/build/common/transactd_common.cmake +237 -0
  22. data/build/common/transactd_required.cmake +28 -0
  23. data/build/swig/ruby/generate.cmake.in +35 -0
  24. data/build/swig/ruby/generate.cmd.in +19 -0
  25. data/build/swig/ruby/ruby.swg +101 -0
  26. data/build/swig/tdcl.i +188 -0
  27. data/build/tdclc/BUILDNUMBER.txt +1 -0
  28. data/build/tdclc/CMakeLists.txt +170 -0
  29. data/build/tdclc/tdclc_32.cbproj +181 -0
  30. data/build/tdclc/tdclc_64.cbproj +205 -0
  31. data/build/tdclcpp/BUILDNUMBER.txt +1 -0
  32. data/build/tdclcpp/CMakeLists.txt +142 -0
  33. data/build/tdclcpp/tdclcpp_bcb_32.cbproj +239 -0
  34. data/build/tdclcpp/tdclcpp_bcb_64.cbproj +304 -0
  35. data/build/tdclrb/BUILDNUMBER.txt +1 -0
  36. data/build/tdclrb/CMakeLists.txt +258 -0
  37. data/build/tdclrb/GEM_VERSION +3 -0
  38. data/build/tdclrb/bldgem/extconf.rb +123 -0
  39. data/build/tdclrb/gem/INSTALLLOG.win32 +9 -0
  40. data/build/tdclrb/gem/Makefile.win32-VS +65 -0
  41. data/build/tdclrb/gem/Makefile.win32-prebuilt +48 -0
  42. data/build/tdclrb/gem/detect.rb +31 -0
  43. data/build/tdclrb/gem/helper.rb +113 -0
  44. data/build/tdclrb/gem/transactd.rb +22 -0
  45. data/build/tdclrb/gem_output.cmake +44 -0
  46. data/source/bzs/db/IBlobBuffer.h +51 -0
  47. data/source/bzs/db/blobBuffer.h +177 -0
  48. data/source/bzs/db/blobStructs.h +85 -0
  49. data/source/bzs/db/engine/mysql/IReadRecords.h +52 -0
  50. data/source/bzs/db/engine/mysql/bookmark.h +195 -0
  51. data/source/bzs/db/engine/mysql/database.cpp +1882 -0
  52. data/source/bzs/db/engine/mysql/database.h +465 -0
  53. data/source/bzs/db/engine/mysql/dbManager.cpp +303 -0
  54. data/source/bzs/db/engine/mysql/dbManager.h +143 -0
  55. data/source/bzs/db/engine/mysql/errorMessage.cpp +75 -0
  56. data/source/bzs/db/engine/mysql/errorMessage.h +43 -0
  57. data/source/bzs/db/engine/mysql/fieldAccess.h +158 -0
  58. data/source/bzs/db/engine/mysql/mydebuglog.cpp +349 -0
  59. data/source/bzs/db/engine/mysql/mydebuglog.h +89 -0
  60. data/source/bzs/db/engine/mysql/mysqlInternal.h +171 -0
  61. data/source/bzs/db/engine/mysql/mysqlThd.cpp +169 -0
  62. data/source/bzs/db/engine/mysql/mysqlThd.h +35 -0
  63. data/source/bzs/db/engine/mysql/percentageKey.h +260 -0
  64. data/source/bzs/db/protocol/ICommandExecuter.h +49 -0
  65. data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +689 -0
  66. data/source/bzs/db/protocol/hs/hsCommandExecuter.h +228 -0
  67. data/source/bzs/db/protocol/tdap/btrDate.cpp +437 -0
  68. data/source/bzs/db/protocol/tdap/btrDate.h +227 -0
  69. data/source/bzs/db/protocol/tdap/client/bulkInsert.h +127 -0
  70. data/source/bzs/db/protocol/tdap/client/client.cpp +106 -0
  71. data/source/bzs/db/protocol/tdap/client/client.h +292 -0
  72. data/source/bzs/db/protocol/tdap/client/connMgr.cpp +144 -0
  73. data/source/bzs/db/protocol/tdap/client/connMgr.h +82 -0
  74. data/source/bzs/db/protocol/tdap/client/database.cpp +863 -0
  75. data/source/bzs/db/protocol/tdap/client/database.h +118 -0
  76. data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +100 -0
  77. data/source/bzs/db/protocol/tdap/client/dbDef.cpp +1640 -0
  78. data/source/bzs/db/protocol/tdap/client/dbDef.h +135 -0
  79. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +434 -0
  80. data/source/bzs/db/protocol/tdap/client/errorMessage.cpp +92 -0
  81. data/source/bzs/db/protocol/tdap/client/errorMessage_ja.cpp +98 -0
  82. data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +174 -0
  83. data/source/bzs/db/protocol/tdap/client/fieldDDF.h +91 -0
  84. data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +140 -0
  85. data/source/bzs/db/protocol/tdap/client/fileDDF.h +86 -0
  86. data/source/bzs/db/protocol/tdap/client/filter.cpp +527 -0
  87. data/source/bzs/db/protocol/tdap/client/filter.h +154 -0
  88. data/source/bzs/db/protocol/tdap/client/indexDDF.cpp +137 -0
  89. data/source/bzs/db/protocol/tdap/client/indexDDF.h +84 -0
  90. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +724 -0
  91. data/source/bzs/db/protocol/tdap/client/nsDatabase.h +123 -0
  92. data/source/bzs/db/protocol/tdap/client/nsTable.cpp +899 -0
  93. data/source/bzs/db/protocol/tdap/client/nsTable.h +199 -0
  94. data/source/bzs/db/protocol/tdap/client/request.h +198 -0
  95. data/source/bzs/db/protocol/tdap/client/sharedData.cpp +58 -0
  96. data/source/bzs/db/protocol/tdap/client/sharedData.h +56 -0
  97. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +574 -0
  98. data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +53 -0
  99. data/source/bzs/db/protocol/tdap/client/stringConverter.h +627 -0
  100. data/source/bzs/db/protocol/tdap/client/table.cpp +2613 -0
  101. data/source/bzs/db/protocol/tdap/client/table.h +221 -0
  102. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +1096 -0
  103. data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +179 -0
  104. data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +40 -0
  105. data/source/bzs/db/protocol/tdap/client/trnsctcl.def +11 -0
  106. data/source/bzs/db/protocol/tdap/myDateTime.cpp +500 -0
  107. data/source/bzs/db/protocol/tdap/mysql/characterset.cpp +184 -0
  108. data/source/bzs/db/protocol/tdap/mysql/characterset.h +60 -0
  109. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +284 -0
  110. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +53 -0
  111. data/source/bzs/db/protocol/tdap/mysql/debuglog.cpp +383 -0
  112. data/source/bzs/db/protocol/tdap/mysql/debuglog.h +106 -0
  113. data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +680 -0
  114. data/source/bzs/db/protocol/tdap/mysql/request.h +202 -0
  115. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +1020 -0
  116. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +141 -0
  117. data/source/bzs/db/protocol/tdap/tdapRequest.h +190 -0
  118. data/source/bzs/db/protocol/tdap/tdapSchema.cpp +295 -0
  119. data/source/bzs/db/protocol/tdap/tdapSchema.h +558 -0
  120. data/source/bzs/db/protocol/tdap/tdapcapi.h +423 -0
  121. data/source/bzs/db/transactd/appBuilderImple.h +55 -0
  122. data/source/bzs/db/transactd/appModule.cpp +183 -0
  123. data/source/bzs/db/transactd/appModule.h +80 -0
  124. data/source/bzs/db/transactd/connManager.cpp +201 -0
  125. data/source/bzs/db/transactd/connManager.h +60 -0
  126. data/source/bzs/db/transactd/connectionRecord.h +69 -0
  127. data/source/bzs/db/transactd/transactd.cpp +325 -0
  128. data/source/bzs/env/compiler.h +135 -0
  129. data/source/bzs/env/crosscompile.cpp +130 -0
  130. data/source/bzs/env/crosscompile.h +150 -0
  131. data/source/bzs/env/fileopen.h +36 -0
  132. data/source/bzs/env/mbcswchrLinux.cpp +40 -0
  133. data/source/bzs/env/mbcswchrLinux.h +88 -0
  134. data/source/bzs/env/tstring.h +183 -0
  135. data/source/bzs/example/changeSchema.cpp +117 -0
  136. data/source/bzs/example/changeSchema_c.cpp +78 -0
  137. data/source/bzs/example/connection_pool_c.cpp +171 -0
  138. data/source/bzs/example/createDatabase.cpp +305 -0
  139. data/source/bzs/example/createDatabase_c.cpp +202 -0
  140. data/source/bzs/example/deleteRecords.cpp +87 -0
  141. data/source/bzs/example/deleteRecords_c.cpp +57 -0
  142. data/source/bzs/example/dropDatabase.cpp +59 -0
  143. data/source/bzs/example/dropDatabase_c.cpp +34 -0
  144. data/source/bzs/example/insertRecords.cpp +212 -0
  145. data/source/bzs/example/insertRecords_c.cpp +153 -0
  146. data/source/bzs/example/readRecords.cpp +141 -0
  147. data/source/bzs/example/readRecords_c.cpp +107 -0
  148. data/source/bzs/example/updateRecords.cpp +99 -0
  149. data/source/bzs/example/updateRecords_c.cpp +71 -0
  150. data/source/bzs/example/update_with_transaction.cpp +104 -0
  151. data/source/bzs/example/update_with_transaction_c.cpp +80 -0
  152. data/source/bzs/netsvc/client/tcpClient.cpp +226 -0
  153. data/source/bzs/netsvc/client/tcpClient.h +489 -0
  154. data/source/bzs/netsvc/server/IAppModule.h +94 -0
  155. data/source/bzs/netsvc/server/iserver.h +65 -0
  156. data/source/bzs/netsvc/server/serverCpt.cpp +522 -0
  157. data/source/bzs/netsvc/server/serverCpt.h +88 -0
  158. data/source/bzs/netsvc/server/serverPipe.cpp +705 -0
  159. data/source/bzs/netsvc/server/serverPipe.h +96 -0
  160. data/source/bzs/netsvc/server/serverTpool.cpp +416 -0
  161. data/source/bzs/netsvc/server/serverTpool.h +84 -0
  162. data/source/bzs/rtl/benchmark.cpp +96 -0
  163. data/source/bzs/rtl/benchmark.h +65 -0
  164. data/source/bzs/rtl/datetime.cpp +375 -0
  165. data/source/bzs/rtl/datetime.h +53 -0
  166. data/source/bzs/rtl/debuglog.cpp +106 -0
  167. data/source/bzs/rtl/debuglog.h +97 -0
  168. data/source/bzs/rtl/exception.h +116 -0
  169. data/source/bzs/rtl/stl_uty.cpp +35 -0
  170. data/source/bzs/rtl/stl_uty.h +29 -0
  171. data/source/bzs/rtl/stringBuffers.cpp +101 -0
  172. data/source/bzs/rtl/stringBuffers.h +58 -0
  173. data/source/bzs/rtl/strtrim.cpp +135 -0
  174. data/source/bzs/rtl/strtrim.h +46 -0
  175. data/source/bzs/test/tdclatl/bench_tdclatl.js +445 -0
  176. data/source/bzs/test/tdclrb/bench_tdclcpp.rb +375 -0
  177. data/source/bzs/test/tdclrb/prepare.rb +226 -0
  178. data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +172 -0
  179. data/source/bzs/test/tdclrb/transactd_kanjischema_spec.rb +208 -0
  180. data/source/bzs/test/tdclrb/transactd_spec.rb +1536 -0
  181. data/source/bzs/test/transactdBench/transactdBench.cpp +430 -0
  182. data/source/bzs/test/transactdBench/transactdBench2.cpp +342 -0
  183. data/source/bzs/test/trdclengn/test_trdclengn.cpp +2030 -0
  184. data/source/global/tdclatl/Database.cpp +503 -0
  185. data/source/global/tdclatl/Database.h +139 -0
  186. data/source/global/tdclatl/DbDef.cpp +242 -0
  187. data/source/global/tdclatl/DbDef.h +79 -0
  188. data/source/global/tdclatl/Field.cpp +92 -0
  189. data/source/global/tdclatl/Field.h +59 -0
  190. data/source/global/tdclatl/FieldDef.cpp +238 -0
  191. data/source/global/tdclatl/FieldDef.h +87 -0
  192. data/source/global/tdclatl/Flags.cpp +111 -0
  193. data/source/global/tdclatl/Flags.h +55 -0
  194. data/source/global/tdclatl/KeyDef.cpp +51 -0
  195. data/source/global/tdclatl/KeyDef.h +55 -0
  196. data/source/global/tdclatl/KeySegment.cpp +55 -0
  197. data/source/global/tdclatl/Table.cpp +600 -0
  198. data/source/global/tdclatl/Table.h +144 -0
  199. data/source/global/tdclatl/TableDef.cpp +291 -0
  200. data/source/global/tdclatl/TableDef.h +86 -0
  201. data/source/global/tdclatl/TdVersion.cpp +74 -0
  202. data/source/global/tdclatl/TdVersion.h +54 -0
  203. data/source/global/tdclatl/_IDatabaseEvents_CP.h +113 -0
  204. data/source/global/tdclatl/dllmain.cpp +30 -0
  205. data/source/global/tdclatl/dllmain.h +27 -0
  206. data/source/global/tdclatl/keySegment.h +57 -0
  207. data/source/global/tdclatl/resource.h +0 -0
  208. data/source/global/tdclatl/stdafx.cpp +2 -0
  209. data/source/global/tdclatl/stdafx.h +25 -0
  210. data/source/global/tdclatl/targetver.h +4 -0
  211. data/source/global/tdclatl/tdclatl.cpp +68 -0
  212. data/source/global/tdclatl/tdclatl.def +10 -0
  213. data/source/global/tdclatl/tdclatl.idl +1035 -0
  214. data/source/linux/charsetConvert.h +112 -0
  215. data/source/linux/linuxTypes.h +33 -0
  216. data/source/linux/tchar.h +428 -0
  217. data/transactd.gemspec +97 -0
  218. metadata +267 -0
@@ -0,0 +1,141 @@
1
+ #ifndef BZS_DB_PROTOCOL_TDAP_MYSQL_TDAPCOMMANDEXECUTER_H
2
+ #define BZS_DB_PROTOCOL_TDAP_MYSQL_TDAPCOMMANDEXECUTER_H
3
+ /*=================================================================
4
+ Copyright (C) 2012 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/engine/mysql/dbManager.h>
23
+ #include <bzs/db/protocol/ICommandExecuter.h>
24
+ #include "request.h"
25
+ #include <bzs/env/crosscompile.h>
26
+
27
+ extern int g_tableNmaeLower;
28
+
29
+ namespace bzs
30
+ {
31
+ namespace db
32
+ {
33
+ class blobBuffer;
34
+ namespace protocol
35
+ {
36
+ namespace tdap
37
+ {
38
+ namespace mysql
39
+ {
40
+
41
+ class ReadRecordsHandler;
42
+
43
+ #define FOR_SQL true
44
+
45
+ std::string getDatabaseName(const request& req, bool forSql=false);
46
+ std::string getTableName(const request& req, bool forSql=false);
47
+ short_td errorCode(int ha_error);
48
+ bool isMetaDb(const request& req);
49
+
50
+ class dbExecuter : public engine::mysql::dbManager
51
+ {
52
+ ReadRecordsHandler* m_readHandler;
53
+ blobBuffer* m_blobBuffer;
54
+
55
+ void connect(request& req);
56
+ void releaseDatabase(request& req, int op);
57
+ std::string makeSQLcreateTable(const request& req);
58
+ inline void doCreateTable(request& req);
59
+ inline void doOpenTable(request& req);
60
+ inline void doSeekKey(request& req, int op);
61
+ inline void doMoveFirst(request& req);
62
+ inline void doMoveKey(request& req, int op);
63
+ inline int doReadMultiWithSeek(request& req, int op, char* resultBuffer, size_t& size, netsvc::server::buffers* optionalData);
64
+ inline int doReadMulti(request& req, int op, char* resultBuffer, size_t& size, netsvc::server::buffers* optionalData);
65
+ inline void doStepRead(request& req, int op);
66
+
67
+
68
+ inline void doInsert(request& req);
69
+ inline void doUpdate(request& req);
70
+ inline void doUpdateKey(request& req);
71
+ inline void doDelete(request& req);
72
+ inline void doDeleteKey(request& req);
73
+ inline void doInsertBulk(request& req);
74
+ inline void doStat(request& req);
75
+
76
+ public:
77
+ dbExecuter();
78
+ ~dbExecuter();
79
+ int commandExec(request& req, char* result, size_t& size, netsvc::server::buffers* optionalData);
80
+ int errorCode(int ha_error);
81
+ short_td errorCodeSht(int ha_error){return (short_td)errorCode(ha_error);};
82
+
83
+ };
84
+
85
+ /** Command dispatcher for connectionManager
86
+ */
87
+ class connMgrExecuter
88
+ {
89
+ request& m_req;
90
+ __int64 m_modHandle;
91
+ public:
92
+ connMgrExecuter(request& req, unsigned __int64 parent);
93
+ int read(char* buf, size_t& size);
94
+ int disconnectOne(char* buf, size_t& size);
95
+ int disconnectAll(char* buf, size_t& size);
96
+ int commandExec(char* buf, size_t& size);
97
+ };
98
+
99
+ class commandExecuter : public ICommandExecuter, public engine::mysql::igetDatabases
100
+ {
101
+ mutable request m_req;
102
+ boost::shared_ptr<dbExecuter> m_dbExec;
103
+
104
+ int readStatistics(char* buf, size_t& size);
105
+ int cmdStatistics(char* buf, size_t& size);
106
+ unsigned __int64 m_modHandle;
107
+ public:
108
+ commandExecuter(__int64 parent);
109
+ ~commandExecuter();
110
+ size_t perseRequestEnd(const char* p, size_t size, bool& comp)const;
111
+
112
+ size_t getAcceptMessage(char* message, size_t size)
113
+ {
114
+ strcpy_s(message, size, "200 OK\n");
115
+ return strlen(message);
116
+ }
117
+
118
+ bool parse(const char* p, size_t size);
119
+
120
+ int execute(char* resultBuffer, size_t& size, netsvc::server::buffers* optionalData)
121
+ {
122
+ if (m_req.op == TD_STASTISTICS)
123
+ return connMgrExecuter(m_req, m_modHandle).commandExec(resultBuffer, size);
124
+ return m_dbExec->commandExec(m_req, resultBuffer, size, optionalData);
125
+ }
126
+
127
+ bool isShutDown(){return m_dbExec->isShutDown();}
128
+
129
+ void cleanup(){};
130
+
131
+ const engine::mysql::databases& dbs() const{return m_dbExec->dbs();};
132
+ };
133
+
134
+ }//namespace mysql
135
+ }//namespace tdap
136
+ }//namespace protocol
137
+ }//namespace db
138
+ }//namespace bzs
139
+
140
+ #endif //BZS_DB_PROTOCOL_TDAP_MYSQL_TDAPCOMMANDEXECUTER_H
141
+
@@ -0,0 +1,190 @@
1
+ #ifndef BZS_DB_PROTOCOL_TDAP_TDAPREQUSET_H
2
+ #define BZS_DB_PROTOCOL_TDAP_TDAPREQUSET_H
3
+ /*=================================================================
4
+ Copyright (C) 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 <bzs/db/blobBuffer.h>
24
+ #include <iostream>
25
+ #include <vector>
26
+ #include <string.h>
27
+ #include <boost/asio/buffer.hpp>
28
+ #include <bzs/env/compiler.h>
29
+
30
+
31
+ namespace bzs
32
+ {
33
+ namespace netsvc{namespace client{class connection;}}
34
+ namespace db
35
+ {
36
+ namespace protocol
37
+ {
38
+ namespace tdap
39
+ {
40
+
41
+ #define P_MASK_OP 0
42
+ #define P_MASK_POSBLK 1
43
+ #define P_MASK_DATA 2
44
+ #define P_MASK_DATALEN 4
45
+ #define P_MASK_KEYBUF 8
46
+ #define P_MASK_KEYNUM 16
47
+ #define P_MASK_EX_SENDLEN 32 //< The data length which transmits to a client is described at 2 bytes of the data buffer head.
48
+ #define P_MASK_BLOBBODY 64
49
+
50
+ #define P_MASK_ALL P_MASK_POSBLK|P_MASK_DATA|P_MASK_DATALEN|P_MASK_KEYBUF|P_MASK_KEYNUM
51
+ #define P_MASK_KEYONLY P_MASK_KEYBUF|P_MASK_KEYNUM
52
+ #define P_MASK_NOKEYBUF P_MASK_POSBLK|P_MASK_DATA|P_MASK_DATALEN|P_MASK_KEYNUM
53
+ #define P_MASK_POS_LEN_KEY P_MASK_POSBLK|P_MASK_DATALEN|P_MASK_KEYNUM
54
+ #define P_MASK_KEYNAVI P_MASK_POSBLK|P_MASK_DATALEN|P_MASK_KEYBUF|P_MASK_KEYNUM
55
+ #define P_MASK_NODATA P_MASK_POSBLK|P_MASK_DATALEN|P_MASK_KEYBUF
56
+
57
+ //server side
58
+ #define P_MASK_READRESULT P_MASK_POSBLK|P_MASK_DATA|P_MASK_DATALEN
59
+ #define P_MASK_STAT P_MASK_DATA|P_MASK_DATALEN
60
+ #define P_MASK_READ_EXT P_MASK_STAT|P_MASK_KEYBUF
61
+ #define P_MASK_MOVPOS P_MASK_POSBLK|P_MASK_DATA|P_MASK_DATALEN|P_MASK_KEYBUF
62
+ #define P_MASK_INS_AUTOINC P_MASK_MOVPOS
63
+
64
+ struct req1
65
+ {
66
+ ushort_td op;
67
+ void_td* keybuf;
68
+ uchar_td keylen;
69
+ short_td keyNum;
70
+ void write(std::ostream& ost);
71
+ };
72
+
73
+ #pragma option -a-
74
+ pragma_pack1
75
+
76
+
77
+ #define POSBLK_SIZE 4
78
+ #define CLIENTID_SIZE 2
79
+
80
+ /** tdap version info struct
81
+ */
82
+ struct version
83
+ {
84
+ ushort_td majorVersion;
85
+ ushort_td minorVersion;
86
+ uchar_td Type;
87
+ };
88
+
89
+ struct posblk
90
+ {
91
+ posblk()
92
+ {
93
+ memset(this, 0, sizeof(posblk));
94
+ }
95
+ int handle;
96
+
97
+ };
98
+ struct clientID
99
+ {
100
+
101
+ #ifdef __x86_64__
102
+ bzs::netsvc::client::connection* con;
103
+ char_td reserved[4];
104
+ #else
105
+ bzs::netsvc::client::connection* con;
106
+ char_td reserved[8];
107
+ #endif
108
+ char_td aid[2];
109
+ ushort_td id;
110
+ };
111
+
112
+
113
+ #pragma option -a
114
+ pragma_pop
115
+
116
+
117
+ class request
118
+ {
119
+ private:
120
+ ushort_td varLenBytesPos; /*Ooffset of last var field*/
121
+ ushort_td varLenBytes; /*Bytes of last var field length */
122
+
123
+ public:
124
+ uchar_td paramMask;
125
+ union
126
+ {
127
+ short_td result;
128
+ short_td op;
129
+ };
130
+
131
+ posblk* pbk;
132
+ uint_td* datalen;
133
+ void_td* data;
134
+ keylen_td keylen;
135
+ void_td* keybuf;
136
+ char_td keyNum;
137
+ uint_td resultLen;
138
+
139
+ request()
140
+ {
141
+ memset(this, 0, sizeof(request));
142
+ }
143
+
144
+ void reset()
145
+ {
146
+ paramMask = 0;
147
+ result = 0;
148
+ varLenBytesPos = 0;
149
+ varLenBytes = 0;
150
+ resultLen = 0;
151
+ }
152
+
153
+ const struct bzs::db::blobHeader* blobHeader;
154
+
155
+ inline unsigned int serializeBlobBody(blobBuffer* blob, char* buf, unsigned int max_size
156
+ , std::vector<boost::asio::const_buffer>* mbuffer)
157
+ {
158
+ unsigned int totallen = *((unsigned int*)(buf));
159
+ unsigned int size = totallen;
160
+ char* blobbuf = buf + totallen;
161
+ //write blob body
162
+ int stat=0;
163
+ if (mbuffer)
164
+ totallen += blob->makeMultiBuffer(*mbuffer);
165
+ else
166
+ totallen += blob->writeBuffer((unsigned char*)blobbuf, max_size - totallen - 200, stat);
167
+ //write total
168
+ memcpy(buf, &totallen, sizeof(unsigned int));
169
+
170
+ //write result
171
+ if (stat)
172
+ {
173
+ short_td* retPtr = (short_td*)(buf + 4 + 1);
174
+ *retPtr = stat;
175
+ }
176
+ //return this buffer size;
177
+ if (mbuffer)
178
+ return size;
179
+ return totallen;
180
+ }
181
+ };
182
+
183
+
184
+ }//namespace tdap
185
+ }//namespace protocol
186
+ }//namespace db
187
+ }//namespace bzs
188
+
189
+
190
+ #endif //BZS_DB_PROTOCOL_TDAP_TDAPREQUSET_H
@@ -0,0 +1,295 @@
1
+ /*=================================================================
2
+ Copyright (C) 2000-2013 BizStation Corp All rights reserved.
3
+
4
+ This program is free software; you can redistribute it and/or
5
+ modify it under the terms of the GNU General Public License
6
+ as published by the Free Software Foundation; either version 2
7
+ of the License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17
+ 02111-1307, USA.
18
+ =================================================================*/
19
+
20
+ #include <tchar.h>
21
+ #pragma hdrstop
22
+
23
+ #include <bzs/db/protocol/tdap/tdapSchema.h>
24
+ #include <bzs/db/protocol/tdap/mysql/characterset.h>
25
+ #include <stdio.h>
26
+ #ifdef _WIN32
27
+ #include <windows.h>
28
+ #endif
29
+
30
+ #pragma package(smart_init)
31
+
32
+
33
+ #if (defined(_WIN32) && _MSC_VER)
34
+ extern DWORD g_tlsiID_SC1;
35
+ #else
36
+ wchar_t __THREAD g_nameBuf[266]={NULL};
37
+ #endif
38
+
39
+
40
+
41
+ namespace bzs
42
+ {
43
+ namespace db
44
+ {
45
+ namespace protocol
46
+ {
47
+ namespace tdap
48
+ {
49
+
50
+
51
+ #ifdef _UNICODE
52
+
53
+ inline wchar_t* namebuf()
54
+ {
55
+ #if (defined(_WIN32) && _MSC_VER)
56
+ return (wchar_t*)TlsGetValue(g_tlsiID_SC1);
57
+ #else
58
+ return g_nameBuf;
59
+ #endif
60
+ }
61
+ const wchar_t* fielddef::name()const
62
+ {
63
+ return name(namebuf());
64
+ }
65
+
66
+ const wchar_t* fielddef::name(wchar_t* buf)const
67
+ {
68
+ MultiByteToWideChar(m_schemaCodePage, (m_schemaCodePage==CP_UTF8)?0:MB_PRECOMPOSED, m_name, -1, buf, MYSQL_FDNAME_SIZE);
69
+ return buf;
70
+ }
71
+
72
+ const wchar_t* fielddef::chainChar()const
73
+ {
74
+ wchar_t* p = namebuf();
75
+ MultiByteToWideChar(m_schemaCodePage, (m_schemaCodePage==CP_UTF8)?0:MB_PRECOMPOSED, m_chainChar, -1, p, 2);
76
+ return p;
77
+ }
78
+
79
+ void fielddef::setName(const wchar_t* s)
80
+ {
81
+ WideCharToMultiByte(m_schemaCodePage, (m_schemaCodePage == CP_UTF8) ? 0:WC_COMPOSITECHECK, s, -1, m_name, MYSQL_FDNAME_SIZE, NULL, NULL);
82
+
83
+ }
84
+
85
+ void fielddef::setChainChar(const wchar_t* s)
86
+ {
87
+ WideCharToMultiByte(m_schemaCodePage, (m_schemaCodePage == CP_UTF8) ? 0:WC_COMPOSITECHECK, s, -1, m_chainChar, 2, NULL, NULL);
88
+ }
89
+
90
+ const wchar_t* tabledef::fileName()const
91
+ {
92
+ wchar_t* p = namebuf();
93
+ MultiByteToWideChar(schemaCodePage, (schemaCodePage==CP_UTF8)?0:MB_PRECOMPOSED, m_fileName, -1, p, FILE_NAME_SIZE);
94
+ return p;
95
+ }
96
+
97
+ const wchar_t* tabledef::tableName()const
98
+ {
99
+ wchar_t* p = namebuf();
100
+ MultiByteToWideChar(schemaCodePage, (schemaCodePage==CP_UTF8)?0:MB_PRECOMPOSED, m_tableName, -1, p, TABLE_NAME_SIZE);
101
+ return p;
102
+
103
+ }
104
+
105
+ const char* tabledef::toChar(char* buf, const wchar_t* s, int size)
106
+ {
107
+ WideCharToMultiByte(schemaCodePage, (schemaCodePage == CP_UTF8) ? 0:WC_COMPOSITECHECK, s, -1, buf, size, NULL, NULL);
108
+ return buf;
109
+
110
+ }
111
+
112
+ void tabledef::setFileName(const wchar_t* s)
113
+ {
114
+ WideCharToMultiByte(schemaCodePage, (schemaCodePage == CP_UTF8) ? 0:WC_COMPOSITECHECK, s, -1, m_fileName, FILE_NAME_SIZE, NULL, NULL);
115
+ }
116
+
117
+ void tabledef::setTableName(const wchar_t* s)
118
+ {
119
+ WideCharToMultiByte(schemaCodePage, (schemaCodePage == CP_UTF8) ? 0:WC_COMPOSITECHECK, s, -1, m_tableName, TABLE_NAME_SIZE, NULL, NULL);
120
+ }
121
+ #endif //_UNICODE
122
+
123
+ bool fielddef::isStringType()const
124
+ {
125
+ return ((type == ft_string)|| (type == ft_zstring)
126
+ ||(type == ft_wstring)|| (type == ft_wzstring)
127
+ ||(type == ft_myvarchar)|| (type == ft_myvarbinary)
128
+ ||(type == ft_mywvarchar)|| (type == ft_mywvarbinary)
129
+ ||(type == ft_myblob)|| (type == ft_mytext)
130
+ ||(type == ft_mychar)|| (type == ft_mywchar)
131
+ ||(type == ft_lstring)|| (type == ft_note));
132
+ }
133
+
134
+ unsigned int fielddef::charNum(/*int index*/)const
135
+ {
136
+ if (type==ft_mychar)
137
+ return (unsigned int)len/mysql::charsize(m_charsetIndex);
138
+ else if (type==ft_mywchar)
139
+ return (unsigned int)len/mysql::charsize(CHARSET_UTF16LE);
140
+ else if (type==ft_myvarchar)
141
+ return (unsigned int)(len - varLenBytes())/mysql::charsize(m_charsetIndex);
142
+ else if (type==ft_mywvarchar)
143
+ return (unsigned int)(len - varLenBytes())/mysql::charsize(CHARSET_UTF16LE);
144
+ return len;
145
+ }
146
+
147
+
148
+
149
+ ushort_td lenByCharnum(uchar_td type, uchar_td charsetIndex, ushort_td charnum)
150
+ {
151
+ ushort_td len;
152
+ if (charsetIndex && ((type == ft_mychar)|| (type == ft_mywchar)
153
+ || (type == ft_myvarchar) || (type == ft_mywvarchar)))
154
+ {
155
+ len = (ushort_td)(mysql::charsize(charsetIndex) * charnum);
156
+ if ((type == ft_myvarchar) || (type == ft_mywvarchar))
157
+ len += ((len >= 256)? 2 : 1);
158
+ else
159
+ len = std::min<ushort_td>(len, 255);
160
+ }else
161
+ len = charnum;
162
+ return len;
163
+ }
164
+
165
+ const _TCHAR* getTypeName(short type)
166
+ {
167
+ switch (type)
168
+ {
169
+ case ft_string: return _T("String");
170
+ case ft_integer: return _T("Integer");
171
+ case ft_float: return _T("Float");
172
+ case ft_date: return _T("Date");
173
+ case ft_time: return _T("Time");
174
+ case ft_decimal: return _T("Decimal");
175
+ case ft_money: return _T("Money");
176
+ case ft_logical: return _T("Logical");
177
+ case ft_numeric: return _T("Numeric");
178
+ case ft_bfloat: return _T("BFloat");
179
+ case ft_lstring: return _T("LString");
180
+ case ft_zstring: return _T("ZString");
181
+ case ft_note: return _T("Note");
182
+ case ft_lvar: return _T("Lvar");
183
+ case ft_uinteger: return _T("Unsigned Binary");
184
+ case ft_autoinc: return _T("AutoIncrement");
185
+ case ft_bit: return _T("Bit");
186
+ case ft_numericsts: return _T("Numericsts");
187
+ case ft_numericsa: return _T("Numericsa");
188
+ case ft_currency: return _T("Currency");
189
+ case ft_timestamp: return _T("TimeStamp");
190
+ case ft_blob: return _T("Blob");
191
+ case ft_wstring: return _T("WString");
192
+ case ft_wzstring: return _T("WZstring");
193
+ case ft_datatime: return _T("DateTime");
194
+ case ft_guid: return _T("Guid");
195
+ case ft_myvarchar: return _T("myVarChar");
196
+ case ft_myvarbinary: return _T("myVarBinary");
197
+ case ft_mywvarchar: return _T("myWVarChar");
198
+ case ft_mywvarbinary: return _T("myWVarBinary");
199
+ case ft_mychar: return _T("myChar");
200
+ case ft_mywchar: return _T("myWChar");
201
+ case ft_mydate: return _T("myDate");
202
+ case ft_mytime: return _T("myTime");
203
+ case ft_mydatetime: return _T("myDateTime");
204
+ case ft_mytimestamp: return _T("myTimeStamp");
205
+ case ft_mytext: return _T("myText");
206
+ case ft_myblob: return _T("myBlob");
207
+ case ft_nullindicator: return _T("Nullindicator");
208
+ default: return _T("Unknown");
209
+ }
210
+
211
+ }
212
+
213
+ int getTypeAlign(short type)
214
+ {
215
+ switch (type)
216
+ {
217
+ case ft_string:
218
+ case ft_date:
219
+ case ft_time:
220
+ case ft_lstring:
221
+ case ft_zstring:
222
+ case ft_note:
223
+ case ft_timestamp:
224
+ case ft_wstring:
225
+ case ft_wzstring:
226
+ case ft_myvarchar:
227
+ case ft_myvarbinary:
228
+ case ft_mychar:
229
+ case ft_mywchar:
230
+ case ft_mywvarchar:
231
+ case ft_mywvarbinary:
232
+ case ft_mydate:
233
+ case ft_mytime:
234
+ case ft_mydatetime:
235
+ case ft_mytimestamp:
236
+ case ft_myblob:
237
+ case ft_mytext: return BT_AL_LEFT;
238
+
239
+ }
240
+
241
+ return BT_AL_RIGHT;
242
+ }
243
+
244
+
245
+ const _TCHAR* btrVersion::moduleTypeString()
246
+ {
247
+ switch (type)
248
+ {
249
+ case 'N': return _T("Requester");
250
+ case 'D': return _T("DOS Workstation MicroKernel");
251
+ case 'W': return _T("Windows Workstation MicroKernel");
252
+ case 'O': return _T("OS/2 WorkStation MicroKernel");
253
+ case '3':
254
+ case '9': return _T("Windows 32Bit Workstation MicroKernel");
255
+ case 'S': return _T("Netware Server MicroKernel");
256
+ case 'T': return _T("Windows Server MicroKernel");
257
+ case 'L': return _T("Linux Server MicroKernel");
258
+ case 'F': return _T("FileSharing WorkStation MicroKernel");
259
+ }
260
+ return _T("Unknown Type");
261
+ }
262
+
263
+ const _TCHAR* btrVersion::moduleVersionShortString(_TCHAR* buf)
264
+ {
265
+ #pragma warning(disable:4996)
266
+ switch (type)
267
+ {
268
+ case 'N': _stprintf(buf, _T("Reqster %d.%d"), majorVersion, minorVersion);
269
+ break;
270
+ case 'D': _stprintf(buf, _T("DosLocal %d.%d"), majorVersion, minorVersion);
271
+ break;
272
+ case 'W': _stprintf(buf, _T("W1Local %d.%d"), majorVersion, minorVersion);
273
+ break;
274
+ case 'O': _stprintf(buf, _T("OS/2Local %d.%d"), majorVersion, minorVersion);
275
+ break;
276
+ case '3':
277
+ case '9': _stprintf(buf, _T("W3Local %d.%d"), majorVersion, minorVersion);
278
+ break;
279
+ case 'S': _stprintf(buf, _T("NServer %d.%d"), majorVersion, minorVersion);
280
+ break;
281
+ case 'T': _stprintf(buf, _T("Server %d.%d"), majorVersion, minorVersion);
282
+ break;
283
+ case 'L': _stprintf(buf, _T("Lerver %d.%d"), majorVersion, minorVersion);
284
+ break;
285
+ default: return _T("Unknown Type");
286
+ }
287
+ #pragma warning(default:4996)
288
+ return buf;
289
+ }
290
+
291
+ }//namespace tdap
292
+ }//namespace protocol
293
+ }//namespace db
294
+ }//namespace bzs
295
+