transactd 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/BUILD_UNIX-JA +174 -0
- data/BUILD_WIN-JA +256 -0
- data/CMakeLists.txt +96 -0
- data/COPYING +339 -0
- data/README +406 -0
- data/README-JA +424 -0
- data/bin/common/tdclc_32_1_0.dll +0 -0
- data/bin/common/tdclc_64_1_0.dll +0 -0
- data/build/common/check_for_link_iconv.cmake +73 -0
- data/build/common/copyifgreater.cmd +30 -0
- data/build/common/copyifgreater.js +290 -0
- data/build/common/get_boost_libs.cmake +106 -0
- data/build/common/get_ruby_path.cmake +115 -0
- data/build/common/options.cmake +127 -0
- data/build/common/smart_install.cmake +263 -0
- data/build/common/system.cmake +122 -0
- data/build/common/transactd.rc.in +52 -0
- data/build/common/transactd_cl_common.cmake +101 -0
- data/build/common/transactd_cl_output.cmake +93 -0
- data/build/common/transactd_common.cmake +237 -0
- data/build/common/transactd_required.cmake +28 -0
- data/build/swig/ruby/generate.cmake.in +35 -0
- data/build/swig/ruby/generate.cmd.in +19 -0
- data/build/swig/ruby/ruby.swg +101 -0
- data/build/swig/tdcl.i +188 -0
- data/build/tdclc/BUILDNUMBER.txt +1 -0
- data/build/tdclc/CMakeLists.txt +170 -0
- data/build/tdclc/tdclc_32.cbproj +181 -0
- data/build/tdclc/tdclc_64.cbproj +205 -0
- data/build/tdclcpp/BUILDNUMBER.txt +1 -0
- data/build/tdclcpp/CMakeLists.txt +142 -0
- data/build/tdclcpp/tdclcpp_bcb_32.cbproj +239 -0
- data/build/tdclcpp/tdclcpp_bcb_64.cbproj +304 -0
- data/build/tdclrb/BUILDNUMBER.txt +1 -0
- data/build/tdclrb/CMakeLists.txt +258 -0
- data/build/tdclrb/GEM_VERSION +3 -0
- data/build/tdclrb/bldgem/extconf.rb +123 -0
- data/build/tdclrb/gem/INSTALLLOG.win32 +9 -0
- data/build/tdclrb/gem/Makefile.win32-VS +65 -0
- data/build/tdclrb/gem/Makefile.win32-prebuilt +48 -0
- data/build/tdclrb/gem/detect.rb +31 -0
- data/build/tdclrb/gem/helper.rb +113 -0
- data/build/tdclrb/gem/transactd.rb +22 -0
- data/build/tdclrb/gem_output.cmake +44 -0
- data/source/bzs/db/IBlobBuffer.h +51 -0
- data/source/bzs/db/blobBuffer.h +177 -0
- data/source/bzs/db/blobStructs.h +85 -0
- data/source/bzs/db/engine/mysql/IReadRecords.h +52 -0
- data/source/bzs/db/engine/mysql/bookmark.h +195 -0
- data/source/bzs/db/engine/mysql/database.cpp +1882 -0
- data/source/bzs/db/engine/mysql/database.h +465 -0
- data/source/bzs/db/engine/mysql/dbManager.cpp +303 -0
- data/source/bzs/db/engine/mysql/dbManager.h +143 -0
- data/source/bzs/db/engine/mysql/errorMessage.cpp +75 -0
- data/source/bzs/db/engine/mysql/errorMessage.h +43 -0
- data/source/bzs/db/engine/mysql/fieldAccess.h +158 -0
- data/source/bzs/db/engine/mysql/mydebuglog.cpp +349 -0
- data/source/bzs/db/engine/mysql/mydebuglog.h +89 -0
- data/source/bzs/db/engine/mysql/mysqlInternal.h +171 -0
- data/source/bzs/db/engine/mysql/mysqlThd.cpp +169 -0
- data/source/bzs/db/engine/mysql/mysqlThd.h +35 -0
- data/source/bzs/db/engine/mysql/percentageKey.h +260 -0
- data/source/bzs/db/protocol/ICommandExecuter.h +49 -0
- data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +689 -0
- data/source/bzs/db/protocol/hs/hsCommandExecuter.h +228 -0
- data/source/bzs/db/protocol/tdap/btrDate.cpp +437 -0
- data/source/bzs/db/protocol/tdap/btrDate.h +227 -0
- data/source/bzs/db/protocol/tdap/client/bulkInsert.h +127 -0
- data/source/bzs/db/protocol/tdap/client/client.cpp +106 -0
- data/source/bzs/db/protocol/tdap/client/client.h +292 -0
- data/source/bzs/db/protocol/tdap/client/connMgr.cpp +144 -0
- data/source/bzs/db/protocol/tdap/client/connMgr.h +82 -0
- data/source/bzs/db/protocol/tdap/client/database.cpp +863 -0
- data/source/bzs/db/protocol/tdap/client/database.h +118 -0
- data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +100 -0
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +1640 -0
- data/source/bzs/db/protocol/tdap/client/dbDef.h +135 -0
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +434 -0
- data/source/bzs/db/protocol/tdap/client/errorMessage.cpp +92 -0
- data/source/bzs/db/protocol/tdap/client/errorMessage_ja.cpp +98 -0
- data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +174 -0
- data/source/bzs/db/protocol/tdap/client/fieldDDF.h +91 -0
- data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +140 -0
- data/source/bzs/db/protocol/tdap/client/fileDDF.h +86 -0
- data/source/bzs/db/protocol/tdap/client/filter.cpp +527 -0
- data/source/bzs/db/protocol/tdap/client/filter.h +154 -0
- data/source/bzs/db/protocol/tdap/client/indexDDF.cpp +137 -0
- data/source/bzs/db/protocol/tdap/client/indexDDF.h +84 -0
- data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +724 -0
- data/source/bzs/db/protocol/tdap/client/nsDatabase.h +123 -0
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +899 -0
- data/source/bzs/db/protocol/tdap/client/nsTable.h +199 -0
- data/source/bzs/db/protocol/tdap/client/request.h +198 -0
- data/source/bzs/db/protocol/tdap/client/sharedData.cpp +58 -0
- data/source/bzs/db/protocol/tdap/client/sharedData.h +56 -0
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +574 -0
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +53 -0
- data/source/bzs/db/protocol/tdap/client/stringConverter.h +627 -0
- data/source/bzs/db/protocol/tdap/client/table.cpp +2613 -0
- data/source/bzs/db/protocol/tdap/client/table.h +221 -0
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +1096 -0
- data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +179 -0
- data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +40 -0
- data/source/bzs/db/protocol/tdap/client/trnsctcl.def +11 -0
- data/source/bzs/db/protocol/tdap/myDateTime.cpp +500 -0
- data/source/bzs/db/protocol/tdap/mysql/characterset.cpp +184 -0
- data/source/bzs/db/protocol/tdap/mysql/characterset.h +60 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +284 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +53 -0
- data/source/bzs/db/protocol/tdap/mysql/debuglog.cpp +383 -0
- data/source/bzs/db/protocol/tdap/mysql/debuglog.h +106 -0
- data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +680 -0
- data/source/bzs/db/protocol/tdap/mysql/request.h +202 -0
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +1020 -0
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +141 -0
- data/source/bzs/db/protocol/tdap/tdapRequest.h +190 -0
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +295 -0
- data/source/bzs/db/protocol/tdap/tdapSchema.h +558 -0
- data/source/bzs/db/protocol/tdap/tdapcapi.h +423 -0
- data/source/bzs/db/transactd/appBuilderImple.h +55 -0
- data/source/bzs/db/transactd/appModule.cpp +183 -0
- data/source/bzs/db/transactd/appModule.h +80 -0
- data/source/bzs/db/transactd/connManager.cpp +201 -0
- data/source/bzs/db/transactd/connManager.h +60 -0
- data/source/bzs/db/transactd/connectionRecord.h +69 -0
- data/source/bzs/db/transactd/transactd.cpp +325 -0
- data/source/bzs/env/compiler.h +135 -0
- data/source/bzs/env/crosscompile.cpp +130 -0
- data/source/bzs/env/crosscompile.h +150 -0
- data/source/bzs/env/fileopen.h +36 -0
- data/source/bzs/env/mbcswchrLinux.cpp +40 -0
- data/source/bzs/env/mbcswchrLinux.h +88 -0
- data/source/bzs/env/tstring.h +183 -0
- data/source/bzs/example/changeSchema.cpp +117 -0
- data/source/bzs/example/changeSchema_c.cpp +78 -0
- data/source/bzs/example/connection_pool_c.cpp +171 -0
- data/source/bzs/example/createDatabase.cpp +305 -0
- data/source/bzs/example/createDatabase_c.cpp +202 -0
- data/source/bzs/example/deleteRecords.cpp +87 -0
- data/source/bzs/example/deleteRecords_c.cpp +57 -0
- data/source/bzs/example/dropDatabase.cpp +59 -0
- data/source/bzs/example/dropDatabase_c.cpp +34 -0
- data/source/bzs/example/insertRecords.cpp +212 -0
- data/source/bzs/example/insertRecords_c.cpp +153 -0
- data/source/bzs/example/readRecords.cpp +141 -0
- data/source/bzs/example/readRecords_c.cpp +107 -0
- data/source/bzs/example/updateRecords.cpp +99 -0
- data/source/bzs/example/updateRecords_c.cpp +71 -0
- data/source/bzs/example/update_with_transaction.cpp +104 -0
- data/source/bzs/example/update_with_transaction_c.cpp +80 -0
- data/source/bzs/netsvc/client/tcpClient.cpp +226 -0
- data/source/bzs/netsvc/client/tcpClient.h +489 -0
- data/source/bzs/netsvc/server/IAppModule.h +94 -0
- data/source/bzs/netsvc/server/iserver.h +65 -0
- data/source/bzs/netsvc/server/serverCpt.cpp +522 -0
- data/source/bzs/netsvc/server/serverCpt.h +88 -0
- data/source/bzs/netsvc/server/serverPipe.cpp +705 -0
- data/source/bzs/netsvc/server/serverPipe.h +96 -0
- data/source/bzs/netsvc/server/serverTpool.cpp +416 -0
- data/source/bzs/netsvc/server/serverTpool.h +84 -0
- data/source/bzs/rtl/benchmark.cpp +96 -0
- data/source/bzs/rtl/benchmark.h +65 -0
- data/source/bzs/rtl/datetime.cpp +375 -0
- data/source/bzs/rtl/datetime.h +53 -0
- data/source/bzs/rtl/debuglog.cpp +106 -0
- data/source/bzs/rtl/debuglog.h +97 -0
- data/source/bzs/rtl/exception.h +116 -0
- data/source/bzs/rtl/stl_uty.cpp +35 -0
- data/source/bzs/rtl/stl_uty.h +29 -0
- data/source/bzs/rtl/stringBuffers.cpp +101 -0
- data/source/bzs/rtl/stringBuffers.h +58 -0
- data/source/bzs/rtl/strtrim.cpp +135 -0
- data/source/bzs/rtl/strtrim.h +46 -0
- data/source/bzs/test/tdclatl/bench_tdclatl.js +445 -0
- data/source/bzs/test/tdclrb/bench_tdclcpp.rb +375 -0
- data/source/bzs/test/tdclrb/prepare.rb +226 -0
- data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +172 -0
- data/source/bzs/test/tdclrb/transactd_kanjischema_spec.rb +208 -0
- data/source/bzs/test/tdclrb/transactd_spec.rb +1536 -0
- data/source/bzs/test/transactdBench/transactdBench.cpp +430 -0
- data/source/bzs/test/transactdBench/transactdBench2.cpp +342 -0
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +2030 -0
- data/source/global/tdclatl/Database.cpp +503 -0
- data/source/global/tdclatl/Database.h +139 -0
- data/source/global/tdclatl/DbDef.cpp +242 -0
- data/source/global/tdclatl/DbDef.h +79 -0
- data/source/global/tdclatl/Field.cpp +92 -0
- data/source/global/tdclatl/Field.h +59 -0
- data/source/global/tdclatl/FieldDef.cpp +238 -0
- data/source/global/tdclatl/FieldDef.h +87 -0
- data/source/global/tdclatl/Flags.cpp +111 -0
- data/source/global/tdclatl/Flags.h +55 -0
- data/source/global/tdclatl/KeyDef.cpp +51 -0
- data/source/global/tdclatl/KeyDef.h +55 -0
- data/source/global/tdclatl/KeySegment.cpp +55 -0
- data/source/global/tdclatl/Table.cpp +600 -0
- data/source/global/tdclatl/Table.h +144 -0
- data/source/global/tdclatl/TableDef.cpp +291 -0
- data/source/global/tdclatl/TableDef.h +86 -0
- data/source/global/tdclatl/TdVersion.cpp +74 -0
- data/source/global/tdclatl/TdVersion.h +54 -0
- data/source/global/tdclatl/_IDatabaseEvents_CP.h +113 -0
- data/source/global/tdclatl/dllmain.cpp +30 -0
- data/source/global/tdclatl/dllmain.h +27 -0
- data/source/global/tdclatl/keySegment.h +57 -0
- data/source/global/tdclatl/resource.h +0 -0
- data/source/global/tdclatl/stdafx.cpp +2 -0
- data/source/global/tdclatl/stdafx.h +25 -0
- data/source/global/tdclatl/targetver.h +4 -0
- data/source/global/tdclatl/tdclatl.cpp +68 -0
- data/source/global/tdclatl/tdclatl.def +10 -0
- data/source/global/tdclatl/tdclatl.idl +1035 -0
- data/source/linux/charsetConvert.h +112 -0
- data/source/linux/linuxTypes.h +33 -0
- data/source/linux/tchar.h +428 -0
- data/transactd.gemspec +97 -0
- 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
|
+
|