transactd 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
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,171 @@
1
+ #ifndef MYSQLINTERNAL_H
2
+ #define MYSQLINTERNAL_H
3
+
4
+ /*=================================================================
5
+ Copyright (C) 2012 2013 BizStation Corp All rights reserved.
6
+
7
+ This program is free software; you can redistribute it and/or
8
+ modify it under the terms of the GNU General Public License
9
+ as published by the Free Software Foundation; either version 2
10
+ of the License, or (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program; if not, write to the Free Software
19
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20
+ 02111-1307, USA.
21
+ =================================================================*/
22
+
23
+ #undef _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES
24
+ #define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES 1
25
+
26
+ #ifndef MYSQL_DYNAMIC_PLUGIN
27
+ #define MYSQL_DYNAMIC_PLUGIN
28
+ #endif
29
+ #define MYSQL_SERVER 1
30
+
31
+ #ifndef HAVE_CONFIG_H
32
+ #define HAVE_CONFIG_H
33
+ #endif
34
+
35
+
36
+ #ifdef ERROR
37
+ #undef ERROR
38
+ #endif
39
+
40
+ #ifdef NOMINMAX
41
+ #undef NOMINMAX
42
+ #endif
43
+ #ifdef _MSC_VER
44
+ #pragma warning(disable:4800)
45
+ #pragma warning(disable:4267)
46
+ #pragma warning(disable:4996)
47
+ #endif
48
+
49
+ #include <my_config.h>
50
+ #include <mysql/plugin.h>
51
+ #include <mysql_version.h>
52
+ #include <sql/sql_const.h>
53
+ #include "sql/mysqld.h"
54
+
55
+ #if ((MYSQL_VERSION_ID >= 50600) && !defined(MARIADB_BASE_VERSION))
56
+ #include "sql/global_threads.h"
57
+ #endif
58
+
59
+ #include "sql/sql_plugin.h"
60
+ #include "sql/sql_cache.h"
61
+ #include "sql/structs.h"
62
+ #include "sql/sql_priv.h"
63
+ #include "sql/sql_class.h"
64
+ #include "sql/unireg.h"
65
+ #include "sql/lock.h"
66
+ #include "sql/key.h"
67
+ #include "my_global.h"
68
+ #include "sql/transaction.h"
69
+ #include "sql/sql_base.h"
70
+ #include "sql/sql_parse.h"
71
+ #include "sql/sql_table.h"
72
+ #include "sql/sql_db.h"
73
+ #include "sql/sql_acl.h"
74
+ #include "mysqld_error.h"
75
+
76
+ #undef test
77
+
78
+ #undef sleep
79
+ #ifdef ERROR
80
+ #define ERROR 0
81
+ #endif
82
+
83
+ #ifdef _MSC_VER
84
+ #pragma warning(default:4996)
85
+ #pragma warning(default:4267)
86
+ #pragma warning(default:4800)
87
+ #endif
88
+
89
+ #undef min
90
+ #undef max
91
+ #define THD_KILLED_STATE THD::killed_state
92
+ #define THD_NOT_KILLED THD::NOT_KILLED
93
+
94
+
95
+
96
+ #if defined(MARIADB_BASE_VERSION)
97
+ #define MARIADB_VERSION_NUM MYSQL_VERSION_ID
98
+ #define MYSQL_VERSION_NUM 1000000
99
+ #else
100
+ #define MARIADB_VERSION_NUM 1000000
101
+ #define MYSQL_VERSION_NUM MYSQL_VERSION_ID
102
+ #endif
103
+
104
+ #if defined(MARIADB_BASE_VERSION)
105
+ #define MDL_SHARED_UPGRADABLE MDL_SHARED_WRITE
106
+ #undef THD_KILLED_STATE
107
+ #define THD_KILLED_STATE killed_state
108
+ #undef THD_NOT_KILLED
109
+ #define THD_NOT_KILLED NOT_KILLED
110
+ #endif
111
+
112
+ #if (MYSQL_VERSION_ID < 50600) //MySQL and MariaDB both
113
+ #define user_defined_key_parts key_parts
114
+ #define MDL_SHARED_UPGRADABLE MDL_SHARED_WRITE
115
+ #define cp_get_sql_error() stmt_da->sql_errno()
116
+ #define cp_isOk() stmt_da->is_ok()
117
+ #else
118
+ #define cp_get_sql_error() get_stmt_da()->sql_errno()
119
+ #define cp_isOk() get_stmt_da()->is_ok()
120
+ #endif
121
+
122
+ #if (MYSQL_VERSION_NUM < 50600) //MySQL Only
123
+ #define ha_index_next index_next
124
+ #define ha_index_prev index_prev
125
+ #define ha_index_first index_first
126
+ #define ha_index_last index_last
127
+ #define ha_index_next_same index_next_same
128
+ #define ha_rnd_next rnd_next
129
+ #define ha_rnd_pos rnd_pos
130
+ #endif
131
+
132
+
133
+
134
+ #if ((MYSQL_VERSION_NUM < 50600) || defined(MARIADB_BASE_VERSION))
135
+ inline void cp_add_global_thread(THD* thd){;}
136
+ inline void cp_remove_global_thread(THD* thd){;}
137
+ inline void cp_thd_release_resources(THD* thd){;}
138
+
139
+ inline void cp_restore_globals(THD* thd)
140
+ {
141
+ my_pthread_setspecific_ptr(THR_THD, 0);
142
+ my_pthread_setspecific_ptr(THR_MALLOC, 0);
143
+ }
144
+
145
+ inline bool cp_is_write_lock(handler* file){return true;}
146
+ inline void cp_thd_set_read_only(THD* thd){;}
147
+ inline bool cp_open_table(THD* thd, TABLE_LIST* tables, Open_table_context* ot_act)
148
+ {
149
+ return open_table(thd, tables, thd->mem_root, ot_act);
150
+ }
151
+ #define set_mysys_var(A)
152
+ #else
153
+ inline void cp_add_global_thread(THD* thd){add_global_thread(thd);}
154
+ inline void cp_remove_global_thread(THD* thd){remove_global_thread(thd);}
155
+ inline void cp_thd_release_resources(THD* thd){thd->release_resources();}
156
+ inline void cp_set_mysys_var(st_my_thread_var* var){set_mysys_var(var);}
157
+ inline void cp_restore_globals(THD* thd){thd->restore_globals();}
158
+ inline bool cp_is_write_lock(handler* file){return (file->get_lock_type() == F_WRLCK);}
159
+ inline void cp_thd_set_read_only(THD* thd){thd->tx_read_only = (thd->variables.tx_read_only != 0);}
160
+ inline bool cp_open_table(THD* thd, TABLE_LIST* tables, Open_table_context* ot_act)
161
+ {
162
+ return open_table(thd, tables, ot_act);
163
+ }
164
+ #endif
165
+
166
+ #if (MYSQL_VERSION_NUM < 50611)
167
+ #define ha_index_read_map index_read_map
168
+ #endif
169
+
170
+
171
+ #endif //MYSQLINTERNAL_H
@@ -0,0 +1,169 @@
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
+ #include "mysqlThd.h"
20
+ #include "mysqlInternal.h"
21
+ #include <bzs/env/compiler.h>
22
+ #include <bzs/env/crosscompile.h>
23
+
24
+ unsigned int g_openDatabases = 0;
25
+
26
+ extern unsigned int g_lock_wait_timeout;
27
+ extern char* g_transaction_isolation;
28
+
29
+ #ifdef USETLS
30
+ DWORD g_tlsiID = 0;
31
+ #endif
32
+
33
+ __THREAD char* __THREAD_BCB t_stack = NULL;
34
+
35
+ inline char* getStackaddr()
36
+ {
37
+ #ifdef USETLS
38
+ return (char*)TlsGetValue(g_tlsiID);
39
+ #else
40
+ return t_stack;
41
+ #endif
42
+ }
43
+
44
+ inline void setStackaddr(char* v)
45
+ {
46
+ #ifdef USETLS
47
+ TlsSetValue(g_tlsiID, v);
48
+ #else
49
+ t_stack = v;
50
+ #endif
51
+ }
52
+
53
+ void* operator new(size_t t)
54
+ {
55
+ return my_malloc(t, MY_WME);
56
+ }
57
+
58
+ void operator delete(void* p)
59
+ {
60
+ my_free(p);
61
+ }
62
+
63
+ void* operator new[](size_t t)
64
+ {
65
+ return my_malloc(t, MY_WME);
66
+ }
67
+
68
+ void operator delete[](void* p)
69
+ {
70
+ my_free(p);
71
+ }
72
+
73
+ void initThread(THD* thd )
74
+ {
75
+ if (getStackaddr() == NULL)
76
+ {
77
+ my_thread_init();
78
+ int v;
79
+ setStackaddr(reinterpret_cast<char*>(&v));
80
+
81
+ }
82
+ if (thd)
83
+ thd->thread_stack = getStackaddr();
84
+ }
85
+
86
+ void endThread()
87
+ {
88
+ setStackaddr(0);
89
+ }
90
+
91
+ THD* buildTHD()
92
+ {
93
+ THD* thd = new THD();
94
+ mysql_mutex_lock(&LOCK_thread_count);
95
+ thd->variables.pseudo_thread_id = thread_id++;
96
+ ++g_openDatabases;
97
+ cp_add_global_thread(thd);
98
+ mysql_mutex_unlock(&LOCK_thread_count);
99
+ thd->thread_id = thd->variables.pseudo_thread_id;
100
+ thd->thread_stack = reinterpret_cast<char*>(&thd);
101
+ thd->store_globals();
102
+ assert(thd->mysys_var);
103
+ set_mysys_var(thd->mysys_var);
104
+ thd->system_thread = NON_SYSTEM_THREAD;
105
+ const NET v = {0};
106
+ thd->net = v;
107
+
108
+ thd->variables.option_bits |= OPTION_BIN_LOG;
109
+ if (strcmp(g_transaction_isolation, "READ-COMMITTED")==0)
110
+ thd->variables.tx_isolation = ISO_READ_COMMITTED;
111
+ else if (strcmp(g_transaction_isolation, "REPEATABLE-READ")==0)
112
+ thd->variables.tx_isolation = ISO_REPEATABLE_READ;
113
+ else if (strcmp(g_transaction_isolation, "READ-UNCOMMITTED")==0)
114
+ thd->variables.tx_isolation = ISO_READ_UNCOMMITTED;
115
+ else if (strcmp(g_transaction_isolation, "SERIALIZABLE")==0)
116
+ thd->variables.tx_isolation = ISO_SERIALIZABLE;
117
+
118
+ thd->clear_error();
119
+ char tmp[256];
120
+ sprintf_s(tmp, 256,"set innodb_lock_wait_timeout=%d;", g_lock_wait_timeout);
121
+ dispatch_command(COM_QUERY, thd, tmp, (uint)strlen(tmp));
122
+
123
+ my_free(thd->db);
124
+ thd->db = my_strdup("bizstation", MYF(0));
125
+ if(thd->variables.sql_log_bin)
126
+ thd->set_current_stmt_binlog_format_row();
127
+ return thd;
128
+ }
129
+
130
+ THD* attachThd(THD* thd)
131
+ {
132
+ THD* curThd = my_pthread_getspecific(THD*, THR_THD);
133
+
134
+
135
+ if (!thd)
136
+ my_pthread_setspecific_ptr(THR_THD, thd);
137
+ else
138
+ {
139
+ initThread(thd);
140
+ assert(thd->mysys_var);
141
+ if (curThd != thd)
142
+ {
143
+ thd->store_globals();
144
+ set_mysys_var(thd->mysys_var);
145
+ }
146
+ }
147
+ return curThd;
148
+ }
149
+
150
+ THD* createThdForThread()
151
+ {
152
+ initThread(NULL);
153
+ THD* thd = buildTHD();
154
+
155
+ attachThd(thd);
156
+ return thd;
157
+ }
158
+
159
+ void deleteThdForThread(THD* thd)
160
+ {
161
+ cp_restore_globals(thd);
162
+ mysql_mutex_lock(&LOCK_thread_count);
163
+ --g_openDatabases;
164
+ cp_thd_release_resources(thd);
165
+ cp_remove_global_thread(thd);
166
+ mysql_mutex_unlock(&LOCK_thread_count);
167
+ delete thd;
168
+
169
+ }
@@ -0,0 +1,35 @@
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
+ #ifndef MYSQLTHD_H
20
+ #define MYSQLTHD_H
21
+
22
+ extern unsigned int g_openDatabases;
23
+
24
+ class THD;
25
+ void initThread(THD* thd );
26
+ THD* attachThd(THD* thd);
27
+ THD* createThdForThread();
28
+ void deleteThdForThread(THD* thd);
29
+ void endThread();
30
+
31
+ #ifdef _WIN32
32
+ #define USETLS
33
+ #endif
34
+
35
+ #endif //MYSQLTHD_H
@@ -0,0 +1,260 @@
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
+ #ifndef PERCENTAGEKEY_H
20
+ #define PERCENTAGEKEY_H
21
+
22
+ #include "mysqlInternal.h"
23
+
24
+ namespace bzs
25
+ {
26
+ namespace db
27
+ {
28
+ namespace engine
29
+ {
30
+ namespace mysql
31
+ {
32
+
33
+
34
+ /** return value of setKeyValueByPer function
35
+ *
36
+ */
37
+ #define KEY_COPY_SUCCESS 0
38
+ #define KEY_ALL_SGMENTS_SAME 1
39
+ #define KEY_NEED_SGMENT_COPY 2
40
+
41
+ class percentageKey
42
+ {
43
+ uchar* m_first;
44
+ uchar* m_last;
45
+ uchar* m_current;
46
+ const KEY& m_key;
47
+ double m_period;
48
+ int m_lastCompSize;
49
+ int m_lastCompPos;
50
+ unsigned short* m_varlenPtr;
51
+ const KEY_PART_INFO* m_curseg;
52
+
53
+ const unsigned char* rev(const unsigned char* p, unsigned char* buf, int size)
54
+ {
55
+ for (int i=0;i<size;i++)
56
+ buf[i] = p[size - i - 1];
57
+ return buf;
58
+ }
59
+
60
+ template <typename T>
61
+ bool setKeyValueByPerPos(unsigned short per)
62
+ {
63
+ m_lastCompSize = sizeof(T);
64
+ double k = (*((T*)m_last) - *((T*)m_first))/(double)10000;
65
+ T v = (T)((per * k) + *((T*)m_first) + m_period);
66
+
67
+ memcpy(m_current, (unsigned char*)&v, m_lastCompSize);
68
+ return ((*((T*)m_last) - *((T*)m_first)) == 1);
69
+ }
70
+
71
+ template <class T>
72
+ bool setKeyValueByPerPosRev(unsigned short per)
73
+ {
74
+ uchar buf1[10];
75
+ uchar buf2[10];
76
+ m_lastCompSize = sizeof(T);
77
+ const unsigned char* fr = rev(m_first, buf1, m_lastCompSize);
78
+ const unsigned char* lr = rev(m_last, buf2, m_lastCompSize);
79
+ double k = (*((T*)lr) - *((T*)fr))/(double)10000;
80
+ T v = (T)((per * k) + *((T*)fr) + m_period);
81
+
82
+ memcpy(m_current, rev((const unsigned char*)&v, buf1, m_lastCompSize), m_lastCompSize);
83
+
84
+ return ((*((T*)fr) - *((T*)lr))==1);
85
+ }
86
+
87
+ void movePosition(int size)
88
+ {
89
+ m_first += size;
90
+ m_last += size;
91
+ m_current += size;
92
+ m_lastCompPos += size;
93
+ }
94
+
95
+ /** if all segment is same return false
96
+ *
97
+ */
98
+ bool seekDifferentKey()
99
+ {
100
+ int pos = 0;
101
+ for (int i=0;i<(int)m_key.user_defined_key_parts;i++)
102
+ {
103
+ m_curseg = &m_key.key_part[i];
104
+ if (memcmp(m_first + pos, m_last + pos, m_curseg->store_length))
105
+ break;
106
+ pos += m_curseg->store_length;
107
+ }
108
+ if (pos)
109
+ {
110
+ memcpy(m_current, m_first, pos); //A key value is the same value so far.
111
+ movePosition(pos);
112
+ }
113
+ return (pos != m_key.key_length);
114
+ }
115
+
116
+ public:
117
+ percentageKey(const KEY& key, uchar* first, uchar* last, uchar* current)
118
+ :m_key(key),m_first(first),m_last(last),m_current(current),m_curseg(&key.key_part[0])
119
+ {
120
+
121
+ }
122
+
123
+ void reset(uchar* first, uchar* last, uchar* current)
124
+ {
125
+ m_first = first;
126
+ m_last = last;
127
+ m_current = current;
128
+ m_curseg = &m_key.key_part[0];
129
+ m_lastCompPos = 0;
130
+ }
131
+
132
+ /**
133
+ * @return 0 succes, 1 allsegmnet are same, 2 need segment copy
134
+ */
135
+ int setKeyValueByPer(unsigned short per, bool forwoard)
136
+ {
137
+ m_period = (forwoard) ? 0.5f:-0.5f;
138
+ if(!seekDifferentKey())
139
+ return KEY_ALL_SGMENTS_SAME;
140
+
141
+ int varSize = 0;
142
+ int len = m_curseg->store_length;
143
+ if (m_curseg->null_bit)
144
+ {
145
+ --len;
146
+ movePosition(1);
147
+ }
148
+
149
+ bool needCopy;
150
+ switch(m_curseg->field->key_type())
151
+ {
152
+ case HA_KEYTYPE_FLOAT:
153
+ case HA_KEYTYPE_DOUBLE:
154
+ {
155
+ if (len ==4)
156
+ needCopy = setKeyValueByPerPos<float>(per);
157
+ else if (len ==8)
158
+ needCopy = setKeyValueByPerPos<double>(per);
159
+ break;
160
+ }
161
+ case HA_KEYTYPE_USHORT_INT:
162
+ case HA_KEYTYPE_ULONG_INT:
163
+ case HA_KEYTYPE_ULONGLONG:
164
+ {
165
+ switch(len)
166
+ {
167
+ case 1:needCopy = setKeyValueByPerPos<unsigned char>(per);break;
168
+ case 2:needCopy = setKeyValueByPerPos<unsigned short>(per);break;
169
+ case 4:needCopy = setKeyValueByPerPos<unsigned int>(per);break;
170
+ case 8:needCopy = setKeyValueByPerPos<unsigned __int64>(per);break;
171
+ }
172
+ break;
173
+ }
174
+ case HA_KEYTYPE_INT8:
175
+ case HA_KEYTYPE_SHORT_INT:
176
+ case HA_KEYTYPE_LONG_INT:
177
+ case HA_KEYTYPE_LONGLONG:
178
+ {
179
+ switch(len)
180
+ {
181
+ case 1:needCopy = setKeyValueByPerPos<char>(per);break;
182
+ case 2:needCopy = setKeyValueByPerPos<short>(per);break;
183
+ case 4:needCopy = setKeyValueByPerPos<int>(per);break;
184
+ case 8:needCopy = setKeyValueByPerPos<__int64>(per);break;
185
+ }
186
+ break;
187
+ }
188
+ case HA_KEYTYPE_VARTEXT1:
189
+ case HA_KEYTYPE_VARBINARY1:
190
+ case HA_KEYTYPE_VARTEXT2:
191
+ case HA_KEYTYPE_VARBINARY2:
192
+
193
+ len = m_curseg->length;
194
+ m_varlenPtr = (unsigned short*)m_current;
195
+ *m_varlenPtr = len;
196
+ movePosition(2);
197
+ case HA_KEYTYPE_TEXT:
198
+ case HA_KEYTYPE_BIT:
199
+ case HA_KEYTYPE_BINARY:
200
+ {
201
+
202
+ //It copies until every 1 byte of values differ,
203
+ //and the following 2 bytes are made into the order of reverse,
204
+ //and it processes as unsigned short.
205
+ for (int i=0;i<len;i++)
206
+ {
207
+ if (*m_first == *m_last)
208
+ {
209
+ *m_current = *m_first;
210
+ movePosition(sizeof(char));
211
+
212
+ }
213
+ else
214
+ {
215
+ int size = (len - i);
216
+
217
+ if (size >= 8)
218
+ needCopy = setKeyValueByPerPosRev<unsigned __int64>(per);
219
+ else if (size >= 4)
220
+ needCopy = setKeyValueByPerPosRev<unsigned int>(per);
221
+ else if (size >= 2)
222
+ needCopy = setKeyValueByPerPosRev<unsigned short>(per);
223
+ else
224
+ needCopy = setKeyValueByPerPos<unsigned char>(per);
225
+ break;
226
+ }
227
+ }
228
+
229
+ break;
230
+ }
231
+ case HA_KEYTYPE_INT24:
232
+ case HA_KEYTYPE_UINT24:
233
+ case HA_KEYTYPE_NUM:
234
+ //no support
235
+ break;
236
+ }
237
+ if (!forwoard && needCopy)
238
+ return KEY_NEED_SGMENT_COPY;
239
+ return KEY_COPY_SUCCESS;
240
+ }
241
+
242
+ void copyFirstDeferentSegment()
243
+ {
244
+
245
+ memcpy(m_last, m_first, m_lastCompSize);
246
+ //After area that pad by ff;
247
+ memset(m_last + m_lastCompSize, 0xff, m_key.key_length - m_lastCompSize - m_lastCompPos);
248
+
249
+ }
250
+
251
+ };
252
+
253
+ }//namespace mysql
254
+ }//namespace engine
255
+ }//namespace db
256
+ }//namespace bzs
257
+
258
+
259
+ #endif //PERCENTAGEKEY_H
260
+
@@ -0,0 +1,49 @@
1
+ #ifndef BZS_DB_PROTOCOL_ICOMMANDEXECUTER_H
2
+ #define BZS_DB_PROTOCOL_ICOMMANDEXECUTER_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/netsvc/server/IAppModule.h>
22
+
23
+ namespace bzs
24
+ {
25
+ namespace db
26
+ {
27
+ namespace protocol
28
+ {
29
+
30
+ class ICommandExecuter
31
+ {
32
+
33
+ public:
34
+ virtual ~ICommandExecuter(){};
35
+ virtual size_t perseRequestEnd(const char* p, size_t size, bool& comp)const=0;
36
+ virtual size_t getAcceptMessage(char* message, size_t bufsize)=0;
37
+ virtual bool parse(const char* p, size_t size)=0;
38
+ virtual int execute(char* resultBuffer, size_t& size, netsvc::server::buffers* optionalData) = 0;
39
+ virtual bool isShutDown() = 0;
40
+ virtual void cleanup() = 0;
41
+ };
42
+
43
+
44
+ }//namespace protocol
45
+ }//namespace db
46
+ }//namespace bzs
47
+
48
+ #endif //BZS_DB_PROTOCOL_ICOMMANDEXECUTER_H
49
+