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,465 @@
|
|
1
|
+
#ifndef DATABASE_H
|
2
|
+
#define DATABASE_H
|
3
|
+
/*=================================================================
|
4
|
+
Copyright (C) 2012 2013 BizStation Corp All rights reserved.
|
5
|
+
|
6
|
+
This program is free software; you can redistribute it and/or
|
7
|
+
modify it under the terms of the GNU General Public License
|
8
|
+
as published by the Free Software Foundation; either version 2
|
9
|
+
of the License, or (at your option) any later version.
|
10
|
+
|
11
|
+
This program is distributed in the hope that it will be useful,
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
GNU General Public License for more details.
|
15
|
+
|
16
|
+
You should have received a copy of the GNU General Public License
|
17
|
+
along with this program; if not, write to the Free Software
|
18
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
19
|
+
02111-1307, USA.
|
20
|
+
=================================================================*/
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
#include <boost/noncopyable.hpp>
|
25
|
+
#include <boost/shared_ptr.hpp>
|
26
|
+
#include <boost/scoped_array.hpp>
|
27
|
+
#include <boost/function.hpp>
|
28
|
+
#include <boost/thread/mutex.hpp>
|
29
|
+
#include <vector>
|
30
|
+
#include <bzs/env/crosscompile.h>
|
31
|
+
#include "fieldAccess.h"
|
32
|
+
#include <bzs/db/IBlobBuffer.h>
|
33
|
+
|
34
|
+
class THD;
|
35
|
+
struct TABLE;
|
36
|
+
|
37
|
+
#ifndef MAX_KEYLEN
|
38
|
+
#define MAX_KEYLEN 1023
|
39
|
+
#endif
|
40
|
+
namespace bzs
|
41
|
+
{
|
42
|
+
namespace db
|
43
|
+
{
|
44
|
+
namespace engine
|
45
|
+
{
|
46
|
+
namespace mysql
|
47
|
+
{
|
48
|
+
|
49
|
+
|
50
|
+
#define READ_RECORD_GETNEXT 1
|
51
|
+
#define READ_RECORD_GETPREV 2
|
52
|
+
#define READ_RECORD_STEPNEXT 3
|
53
|
+
#define READ_RECORD_STEPPREV 4
|
54
|
+
|
55
|
+
#define RF_FIXED_LEN 0
|
56
|
+
#define RF_FIXED_PLUS_VALIABLE_LEN 1
|
57
|
+
#define RF_VALIABLE_LEN 2
|
58
|
+
#define RF_INCLUDE_NIS 4
|
59
|
+
|
60
|
+
#define TRN_RECORD_LOCK_SINGLE 0
|
61
|
+
#define TRN_RECORD_LOCK_MUILTI 1
|
62
|
+
|
63
|
+
|
64
|
+
/** bookmark size
|
65
|
+
* btreive API is MAX 4 byte
|
66
|
+
*/
|
67
|
+
#define REF_SIZE_MAX 4
|
68
|
+
class table;
|
69
|
+
|
70
|
+
extern bool g_safe_share_mode;
|
71
|
+
|
72
|
+
/** Control mysql table cahche
|
73
|
+
*/
|
74
|
+
class tableCacheCounter
|
75
|
+
{
|
76
|
+
std::vector<int> m_tables;
|
77
|
+
std::vector<int> m_counts;
|
78
|
+
|
79
|
+
boost::mutex m_mutex;
|
80
|
+
int getHash(const std::string& dbname, const std::string& tbname);
|
81
|
+
size_t getCounterIndex(const std::string& dbname, const std::string& tbname);
|
82
|
+
public:
|
83
|
+
tableCacheCounter();
|
84
|
+
void addref(const std::string& dbname, const std::string& tbname);
|
85
|
+
int count(const std::string& dbname, const std::string& tbname);
|
86
|
+
void release(const std::string& dbname, const std::string& tbname);
|
87
|
+
|
88
|
+
};
|
89
|
+
|
90
|
+
class database : private boost::noncopyable
|
91
|
+
{
|
92
|
+
friend class table;
|
93
|
+
friend class smartDbReopen;
|
94
|
+
std::string m_dbname;
|
95
|
+
|
96
|
+
mutable THD* m_thd;
|
97
|
+
short m_cid;
|
98
|
+
int m_inTransaction;
|
99
|
+
int m_inSnapshot;
|
100
|
+
int m_stat;
|
101
|
+
short m_trnType;
|
102
|
+
|
103
|
+
std::vector<boost::shared_ptr<table> > m_tables;
|
104
|
+
TABLE* doOpenTable(const std::string& name, short mode);
|
105
|
+
|
106
|
+
void unUseTable(table* tb);
|
107
|
+
public:
|
108
|
+
database(const char* name, short cid);
|
109
|
+
~database();
|
110
|
+
int stat(){return m_stat;};
|
111
|
+
THD* thd()const{return m_thd;};
|
112
|
+
void use() const;
|
113
|
+
short clientID()const{return m_cid;}
|
114
|
+
table* openTable(const std::string& name, short mode);
|
115
|
+
const std::string& name()const{return m_dbname;};
|
116
|
+
table* useTable(int index, enum_sql_command cmd);
|
117
|
+
bool beginTrn(short type);
|
118
|
+
bool commitTrn();
|
119
|
+
bool abortTrn();
|
120
|
+
bool inTransaction()const{return (m_inTransaction!=0);}
|
121
|
+
short transactionType()const{return m_trnType;}
|
122
|
+
bool beginSnapshot();
|
123
|
+
bool endSnapshot();
|
124
|
+
bool inSnapshot()const{return m_inSnapshot!=0;}
|
125
|
+
bool existsTable(const std::string& name);
|
126
|
+
bool existsDatabase();
|
127
|
+
void closeTable(const std::string& name, bool drop);
|
128
|
+
void closeTable(table* tb);
|
129
|
+
void unUseTables(bool rollback);
|
130
|
+
void closeForReopen();
|
131
|
+
void reopen();
|
132
|
+
void cleanTable();
|
133
|
+
const std::vector<boost::shared_ptr<table> >& tables() const {return m_tables;};
|
134
|
+
static tableCacheCounter tableRef;
|
135
|
+
};
|
136
|
+
|
137
|
+
typedef std::vector<boost::shared_ptr<database> > databases;
|
138
|
+
|
139
|
+
class IReadRecordsHandler;
|
140
|
+
class bookmarks;
|
141
|
+
|
142
|
+
/*
|
143
|
+
* Since it differs from the key number which a client specifies
|
144
|
+
* , and an internal key number, it changes.
|
145
|
+
* As for the key name, it is a premise that it is keyNN.
|
146
|
+
* NN is client specifies key number.
|
147
|
+
*/
|
148
|
+
class keynumConvert
|
149
|
+
{
|
150
|
+
KEY* m_key;
|
151
|
+
int m_keyCount;
|
152
|
+
char m_keyNum;
|
153
|
+
char m_convNum;
|
154
|
+
|
155
|
+
public:
|
156
|
+
keynumConvert(KEY* key, int count):m_key(key),m_keyCount(count),m_keyNum(-1){}
|
157
|
+
void setKey(KEY* key){m_key=key;};
|
158
|
+
char keyNumByMakeOrder(char num)
|
159
|
+
{
|
160
|
+
if (m_keyNum==num)
|
161
|
+
return m_convNum;
|
162
|
+
|
163
|
+
m_keyNum = num;
|
164
|
+
for (int i=0;i<m_keyCount;i++)
|
165
|
+
if (strstr(m_key[i].name, "key") && m_key[i].name[3] == num + '0')
|
166
|
+
return m_convNum = i;
|
167
|
+
return m_convNum = num;//If not found, a value as it is is returned.
|
168
|
+
}
|
169
|
+
};
|
170
|
+
|
171
|
+
class table : private boost::noncopyable
|
172
|
+
{
|
173
|
+
friend class database;
|
174
|
+
|
175
|
+
|
176
|
+
TABLE* m_table;
|
177
|
+
std::string m_name;
|
178
|
+
const short m_mode;
|
179
|
+
int m_recordFormatType;
|
180
|
+
int m_id;
|
181
|
+
unsigned short m_nullFields;
|
182
|
+
uint m_recordLenCl;
|
183
|
+
uint m_lastVarLenBytes;
|
184
|
+
|
185
|
+
database& m_db;
|
186
|
+
table(TABLE* table, database& db, const std::string& name, short mode, int id);
|
187
|
+
char m_keyNum;
|
188
|
+
mutable boost::scoped_array<unsigned char> m_keybuf;
|
189
|
+
mutable boost::scoped_array<unsigned char> m_nonNccKeybuf;
|
190
|
+
bool m_nonNcc;
|
191
|
+
int m_stat;
|
192
|
+
bool m_validCursor;
|
193
|
+
bool m_cursor;
|
194
|
+
bool m_locked;
|
195
|
+
bool m_changed;
|
196
|
+
bool m_nounlock;
|
197
|
+
bool m_bulkInserting;
|
198
|
+
int m_percentResult;
|
199
|
+
boost::shared_ptr<bookmarks> m_bms;
|
200
|
+
String m_str;
|
201
|
+
keynumConvert m_keyconv;
|
202
|
+
IblobBuffer* m_blobBuffer;
|
203
|
+
std::vector<Field*> m_nonKeySegNullFields;
|
204
|
+
|
205
|
+
void moveKey(boost::function<int()> func);
|
206
|
+
void readRecords(IReadRecordsHandler* handler, bool includeCurrent, int type);
|
207
|
+
|
208
|
+
bool keyCheckForPercent();
|
209
|
+
inline bool keynumCheck(char num);
|
210
|
+
void preBuildPercent(uchar* first, uchar* last);
|
211
|
+
inline key_part_map keymap(){return (1U << m_table->key_info[m_keyNum].user_defined_key_parts) -1;}
|
212
|
+
void seekPos(const uchar* pos);
|
213
|
+
int setKeyNullFlags();
|
214
|
+
void setFiledNullFlags();
|
215
|
+
|
216
|
+
bookmarks* bms();
|
217
|
+
int percentage(uchar* first, uchar* last, uchar* cur);
|
218
|
+
|
219
|
+
bool setNonKey(bool scan=false);
|
220
|
+
void fillNull(uchar* ptr, int size);
|
221
|
+
inline void* keybuf()const{return &m_keybuf[0];}
|
222
|
+
inline uint keylen()const{return m_table->key_info[m_keyNum].key_length;};
|
223
|
+
void setKeyValues(const uchar* ptr, int size);
|
224
|
+
void setBlobFieldPointer(const bzs::db::blobHeader* hd);
|
225
|
+
inline void unlockRow();
|
226
|
+
|
227
|
+
#ifdef USE_HANDLERSOCKET
|
228
|
+
std::vector<int> m_useFields;
|
229
|
+
void checkFiledIndex(int index);
|
230
|
+
int fieldIndexByName(const char* name)const;
|
231
|
+
void addUseField(int index){m_useFields.push_back(index);};
|
232
|
+
|
233
|
+
public:
|
234
|
+
std::vector<int>& useFields(){return m_useFields;};
|
235
|
+
void setUseFieldList(const std::string& csv);
|
236
|
+
void setKeyValues(const std::vector<std::string>& values
|
237
|
+
, int keypart, const std::string* inValue=NULL);
|
238
|
+
void setValue(int index, const std::string& v, int type);
|
239
|
+
void setUseValues(const std::vector<std::string>& values, int type);
|
240
|
+
|
241
|
+
#define UPDATE_REPLACE 0
|
242
|
+
#define UPDATE_INC 1
|
243
|
+
#define UPDATE_DEC 2
|
244
|
+
|
245
|
+
#endif
|
246
|
+
public:
|
247
|
+
static bool noKeybufResult;
|
248
|
+
|
249
|
+
~table();
|
250
|
+
|
251
|
+
inline void setBlobBuffer(IblobBuffer* blobBuffer){m_blobBuffer = blobBuffer;};
|
252
|
+
inline IblobBuffer* blobBuffer(IblobBuffer* blobBuffer){return m_blobBuffer;};
|
253
|
+
|
254
|
+
inline short mode()const {return m_mode;};
|
255
|
+
inline bool islocked(){return m_locked;}
|
256
|
+
inline void setLocked(bool value){m_locked = value;}
|
257
|
+
inline bool isChanged(){return m_changed;}
|
258
|
+
int id(){return m_id;};
|
259
|
+
inline void unUse(){m_db.unUseTable(this);}
|
260
|
+
void resetTransctionInfo(THD* thd);
|
261
|
+
void resetInternalTable(TABLE* table);
|
262
|
+
inline const std::string& name()const{return m_name;};
|
263
|
+
inline int recordFormatType()const {return m_recordFormatType;};
|
264
|
+
inline int blobFields()const {return m_table->s->blob_fields;};
|
265
|
+
|
266
|
+
/** if call close then table is deleten.
|
267
|
+
*/
|
268
|
+
inline void close()
|
269
|
+
{
|
270
|
+
m_table->file->ha_index_or_rnd_end();
|
271
|
+
m_db.closeTable(this);
|
272
|
+
}
|
273
|
+
inline char keyNum()const {return m_keyNum;}
|
274
|
+
|
275
|
+
/*
|
276
|
+
* Since it differs from the key number which a client specifies
|
277
|
+
* , and an internal key number, it changes.
|
278
|
+
* As for the key name, it is a premise that it is keyNN.
|
279
|
+
* NN is client specifies key number.
|
280
|
+
*/
|
281
|
+
inline char keyNumByMakeOrder(char num)
|
282
|
+
{
|
283
|
+
return m_keyconv.keyNumByMakeOrder(num);
|
284
|
+
}
|
285
|
+
|
286
|
+
bool setKeyNum(char num);
|
287
|
+
inline void setKeyNum(const char* name){setKeyNum(keynumByName(name));};
|
288
|
+
bool isNisKey(char num)const;
|
289
|
+
void seekKey(enum ha_rkey_function find_flag);
|
290
|
+
void getNextSame();
|
291
|
+
void getLast();
|
292
|
+
void getFirst();
|
293
|
+
void getNext();
|
294
|
+
void getPrev();
|
295
|
+
void getByPercentage(unsigned short per);
|
296
|
+
void calcPercentage();
|
297
|
+
inline int* percentResult(){return &m_percentResult;};
|
298
|
+
|
299
|
+
void stepLast();
|
300
|
+
void stepFirst();
|
301
|
+
void stepNext();
|
302
|
+
void stepPrev();
|
303
|
+
void movePos(const uchar* pos, char keyNum, bool sureRawValue=false);
|
304
|
+
|
305
|
+
inline void getNextExt(IReadRecordsHandler* handler, bool includeCurrent)
|
306
|
+
{
|
307
|
+
readRecords(handler, includeCurrent, READ_RECORD_GETNEXT);
|
308
|
+
}
|
309
|
+
|
310
|
+
inline void getPrevExt(IReadRecordsHandler* handler, bool includeCurrent)
|
311
|
+
{
|
312
|
+
readRecords(handler, includeCurrent, READ_RECORD_GETPREV);
|
313
|
+
}
|
314
|
+
|
315
|
+
inline void stepNextExt(IReadRecordsHandler* handler, bool includeCurrent)
|
316
|
+
{
|
317
|
+
readRecords(handler, includeCurrent, READ_RECORD_GETNEXT);
|
318
|
+
}
|
319
|
+
|
320
|
+
inline void stepPrevExt(IReadRecordsHandler* handler, bool includeCurrent)
|
321
|
+
{
|
322
|
+
readRecords(handler, includeCurrent, READ_RECORD_GETPREV);
|
323
|
+
}
|
324
|
+
|
325
|
+
void clearBuffer();
|
326
|
+
void clearKeybuf(){memset(&m_keybuf[0], 0x00, MAX_KEYLEN);};
|
327
|
+
|
328
|
+
__int64 insert(bool ncc);
|
329
|
+
void update(bool ncc);
|
330
|
+
void updateDirectkey();
|
331
|
+
void beginUpdate(char keyNum);
|
332
|
+
void del();
|
333
|
+
void beginDel();
|
334
|
+
|
335
|
+
int keynumByName(const char* name)const;
|
336
|
+
int stat(){return m_stat;};
|
337
|
+
void setKeyValuesPacked(const uchar* ptr, int size);
|
338
|
+
void* record()const;
|
339
|
+
|
340
|
+
uint keyPackCopy(uchar* ptr);
|
341
|
+
|
342
|
+
void setRecord(void* ptr, unsigned short size, int offset=0);
|
343
|
+
void setRecordFromPacked(const uchar* packedPtr, uint size, const bzs::db::blobHeader* hd);
|
344
|
+
uint recordPackCopy(char* buf, uint maxsize=0);
|
345
|
+
|
346
|
+
uint fieldSizeByte(int fieldNum){return var_bytes_if(m_table->field[fieldNum]);}
|
347
|
+
unsigned short fieldDataLen(int fieldNum)const;
|
348
|
+
|
349
|
+
inline unsigned short fieldLen(int fieldNum)const
|
350
|
+
{
|
351
|
+
return m_table->field[fieldNum]->pack_length();
|
352
|
+
}
|
353
|
+
|
354
|
+
inline unsigned short filedVarLenBytes(int fieldNum)const {return var_bytes_if(m_table->field[fieldNum]);}
|
355
|
+
inline char* fieldPos(int fieldNum)const{return (char*)m_table->field[fieldNum]->ptr;};
|
356
|
+
inline enum enum_field_types fieldType(int fieldNum) const {return m_table->field[fieldNum]->type();};
|
357
|
+
inline unsigned int fieldFlags(int fieldNum) const {return m_table->field[fieldNum]->flags;};
|
358
|
+
inline unsigned short fields()const{return m_table->s->fields;};
|
359
|
+
inline unsigned int nisFields()const {return m_nullFields;}
|
360
|
+
inline const char* fieldName(int fieldNum)const {return m_table->s->field[fieldNum]->field_name;};
|
361
|
+
inline const CHARSET_INFO& fieldCharset(int fieldNum)const {return *m_table->s->field[fieldNum]->charset();}
|
362
|
+
inline uint lastVarFiledNum()const{return m_table->s->fields-1-nisFields();}
|
363
|
+
inline const Field* lastVarFiled ()const{return m_table->s->field[lastVarFiledNum()];}
|
364
|
+
unsigned short lastVarLenBytes()const{return m_lastVarLenBytes;};
|
365
|
+
unsigned short lastVarFieldPos()const;
|
366
|
+
inline unsigned short lastVarFieldDataLen()const{return fieldDataLen(lastVarFiledNum());}
|
367
|
+
/*number of key.*/
|
368
|
+
inline unsigned short keys()const{return m_table->s->keys;};
|
369
|
+
inline const KEY& keyDef(char keyNum)const{return m_table->key_info[keyNum];};
|
370
|
+
inline Field* field(int fieldNum)const{return m_table->field[fieldNum];};
|
371
|
+
inline char primarykey()const{return m_table->s->primary_key;};
|
372
|
+
/** is this view. not table*/
|
373
|
+
inline bool isView()const{return m_table->s->is_view;}
|
374
|
+
|
375
|
+
/** char set of this table.*/
|
376
|
+
inline const CHARSET_INFO& charset()const {return *m_table->s->table_charset;}
|
377
|
+
|
378
|
+
ha_rows recordCount(bool estimate);
|
379
|
+
inline ulong recordLen()const{return m_table->s->reclength;}
|
380
|
+
|
381
|
+
/** record length for client side. exclude null flag segmnet
|
382
|
+
* ,lastVarLenBytes and NIS fields from recordLen()
|
383
|
+
*/
|
384
|
+
inline uint recordLenCl()const{return m_recordLenCl;}
|
385
|
+
inline uint nullBytes()const{return (uint)(m_table->s->null_fields>0);}
|
386
|
+
/** bookmark length*/
|
387
|
+
uint posPtrLen()const;
|
388
|
+
|
389
|
+
/** bookmark */
|
390
|
+
const uchar* position(bool raw=false);
|
391
|
+
const char* keyName(char keyNum);
|
392
|
+
inline void errorMessage(String *buf){m_table->file->get_error_message(m_stat, buf);}
|
393
|
+
|
394
|
+
void startBulkInsert(ha_rows rows);
|
395
|
+
void endBulkInsert();
|
396
|
+
|
397
|
+
inline TABLE* internalTable(){return m_table;} ///for debuglog
|
398
|
+
const char* valStr(int index, int &size); ///for debuglog
|
399
|
+
|
400
|
+
/** add blob field list.
|
401
|
+
* @param fieldNum field index if it is -1 then all fields of cureent row;
|
402
|
+
* @return field count of listed.
|
403
|
+
*/
|
404
|
+
uint makeBlobFieldList(int fieldNum);
|
405
|
+
|
406
|
+
inline void addBlobBuffer(int fieldNum)
|
407
|
+
{
|
408
|
+
Field* fd = m_table->field[fieldNum];
|
409
|
+
m_blobBuffer->addBlob(blob_len(fd), fd->field_index, blobBodyPtr(fd));
|
410
|
+
}
|
411
|
+
|
412
|
+
inline void setBlobFieldCount(uint num){m_blobBuffer->setFieldCount(num);};
|
413
|
+
|
414
|
+
};
|
415
|
+
|
416
|
+
//smart wrapper for exception
|
417
|
+
class smartBulkInsert
|
418
|
+
{
|
419
|
+
table* m_tb;
|
420
|
+
public:
|
421
|
+
smartBulkInsert(table* tb, ha_rows rows):m_tb(tb)
|
422
|
+
{
|
423
|
+
m_tb->startBulkInsert(rows);
|
424
|
+
}
|
425
|
+
|
426
|
+
~smartBulkInsert()
|
427
|
+
{
|
428
|
+
m_tb->endBulkInsert();
|
429
|
+
}
|
430
|
+
};
|
431
|
+
|
432
|
+
class smartTransction
|
433
|
+
{
|
434
|
+
database* m_db;
|
435
|
+
short m_type;
|
436
|
+
public:
|
437
|
+
smartTransction(database* db, short type=TRN_RECORD_LOCK_SINGLE):m_db(db)
|
438
|
+
{
|
439
|
+
m_db->beginTrn(type);
|
440
|
+
}
|
441
|
+
|
442
|
+
void end()
|
443
|
+
{
|
444
|
+
m_db->commitTrn();
|
445
|
+
m_db=NULL;
|
446
|
+
}
|
447
|
+
|
448
|
+
~smartTransction()
|
449
|
+
{
|
450
|
+
if (m_db)
|
451
|
+
m_db->abortTrn();
|
452
|
+
}
|
453
|
+
|
454
|
+
};
|
455
|
+
|
456
|
+
#define BUILINSERT_SCOPE
|
457
|
+
|
458
|
+
}//namespace mysql
|
459
|
+
}//namespace engine
|
460
|
+
}//namespace db
|
461
|
+
}//namespace bzs
|
462
|
+
|
463
|
+
#endif //DATABASE_H
|
464
|
+
|
465
|
+
|