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
@@ -12,14 +12,15 @@
|
|
12
12
|
GNU General Public License for more details.
|
13
13
|
|
14
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
|
15
|
+
along with this program; if not, write to the Free Software
|
16
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
17
17
|
02111-1307, USA.
|
18
18
|
=================================================================*/
|
19
19
|
#ifndef BZS_DB_PROTOCOL_TDAP_MYSQL_RECORDSETREADER_H
|
20
20
|
#define BZS_DB_PROTOCOL_TDAP_MYSQL_RECORDSETREADER_H
|
21
21
|
|
22
22
|
#include "request.h"
|
23
|
+
#include <bzs/db/protocol/tdap/tdapSchema.h>
|
23
24
|
#include <bzs/rtl/exception.h>
|
24
25
|
#include <bzs/db/engine/mysql/IReadRecords.h>
|
25
26
|
#include <bzs/db/engine/mysql/fieldAccess.h>
|
@@ -39,8 +40,8 @@ namespace tdap
|
|
39
40
|
namespace mysql
|
40
41
|
{
|
41
42
|
|
42
|
-
#pragma
|
43
|
-
pragma_pack1
|
43
|
+
#pragma pack(push, 1)
|
44
|
+
pragma_pack1;
|
44
45
|
|
45
46
|
struct logicalField;
|
46
47
|
struct resultField;
|
@@ -49,843 +50,1008 @@ struct resultField;
|
|
49
50
|
*/
|
50
51
|
class position
|
51
52
|
{
|
52
|
-
|
53
|
-
|
53
|
+
engine::mysql::table* m_tb;
|
54
|
+
const char* m_record;
|
55
|
+
|
54
56
|
public:
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
57
|
+
inline position();
|
58
|
+
inline void setTable(engine::mysql::table* tb);
|
59
|
+
inline char* fieldPtr(const resultField* rf) const;
|
60
|
+
inline bool isBlobField(const resultField* rf) const;
|
61
|
+
inline void addBlobBuffer(int fieldNum) { m_tb->addBlobBuffer(fieldNum); };
|
62
|
+
inline void setBlobFieldCount(int v) { m_tb->setBlobFieldCount(v); };
|
63
|
+
inline unsigned short packLen(const resultField* rf) const;
|
64
|
+
inline const char* record() const { return m_record; }
|
65
|
+
inline ulong recordLenCl() const { return m_tb->recordLenCl(); }
|
66
|
+
inline int recordFormatType() const { return m_tb->recordFormatType(); };
|
67
|
+
inline uint recordPackCopy(char* buf, uint maxlen) const
|
68
|
+
{
|
69
|
+
return m_tb->recordPackCopy(buf, maxlen);
|
70
|
+
}
|
71
|
+
int getFieldNumByPos(unsigned short pos) const
|
72
|
+
{
|
73
|
+
for (int i = 0; i < m_tb->fields(); i++)
|
74
|
+
{
|
75
|
+
char* start = m_tb->fieldPos(0);
|
76
|
+
if (m_tb->fieldPos(i) - start == pos)
|
77
|
+
return i;
|
78
|
+
}
|
79
|
+
return -1;
|
80
|
+
}
|
81
|
+
inline uint fieldSizeByte(int fieldNum)
|
82
|
+
{
|
83
|
+
return m_tb->fieldSizeByte(fieldNum);
|
84
|
+
}
|
85
|
+
inline ushort fieldPackCopy(unsigned char* dest, short filedNum)
|
86
|
+
{
|
87
|
+
return m_tb->fieldPackCopy(dest, filedNum);
|
88
|
+
}
|
77
89
|
};
|
78
90
|
|
79
91
|
/** If get all field then len = record length.
|
80
|
-
*
|
92
|
+
*
|
81
93
|
*/
|
82
94
|
struct resultField
|
83
95
|
{
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
96
|
+
unsigned short len;
|
97
|
+
union
|
98
|
+
{
|
99
|
+
unsigned short pos;
|
100
|
+
unsigned short fieldNum;
|
101
|
+
};
|
90
102
|
};
|
91
103
|
|
92
104
|
struct extResultDef
|
93
105
|
{
|
94
|
-
|
95
|
-
|
96
|
-
|
106
|
+
unsigned short maxRows;
|
107
|
+
unsigned short fieldCount;
|
108
|
+
resultField field[1]; // variable
|
97
109
|
};
|
98
110
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
inline position::position():m_tb(NULL),m_record(NULL){};
|
103
|
-
inline void position::setTable( engine::mysql::table* tb)
|
111
|
+
inline position::position() : m_tb(NULL), m_record(NULL){};
|
112
|
+
inline void position::setTable(engine::mysql::table* tb)
|
104
113
|
{
|
105
|
-
|
106
|
-
|
114
|
+
m_tb = tb;
|
115
|
+
m_record = (const char*)m_tb->record();
|
107
116
|
}
|
108
117
|
|
109
118
|
inline char* position::fieldPtr(const resultField* rf) const
|
110
119
|
{
|
111
|
-
|
120
|
+
return m_tb->fieldPos(rf->fieldNum);
|
112
121
|
}
|
113
122
|
|
114
123
|
inline bool position::isBlobField(const resultField* rf) const
|
115
124
|
{
|
116
|
-
|
125
|
+
return db::engine::mysql::isBlobType(m_tb->fieldType(rf->fieldNum));
|
117
126
|
}
|
118
127
|
|
119
|
-
|
120
128
|
/** return data length as real rength.
|
121
129
|
*/
|
122
130
|
inline unsigned short position::packLen(const resultField* rf) const
|
123
131
|
{
|
124
|
-
|
132
|
+
return m_tb->fieldDataLen(rf->fieldNum);
|
125
133
|
}
|
126
134
|
|
127
135
|
inline int compareUint24(const char* l, const char* r)
|
128
136
|
{
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
137
|
+
unsigned int lv = *((unsigned int*)l) & 0xFFFFFF;
|
138
|
+
unsigned int rv = *((unsigned int*)r) & 0xFFFFFF;
|
139
|
+
if (lv < rv)
|
140
|
+
return -1;
|
141
|
+
if (lv > rv)
|
142
|
+
return 1;
|
143
|
+
return 0;
|
136
144
|
}
|
137
145
|
|
138
146
|
inline int compareInt24(const char* l, const char* r)
|
139
147
|
{
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
+
int lv = ((*((int*)l) & 0xFFFFFF) << 8) / 0x100;
|
149
|
+
int rv = ((*((int*)r) & 0xFFFFFF) << 8) / 0x100;
|
150
|
+
|
151
|
+
if (lv < rv)
|
152
|
+
return -1;
|
153
|
+
else if (lv > rv)
|
154
|
+
return 1;
|
155
|
+
return 0;
|
148
156
|
}
|
149
157
|
|
150
|
-
template <class T>
|
151
|
-
inline int compare(const char* l, const char* r)
|
158
|
+
template <class T> inline int compare(const char* l, const char* r)
|
152
159
|
{
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
160
|
+
if (*((T*)l) < *((T*)r))
|
161
|
+
return -1;
|
162
|
+
else if (*((T*)l) > *((T*)r))
|
163
|
+
return 1;
|
164
|
+
return 0;
|
158
165
|
}
|
159
166
|
|
160
|
-
template <class T>
|
161
|
-
inline int compare(T l, T r)
|
167
|
+
template <class T> inline int compare(T l, T r)
|
162
168
|
{
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
169
|
+
if (l < r)
|
170
|
+
return -1;
|
171
|
+
else if (l > r)
|
172
|
+
return 1;
|
173
|
+
return 0;
|
168
174
|
}
|
169
175
|
|
170
176
|
template <class T>
|
171
177
|
inline int compareVartype(const char* l, const char* r, bool bin, char logType)
|
172
178
|
{
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
179
|
+
int llen = (*(T*)l);
|
180
|
+
int rlen = (*(T*)r);
|
181
|
+
int tmp = std::min(llen, rlen);
|
182
|
+
if (logType & CMPLOGICAL_CASEINSENSITIVE)
|
183
|
+
tmp = _strnicmp(l + sizeof(T), r + sizeof(T), tmp);
|
184
|
+
else if (bin)
|
185
|
+
tmp = memcmp(l + sizeof(T), r + sizeof(T), tmp);
|
186
|
+
else
|
187
|
+
tmp = strncmp(l + sizeof(T), r + sizeof(T), tmp);
|
188
|
+
|
189
|
+
if (logType & CMPLOGICAL_VAR_COMP_ALL)
|
190
|
+
return (tmp == 0) ? compare<int>(llen, rlen) : tmp; // match complete
|
191
|
+
return (tmp == 0 && (llen < rlen)) ? -1 : tmp; // match a part
|
186
192
|
}
|
187
193
|
|
188
194
|
template <class T>
|
189
195
|
inline int compareWvartype(const char* l, const char* r, bool bin, char logType)
|
190
196
|
{
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
197
|
+
int llen = (*(T*)l) / sizeof(char16_t);
|
198
|
+
int rlen = (*(T*)r) / sizeof(char16_t);
|
199
|
+
int tmp = std::min(llen, rlen);
|
200
|
+
if (logType & CMPLOGICAL_CASEINSENSITIVE)
|
201
|
+
tmp = wcsnicmp16((char16_t*)(l + sizeof(T)), (char16_t*)(r + sizeof(T)),
|
202
|
+
tmp);
|
203
|
+
else if (bin)
|
204
|
+
tmp =
|
205
|
+
memcmp((char16_t*)(l + sizeof(T)), (char16_t*)(r + sizeof(T)), tmp);
|
206
|
+
else
|
207
|
+
tmp = wcsncmp16((char16_t*)(l + sizeof(T)), (char16_t*)(r + sizeof(T)),
|
208
|
+
tmp);
|
209
|
+
if (logType & CMPLOGICAL_VAR_COMP_ALL)
|
210
|
+
return (tmp == 0) ? compare<int>(llen, rlen) : tmp; // match complete
|
211
|
+
return (tmp == 0 && (llen < rlen)) ? -1 : tmp; // match a part
|
203
212
|
}
|
204
213
|
|
205
|
-
inline int compareBlobType(const char* l, const char* r, bool bin, char logType,
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
214
|
+
inline int compareBlobType(const char* l, const char* r, bool bin, char logType,
|
215
|
+
int sizeByte)
|
216
|
+
{
|
217
|
+
int llen = 0;
|
218
|
+
int rlen = 0;
|
219
|
+
memcpy(&llen, l, sizeByte);
|
220
|
+
memcpy(&rlen, r, sizeByte);
|
221
|
+
int tmp = std::min(llen, rlen);
|
222
|
+
const char* lptr = *((const char**)(l + sizeByte));
|
223
|
+
const char* rptr = r + sizeByte;
|
224
|
+
if (logType & CMPLOGICAL_CASEINSENSITIVE)
|
225
|
+
tmp = _strnicmp(lptr, rptr, tmp);
|
226
|
+
else if (bin)
|
227
|
+
tmp = memcmp(lptr, rptr, tmp);
|
228
|
+
else
|
229
|
+
tmp = strncmp(lptr, rptr, tmp);
|
230
|
+
|
231
|
+
if (logType & CMPLOGICAL_VAR_COMP_ALL)
|
232
|
+
return (tmp == 0) ? compare<int>(llen, rlen) : tmp;
|
233
|
+
return (tmp == 0 && (llen < rlen)) ? -1 : tmp;
|
224
234
|
}
|
225
235
|
|
226
|
-
#define REC_MACTH
|
227
|
-
#define REC_NOMACTH
|
228
|
-
#define REC_NOMACTH_NOMORE
|
236
|
+
#define REC_MACTH 0
|
237
|
+
#define REC_NOMACTH 1
|
238
|
+
#define REC_NOMACTH_NOMORE 2
|
229
239
|
|
230
240
|
//#define COMP_USE_SWITCHCASE
|
231
241
|
#ifndef COMP_USE_SWITCHCASE
|
232
|
-
#define COMP_USE_FUNCTION_POINTER
|
242
|
+
#define COMP_USE_FUNCTION_POINTER
|
233
243
|
#endif
|
234
244
|
|
245
|
+
struct seek
|
246
|
+
{
|
247
|
+
unsigned short len;
|
248
|
+
unsigned char ptr[1]; // variable
|
249
|
+
seek* next() const
|
250
|
+
{
|
251
|
+
return (seek*)((char*)this + len + sizeof(unsigned short));
|
252
|
+
}
|
253
|
+
|
254
|
+
extResultDef* resultDef(int count) const
|
255
|
+
{
|
256
|
+
const seek* s = this;
|
257
|
+
while (count--)
|
258
|
+
s = s->next();
|
259
|
+
return (extResultDef*)s;
|
260
|
+
}
|
261
|
+
};
|
262
|
+
|
235
263
|
struct logicalField;
|
236
|
-
typedef int (logicalField::*compFunc)(const char* l, const char* r,
|
264
|
+
typedef int (logicalField::*compFunc)(const char* l, const char* r,
|
265
|
+
int sizeByte) const;
|
237
266
|
struct logicalField
|
238
267
|
{
|
239
|
-
|
268
|
+
|
269
|
+
public:
|
270
|
+
unsigned char type;
|
271
|
+
unsigned short len;
|
272
|
+
unsigned short pos;
|
273
|
+
char logType;
|
274
|
+
char opr;
|
275
|
+
union
|
276
|
+
{
|
277
|
+
unsigned short offset;
|
278
|
+
unsigned char ptr[2]; // variable
|
279
|
+
};
|
280
|
+
|
281
|
+
logicalField* next() const
|
282
|
+
{
|
283
|
+
return (logType & 64) ? (logicalField*)(ptr + 2)
|
284
|
+
: (logicalField*)(ptr + len);
|
285
|
+
}
|
286
|
+
|
240
287
|
public:
|
241
|
-
unsigned char type;
|
242
|
-
unsigned short len;
|
243
|
-
unsigned short pos;
|
244
|
-
char logType;
|
245
|
-
char opr;
|
246
|
-
union
|
247
|
-
{
|
248
|
-
unsigned short offset;
|
249
|
-
unsigned char ptr[2]; //variable
|
250
|
-
};
|
251
|
-
|
252
|
-
logicalField* next() const
|
253
|
-
{
|
254
|
-
return (logType & 64)?(logicalField*)(ptr + 2):(logicalField*)(ptr + len);
|
255
|
-
}
|
256
|
-
|
257
|
-
public:
|
258
288
|
#ifdef COMP_USE_SWITCHCASE
|
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
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
289
|
+
int comp(const char* record, int sizeByte) const
|
290
|
+
{
|
291
|
+
const char* r = (const char*)ptr;
|
292
|
+
if (logType & CMPLOGICAL_FIELD)
|
293
|
+
r = record + offset;
|
294
|
+
const char* l = record + pos;
|
295
|
+
switch (type)
|
296
|
+
{
|
297
|
+
case ft_integer:
|
298
|
+
case ft_autoinc:
|
299
|
+
case ft_currency:
|
300
|
+
{
|
301
|
+
switch (len)
|
302
|
+
{
|
303
|
+
case 1:
|
304
|
+
return compare<char>(l, r);
|
305
|
+
case 2:
|
306
|
+
return compare<short>(l, r);
|
307
|
+
case 3:
|
308
|
+
return compareInt24(l, r);
|
309
|
+
case 4:
|
310
|
+
return compare<int>(l, r);
|
311
|
+
case 8:
|
312
|
+
return compare<__int64>(l, r);
|
313
|
+
}
|
314
|
+
}
|
315
|
+
case ft_mychar:
|
316
|
+
case ft_string:
|
317
|
+
if (logType & CMPLOGICAL_CASEINSENSITIVE)
|
318
|
+
return _strnicmp(l, r, len);
|
319
|
+
return memcmp(l, r, len);
|
320
|
+
case ft_zstring:
|
321
|
+
case ft_note:
|
322
|
+
if (logType & CMPLOGICAL_CASEINSENSITIVE)
|
323
|
+
return _strnicmp(l, r, len);
|
324
|
+
return strncmp(l, r, len);
|
325
|
+
case ft_logical:
|
326
|
+
case ft_uinteger:
|
327
|
+
case ft_autoIncUnsigned:
|
328
|
+
case ft_date:
|
329
|
+
case ft_time:
|
330
|
+
case ft_timestamp:
|
331
|
+
case ft_mydate:
|
332
|
+
{
|
333
|
+
switch (len)
|
334
|
+
{
|
335
|
+
case 1:
|
336
|
+
return compare<unsigned char>(l, r);
|
337
|
+
case 2:
|
338
|
+
return compare<unsigned short>(l, r);
|
339
|
+
case 3:
|
340
|
+
return compareUint24(l, r);
|
341
|
+
case 4:
|
342
|
+
return compare<unsigned int>(l, r);
|
343
|
+
case 8:
|
344
|
+
return compare<unsigned __int64>(l, r);
|
345
|
+
}
|
346
|
+
}
|
347
|
+
|
348
|
+
case ft_mytime:
|
349
|
+
case ft_mydatetime:
|
350
|
+
case ft_mytimestamp:
|
351
|
+
return memcmp(l, r, len);
|
352
|
+
case ft_float:
|
353
|
+
switch (len)
|
354
|
+
{
|
355
|
+
case 4:
|
356
|
+
return compare<float>(l, r);
|
357
|
+
case 8:
|
358
|
+
return compare<double>(l, r);
|
359
|
+
}
|
360
|
+
case ft_mywchar:
|
361
|
+
case ft_wstring:
|
362
|
+
case ft_wzstring:
|
363
|
+
if (logType & CMPLOGICAL_CASEINSENSITIVE)
|
364
|
+
return wcsnicmp16((char16_t*)l, (char16_t*)r, len);
|
365
|
+
if ((type == ft_wstring) || (type == ft_mywchar))
|
366
|
+
return memcmp(l, r, len);
|
367
|
+
return wcsncmp16((char16_t*)l, (char16_t*)r, len);
|
368
|
+
case ft_lstring:
|
369
|
+
case ft_myvarchar:
|
370
|
+
case ft_myvarbinary:
|
371
|
+
if (sizeByte == 1)
|
372
|
+
return compareVartype<unsigned char>(
|
373
|
+
l, r, type == ft_myvarbinary, logType);
|
374
|
+
return compareVartype<unsigned short>(l, r, type == ft_myvarbinary,
|
375
|
+
logType);
|
376
|
+
case ft_mywvarchar:
|
377
|
+
case ft_mywvarbinary:
|
378
|
+
if (sizeByte == 1)
|
379
|
+
return compareWvartype<unsigned char>(
|
380
|
+
l, r, type == ft_mywvarbinary, logType);
|
381
|
+
return compareWvartype<unsigned short>(
|
382
|
+
l, r, type == ft_mywvarbinary, logType);
|
383
|
+
case ft_mytext:
|
384
|
+
case ft_myblob:
|
385
|
+
return compareBlobType(l, r, type == ft_myblob, logType, sizeByte);
|
386
|
+
}
|
387
|
+
return 0;
|
388
|
+
};
|
389
|
+
#else // COMP_USE_FUNCTION_POINTER
|
390
|
+
|
391
|
+
template <class T>
|
392
|
+
int compNumber(const char* l, const char* r, int sizeByte) const
|
393
|
+
{
|
394
|
+
return compare<T>(l, r);
|
395
|
+
}
|
396
|
+
|
397
|
+
int compNumber24(const char* l, const char* r, int sizeByte) const
|
398
|
+
{
|
399
|
+
return compareInt24(l, r);
|
400
|
+
}
|
401
|
+
|
402
|
+
int compNumberU24(const char* l, const char* r, int sizeByte) const
|
403
|
+
{
|
404
|
+
return compareUint24(l, r);
|
405
|
+
}
|
406
|
+
|
407
|
+
int compMem(const char* l, const char* r, int sizeByte) const
|
408
|
+
{
|
409
|
+
return memcmp(l, r, len);
|
410
|
+
}
|
411
|
+
|
412
|
+
int compString(const char* l, const char* r, int sizeByte) const
|
413
|
+
{
|
414
|
+
return strncmp(l, r, len);
|
415
|
+
}
|
416
|
+
|
417
|
+
int compiString(const char* l, const char* r, int sizeByte) const
|
418
|
+
{
|
419
|
+
return _strnicmp(l, r, len);
|
420
|
+
}
|
421
|
+
|
422
|
+
int compWString(const char* l, const char* r, int sizeByte) const
|
423
|
+
{
|
424
|
+
return wcsncmp16((char16_t*)l, (char16_t*)r, len);
|
425
|
+
}
|
426
|
+
|
427
|
+
int compiWString(const char* l, const char* r, int sizeByte) const
|
428
|
+
{
|
429
|
+
return wcsnicmp16((char16_t*)l, (char16_t*)r, len);
|
430
|
+
}
|
431
|
+
|
432
|
+
template <class T>
|
433
|
+
int compVarString(const char* l, const char* r, int sizeByte) const
|
434
|
+
{
|
435
|
+
return compareVartype<T>(l, r, type == ft_myvarbinary, logType);
|
436
|
+
}
|
437
|
+
|
438
|
+
template <class T>
|
439
|
+
int compWVarString(const char* l, const char* r, int sizeByte) const
|
440
|
+
{
|
441
|
+
return compareWvartype<T>(l, r, type == ft_mywvarbinary, logType);
|
442
|
+
}
|
443
|
+
|
444
|
+
int compBlob(const char* l, const char* r, int sizeByte) const
|
445
|
+
{
|
446
|
+
return compareBlobType(l, r, type == ft_myblob, logType, sizeByte);
|
447
|
+
}
|
448
|
+
|
449
|
+
compFunc getCompFunc(int sizeByte)
|
450
|
+
{
|
451
|
+
switch (type)
|
452
|
+
{
|
453
|
+
case ft_integer:
|
454
|
+
case ft_autoinc:
|
455
|
+
case ft_currency:
|
456
|
+
{
|
457
|
+
switch (len)
|
458
|
+
{
|
459
|
+
case 1:
|
460
|
+
return &logicalField::compNumber<char>;
|
461
|
+
case 2:
|
462
|
+
return &logicalField::compNumber<short>;
|
463
|
+
case 3:
|
464
|
+
return &logicalField::compNumber24;
|
465
|
+
case 4:
|
466
|
+
return &logicalField::compNumber<int>;
|
467
|
+
case 8:
|
468
|
+
return &logicalField::compNumber<__int64>;
|
469
|
+
}
|
470
|
+
}
|
471
|
+
case ft_mychar:
|
472
|
+
case ft_string:
|
473
|
+
if (logType & CMPLOGICAL_CASEINSENSITIVE)
|
474
|
+
return &logicalField::compiString;
|
475
|
+
return &logicalField::compMem;
|
476
|
+
case ft_zstring:
|
477
|
+
case ft_note:
|
478
|
+
if (logType & CMPLOGICAL_CASEINSENSITIVE)
|
479
|
+
return &logicalField::compiString;
|
480
|
+
return &logicalField::compString;
|
481
|
+
case ft_logical:
|
482
|
+
case ft_uinteger:
|
483
|
+
case ft_autoIncUnsigned:
|
484
|
+
case ft_date:
|
485
|
+
case ft_time:
|
486
|
+
case ft_timestamp:
|
487
|
+
case ft_mydate:
|
488
|
+
{
|
489
|
+
switch (len)
|
490
|
+
{
|
491
|
+
case 1:
|
492
|
+
return &logicalField::compNumber<unsigned char>;
|
493
|
+
case 2:
|
494
|
+
return &logicalField::compNumber<unsigned short>;
|
495
|
+
case 3:
|
496
|
+
return &logicalField::compNumberU24;
|
497
|
+
case 4:
|
498
|
+
return &logicalField::compNumber<unsigned int>;
|
499
|
+
case 8:
|
500
|
+
return &logicalField::compNumber<unsigned __int64>;
|
501
|
+
}
|
502
|
+
}
|
503
|
+
case ft_mytime:
|
504
|
+
case ft_mydatetime:
|
505
|
+
case ft_mytimestamp:
|
506
|
+
return &logicalField::compMem;
|
507
|
+
case ft_float:
|
508
|
+
switch (len)
|
509
|
+
{
|
510
|
+
case 4:
|
511
|
+
return &logicalField::compNumber<float>;
|
512
|
+
case 8:
|
513
|
+
return &logicalField::compNumber<double>;
|
514
|
+
}
|
515
|
+
case ft_mywchar:
|
516
|
+
case ft_wstring:
|
517
|
+
case ft_wzstring:
|
518
|
+
if (logType & CMPLOGICAL_CASEINSENSITIVE)
|
519
|
+
return &logicalField::compiWString;
|
520
|
+
if ((type == ft_wstring) || (type == ft_mywchar))
|
521
|
+
return &logicalField::compMem;
|
522
|
+
return &logicalField::compWString;
|
523
|
+
case ft_lstring:
|
524
|
+
case ft_myvarchar:
|
525
|
+
case ft_myvarbinary:
|
526
|
+
if (sizeByte == 1)
|
527
|
+
return &logicalField::compVarString<unsigned char>;
|
528
|
+
return &logicalField::compVarString<unsigned short>;
|
529
|
+
case ft_mywvarchar:
|
530
|
+
case ft_mywvarbinary:
|
531
|
+
if (sizeByte == 1)
|
532
|
+
return &logicalField::compWVarString<unsigned char>;
|
533
|
+
return &logicalField::compWVarString<unsigned short>;
|
534
|
+
case ft_mytext:
|
535
|
+
case ft_myblob:
|
536
|
+
return &logicalField::compBlob;
|
537
|
+
}
|
538
|
+
return NULL;
|
539
|
+
}
|
482
540
|
#endif
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
541
|
+
extResultDef* resultDef() const
|
542
|
+
{
|
543
|
+
if (opr == 0)
|
544
|
+
return (extResultDef*)next();
|
545
|
+
return next()->resultDef();
|
546
|
+
}
|
489
547
|
};
|
490
548
|
|
491
549
|
struct extRequest
|
492
550
|
{
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
551
|
+
int ilen : 28;
|
552
|
+
int itype : 4;
|
553
|
+
unsigned short rejectCount;
|
554
|
+
unsigned short logicalCount;
|
555
|
+
logicalField field;
|
556
|
+
|
557
|
+
extResultDef* resultDef() const
|
558
|
+
{
|
559
|
+
if (logicalCount)
|
560
|
+
return field.resultDef();
|
561
|
+
return (extResultDef*)&field;
|
562
|
+
}
|
563
|
+
};
|
505
564
|
|
565
|
+
struct extRequestSeeks
|
566
|
+
{
|
567
|
+
int ilen : 28;
|
568
|
+
int itype : 4;
|
569
|
+
unsigned short rejectCount;
|
570
|
+
unsigned short logicalCount;
|
571
|
+
seek seekData;
|
572
|
+
|
573
|
+
extResultDef* resultDef() const
|
574
|
+
{
|
575
|
+
if (logicalCount)
|
576
|
+
return seekData.resultDef(logicalCount);
|
577
|
+
return (extResultDef*)&seekData;
|
578
|
+
}
|
506
579
|
};
|
507
580
|
|
508
|
-
#pragma
|
509
|
-
pragma_pop
|
581
|
+
#pragma pack(pop)
|
582
|
+
pragma_pop;
|
510
583
|
|
511
|
-
bool isMatch1(int v)
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
bool
|
516
|
-
|
584
|
+
bool isMatch1(int v)
|
585
|
+
{
|
586
|
+
return (v == 0);
|
587
|
+
}
|
588
|
+
bool isMatch2(int v)
|
589
|
+
{
|
590
|
+
return (v > 0);
|
591
|
+
}
|
592
|
+
bool isMatch3(int v)
|
593
|
+
{
|
594
|
+
return (v < 0);
|
595
|
+
}
|
596
|
+
bool isMatch4(int v)
|
597
|
+
{
|
598
|
+
return (v != 0);
|
599
|
+
}
|
600
|
+
bool isMatch5(int v)
|
601
|
+
{
|
602
|
+
return (v >= 0);
|
603
|
+
}
|
604
|
+
bool isMatch6(int v)
|
605
|
+
{
|
606
|
+
return (v <= 0);
|
607
|
+
}
|
517
608
|
|
518
609
|
class fields;
|
519
610
|
class fieldAdapter
|
520
611
|
{
|
521
|
-
|
522
|
-
|
523
|
-
|
612
|
+
logicalField* m_fd;
|
613
|
+
fieldAdapter* m_next;
|
614
|
+
bool (*m_isMatchFunc)(int);
|
524
615
|
#ifdef COMP_USE_FUNCTION_POINTER
|
525
|
-
|
616
|
+
compFunc m_compFunc;
|
526
617
|
#endif
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
618
|
+
unsigned char m_keySeg;
|
619
|
+
mutable bool m_judge;
|
620
|
+
char m_judgeType;
|
621
|
+
char m_sizeBytes;
|
622
|
+
mutable bool m_matched;
|
623
|
+
|
532
624
|
public:
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
625
|
+
friend class fields;
|
626
|
+
fieldAdapter()
|
627
|
+
: m_keySeg(0xff), m_judge(false), m_judgeType(0), m_sizeBytes(0),
|
628
|
+
m_matched(false)
|
629
|
+
{
|
630
|
+
}
|
631
|
+
|
632
|
+
int init(logicalField* fd, position& position, const KEY* key, bool forword)
|
633
|
+
{
|
634
|
+
m_fd = fd;
|
635
|
+
int num = position.getFieldNumByPos(fd->pos);
|
636
|
+
if (num == -1)
|
637
|
+
return STATUS_INVALID_FIELD_OFFSET;
|
638
|
+
m_sizeBytes = (char)position.fieldSizeByte(num);
|
544
639
|
#ifdef COMP_USE_FUNCTION_POINTER
|
545
|
-
|
640
|
+
m_compFunc = fd->getCompFunc(m_sizeBytes);
|
546
641
|
#endif
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
642
|
+
if (fd->opr == 2)
|
643
|
+
{
|
644
|
+
m_judgeType = 0;
|
645
|
+
return 0;
|
646
|
+
}
|
647
|
+
if (key)
|
648
|
+
{
|
649
|
+
int segmentIndex = 0;
|
650
|
+
int segments =
|
651
|
+
std::min<uint>(MAX_KEY_SEGMENT, key->user_defined_key_parts);
|
652
|
+
while (segmentIndex < segments)
|
653
|
+
{
|
654
|
+
if (key->key_part[segmentIndex].field->field_index == num)
|
655
|
+
{
|
656
|
+
eCompType comp = (eCompType)(fd->logType & 0x0f);
|
657
|
+
bool gt = (comp == eGreater) || (comp == eGreaterEq);
|
658
|
+
bool le = (comp == eLess) || (comp == eLessEq);
|
659
|
+
bool valid = !(forword ? gt : le);
|
660
|
+
if (valid)
|
661
|
+
{
|
662
|
+
m_keySeg = (unsigned char)segmentIndex + 1;
|
663
|
+
m_judgeType = (comp == eEqual) ? 2 : 1;
|
664
|
+
}
|
665
|
+
break;
|
666
|
+
}
|
667
|
+
++segmentIndex;
|
668
|
+
}
|
669
|
+
}
|
670
|
+
return 0;
|
671
|
+
}
|
672
|
+
|
673
|
+
inline int checkNomore(bool typeNext, eCompType log) const
|
674
|
+
{
|
675
|
+
if (m_judge)
|
676
|
+
{
|
677
|
+
if ((log == eEqual) && m_matched) //==
|
678
|
+
return REC_NOMACTH_NOMORE;
|
679
|
+
else if (typeNext && (log == eLess || log == eLessEq))
|
680
|
+
return REC_NOMACTH_NOMORE;
|
681
|
+
else if (!typeNext && (log == eGreater || log == eGreaterEq))
|
682
|
+
return REC_NOMACTH_NOMORE;
|
683
|
+
}
|
684
|
+
return REC_NOMACTH;
|
685
|
+
}
|
686
|
+
|
687
|
+
int match(const char* record, bool typeNext) const
|
688
|
+
{
|
590
689
|
#ifdef COMP_USE_SWITCHCASE
|
591
|
-
|
592
|
-
#else //COMP_USE_FUNCTION_POINTER
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
#endif
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
690
|
+
int v = m_fd->comp(record, m_sizeBytes);
|
691
|
+
#else // COMP_USE_FUNCTION_POINTER
|
692
|
+
const char* r = (const char*)m_fd->ptr;
|
693
|
+
if (m_fd->logType & CMPLOGICAL_FIELD)
|
694
|
+
r = record + m_fd->offset;
|
695
|
+
const char* l = record + m_fd->pos;
|
696
|
+
int v = (m_fd->*m_compFunc)(l, r, m_sizeBytes);
|
697
|
+
#endif
|
698
|
+
bool ret = m_isMatchFunc(v);
|
699
|
+
if (ret && m_judgeType)
|
700
|
+
{
|
701
|
+
m_matched = true;
|
702
|
+
// check is this logic range of max ?
|
703
|
+
// if max then set judge node to next logic
|
704
|
+
if ((m_fd->opr != 0) && m_judge && (v == 0) && m_next->m_judgeType)
|
705
|
+
m_next->m_judge = true;
|
706
|
+
}
|
707
|
+
bool end = (m_fd->opr == 0) || (!ret && (m_fd->opr == 1)) ||
|
708
|
+
(ret && (m_fd->opr == 2));
|
709
|
+
if (!end)
|
710
|
+
return m_next->match(record, typeNext);
|
711
|
+
return ret ? REC_MACTH
|
712
|
+
: checkNomore(typeNext, (eCompType)(m_fd->logType & 0xF));
|
713
|
+
}
|
714
|
+
|
715
|
+
bool operator<(const fieldAdapter& r) const
|
716
|
+
{
|
717
|
+
if (m_judgeType != r.m_judgeType)
|
718
|
+
return m_judgeType > r.m_judgeType;
|
719
|
+
else if (m_keySeg == r.m_keySeg)
|
720
|
+
return this < &r; // no change order
|
721
|
+
return m_keySeg < r.m_keySeg;
|
722
|
+
}
|
619
723
|
};
|
620
724
|
|
621
725
|
class fields
|
622
726
|
{
|
623
|
-
|
727
|
+
fieldAdapter* m_fields;
|
624
728
|
|
625
729
|
public:
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
730
|
+
fields() : m_fields(NULL){};
|
731
|
+
|
732
|
+
~fields() { delete[] m_fields; }
|
733
|
+
|
734
|
+
void init(extRequest& req, position& position, const KEY* key, bool forword)
|
735
|
+
{
|
736
|
+
if (req.logicalCount == 0)
|
737
|
+
return;
|
738
|
+
|
739
|
+
logicalField* fd = &req.field;
|
740
|
+
delete[] m_fields;
|
741
|
+
m_fields = new fieldAdapter[req.logicalCount];
|
742
|
+
int lastIndex = req.logicalCount;
|
743
|
+
for (int i = 0; i < req.logicalCount; ++i)
|
744
|
+
{
|
745
|
+
fieldAdapter& fda = m_fields[i];
|
746
|
+
fda.init(fd, position, key, forword);
|
747
|
+
eCompType log = (eCompType)(fd->logType & 0xF);
|
748
|
+
switch (log)
|
749
|
+
{
|
750
|
+
case 1:
|
751
|
+
fda.m_isMatchFunc = isMatch1;
|
752
|
+
break;
|
753
|
+
case 2:
|
754
|
+
fda.m_isMatchFunc = isMatch2;
|
755
|
+
break;
|
756
|
+
case 3:
|
757
|
+
fda.m_isMatchFunc = isMatch3;
|
758
|
+
break;
|
759
|
+
case 4:
|
760
|
+
fda.m_isMatchFunc = isMatch4;
|
761
|
+
break;
|
762
|
+
case 5:
|
763
|
+
fda.m_isMatchFunc = isMatch5;
|
764
|
+
break;
|
765
|
+
case 6:
|
766
|
+
fda.m_isMatchFunc = isMatch6;
|
767
|
+
break;
|
768
|
+
}
|
769
|
+
|
770
|
+
fd = fd->next();
|
771
|
+
if (fda.m_fd->opr == 2 && (lastIndex == req.logicalCount))
|
772
|
+
lastIndex = i; // the first 'or' index
|
773
|
+
}
|
774
|
+
if (key)
|
775
|
+
{
|
776
|
+
fieldAdapter* begin = &m_fields[0], *cur = &m_fields[0],
|
777
|
+
*end = &m_fields[lastIndex];
|
778
|
+
char tmpOpr = (lastIndex != req.logicalCount) ? end->m_fd->opr : 0;
|
779
|
+
std::sort(begin, end);
|
780
|
+
bool flag = true;
|
781
|
+
while (cur != end)
|
782
|
+
{
|
783
|
+
cur->m_fd->opr = 1; // and
|
784
|
+
if (flag && cur->m_judgeType == 2)
|
785
|
+
cur->m_judge = true;
|
786
|
+
else
|
787
|
+
flag = false;
|
788
|
+
++cur;
|
789
|
+
}
|
790
|
+
|
791
|
+
// if first logic is first segmnet then first logic can judge.
|
792
|
+
if ((begin->m_keySeg == 1) && begin->m_judgeType)
|
793
|
+
begin->m_judge = true;
|
794
|
+
|
795
|
+
if (lastIndex == req.logicalCount)
|
796
|
+
--end;
|
797
|
+
end->m_fd->opr = tmpOpr;
|
798
|
+
}
|
799
|
+
for (int i = 0; i < req.logicalCount - 1; ++i)
|
800
|
+
m_fields[i].m_next = &m_fields[i + 1];
|
801
|
+
}
|
802
|
+
|
803
|
+
int match(const char* record, bool typeNext) const
|
804
|
+
{
|
805
|
+
return m_fields[0].match(record, typeNext);
|
806
|
+
}
|
688
807
|
};
|
689
808
|
|
690
809
|
class resultWriter
|
691
810
|
{
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
else
|
756
|
-
return STATUS_BUFFERTOOSMALL;
|
757
|
-
}
|
758
|
-
}
|
759
|
-
}
|
760
|
-
//write recLength;
|
761
|
-
*((unsigned short*)(m_buf + recLenPos)) = recLen;
|
762
|
-
return 0;
|
763
|
-
}
|
811
|
+
netsvc::server::netWriter* m_nw;
|
812
|
+
extResultDef* m_def;
|
813
|
+
bool m_noBookmark;
|
814
|
+
|
815
|
+
short doWrite(position* pos, unsigned int bookmark)
|
816
|
+
{
|
817
|
+
// write recLength space;
|
818
|
+
unsigned short recLen = 0;
|
819
|
+
unsigned short* recLenPos = (unsigned short*)m_nw->curPtr();
|
820
|
+
m_nw->asyncWrite((const char*)&recLen, 2);
|
821
|
+
|
822
|
+
// write bookmark
|
823
|
+
if (!m_noBookmark)
|
824
|
+
m_nw->asyncWrite((const char*)&bookmark, 4);
|
825
|
+
|
826
|
+
// if pos ==NULL , that is not found record in a TD_KEY_SEEK_MULTI
|
827
|
+
// operation
|
828
|
+
// and bookmark has error code also STATUS_NOT_FOUND_TI
|
829
|
+
// in the client, fieldCount > 0 buf recLen=0 then this pattern
|
830
|
+
if (pos)
|
831
|
+
{
|
832
|
+
if ((m_def->fieldCount == 1) &&
|
833
|
+
(m_def->field[0].len >= pos->recordLenCl()))
|
834
|
+
{ // write whole row
|
835
|
+
int len = pos->recordPackCopy(m_nw->curPtr(),
|
836
|
+
(uint)m_nw->bufferSpace());
|
837
|
+
if (len == 0)
|
838
|
+
return STATUS_BUFFERTOOSMALL;
|
839
|
+
if (!m_nw->asyncWrite(NULL, len,
|
840
|
+
netsvc::server::netWriter::curSeekOnly))
|
841
|
+
return STATUS_BUFFERTOOSMALL;
|
842
|
+
recLen += len;
|
843
|
+
}
|
844
|
+
else
|
845
|
+
{
|
846
|
+
// write each fields by field num.
|
847
|
+
for (int i = 0; i < m_def->fieldCount; i++)
|
848
|
+
{
|
849
|
+
resultField& fd = m_def->field[i];
|
850
|
+
if (m_nw->bufferSpace() > fd.len)
|
851
|
+
{
|
852
|
+
uint len = pos->fieldPackCopy(
|
853
|
+
(unsigned char*)m_nw->curPtr(), fd.fieldNum);
|
854
|
+
m_nw->asyncWrite(
|
855
|
+
NULL, len, netsvc::server::netWriter::curSeekOnly);
|
856
|
+
recLen += len;
|
857
|
+
if (pos->isBlobField(&fd))
|
858
|
+
pos->addBlobBuffer(fd.fieldNum);
|
859
|
+
}
|
860
|
+
else
|
861
|
+
return STATUS_BUFFERTOOSMALL;
|
862
|
+
}
|
863
|
+
}
|
864
|
+
}
|
865
|
+
|
866
|
+
// write recLength;
|
867
|
+
*recLenPos = recLen;
|
868
|
+
m_nw->asyncWrite(NULL, 0, netsvc::server::netWriter::netwrite);
|
869
|
+
// rowCount
|
870
|
+
m_nw->incremetRows();
|
871
|
+
return 0;
|
872
|
+
}
|
873
|
+
|
764
874
|
public:
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
const char* resultBuffer(){return m_buf;}
|
875
|
+
resultWriter(netsvc::server::netWriter* nw, extResultDef* def,
|
876
|
+
bool noBookmark)
|
877
|
+
: m_nw(nw), m_def(def), m_noBookmark(noBookmark)
|
878
|
+
{
|
879
|
+
}
|
880
|
+
|
881
|
+
short write(position* pos, unsigned int bookmark)
|
882
|
+
{
|
883
|
+
return doWrite(pos, bookmark);
|
884
|
+
}
|
885
|
+
inline unsigned int end()
|
886
|
+
{
|
887
|
+
m_nw->asyncWrite(NULL, 0, netsvc::server::netWriter::writeEnd);
|
888
|
+
return m_nw->resultLen();
|
889
|
+
}
|
890
|
+
|
891
|
+
const char* resultBuffer() { return m_nw->ptr(); }
|
784
892
|
};
|
785
893
|
|
786
|
-
|
787
894
|
class ReadRecordsHandler : public engine::mysql::IReadRecordsHandler
|
788
895
|
{
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
896
|
+
boost::shared_ptr<resultWriter> m_writer;
|
897
|
+
extRequest* m_req;
|
898
|
+
extResultDef* m_resultDef;
|
899
|
+
position m_position;
|
900
|
+
fields m_fields;
|
901
|
+
engine::mysql::fieldBitmap bm;
|
902
|
+
bool m_seeksMode;
|
794
903
|
|
795
904
|
public:
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
905
|
+
short begin(engine::mysql::table* tb, extRequest* req, bool fieldCache,
|
906
|
+
netsvc::server::netWriter* nw, bool forword, bool noBookmark,
|
907
|
+
bool seeksMode)
|
908
|
+
{
|
909
|
+
short ret = 0;
|
910
|
+
m_seeksMode = seeksMode;
|
911
|
+
m_position.setTable(tb);
|
912
|
+
m_req = req;
|
913
|
+
m_resultDef = seeksMode ? ((extRequestSeeks*)m_req)->resultDef()
|
914
|
+
: m_req->resultDef();
|
915
|
+
if (fieldCache)
|
916
|
+
{
|
917
|
+
const KEY* key = NULL;
|
918
|
+
if (tb->keyNum() >= 0)
|
919
|
+
key = &tb->keyDef(tb->keyNum());
|
920
|
+
m_fields.init(*m_req, m_position, key, forword);
|
921
|
+
}
|
922
|
+
if ((m_resultDef->fieldCount > 1) ||
|
923
|
+
((m_resultDef->fieldCount == 1) &&
|
924
|
+
(m_resultDef->field[0].len < m_position.recordLenCl())))
|
925
|
+
ret = convResultPosToFieldNum(tb, noBookmark, seeksMode);
|
926
|
+
|
927
|
+
nw->beginExt(tb->blobFields() != 0);
|
928
|
+
m_writer.reset(new resultWriter(nw, m_resultDef, noBookmark));
|
929
|
+
// DEBUG_RECORDS_BEGIN(m_resultDef, m_req)
|
930
|
+
|
931
|
+
return ret;
|
932
|
+
}
|
933
|
+
|
934
|
+
// TODO This convert is move to client. but legacy app is need this
|
935
|
+
short convResultPosToFieldNum(engine::mysql::table* tb, bool noBookmark,
|
936
|
+
bool seeksMode)
|
937
|
+
{
|
938
|
+
int blobs = 0;
|
939
|
+
bm.setTable(tb);
|
940
|
+
for (int i = 0; i < m_resultDef->fieldCount; i++)
|
941
|
+
{
|
942
|
+
resultField& fd = m_resultDef->field[i];
|
943
|
+
int num = m_position.getFieldNumByPos(fd.pos);
|
944
|
+
if (num == -1)
|
945
|
+
return STATUS_INVALID_FIELD_OFFSET;
|
946
|
+
fd.fieldNum = num;
|
947
|
+
bm.setReadBitmap(num);
|
948
|
+
if (m_position.isBlobField(&fd))
|
949
|
+
++blobs;
|
950
|
+
}
|
951
|
+
|
952
|
+
if (!seeksMode)
|
953
|
+
{
|
954
|
+
logicalField* fd = &m_req->field;
|
955
|
+
for (int i = 0; i < m_req->logicalCount; ++i)
|
956
|
+
{
|
957
|
+
bm.setReadBitmap(m_position.getFieldNumByPos(fd->pos));
|
958
|
+
fd = fd->next();
|
959
|
+
}
|
960
|
+
}
|
961
|
+
else
|
962
|
+
{
|
963
|
+
const KEY* key = &tb->keyDef(tb->keyNum());
|
964
|
+
if (key)
|
965
|
+
{
|
966
|
+
int sgi = 0;
|
967
|
+
int segments = std::min<uint>(MAX_KEY_SEGMENT,
|
968
|
+
key->user_defined_key_parts);
|
969
|
+
while (sgi < segments)
|
970
|
+
{
|
971
|
+
bm.setReadBitmap(key->key_part[sgi].field->field_index);
|
972
|
+
++sgi;
|
973
|
+
}
|
974
|
+
}
|
975
|
+
}
|
976
|
+
|
977
|
+
// if need bookmark , add primary key fields
|
978
|
+
if (!noBookmark)
|
979
|
+
{
|
980
|
+
const KEY* key = tb->primaryKey();
|
981
|
+
if (key)
|
982
|
+
{
|
983
|
+
int sgi = 0;
|
984
|
+
int segments = std::min<uint>(MAX_KEY_SEGMENT,
|
985
|
+
key->user_defined_key_parts);
|
986
|
+
while (sgi < segments)
|
987
|
+
{
|
988
|
+
bm.setReadBitmap(key->key_part[sgi].field->field_index);
|
989
|
+
++sgi;
|
990
|
+
}
|
991
|
+
}
|
992
|
+
}
|
993
|
+
|
994
|
+
tb->indexInit();
|
995
|
+
m_position.setBlobFieldCount(blobs);
|
996
|
+
return 0;
|
997
|
+
}
|
998
|
+
|
999
|
+
unsigned int end()
|
1000
|
+
{
|
1001
|
+
unsigned int len = m_writer->end();
|
1002
|
+
// DEBUG_RECORDS_END(m_writer.get())
|
1003
|
+
m_writer.reset();
|
1004
|
+
bm.setTable(NULL);
|
1005
|
+
return len;
|
1006
|
+
}
|
1007
|
+
|
1008
|
+
int match(bool typeNext) const
|
1009
|
+
{
|
1010
|
+
if (m_req->logicalCount)
|
1011
|
+
return m_fields.match(m_position.record(), typeNext);
|
1012
|
+
return REC_MACTH;
|
1013
|
+
}
|
1014
|
+
|
1015
|
+
short write(const unsigned char* bmPtr,
|
1016
|
+
unsigned int bmlen /*, short stat=0*/)
|
1017
|
+
{
|
1018
|
+
unsigned int bookmark = 0;
|
1019
|
+
// if bmPtr ==NULL , that is not found record in a TD_KEY_SEEK_MULTI
|
1020
|
+
// operation
|
1021
|
+
// and set error code to bookmark also STATUS_NOT_FOUND_TI
|
1022
|
+
if (bmPtr == NULL)
|
1023
|
+
{
|
1024
|
+
// bookmark = stat;
|
1025
|
+
return m_writer->write(NULL, bookmark);
|
1026
|
+
}
|
1027
|
+
else
|
1028
|
+
{
|
1029
|
+
switch (bmlen)
|
1030
|
+
{
|
1031
|
+
case 4:
|
1032
|
+
bookmark = *((unsigned int*)bmPtr);
|
1033
|
+
break;
|
1034
|
+
case 2:
|
1035
|
+
bookmark = *((unsigned short*)bmPtr);
|
1036
|
+
break;
|
1037
|
+
case 3:
|
1038
|
+
bookmark = *((unsigned int*)bmPtr) & 0x0FFFFFF;
|
1039
|
+
break;
|
1040
|
+
case 1:
|
1041
|
+
bookmark = *((unsigned short*)bmPtr) & 0x0FF;
|
1042
|
+
break;
|
1043
|
+
}
|
1044
|
+
return m_writer->write(&m_position, bookmark);
|
1045
|
+
}
|
1046
|
+
}
|
1047
|
+
unsigned short rejectCount() const { return m_req->rejectCount; };
|
1048
|
+
unsigned short maxRows() const { return m_resultDef->maxRows; };
|
883
1049
|
};
|
884
1050
|
|
885
|
-
}//namespace mysql
|
886
|
-
}//namespace protocol
|
887
|
-
}//namespace db
|
888
|
-
}//namespace tdap
|
889
|
-
}//namespace bzs
|
1051
|
+
} // namespace mysql
|
1052
|
+
} // namespace protocol
|
1053
|
+
} // namespace db
|
1054
|
+
} // namespace tdap
|
1055
|
+
} // namespace bzs
|
890
1056
|
|
891
|
-
#endif //BZS_DB_PROTOCOL_TDAP_MYSQL_RECORDSETREADER_H
|
1057
|
+
#endif // BZS_DB_PROTOCOL_TDAP_MYSQL_RECORDSETREADER_H
|