transactd 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/BUILD_UNIX-JA +46 -67
- data/BUILD_WIN-JA +106 -63
- data/CMakeLists.txt +40 -15
- data/README +219 -75
- data/README-JA +207 -76
- data/README_ORMSRCGEN +118 -0
- data/README_ORMSRCGEN-JA +115 -0
- data/bin/common/tdclc_32_2_0.dll +0 -0
- data/bin/common/tdclc_64_2_0.dll +0 -0
- data/build/common/check_for_link_iconv.cmake +18 -14
- data/build/common/create_symlink.cmake.in +25 -0
- data/build/common/get_boost_libs.cmake +23 -23
- data/build/common/options.cmake +0 -66
- data/build/common/smart_install.cmake +3 -3
- data/build/common/transactd.rc.in +15 -5
- data/build/common/transactd_cl_common.cmake +37 -18
- data/build/common/transactd_cl_output.cmake +55 -13
- data/build/common/transactd_common.cmake +108 -31
- data/build/swig/php/generate.cmake.in +15 -17
- data/build/swig/php/generate.cmd.in +15 -9
- data/build/swig/php/php.swg +124 -82
- data/build/swig/php/transactd.no_yield.php +4494 -0
- data/build/swig/php/transactd.no_yield.php.git.patch +685 -0
- data/build/swig/php/transactd.no_yield.php.patch +685 -0
- data/build/swig/php/transactd.yield.php +4461 -0
- data/build/swig/php/transactd.yield.php.git.patch +652 -0
- data/build/swig/php/transactd.yield.php.patch +652 -0
- data/build/swig/referencecounter.h +79 -0
- data/build/swig/ruby/ruby.swg +226 -76
- data/build/swig/ruby/threadBlockRegionWrapper.h +71 -0
- data/build/swig/ruby/without_gvl.swg +87 -0
- data/build/swig/tdcl.i +659 -170
- data/build/swig/validatablepointer.h +91 -0
- data/build/tdclc/CMakeLists.txt +49 -34
- data/build/tdclc/{tdclc_64.cbproj → tdclc.cbproj} +65 -20
- data/build/tdclc/tdclc.rc +0 -0
- data/build/tdclcpp/CMakeLists.txt +84 -20
- data/build/tdclcpp/tdclcpp.rc +0 -0
- data/build/tdclcpp/{tdclcpp_bcb_64.cbproj → tdclcpp_bc.cbproj} +168 -44
- data/build/tdclrb/CMakeLists.txt +84 -66
- data/build/tdclrb/bldgem/extconf.rb +28 -3
- data/build/tdclrb/gem/helper.rb +11 -1
- data/build/tdclrb/gem_output.cmake +20 -16
- data/index_ja.html +15 -0
- data/source/bzs/db/IBlobBuffer.h +15 -17
- data/source/bzs/db/blobBuffer.h +186 -140
- data/source/bzs/db/blobStructs.h +37 -37
- data/source/bzs/db/engine/mysql/IReadRecords.h +34 -34
- data/source/bzs/db/engine/mysql/bookmark.h +150 -147
- data/source/bzs/db/engine/mysql/database.cpp +1721 -1526
- data/source/bzs/db/engine/mysql/database.h +608 -370
- data/source/bzs/db/engine/mysql/dbManager.cpp +213 -201
- data/source/bzs/db/engine/mysql/dbManager.h +115 -104
- data/source/bzs/db/engine/mysql/errorMessage.cpp +49 -50
- data/source/bzs/db/engine/mysql/errorMessage.h +25 -26
- data/source/bzs/db/engine/mysql/fieldAccess.h +55 -61
- data/source/bzs/db/engine/mysql/mydebuglog.cpp +326 -292
- data/source/bzs/db/engine/mysql/mydebuglog.h +63 -55
- data/source/bzs/db/engine/mysql/mysqlInternal.h +182 -125
- data/source/bzs/db/engine/mysql/mysqlThd.cpp +121 -121
- data/source/bzs/db/engine/mysql/mysqlThd.h +20 -20
- data/source/bzs/db/engine/mysql/percentageKey.h +241 -228
- data/source/bzs/db/protocol/ICommandExecuter.h +18 -17
- data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +543 -514
- data/source/bzs/db/protocol/hs/hsCommandExecuter.h +155 -158
- data/source/bzs/db/protocol/tdap/btrDate.cpp +213 -180
- data/source/bzs/db/protocol/tdap/btrDate.h +39 -37
- data/source/bzs/db/protocol/tdap/client/activeTable.cpp +173 -0
- data/source/bzs/db/protocol/tdap/client/activeTable.h +165 -0
- data/source/bzs/db/protocol/tdap/client/activeTableImple.h +370 -0
- data/source/bzs/db/protocol/tdap/client/bulkInsert.h +13 -23
- data/source/bzs/db/protocol/tdap/client/client.cpp +81 -68
- data/source/bzs/db/protocol/tdap/client/client.h +361 -320
- data/source/bzs/db/protocol/tdap/client/connMgr.cpp +17 -22
- data/source/bzs/db/protocol/tdap/client/connMgr.h +17 -19
- data/source/bzs/db/protocol/tdap/client/connectionPool.cpp +243 -0
- data/source/bzs/db/protocol/tdap/client/connectionPool.h +109 -0
- data/source/bzs/db/protocol/tdap/client/database.cpp +327 -219
- data/source/bzs/db/protocol/tdap/client/database.h +141 -118
- data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +60 -62
- data/source/bzs/db/protocol/tdap/client/databaseManager.h +255 -0
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +315 -202
- data/source/bzs/db/protocol/tdap/client/dbDef.h +40 -32
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +390 -371
- data/source/bzs/db/protocol/tdap/client/errorMessage.cpp +148 -56
- data/source/bzs/db/protocol/tdap/client/errorMessage_ja.cpp +149 -57
- data/source/bzs/db/protocol/tdap/client/export.h +35 -0
- data/source/bzs/db/protocol/tdap/client/field.cpp +1985 -0
- data/source/bzs/db/protocol/tdap/client/field.h +393 -0
- data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +14 -14
- data/source/bzs/db/protocol/tdap/client/fieldDDF.h +11 -14
- data/source/bzs/db/protocol/tdap/client/fieldNameAlias.cpp +123 -0
- data/source/bzs/db/protocol/tdap/client/fieldNameAlias.h +58 -0
- data/source/bzs/db/protocol/tdap/client/fields.h +178 -0
- data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +13 -16
- data/source/bzs/db/protocol/tdap/client/fileDDF.h +11 -17
- data/source/bzs/db/protocol/tdap/client/filter.h +423 -259
- data/source/bzs/db/protocol/tdap/client/groupComp.h +117 -0
- data/source/bzs/db/protocol/tdap/client/groupQuery.cpp +818 -0
- data/source/bzs/db/protocol/tdap/client/groupQuery.h +281 -0
- data/source/bzs/db/protocol/tdap/client/indexDDF.cpp +14 -17
- data/source/bzs/db/protocol/tdap/client/indexDDF.h +11 -14
- data/source/bzs/db/protocol/tdap/client/memRecord.cpp +231 -0
- data/source/bzs/db/protocol/tdap/client/memRecord.h +145 -0
- data/source/bzs/db/protocol/tdap/client/memRecordset.cpp +448 -0
- data/source/bzs/db/protocol/tdap/client/memRecordset.h +159 -0
- data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +300 -173
- data/source/bzs/db/protocol/tdap/client/nsDatabase.h +53 -36
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +171 -128
- data/source/bzs/db/protocol/tdap/client/nsTable.h +121 -87
- data/source/bzs/db/protocol/tdap/client/pooledDatabaseManager.h +173 -0
- data/source/bzs/db/protocol/tdap/client/recordset.cpp +209 -0
- data/source/bzs/db/protocol/tdap/client/recordset.h +86 -0
- data/source/bzs/db/protocol/tdap/client/recordsetImple.h +596 -0
- data/source/bzs/db/protocol/tdap/client/request.h +227 -170
- data/source/bzs/db/protocol/tdap/client/serializer.cpp +1288 -0
- data/source/bzs/db/protocol/tdap/client/serializer.h +295 -0
- data/source/bzs/db/protocol/tdap/client/sharedData.cpp +9 -12
- data/source/bzs/db/protocol/tdap/client/sharedData.h +18 -16
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +494 -473
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +51 -53
- data/source/bzs/db/protocol/tdap/client/stringConverter.h +214 -148
- data/source/bzs/db/protocol/tdap/client/table.cpp +929 -1665
- data/source/bzs/db/protocol/tdap/client/table.h +413 -87
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +642 -534
- data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +25 -40
- data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +11 -15
- data/source/bzs/db/protocol/tdap/client/trdormapi.h +378 -437
- data/source/bzs/db/protocol/tdap/client/trnsctcl.def +1 -1
- data/source/bzs/db/protocol/tdap/fieldComp.h +127 -0
- data/source/bzs/db/protocol/tdap/myDateTime.cpp +352 -345
- data/source/bzs/db/protocol/tdap/mysql/characterset.cpp +75 -78
- data/source/bzs/db/protocol/tdap/mysql/characterset.h +18 -19
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +216 -199
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +23 -14
- data/source/bzs/db/protocol/tdap/mysql/debuglog.cpp +354 -314
- data/source/bzs/db/protocol/tdap/mysql/debuglog.h +57 -47
- data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +905 -739
- data/source/bzs/db/protocol/tdap/mysql/request.h +152 -159
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +1044 -879
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +87 -81
- data/source/bzs/db/protocol/tdap/tdapRequest.h +162 -130
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +368 -166
- data/source/bzs/db/protocol/tdap/tdapSchema.h +702 -566
- data/source/bzs/db/protocol/tdap/tdapcapi.h +387 -353
- data/source/bzs/db/transactd/appBuilderImple.h +21 -20
- data/source/bzs/db/transactd/appModule.cpp +350 -98
- data/source/bzs/db/transactd/appModule.h +31 -37
- data/source/bzs/db/transactd/connManager.cpp +138 -135
- data/source/bzs/db/transactd/connManager.h +28 -21
- data/source/bzs/db/transactd/connectionRecord.h +39 -39
- data/source/bzs/db/transactd/transactd.cpp +217 -203
- data/source/bzs/env/boost_bcb_link.h +131 -0
- data/source/bzs/env/compiler.h +136 -79
- data/source/bzs/env/crosscompile.cpp +57 -57
- data/source/bzs/env/crosscompile.h +130 -115
- data/source/bzs/env/fileopen.h +7 -8
- data/source/bzs/env/mbcswchrLinux.cpp +4 -9
- data/source/bzs/env/mbcswchrLinux.h +37 -34
- data/source/bzs/env/tcharMinGW.h +59 -0
- data/source/bzs/env/tstring.h +90 -95
- data/source/bzs/example/changeSchema.cpp +22 -23
- data/source/bzs/example/changeSchema_c.cpp +22 -24
- data/source/bzs/example/connection_pool_c.cpp +49 -104
- data/source/bzs/example/createDatabase.cpp +40 -47
- data/source/bzs/example/createDatabase_c.cpp +38 -43
- data/source/bzs/example/deleteRecords.cpp +10 -15
- data/source/bzs/example/deleteRecords_c.cpp +10 -14
- data/source/bzs/example/dropDatabase.cpp +3 -9
- data/source/bzs/example/dropDatabase_c.cpp +5 -6
- data/source/bzs/example/insertRecords.cpp +37 -29
- data/source/bzs/example/insertRecords_c.cpp +19 -25
- data/source/bzs/example/ormap_c.cpp +621 -0
- data/source/bzs/example/queryData.cpp +371 -0
- data/source/bzs/example/queryData.h +16 -0
- data/source/bzs/example/query_c.cpp +109 -0
- data/source/bzs/example/readRecords.cpp +27 -27
- data/source/bzs/example/readRecords_c.cpp +25 -23
- data/source/bzs/example/updateRecords.cpp +16 -21
- data/source/bzs/example/updateRecords_c.cpp +8 -12
- data/source/bzs/example/update_with_transaction.cpp +21 -24
- data/source/bzs/example/update_with_transaction_c.cpp +12 -15
- data/source/bzs/example/useORMRecord.cpp +177 -0
- data/source/bzs/netsvc/client/tcpClient.cpp +167 -156
- data/source/bzs/netsvc/client/tcpClient.h +541 -489
- data/source/bzs/netsvc/server/IAppModule.h +119 -32
- data/source/bzs/netsvc/server/iserver.h +21 -23
- data/source/bzs/netsvc/server/serverCpt.cpp +421 -391
- data/source/bzs/netsvc/server/serverCpt.h +41 -43
- data/source/bzs/netsvc/server/serverPipe.cpp +580 -565
- data/source/bzs/netsvc/server/serverPipe.h +44 -45
- data/source/bzs/netsvc/server/serverTpool.cpp +333 -303
- data/source/bzs/netsvc/server/serverTpool.h +38 -43
- data/source/bzs/rtl/benchmark.cpp +91 -31
- data/source/bzs/rtl/benchmark.h +76 -22
- data/source/bzs/rtl/datetime.cpp +231 -233
- data/source/bzs/rtl/datetime.h +16 -16
- data/source/bzs/rtl/debuglog.cpp +48 -51
- data/source/bzs/rtl/debuglog.h +55 -44
- data/source/bzs/rtl/exception.h +55 -48
- data/source/bzs/rtl/stl_uty.cpp +27 -28
- data/source/bzs/rtl/stl_uty.h +28 -29
- data/source/bzs/rtl/stringBuffers.cpp +8 -6
- data/source/bzs/rtl/stringBuffers.h +16 -9
- data/source/bzs/rtl/strtrim.cpp +90 -91
- data/source/bzs/rtl/strtrim.h +14 -16
- data/source/bzs/test/tdclatl/bench_query_atl.js +647 -0
- data/source/bzs/test/tdclatl/bench_tdclatl.js +303 -303
- data/source/bzs/test/tdclatl/test_query_atl.js +669 -0
- data/source/bzs/test/tdclphp/bench.php +357 -0
- data/source/bzs/test/tdclphp/transactd_Test.php +907 -303
- data/source/bzs/test/tdclphp/transactd_blob_Test.php +21 -49
- data/source/bzs/test/tdclphp/transactd_datetime_Test.php +41 -75
- data/source/bzs/test/tdclphp/transactd_kanjischema_Test.php +23 -37
- data/source/bzs/test/tdclphp/transactd_pool_Test.php +120 -0
- data/source/bzs/test/tdclrb/bench_tdclcpp.rb +4 -6
- data/source/bzs/test/tdclrb/prepare.rb +15 -12
- data/source/bzs/test/tdclrb/transactd_blob_spec.rb +29 -32
- data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +0 -29
- data/source/bzs/test/tdclrb/transactd_kanjischema_spec.rb +18 -19
- data/source/bzs/test/tdclrb/transactd_pool_spec.rb +107 -0
- data/source/bzs/test/tdclrb/transactd_spec.rb +734 -142
- data/source/bzs/test/transactdBench/query_bench.cpp +156 -0
- data/source/bzs/test/transactdBench/scaling_bench.cpp +265 -0
- data/source/bzs/test/transactdBench/transactdBench.cpp +107 -83
- data/source/bzs/test/transactdBench/transactdBench2.cpp +122 -83
- data/source/bzs/test/transactdBench/workerBase.cpp +5 -0
- data/source/bzs/test/transactdBench/workerBase.h +88 -0
- data/source/bzs/test/transactdBench/workerMySQLImple.h +333 -0
- data/source/bzs/test/transactdBench/workerTransactdImple.h +201 -0
- data/source/bzs/test/trdclengn/test_blob.cpp +121 -73
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +1244 -426
- data/source/global/ormsrcgen/confParam.h +80 -0
- data/source/global/ormsrcgen/fieldName.cpp +77 -0
- data/source/global/ormsrcgen/fieldName.h +43 -0
- data/source/global/ormsrcgen/main.cpp +196 -0
- data/source/global/ormsrcgen/srcgen.cpp +763 -0
- data/source/global/ormsrcgen/srcgen.h +72 -0
- data/source/global/ormsrcgen/template/fieldNameList_sample.txt +2 -0
- data/source/global/ormsrcgen/template/ormDataClass_template.cpp +48 -0
- data/source/global/ormsrcgen/template/ormDataClass_template.h +34 -0
- data/source/global/ormsrcgen/template/ormMapClass_template.cpp +51 -0
- data/source/global/ormsrcgen/template/ormMapClass_template.h +62 -0
- data/source/global/ormsrcgen/template/template.cnf +38 -0
- data/source/global/querystmts/querystmts.cpp +237 -0
- data/source/global/tdclatl/ConnectParams.cpp +77 -0
- data/source/global/tdclatl/ConnectParams.h +70 -0
- data/source/global/tdclatl/Database.cpp +132 -128
- data/source/global/tdclatl/Database.h +60 -49
- data/source/global/tdclatl/DbDef.cpp +68 -64
- data/source/global/tdclatl/DbDef.h +36 -36
- data/source/global/tdclatl/Field.cpp +12 -17
- data/source/global/tdclatl/Field.h +15 -12
- data/source/global/tdclatl/FieldDef.cpp +75 -36
- data/source/global/tdclatl/FieldDef.h +38 -19
- data/source/global/tdclatl/FieldDefs.cpp +74 -0
- data/source/global/tdclatl/FieldDefs.h +56 -0
- data/source/global/tdclatl/FieldNames.cpp +99 -0
- data/source/global/tdclatl/FieldNames.h +66 -0
- data/source/global/tdclatl/Flags.cpp +75 -37
- data/source/global/tdclatl/Flags.h +13 -12
- data/source/global/tdclatl/GroupQuery.cpp +119 -0
- data/source/global/tdclatl/GroupQuery.h +65 -0
- data/source/global/tdclatl/KeyDef.cpp +15 -14
- data/source/global/tdclatl/KeyDef.h +20 -17
- data/source/global/tdclatl/KeySegment.cpp +13 -12
- data/source/global/tdclatl/PooledDbManager.cpp +223 -0
- data/source/global/tdclatl/PooledDbManager.h +76 -0
- data/source/global/tdclatl/QueryBase.cpp +206 -127
- data/source/global/tdclatl/QueryBase.h +55 -59
- data/source/global/tdclatl/Record.cpp +214 -0
- data/source/global/tdclatl/Record.h +96 -0
- data/source/global/tdclatl/Recordset.cpp +278 -0
- data/source/global/tdclatl/Recordset.h +83 -0
- data/source/global/tdclatl/RecordsetQuery.cpp +118 -0
- data/source/global/tdclatl/RecordsetQuery.h +126 -0
- data/source/global/tdclatl/Table.cpp +57 -60
- data/source/global/tdclatl/Table.h +32 -29
- data/source/global/tdclatl/TableDef.cpp +63 -62
- data/source/global/tdclatl/TableDef.h +20 -22
- data/source/global/tdclatl/TdVersion.cpp +3 -3
- data/source/global/tdclatl/TdVersion.h +15 -11
- data/source/global/tdclatl/_IDatabaseEvents_CP.h +99 -92
- data/source/global/tdclatl/activeTable.cpp +355 -0
- data/source/global/tdclatl/activeTable.h +79 -0
- data/source/global/tdclatl/dllmain.cpp +4 -3
- data/source/global/tdclatl/dllmain.h +7 -6
- data/source/global/tdclatl/keySegment.h +22 -18
- data/source/global/tdclatl/resource.h +0 -0
- data/source/global/tdclatl/stdafx.h +6 -4
- data/source/global/tdclatl/targetver.h +0 -1
- data/source/global/tdclatl/tdclatl.cpp +10 -5
- data/source/global/tdclatl/tdclatl.idl +530 -14
- data/source/linux/charsetConvert.h +78 -79
- data/source/linux/linuxTypes.h +9 -12
- data/source/linux/tchar.h +168 -166
- data/transactd.gemspec +24 -16
- metadata +98 -12
- data/bin/common/tdclc_32_1_2.dll +0 -0
- data/bin/common/tdclc_64_1_2.dll +0 -0
- data/build/tdclc/tdclc_32.cbproj +0 -173
- data/build/tdclcpp/tdclcpp_bcb_32.cbproj +0 -232
- data/build/tdclrb/GEM_VERSION +0 -3
- data/source/bzs/db/protocol/tdap/client/filter.cpp +0 -43
- data/source/bzs/example/useORM.cpp +0 -585
@@ -1,25 +1,23 @@
|
|
1
|
-
#ifndef
|
2
|
-
#define
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
1
|
+
#ifndef BZS_DB_ENGINE_MYSQL_DATABASE_H
|
2
|
+
#define BZS_DB_ENGINE_MYSQL_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
|
+
================================================================= */
|
23
21
|
|
24
22
|
#include <boost/noncopyable.hpp>
|
25
23
|
#include <boost/shared_ptr.hpp>
|
@@ -35,8 +33,9 @@ class THD;
|
|
35
33
|
struct TABLE;
|
36
34
|
|
37
35
|
#ifndef MAX_KEYLEN
|
38
|
-
|
36
|
+
#define MAX_KEYLEN 1023
|
39
37
|
#endif
|
38
|
+
|
40
39
|
namespace bzs
|
41
40
|
{
|
42
41
|
namespace db
|
@@ -46,21 +45,26 @@ namespace engine
|
|
46
45
|
namespace mysql
|
47
46
|
{
|
48
47
|
|
48
|
+
/*
|
49
|
+
Please comment out the following,
|
50
|
+
when you emulate btrv variable length record of btrv with a server.
|
51
|
+
|
52
|
+
#define USE_BTRV_VARIABLE_LEN
|
53
|
+
*/
|
49
54
|
|
50
55
|
#define READ_RECORD_GETNEXT 1
|
51
56
|
#define READ_RECORD_GETPREV 2
|
52
57
|
#define READ_RECORD_STEPNEXT 3
|
53
58
|
#define READ_RECORD_STEPPREV 4
|
54
59
|
|
55
|
-
#define RF_FIXED_LEN
|
56
|
-
#define
|
57
|
-
#define
|
58
|
-
#define
|
60
|
+
#define RF_FIXED_LEN 0
|
61
|
+
#define RF_FIXED_PLUS_VALIABLE_LEN 1
|
62
|
+
#define RF_VALIABLE_LEN 2
|
63
|
+
#define RF_INCLUDE_NIS 4
|
59
64
|
|
60
65
|
#define TRN_RECORD_LOCK_SINGLE 0
|
61
66
|
#define TRN_RECORD_LOCK_MUILTI 1
|
62
67
|
|
63
|
-
|
64
68
|
/** bookmark size
|
65
69
|
* btreive API is MAX 4 byte
|
66
70
|
*/
|
@@ -73,65 +77,83 @@ extern bool g_safe_share_mode;
|
|
73
77
|
*/
|
74
78
|
class tableCacheCounter
|
75
79
|
{
|
76
|
-
|
77
|
-
|
80
|
+
std::vector<int> m_tables;
|
81
|
+
std::vector<int> m_counts;
|
78
82
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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);
|
83
|
+
boost::mutex m_mutex;
|
84
|
+
int getHash(const std::string& dbname, const std::string& tbname);
|
85
|
+
size_t getCounterIndex(const std::string& dbname,
|
86
|
+
const std::string& tbname);
|
87
87
|
|
88
|
+
public:
|
89
|
+
tableCacheCounter();
|
90
|
+
void addref(const std::string& dbname, const std::string& tbname);
|
91
|
+
int count(const std::string& dbname, const std::string& tbname);
|
92
|
+
void release(const std::string& dbname, const std::string& tbname);
|
88
93
|
};
|
89
94
|
|
90
95
|
class database : private boost::noncopyable
|
91
96
|
{
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
97
|
+
friend class table;
|
98
|
+
friend class smartDbReopen;
|
99
|
+
|
100
|
+
std::string m_dbname;
|
101
|
+
|
102
|
+
mutable THD* m_thd;
|
103
|
+
short m_cid;
|
104
|
+
int m_inTransaction;
|
105
|
+
int m_inSnapshot;
|
106
|
+
int m_stat;
|
107
|
+
short m_trnType;
|
108
|
+
|
109
|
+
std::vector<boost::shared_ptr<table> > m_tables;
|
110
|
+
TABLE* doOpenTable(const std::string& name, short mode,
|
111
|
+
const char* ownerName);
|
112
|
+
|
113
|
+
void unUseTable(table* tb);
|
114
|
+
|
107
115
|
public:
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
116
|
+
database(const char* name, short cid);
|
117
|
+
~database();
|
118
|
+
|
119
|
+
int stat() { return m_stat; }
|
120
|
+
|
121
|
+
THD* thd() const { return m_thd; }
|
122
|
+
void use() const;
|
123
|
+
|
124
|
+
short clientID() const { return m_cid; }
|
125
|
+
|
126
|
+
const std::string& name() const { return m_dbname; }
|
127
|
+
|
128
|
+
bool inTransaction() const { return (m_inTransaction != 0); }
|
129
|
+
|
130
|
+
short transactionType() const { return m_trnType; }
|
131
|
+
|
132
|
+
bool inSnapshot() const { return m_inSnapshot != 0; }
|
133
|
+
|
134
|
+
const std::vector<boost::shared_ptr<table> >& tables() const
|
135
|
+
{
|
136
|
+
return m_tables;
|
137
|
+
}
|
138
|
+
|
139
|
+
bool beginSnapshot();
|
140
|
+
bool endSnapshot();
|
141
|
+
table* openTable(const std::string& name, short mode,
|
142
|
+
const char* ownerName);
|
143
|
+
table* useTable(int index, enum_sql_command cmd);
|
144
|
+
bool beginTrn(short type);
|
145
|
+
bool commitTrn();
|
146
|
+
bool abortTrn();
|
147
|
+
bool existsTable(const std::string& name);
|
148
|
+
bool existsDatabase();
|
149
|
+
void closeTable(const std::string& name, bool drop);
|
150
|
+
void closeTable(table* tb);
|
151
|
+
void unUseTables(bool rollback);
|
152
|
+
void closeForReopen();
|
153
|
+
void reopen();
|
154
|
+
void cleanTable();
|
155
|
+
|
156
|
+
static tableCacheCounter tableRef;
|
135
157
|
};
|
136
158
|
|
137
159
|
typedef std::vector<boost::shared_ptr<database> > databases;
|
@@ -140,326 +162,542 @@ class IReadRecordsHandler;
|
|
140
162
|
class bookmarks;
|
141
163
|
|
142
164
|
/*
|
143
|
-
*
|
165
|
+
* Since it differs from the key number which a client specifies
|
144
166
|
* , and an internal key number, it changes.
|
145
|
-
* As for the key name, it is a premise that it is keyNN.
|
167
|
+
* As for the key name, it is a premise that it is keyNN.
|
146
168
|
* NN is client specifies key number.
|
147
169
|
*/
|
148
170
|
class keynumConvert
|
149
171
|
{
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
172
|
+
KEY* m_key;
|
173
|
+
int m_keyCount;
|
174
|
+
char m_keyNum;
|
175
|
+
char m_convNum;
|
176
|
+
|
155
177
|
public:
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
178
|
+
keynumConvert(KEY* key, int count)
|
179
|
+
: m_key(key), m_keyCount(count), m_keyNum(-1), m_convNum(-1)
|
180
|
+
{
|
181
|
+
}
|
182
|
+
|
183
|
+
void setKey(KEY* key) { m_key = key; }
|
184
|
+
|
185
|
+
char keyNumByMakeOrder(char num)
|
186
|
+
{
|
187
|
+
if (m_keyNum == num)
|
188
|
+
return m_convNum;
|
189
|
+
|
190
|
+
m_keyNum = num;
|
191
|
+
for (int i = 0; i < m_keyCount; i++)
|
192
|
+
if (strstr(m_key[i].name, "key") && m_key[i].name[3] == num + '0')
|
193
|
+
return m_convNum = i;
|
194
|
+
return m_convNum = num; // If not found, a value as it is is returned.
|
195
|
+
}
|
169
196
|
};
|
170
197
|
|
171
198
|
class table : private boost::noncopyable
|
172
199
|
{
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
200
|
+
friend class database;
|
201
|
+
TABLE* m_table;
|
202
|
+
|
203
|
+
std::string m_name;
|
204
|
+
|
205
|
+
const short m_mode;
|
206
|
+
int m_id;
|
207
|
+
unsigned short m_nullFields;
|
208
|
+
uint m_recordLenCl;
|
209
|
+
int m_recordFormatType;
|
210
|
+
#ifdef USE_BTRV_VARIABLE_LEN
|
211
|
+
uint m_lastVarLenBytes;
|
212
|
+
#endif
|
213
|
+
database& m_db;
|
214
|
+
char m_keyNum;
|
215
|
+
|
216
|
+
mutable boost::scoped_array<unsigned char> m_keybuf;
|
217
|
+
mutable boost::scoped_array<unsigned char> m_nonNccKeybuf;
|
218
|
+
|
219
|
+
bool m_nonNcc;
|
220
|
+
int m_stat;
|
221
|
+
bool m_validCursor;
|
222
|
+
bool m_cursor;
|
223
|
+
bool m_locked;
|
224
|
+
bool m_changed;
|
225
|
+
bool m_nounlock;
|
226
|
+
bool m_bulkInserting;
|
227
|
+
int m_percentResult;
|
228
|
+
|
229
|
+
boost::shared_ptr<bookmarks> m_bms;
|
230
|
+
|
231
|
+
String m_str;
|
232
|
+
keynumConvert m_keyconv;
|
233
|
+
IblobBuffer* m_blobBuffer;
|
234
|
+
|
235
|
+
std::vector<Field*> m_nonKeySegNullFields;
|
236
|
+
|
237
|
+
table(TABLE* table, database& db, const std::string& name, short mode,
|
238
|
+
int id);
|
239
|
+
void moveKey(boost::function<int()> func);
|
240
|
+
void readRecords(IReadRecordsHandler* handler, bool includeCurrent,
|
241
|
+
int type, bool noBookmark);
|
242
|
+
|
243
|
+
bool keyCheckForPercent();
|
244
|
+
inline bool keynumCheck(char num);
|
245
|
+
void preBuildPercent(uchar* first, uchar* last);
|
246
|
+
void seekPos(const uchar* pos);
|
247
|
+
int setKeyNullFlags();
|
248
|
+
void setFiledNullFlags();
|
249
|
+
|
250
|
+
bookmarks* bms();
|
251
|
+
int percentage(uchar* first, uchar* last, uchar* cur);
|
252
|
+
|
253
|
+
bool setNonKey(bool scan = false);
|
254
|
+
void fillNull(uchar* ptr, int size);
|
255
|
+
|
256
|
+
inline void* keybuf() const { return &m_keybuf[0]; }
|
257
|
+
|
258
|
+
inline uint keylen() const
|
259
|
+
{
|
260
|
+
return m_table->key_info[m_keyNum].key_length;
|
261
|
+
}
|
262
|
+
void setKeyValues(const uchar* ptr, int size);
|
263
|
+
void setBlobFieldPointer(const bzs::db::blobHeader* hd);
|
264
|
+
inline void unlockRow();
|
265
|
+
|
266
|
+
inline void initHandler()
|
267
|
+
{
|
268
|
+
if ((m_db.m_inSnapshot == 0) &&
|
269
|
+
(m_table->reginfo.lock_type != TL_WRITE))
|
270
|
+
m_table->file->init_table_handle_for_HANDLER();
|
271
|
+
}
|
226
272
|
|
227
273
|
#ifdef USE_HANDLERSOCKET
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
274
|
+
std::vector<int> m_useFields;
|
275
|
+
void checkFiledIndex(int index);
|
276
|
+
int fieldIndexByName(const char* name) const;
|
277
|
+
|
278
|
+
void addUseField(int index) { m_useFields.push_back(index); };
|
232
279
|
|
233
280
|
public:
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
281
|
+
std::vector<int>& useFields() { return m_useFields; };
|
282
|
+
void setUseFieldList(const std::string& csv);
|
283
|
+
void setKeyValues(const std::vector<std::string>& values, int keypart,
|
284
|
+
const std::string* inValue = NULL);
|
285
|
+
void setValue(int index, const std::string& v, int type);
|
286
|
+
void setUseValues(const std::vector<std::string>& values, int type);
|
287
|
+
|
288
|
+
#define UPDATE_REPLACE 0
|
289
|
+
#define UPDATE_INC 1
|
290
|
+
#define UPDATE_DEC 2
|
244
291
|
|
245
292
|
#endif
|
293
|
+
|
246
294
|
public:
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
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_STEPNEXT);
|
318
|
-
}
|
319
|
-
|
320
|
-
inline void stepPrevExt(IReadRecordsHandler* handler, bool includeCurrent)
|
321
|
-
{
|
322
|
-
readRecords(handler, includeCurrent, READ_RECORD_STEPPREV);
|
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);};
|
295
|
+
static bool noKeybufResult;
|
296
|
+
|
297
|
+
~table();
|
298
|
+
|
299
|
+
inline void setBlobBuffer(IblobBuffer* blobBuffer)
|
300
|
+
{
|
301
|
+
m_blobBuffer = blobBuffer;
|
302
|
+
}
|
303
|
+
|
304
|
+
inline IblobBuffer* blobBuffer(IblobBuffer* blobBuffer)
|
305
|
+
{
|
306
|
+
return m_blobBuffer;
|
307
|
+
}
|
308
|
+
|
309
|
+
inline short mode() const { return m_mode; }
|
310
|
+
|
311
|
+
inline bool islocked() { return m_locked; }
|
312
|
+
|
313
|
+
inline void setLocked(bool value) { m_locked = value; }
|
314
|
+
|
315
|
+
inline bool isChanged() { return m_changed; }
|
316
|
+
|
317
|
+
int id() { return m_id; };
|
318
|
+
|
319
|
+
inline void unUse() { m_db.unUseTable(this); }
|
320
|
+
|
321
|
+
inline const std::string& name() const { return m_name; }
|
322
|
+
|
323
|
+
inline int recordFormatType() const { return m_recordFormatType; }
|
324
|
+
void resetTransctionInfo(THD* thd);
|
325
|
+
void resetInternalTable(TABLE* table);
|
326
|
+
|
327
|
+
#ifdef USE_BTRV_VARIABLE_LEN
|
328
|
+
|
329
|
+
inline uint lastVarFiledNum() const
|
330
|
+
{
|
331
|
+
return m_table->s->fields - 1 - nisFields();
|
332
|
+
}
|
333
|
+
|
334
|
+
inline const Field* lastVarFiled() const
|
335
|
+
{
|
336
|
+
return m_table->s->field[lastVarFiledNum()];
|
337
|
+
}
|
413
338
|
|
339
|
+
unsigned short lastVarLenBytes() const { return m_lastVarLenBytes; }
|
340
|
+
|
341
|
+
inline unsigned short lastVarFieldDataLen() const
|
342
|
+
{
|
343
|
+
return fieldDataLen(lastVarFiledNum());
|
344
|
+
}
|
345
|
+
|
346
|
+
unsigned short lastVarFieldPos() const;
|
347
|
+
#endif
|
348
|
+
|
349
|
+
inline int blobFields() const { return m_table->s->blob_fields; }
|
350
|
+
|
351
|
+
/** if call close then table is deleten.
|
352
|
+
*/
|
353
|
+
inline void close()
|
354
|
+
{
|
355
|
+
m_table->file->ha_index_or_rnd_end();
|
356
|
+
m_db.closeTable(this);
|
357
|
+
}
|
358
|
+
|
359
|
+
inline char keyNum() const { return m_keyNum; }
|
360
|
+
|
361
|
+
inline bool isUniqueKey()
|
362
|
+
{
|
363
|
+
return (m_table->key_info[m_keyNum].flags & HA_NOSAME);
|
364
|
+
}
|
365
|
+
|
366
|
+
/*
|
367
|
+
* Since it differs from the key number which a client specifies
|
368
|
+
* , and an internal key number, it changes.
|
369
|
+
* As for the key name, it is a premise that it is keyNN.
|
370
|
+
* NN is client specifies key number.
|
371
|
+
*/
|
372
|
+
inline char keyNumByMakeOrder(char num)
|
373
|
+
{
|
374
|
+
return m_keyconv.keyNumByMakeOrder(num);
|
375
|
+
}
|
376
|
+
|
377
|
+
bool setKeyNum(char num, bool sorted = true);
|
378
|
+
|
379
|
+
inline void setKeyNum(const char* name, bool sorted = true)
|
380
|
+
{
|
381
|
+
setKeyNum(keynumByName(name), sorted);
|
382
|
+
}
|
383
|
+
bool isNisKey(char num) const;
|
384
|
+
|
385
|
+
inline key_part_map keymap()
|
386
|
+
{
|
387
|
+
return (1U << m_table->key_info[m_keyNum].user_defined_key_parts) - 1;
|
388
|
+
}
|
389
|
+
void seekKey(enum ha_rkey_function find_flag, key_part_map keyMap);
|
390
|
+
void getNextSame(key_part_map keyMap);
|
391
|
+
void getLast();
|
392
|
+
void getFirst();
|
393
|
+
void getNext();
|
394
|
+
void getPrev();
|
395
|
+
void getByPercentage(unsigned short per);
|
396
|
+
void calcPercentage();
|
397
|
+
|
398
|
+
inline int* percentResult() { return &m_percentResult; }
|
399
|
+
|
400
|
+
void stepLast();
|
401
|
+
void stepFirst();
|
402
|
+
void stepNext();
|
403
|
+
void stepPrev();
|
404
|
+
void movePos(const uchar* pos, char keyNum, bool sureRawValue = false);
|
405
|
+
|
406
|
+
inline void getNextExt(IReadRecordsHandler* handler, bool includeCurrent,
|
407
|
+
bool noBookmark)
|
408
|
+
{
|
409
|
+
readRecords(handler, includeCurrent, READ_RECORD_GETNEXT, noBookmark);
|
410
|
+
}
|
411
|
+
|
412
|
+
inline void getPrevExt(IReadRecordsHandler* handler, bool includeCurrent,
|
413
|
+
bool noBookmark)
|
414
|
+
{
|
415
|
+
readRecords(handler, includeCurrent, READ_RECORD_GETPREV, noBookmark);
|
416
|
+
}
|
417
|
+
|
418
|
+
inline void stepNextExt(IReadRecordsHandler* handler, bool includeCurrent,
|
419
|
+
bool noBookmark)
|
420
|
+
{
|
421
|
+
if (m_table->file->inited != handler::RND)
|
422
|
+
setNonKey(true);
|
423
|
+
readRecords(handler, includeCurrent, READ_RECORD_STEPNEXT, noBookmark);
|
424
|
+
}
|
425
|
+
|
426
|
+
inline void stepPrevExt(IReadRecordsHandler* handler, bool includeCurrent,
|
427
|
+
bool noBookmark)
|
428
|
+
{
|
429
|
+
if (m_table->file->inited != handler::RND)
|
430
|
+
setNonKey(true);
|
431
|
+
readRecords(handler, includeCurrent, READ_RECORD_STEPPREV, noBookmark);
|
432
|
+
}
|
433
|
+
|
434
|
+
void clearBuffer();
|
435
|
+
|
436
|
+
inline void clearKeybuf() { memset(&m_keybuf[0], 0x00, MAX_KEYLEN); }
|
437
|
+
|
438
|
+
__int64 insert(bool ncc);
|
439
|
+
void update(bool ncc);
|
440
|
+
void updateDirectkey();
|
441
|
+
void beginUpdate(char keyNum);
|
442
|
+
void del();
|
443
|
+
void beginDel();
|
444
|
+
|
445
|
+
int keynumByName(const char* name) const;
|
446
|
+
|
447
|
+
inline int stat() { return m_stat; }
|
448
|
+
short setKeyValuesPacked(const uchar* ptr, int size);
|
449
|
+
void* record() const;
|
450
|
+
|
451
|
+
uint keyPackCopy(uchar* ptr);
|
452
|
+
|
453
|
+
void setRecord(void* ptr, unsigned short size, int offset = 0);
|
454
|
+
void setRecordFromPacked(const uchar* packedPtr, uint size,
|
455
|
+
const bzs::db::blobHeader* hd);
|
456
|
+
uint recordPackCopy(char* buf, uint maxsize = 0);
|
457
|
+
|
458
|
+
ushort fieldPackCopy(unsigned char* dest, short filedNum);
|
459
|
+
|
460
|
+
inline uint fieldSizeByte(int fieldNum)
|
461
|
+
{
|
462
|
+
return var_bytes_if(m_table->field[fieldNum]);
|
463
|
+
}
|
464
|
+
unsigned short fieldDataLen(int fieldNum) const;
|
465
|
+
|
466
|
+
inline unsigned short fieldLen(int fieldNum) const
|
467
|
+
{
|
468
|
+
return m_table->field[fieldNum]->pack_length();
|
469
|
+
}
|
470
|
+
|
471
|
+
inline unsigned short filedVarLenBytes(int fieldNum) const
|
472
|
+
{
|
473
|
+
return var_bytes_if(m_table->field[fieldNum]);
|
474
|
+
}
|
475
|
+
|
476
|
+
inline char* fieldPos(int fieldNum) const
|
477
|
+
{
|
478
|
+
return (char*)m_table->field[fieldNum]->ptr;
|
479
|
+
}
|
480
|
+
|
481
|
+
inline enum enum_field_types fieldType(int fieldNum) const
|
482
|
+
{
|
483
|
+
return m_table->field[fieldNum]->type();
|
484
|
+
}
|
485
|
+
|
486
|
+
inline unsigned int fieldFlags(int fieldNum) const
|
487
|
+
{
|
488
|
+
return m_table->field[fieldNum]->flags;
|
489
|
+
}
|
490
|
+
|
491
|
+
inline unsigned short fields() const { return m_table->s->fields; }
|
492
|
+
|
493
|
+
inline unsigned int nisFields() const { return m_nullFields; }
|
494
|
+
|
495
|
+
inline const char* fieldName(int fieldNum) const
|
496
|
+
{
|
497
|
+
return m_table->s->field[fieldNum]->field_name;
|
498
|
+
}
|
499
|
+
|
500
|
+
inline const CHARSET_INFO& fieldCharset(int fieldNum) const
|
501
|
+
{
|
502
|
+
return *m_table->s->field[fieldNum]->charset();
|
503
|
+
}
|
504
|
+
|
505
|
+
/* number of key. */
|
506
|
+
inline unsigned short keys() const { return m_table->s->keys; }
|
507
|
+
|
508
|
+
inline const KEY& keyDef(char keyNum) const
|
509
|
+
{
|
510
|
+
return m_table->key_info[keyNum];
|
511
|
+
}
|
512
|
+
|
513
|
+
inline const KEY* primaryKey() const
|
514
|
+
{
|
515
|
+
return (m_table->s->primary_key != MAX_KEY)
|
516
|
+
? &m_table->key_info[m_table->s->primary_key]
|
517
|
+
: NULL;
|
518
|
+
}
|
519
|
+
|
520
|
+
inline Field* field(int fieldNum) const { return m_table->field[fieldNum]; }
|
521
|
+
|
522
|
+
inline char primarykey() const { return m_table->s->primary_key; }
|
523
|
+
|
524
|
+
/** is this view. not table */
|
525
|
+
inline bool isView() const { return m_table->s->is_view; }
|
526
|
+
|
527
|
+
/** char set of this table. */
|
528
|
+
inline const CHARSET_INFO& charset() const
|
529
|
+
{
|
530
|
+
return *m_table->s->table_charset;
|
531
|
+
}
|
532
|
+
|
533
|
+
ha_rows recordCount(bool estimate);
|
534
|
+
|
535
|
+
inline ulong recordLen() const { return m_table->s->reclength; }
|
536
|
+
|
537
|
+
/** record length for client side. exclude null flag segmnet
|
538
|
+
* ,lastVarLenBytes and NIS fields from recordLen()
|
539
|
+
*/
|
540
|
+
inline uint recordLenCl() const { return m_recordLenCl; }
|
541
|
+
|
542
|
+
inline uint nullBytes() const
|
543
|
+
{
|
544
|
+
return (uint)(m_table->s->null_fields > 0);
|
545
|
+
}
|
546
|
+
/** bookmark length */
|
547
|
+
uint posPtrLen() const;
|
548
|
+
|
549
|
+
/** bookmark */
|
550
|
+
const uchar* position(bool raw = false);
|
551
|
+
const char* keyName(char keyNum);
|
552
|
+
|
553
|
+
inline void errorMessage(String* buf)
|
554
|
+
{
|
555
|
+
m_table->file->get_error_message(m_stat, buf);
|
556
|
+
}
|
557
|
+
|
558
|
+
void startBulkInsert(ha_rows rows);
|
559
|
+
void endBulkInsert();
|
560
|
+
|
561
|
+
inline TABLE* internalTable() { return m_table; }
|
562
|
+
/// for debuglog
|
563
|
+
const char* valStr(int index, int& size);
|
564
|
+
/// for debuglog
|
565
|
+
|
566
|
+
/** add blob field list.
|
567
|
+
* @param fieldNum field index if it is -1 then all fields of cureent row;
|
568
|
+
* @return field count of listed.
|
569
|
+
*/
|
570
|
+
uint makeBlobFieldList(int fieldNum);
|
571
|
+
|
572
|
+
inline void addBlobBuffer(int fieldNum)
|
573
|
+
{
|
574
|
+
Field* fd = m_table->field[fieldNum];
|
575
|
+
m_blobBuffer->addBlob(blob_len(fd), fd->field_index, blobBodyPtr(fd));
|
576
|
+
}
|
577
|
+
|
578
|
+
inline void setBlobFieldCount(uint num)
|
579
|
+
{
|
580
|
+
m_blobBuffer->setFieldCount(num);
|
581
|
+
}
|
582
|
+
|
583
|
+
inline void indexInit()
|
584
|
+
{
|
585
|
+
int ret = m_table->file->ha_index_or_rnd_end();
|
586
|
+
assert(ret == 0);
|
587
|
+
if (m_keyNum >= 0)
|
588
|
+
ret = m_table->file->ha_index_init(m_keyNum, true);
|
589
|
+
else
|
590
|
+
ret = m_table->file->ha_rnd_init(true);
|
591
|
+
assert(ret == 0);
|
592
|
+
}
|
414
593
|
};
|
415
594
|
|
416
|
-
|
417
|
-
class smartBulkInsert
|
595
|
+
class fieldBitmap
|
418
596
|
{
|
419
|
-
|
597
|
+
TABLE* m_table;
|
598
|
+
bool m_keyRead;
|
599
|
+
|
420
600
|
public:
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
601
|
+
inline fieldBitmap(TABLE* table) : m_table(table), m_keyRead(false)
|
602
|
+
{
|
603
|
+
m_table->read_set = &m_table->tmp_set;
|
604
|
+
m_table->write_set = &m_table->tmp_set;
|
605
|
+
bitmap_clear_all(m_table->read_set);
|
606
|
+
}
|
607
|
+
|
608
|
+
inline fieldBitmap() : m_table(NULL), m_keyRead(false) {}
|
609
|
+
|
610
|
+
inline void setTable(table* tb)
|
611
|
+
{
|
612
|
+
if (tb)
|
613
|
+
{
|
614
|
+
m_table = tb->internalTable();
|
615
|
+
m_table->read_set = &m_table->tmp_set;
|
616
|
+
m_table->write_set = &m_table->tmp_set;
|
617
|
+
bitmap_clear_all(m_table->read_set);
|
618
|
+
}
|
619
|
+
else if (m_table)
|
620
|
+
{
|
621
|
+
if (m_keyRead)
|
622
|
+
m_table->file->extra(HA_EXTRA_NO_KEYREAD);
|
623
|
+
m_table->read_set = &m_table->s->all_set;
|
624
|
+
m_table->write_set = &m_table->s->all_set;
|
625
|
+
m_table = NULL;
|
626
|
+
}
|
627
|
+
}
|
628
|
+
|
629
|
+
inline ~fieldBitmap()
|
630
|
+
{
|
631
|
+
if (m_table)
|
632
|
+
{
|
633
|
+
if (m_keyRead)
|
634
|
+
m_table->file->extra(HA_EXTRA_NO_KEYREAD);
|
635
|
+
m_table->read_set = &m_table->s->all_set;
|
636
|
+
m_table->write_set = &m_table->s->all_set;
|
637
|
+
}
|
638
|
+
}
|
639
|
+
|
640
|
+
inline void setKeyRead(bool v)
|
641
|
+
{
|
642
|
+
assert(m_table);
|
643
|
+
if (v)
|
644
|
+
m_table->file->extra(HA_EXTRA_KEYREAD);
|
645
|
+
else if (m_keyRead)
|
646
|
+
m_table->file->extra(HA_EXTRA_NO_KEYREAD);
|
647
|
+
m_keyRead = v;
|
648
|
+
}
|
649
|
+
|
650
|
+
inline void setReadBitmap(uint bit)
|
651
|
+
{
|
652
|
+
assert(m_table);
|
653
|
+
bitmap_set_bit(m_table->read_set, bit);
|
654
|
+
}
|
430
655
|
};
|
431
656
|
|
432
|
-
|
657
|
+
// smart wrapper for exception
|
658
|
+
class smartBulkInsert
|
433
659
|
{
|
434
|
-
|
435
|
-
|
660
|
+
table* m_tb;
|
661
|
+
|
436
662
|
public:
|
437
|
-
|
438
|
-
|
439
|
-
|
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
|
-
}
|
663
|
+
smartBulkInsert(table* tb, ha_rows rows) : m_tb(tb)
|
664
|
+
{
|
665
|
+
m_tb->startBulkInsert(rows);
|
666
|
+
}
|
453
667
|
|
668
|
+
~smartBulkInsert() { m_tb->endBulkInsert(); }
|
454
669
|
};
|
455
670
|
|
456
|
-
|
671
|
+
class smartTransction
|
672
|
+
{
|
673
|
+
database* m_db;
|
674
|
+
short m_type;
|
457
675
|
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
676
|
+
public:
|
677
|
+
smartTransction(database* db, short type = TRN_RECORD_LOCK_SINGLE)
|
678
|
+
: m_db(db)
|
679
|
+
{
|
680
|
+
m_db->beginTrn(type);
|
681
|
+
}
|
682
|
+
|
683
|
+
void end()
|
684
|
+
{
|
685
|
+
m_db->commitTrn();
|
686
|
+
m_db = NULL;
|
687
|
+
}
|
688
|
+
|
689
|
+
~smartTransction()
|
690
|
+
{
|
691
|
+
if (m_db)
|
692
|
+
m_db->abortTrn();
|
693
|
+
}
|
694
|
+
};
|
462
695
|
|
463
|
-
#
|
696
|
+
#define BUILINSERT_SCOPE
|
464
697
|
|
698
|
+
} // namespace mysql
|
699
|
+
} // namespace engine
|
700
|
+
} // namespace db
|
701
|
+
} // namespace bzs
|
465
702
|
|
703
|
+
#endif // BZS_DB_ENGINE_MYSQL_DATABASE_H
|