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,158 @@
1
+ #ifndef FIELDACCESS_H
2
+ #define FIELDACCESS_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
+ #include "mysqlInternal.h"
22
+
23
+
24
+
25
+ namespace bzs
26
+ {
27
+ namespace db
28
+ {
29
+ namespace engine
30
+ {
31
+ namespace mysql
32
+ {
33
+
34
+ //-----------------------------------------------------------------------------
35
+ /**
36
+ * var or bolob type sub functions;
37
+ */
38
+ //-----------------------------------------------------------------------------
39
+ inline uint var_bytes(Field* fd)
40
+ {
41
+ return (uint)HA_VARCHAR_PACKLENGTH(fd->field_length);
42
+ }
43
+
44
+ /** sizeof var text body
45
+ */
46
+ inline uint var_strlen(const uchar* ptr, uint varlen)
47
+ {
48
+ return (varlen==1)? *ptr:*((const unsigned short*)ptr);
49
+ }
50
+
51
+ inline uint var_strlen(Field* fd)
52
+ {
53
+ return var_strlen(fd->ptr, var_bytes(fd));
54
+ }
55
+
56
+ /** sizeof var text body + size bytes
57
+ */
58
+ inline uint var_total_len(Field* fd)
59
+ {
60
+ uint varlen = var_bytes(fd);
61
+ return var_strlen(fd->ptr, varlen) + varlen;
62
+ }
63
+
64
+ inline uint var_total_len(const uchar* ptr, uint varlen)
65
+ {
66
+ return var_strlen(ptr, varlen) + varlen;
67
+ }
68
+
69
+
70
+ /** var text body length on key buffer
71
+ * size bytes is 2 byte fixed in key buffer.
72
+ */
73
+ inline uint var_strlen_key(const uchar* ptr)
74
+ {
75
+ return *((const unsigned short*)ptr);
76
+ }
77
+
78
+ /** return Is type var type
79
+ */
80
+ inline bool isVarType(enum_field_types type)
81
+ {
82
+ return ((type==MYSQL_TYPE_VAR_STRING) || (type==MYSQL_TYPE_VARCHAR));
83
+ }
84
+ /** return Is type blob type
85
+ */
86
+ inline bool isBlobType(enum_field_types type)
87
+ {
88
+ return ((type==MYSQL_TYPE_TINY_BLOB) || (type==MYSQL_TYPE_BLOB)
89
+ || (type==MYSQL_TYPE_MEDIUM_BLOB) || (type==MYSQL_TYPE_LONG_BLOB));
90
+ }
91
+
92
+ inline uint blob_var_bytes(Field* fd)
93
+ {
94
+ return fd->pack_length() - portable_sizeof_char_ptr;
95
+
96
+ }
97
+ /** sizeof blob body
98
+ */
99
+ inline uint blob_len(const uchar* ptr, uint varlen)
100
+ {
101
+ uint v = 0;
102
+ memcpy(&v, ptr, varlen);
103
+ return v;
104
+ }
105
+
106
+ inline uint blob_len(Field* fd)
107
+ {
108
+ return blob_len(fd->ptr, blob_var_bytes(fd));
109
+ }
110
+
111
+ /** sizeof blob body ptr + size bytes. not include blob body length
112
+ */
113
+ inline uint blob_total_len(Field* fd)
114
+ {
115
+ return sizeof(char*) + blob_var_bytes(fd);
116
+ }
117
+
118
+ inline uint blob_total_len(uint varlen)
119
+ {
120
+ return sizeof(char*) + varlen;
121
+ }
122
+
123
+ inline const uchar** blobBodyPtrRef(Field* fd)
124
+ {
125
+ return (const uchar**)(fd->ptr + blob_var_bytes(fd));
126
+ }
127
+
128
+ inline const uchar* blobBodyPtr(Field* fd)
129
+ {
130
+ return *(blobBodyPtrRef(fd));
131
+ }
132
+
133
+ /** return size bytes
134
+ */
135
+ inline uint var_bytes_if(Field* fd)
136
+ {
137
+ if (isVarType(fd->type()))
138
+ return var_bytes(fd);
139
+ else if (isBlobType(fd->type()))
140
+ return blob_var_bytes(fd);
141
+ return 0;
142
+ }
143
+
144
+ /** Is this field name NIS?
145
+ */
146
+ inline bool isNisField(const char* name)
147
+ {
148
+ return (name[0] && (name[0] == '$')
149
+ && name[1] && (name[1] == 'n')
150
+ && name[2] && (name[2] == 'f'));
151
+ }
152
+
153
+ }//namespace mysql
154
+ }//namespace engine
155
+ }//namespace db
156
+ }//namespace bzs
157
+ #endif
158
+
@@ -0,0 +1,349 @@
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
+
20
+ #include "mydebuglog.h"
21
+ #include "dbManager.h"
22
+ #include <bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h>
23
+ #include <bzs/env/crosscompile.h>
24
+ #include <bzs/env/fileopen.h>
25
+
26
+ using namespace bzs::db::protocol::tdap::mysql;
27
+
28
+ #ifdef DEBUG_LOG
29
+ bzs::db::engine::mysql::debugdb dbg;
30
+ #endif
31
+
32
+
33
+ void bzs::rtl::debuglog::init()
34
+ {
35
+ #ifdef DEBUG_LOG
36
+ bzs::rtl::debuglog::regist(&dbg);
37
+ #endif
38
+ fn_format(logfilename, "transctd_debug","",".log",MY_REPLACE_EXT|MY_UNPACK_FILENAME);
39
+
40
+ FILE* fp = fileOpen(logfilename, "w");
41
+ if (fp)
42
+ {
43
+ fputs(dateTime(), fp);
44
+ fputs("Transctd debug Start\n", fp);
45
+ fclose(fp);
46
+ }
47
+ }
48
+
49
+ namespace bzs
50
+ {
51
+ namespace db
52
+ {
53
+ namespace engine
54
+ {
55
+ namespace mysql
56
+ {
57
+
58
+ char msg[1024];
59
+
60
+ void debugdb::stop()
61
+ {
62
+ bzs::rtl::debuglog::write("Transctd debug End");
63
+ }
64
+
65
+ void debugdb::write(ushort_td op, request& req, bool error)
66
+ {
67
+ bool writeflag = false;
68
+
69
+ switch(op)
70
+ {
71
+ case TD_RESET_CLIENT:
72
+ {
73
+ std::string dbname = getDatabaseName(req);
74
+ sprintf_s(msg,1024, "TD_RESET_CLIENT result = %d \tdbname = %s\t cid = %d \n"
75
+ , req.result, dbname.c_str(), req.cid);
76
+ writeflag = true;
77
+ break;
78
+ }
79
+ case TD_CREATETABLE:
80
+ {
81
+ std::string dbname = getDatabaseName(req);
82
+ sprintf_s(msg, 1024, "TD_CREATETABLE result = %d \tdbname = %s\t table=%s\n"
83
+ , req.result, dbname.c_str(), getTableName(req).c_str());
84
+ writeflag = true;
85
+ break;
86
+ }
87
+ case TD_OPENTABLE:
88
+ {
89
+ std::string dbname = getDatabaseName(req);
90
+ sprintf_s(msg, 1024, "TD_OPENTABLE result = %d \tHandle = %d \tdbname = %s\n"
91
+ , req.result, req.pbk->handle, dbname.c_str());
92
+ writeflag = true;
93
+ break;
94
+ }
95
+ case TD_CLOSETABLE:
96
+ sprintf_s(msg, 1024, "TD_CLOSETABLE result = %d \tHandle = %d\n"
97
+ , req.result, req.pbk->handle);
98
+ writeflag = true;
99
+ break;
100
+ case TD_KEY_SEEK:
101
+ sprintf_s(msg, 1024, "TD_KEY_SEEK result = %d \tHandle = %d\n" , req.result, req.pbk->handle);
102
+ writeflag = true;
103
+ break;
104
+ case TD_KEY_AFTER:
105
+ sprintf_s(msg, 1024, "TD_KEY_AFTER result = %d \tHandle = %d\n" , req.result, req.pbk->handle);
106
+ writeflag = true;
107
+ break;
108
+ case TD_KEY_OR_AFTER:
109
+ sprintf_s(msg, 1024, "TD_KEY_OR_AFTER result = %d \tHandle = %d\n" , req.result, req.pbk->handle);
110
+ writeflag = true;
111
+ break;
112
+ case TD_KEY_BEFORE:
113
+ sprintf_s(msg, 1024, "TD_KEY_BEFORE result = %d \tHandle = %d\n", req.result, req.pbk->handle);
114
+ writeflag = true;
115
+ break;
116
+ case TD_KEY_OR_BEFORE:
117
+ sprintf_s(msg, 1024, "TD_KEY_OR_BEFORE result = %d \tHandle = %d\n" , req.result, req.pbk->handle);
118
+ writeflag = true;
119
+ break;
120
+ case TD_KEY_FIRST:
121
+ sprintf_s(msg, 1024, "TD_KEY_FIRST result = %d \tHandle = %d\n" , req.result, req.pbk->handle);
122
+ writeflag = true;
123
+ break;
124
+ case TD_KEY_PREV:
125
+ sprintf_s(msg, 1024, "TD_KEY_PREV result = %d \tHandle = %d\n" , req.result, req.pbk->handle);
126
+ writeflag = true;
127
+ break;
128
+ case TD_KEY_LAST:
129
+ sprintf_s(msg, 1024, "TD_KEY_LAST result = %d \tHandle = %d\n", req.result, req.pbk->handle);
130
+ writeflag = true;
131
+ break;
132
+ case TD_KEY_NEXT:
133
+ sprintf_s(msg, 1024, "TD_KEY_NEXT result = %d \tHandle = %d\n", req.result, req.pbk->handle);
134
+ writeflag = true;
135
+ break;
136
+ case TD_REC_INSERT:
137
+ sprintf_s(msg, 1024, "TD_REC_INSERT result = %d \tHandle = %d\n"
138
+ , req.result, req.pbk->handle);
139
+ writeflag = true;
140
+ break;
141
+ case TD_REC_UPDATE:
142
+ sprintf_s(msg, 1024, "TD_REC_UPDATE result = %d \tHandle = %d\n"
143
+ , req.result, req.pbk->handle);
144
+ writeflag = true;
145
+ break;
146
+ case TD_REC_DELETE:
147
+ sprintf_s(msg, 1024, "TD_REC_DELETE result = %d \tHandle = %d\n"
148
+ , req.result, req.pbk->handle);
149
+ writeflag = true;
150
+ break;
151
+ case TD_BEGIN_TRANSACTION:
152
+ sprintf_s(msg, 1024, "TD_BEGIN_TRANSACTION cid = %d \n", req.cid);
153
+ writeflag = true;
154
+ break;
155
+ case TD_END_TRANSACTION:
156
+ sprintf_s(msg, 1024, "TD_END_TRANSACTION cid = %d \n", req.cid);
157
+ writeflag = true;
158
+ break;
159
+ case TD_ABORT_TRANSACTION:
160
+ sprintf_s(msg, 1024, "TD_ABORT_TRANSACTION cid = %d \n", req.cid);
161
+ writeflag = true;
162
+ break;
163
+ case TD_BEGIN_SHAPSHOT:
164
+ sprintf_s(msg, 1024, "TD_BEGIN_SHAPSHOT cid = %d \n", req.cid);
165
+ writeflag = true;
166
+ break;
167
+ case TD_END_SNAPSHOT:
168
+ sprintf_s(msg, 1024, "TD_END_SNAPSHOT cid = %d \n", req.cid);
169
+ writeflag = true;
170
+ break;
171
+ case TD_TABLE_INFO:
172
+ {
173
+ std::string dbname = getDatabaseName(req);
174
+ sprintf_s(msg, 1024, "TD_TABLE_INFO result = %d \tHandle = %d\n"
175
+ , req.result, req.pbk->handle);
176
+ writeflag = true;
177
+ break;
178
+ }
179
+
180
+ case TD_POS_FIRST:
181
+ sprintf_s(msg, 1024, "TD_POS_FIRST result = %d \tHandle = %d\n", req.result, req.pbk->handle);
182
+ writeflag = true;
183
+ break;
184
+ case TD_POS_LAST:
185
+ sprintf_s(msg, 1024, "TD_POS_LAST result = %d \tHandle = %d\n", req.result, req.pbk->handle);
186
+ writeflag = true;
187
+ break;
188
+ case TD_POS_NEXT:
189
+ sprintf_s(msg, 1024, "TD_POS_NEXT result = %d \tHandle = %d\n", req.result, req.pbk->handle);
190
+ writeflag = true;
191
+ break;
192
+ case TD_POS_PREV:
193
+ sprintf_s(msg, 1024, "TD_POS_PREV result = %d \tHandle = %d\n", req.result, req.pbk->handle);
194
+ writeflag = true;
195
+ break;
196
+ case TD_BOOKMARK:
197
+ if (req.result==0)
198
+ sprintf_s(msg, 1024, "TD_BOOKMARK result = %d \tHandle = %d key = %d pos = %d\n"
199
+ , req.result, req.pbk->handle, req.keyNum, *((uint*)req.data));
200
+ else
201
+ sprintf_s(msg, 1024, "TD_BOOKMARK result = %d \tHandle = %d key = %d \n"
202
+ , req.result, req.pbk->handle, req.keyNum);
203
+ writeflag = true;
204
+ break;
205
+
206
+ case TD_MOVE_BOOKMARK:
207
+ sprintf_s(msg, 1024, "TD_MOVE_BOOKMARK result = %d \tHandle = %d key = %d pos = %d\n"
208
+ , req.result, req.pbk->handle, req.keyNum, *((uchar*)req.data));
209
+ writeflag = true;
210
+ break;
211
+
212
+ case TD_GETDIRECTORY:
213
+ sprintf_s(msg, 1024, "TD_GETDIRECTORY cid = %d \n", req.cid);
214
+ writeflag = true;
215
+ break;
216
+
217
+
218
+ case TD_SET_OWNERNAME:
219
+ sprintf_s(msg, 1024, "TD_SET_OWNERNAME result = %d \tHandle = %d\n", req.result, req.pbk->handle);
220
+ writeflag = true;
221
+ break;
222
+ case TD_DROP_INDEX:
223
+ sprintf_s(msg, 1024, "TD_DROP_INDEX result = %d \tHandle = %d\n", req.result, req.pbk->handle);
224
+ writeflag = true;
225
+ break;
226
+ case TD_KEY_NEXT_MULTI:
227
+ sprintf_s(msg, 1024, "TD_KEY_NEXT_MULTI result = %d \tHandle = %d\n", req.result, req.pbk->handle);
228
+ writeflag = true;
229
+ break;
230
+ case TD_KEY_PREV_MULTI:
231
+ sprintf_s(msg, 1024, "TD_KEY_PREV_MULTI result = %d \tHandle = %d\n", req.result, req.pbk->handle);
232
+ writeflag = true;
233
+ break;
234
+ case TD_POS_NEXT_MULTI:
235
+ sprintf_s(msg, 1024, "TD_POS_NEXT_MULTI result = %d \tHandle = %d\n", req.result, req.pbk->handle);
236
+ writeflag = true;
237
+ break;
238
+ case TD_POS_PREV_MULTI:
239
+ sprintf_s(msg, 1024, "TD_POS_PREV_MULTI result = %d \tHandle = %d\n", req.result, req.pbk->handle);
240
+ writeflag = true;
241
+ break;
242
+ case TD_MOVE_PER:
243
+ sprintf_s(msg, 1024, "TD_MOVE_PER result = %d \tHandle = %d\n", req.result, req.pbk->handle);
244
+ writeflag = true;
245
+ break;
246
+ case TD_GET_PER:
247
+ sprintf_s(msg, 1024, "TD_GET_PER result = %d \tHandle = %d\n", req.result, req.pbk->handle);
248
+ writeflag = true;
249
+ break;
250
+ case TD_INSERT_BULK:
251
+ sprintf_s(msg, 1024, "TD_INSERT_BULK result = %d \tHandle = %d\n", req.result, req.pbk->handle);
252
+ writeflag = true;
253
+ break;
254
+ case TD_VERSION:
255
+ sprintf_s(msg, 1024, "TD_VERSION result = %d \n", req.result);
256
+ writeflag = true;
257
+ break;
258
+
259
+ }
260
+ if (error)
261
+ {
262
+ sprintf_s(msg, 1024, "ERROR result = %d op=%d\t\tHandle = %d\n"
263
+ , req.result, op, req.pbk?req.pbk->handle:0);
264
+ writeflag = true;
265
+ }
266
+ if (writeflag)
267
+ bzs::rtl::debuglog::write(msg);
268
+
269
+ }
270
+
271
+ void debugdb::fieldDump(table* tb)
272
+ {
273
+ boost::mutex::scoped_lock lck(m_mutex);
274
+ FILE* fp = fileOpen(logfilename, "a+");
275
+ if (fp)
276
+ {
277
+ int size;
278
+ for (int j=0;j<(int)tb->internalTable()->s->fields;j++)
279
+ {
280
+ fputs(tb->internalTable()->s->field[j]->field_name, fp);
281
+ fputs("=", fp);
282
+ fputs(tb->valStr(j, size), fp);
283
+ fputs("\n", fp);
284
+ }
285
+ fclose(fp);
286
+ }
287
+ }
288
+
289
+ void debugdb::writeInsert(table* tb, const char* packPtr,int packlen, int row, int errorCount)
290
+ {
291
+ char tmp[64];
292
+ sprintf(tmp, "INSERT PACKED Row=%d len=%d ErrorRows=%d ", packlen, row, errorCount);
293
+ writeDump(tmp, packPtr + sizeof(ushort_td), packlen);
294
+ uint len = tb->recordLen()-tb->nullBytes();
295
+ sprintf(tmp, "INSERT UNPACKED Row=%d len=%d stat=%d", row, len, tb->stat());
296
+ writeDump(tmp, (const char*)tb->record(), len);
297
+ fieldDump(tb);
298
+ }
299
+
300
+ #ifdef DEBUG_READRECORDS
301
+ void debugdb::writeReadRecordsBegin(extResultDef* resultDef, extRequest* req)
302
+ {
303
+ char tmp[2048];
304
+ char tmp2[1024]={0x00};
305
+ sprintf(tmp, "READS RESULTDEF maxRows=%d fieldCount=%d\n", resultDef->maxRows, resultDef->fieldCount);
306
+ for (int i=0;i<resultDef->fieldCount;i++)
307
+ {
308
+ resultField* fd = &resultDef->field[i];
309
+ sprintf(tmp2,"RESULTDEF FIELD%d pos =%d len=%d \n",i+1, fd->pos, fd->len);
310
+ strcat(tmp, tmp2);
311
+ }
312
+ sprintf(tmp2, "READS REQ len=%d reject=%d logicalCount=%d\n", req->len, req->rejectCount, req->logicalCount);
313
+ strcat(tmp, tmp2);
314
+ logicalField* field = &req->field;
315
+ while(1)
316
+ {
317
+ sprintf(tmp2,"REQUEST FIELD1 type =%d len=%d pos=%d logType=%d opr=%d "
318
+ , field->type, field->len, field->pos, field->logType, field->opr);
319
+ strcat(tmp, tmp2);
320
+ if (field->logType & CMPLOGICAL_FIELD)
321
+ sprintf(tmp2, "offset=%d\n", field->offset);
322
+ else
323
+ {
324
+ strcat(tmp, "Value=");
325
+ for (int j=0;j<field->len;j++)
326
+ {
327
+ sprintf(tmp2, "%02X ", *(field->ptr+j));
328
+ strcat(tmp, tmp2);
329
+ }
330
+ strcat(tmp, "\n");
331
+ }
332
+ if (field->opr == 0) break;//this is last
333
+ field = field->next();
334
+ }
335
+ write(tmp);
336
+ }
337
+
338
+ void debugdb::writeReadRecordsEnd(resultWriter* rw)
339
+ {
340
+ dump("READS RESULT DUMP", rw->resultBuffer()+RETBUF_EXT_RESERVE_SIZE
341
+ , rw->resultLen()-RETBUF_EXT_RESERVE_SIZE);
342
+ }
343
+ #endif //DEBUG_READRECORDS
344
+
345
+ }//namespace mysql
346
+ }//namespace engine
347
+ }//namespace db
348
+ }//namespace bzs
349
+
@@ -0,0 +1,89 @@
1
+ #ifndef MYDEBUGLOG_H
2
+ #define MYDEBUGLOG_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
+ #include <bzs/db/protocol/tdap/mysql/request.h>
22
+ #include <boost/noncopyable.hpp>
23
+ #include <stdio.h>
24
+ #include <bzs/rtl/debuglog.h>
25
+
26
+ using namespace bzs::rtl;
27
+
28
+ namespace bzs
29
+ {
30
+
31
+ namespace db
32
+ {
33
+ using namespace protocol::tdap::mysql;
34
+ namespace engine
35
+ {
36
+ namespace mysql
37
+ {
38
+
39
+ class table;
40
+
41
+ class debugdb : public rtl::debuglog
42
+ {
43
+ void fieldDump(table* tb);
44
+ public:
45
+ virtual ~debugdb(){};
46
+
47
+ virtual void stop();
48
+ void write(ushort_td op, protocol::tdap::mysql::request& req, bool error = false);
49
+ void writeInsert(table* tb, const char* packPtr,int packlen, int row, int errorCount);
50
+ };
51
+
52
+ extern char msg[1024];
53
+
54
+ #ifdef DEBUG_LOG
55
+
56
+ #define DEBUG_WRITELOG2(OP, REQ) ((debugdb*)debuglog::get())->write(OP, REQ);
57
+ #define DEBUG_WRITELOG3(OP, REQ, ERR) ((debugdb*)debuglog::get())->write(OP, REQ, ERR);
58
+ #define DEBUG_WRITELOG_SP1(FORMAT, PARAM) \
59
+ sprintf_s(msg,FORMAT, PARAM); \
60
+ debuglog::get()->write(msg);
61
+
62
+ #else //DEBUG_LOG
63
+ #define DEBUG_WRITELOG2(OP, REQ)
64
+ #define DEBUG_WRITELOG3(OP, REQ, ERR)
65
+ #define DEBUG_WRITELOG_SP1(FORMAT, PARAM)
66
+ #endif //DEBUG_LOG
67
+
68
+ #ifdef DEBUG_LOG_BINSERT
69
+ #define DEBUG_INSERT(TB,PTR,LEN,ROW,ERRORS) ((debugdb*)debuglog::get())->writeInsert(TB, PTR, LEN, ROW, ERRORS);
70
+ #else
71
+ #define DEBUG_INSERT(TB,PTR,LEN,ROW,ERRORS)
72
+ #endif
73
+
74
+
75
+ #ifdef DEBUG_READRECORDS
76
+ #define DEBUG_RECORDS_BEGIN( RDEF, REQ) debuglog::get()->writeReadRecordsBegin(RDEF, REQ);
77
+ #define DEBUG_RECORDS_END( WRITER) debuglog::get()->writeReadRecordsEnd(WRITER);
78
+ #else
79
+ #define DEBUG_RECORDS_BEGIN( RDEF, REQ)
80
+ #define DEBUG_RECORDS_END( WRITER)
81
+ #endif
82
+
83
+
84
+ }//namespace mysql
85
+ }//namespace engine
86
+ }//namespace db
87
+ }//namespace bzs
88
+
89
+ #endif //MYDEBUGLOG_H