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
@@ -16,9 +16,6 @@
|
|
16
16
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
17
17
|
02111-1307, USA.
|
18
18
|
================================================================= */
|
19
|
-
#include <bzs/env/tstring.h>
|
20
|
-
#pragma hdrstop
|
21
|
-
|
22
19
|
#include "dbDef.h"
|
23
20
|
#include "database.h"
|
24
21
|
#include <bzs/rtl/strtrim.h>
|
@@ -42,60 +39,64 @@ namespace tdap
|
|
42
39
|
namespace client
|
43
40
|
{
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
static const
|
42
|
+
#define FORMAT_VERSON_BTRV_DEF 0
|
43
|
+
#define FORMAT_VERSON_CURRENT 1
|
44
|
+
|
45
|
+
static const _TCHAR BDFFORMAT_VERSION[] = _T("2.000.00");
|
46
|
+
static const _TCHAR ow0[11] = { 46, 46, 83, 67, 46, 46, 46, 46, 93, 4, 0 };
|
47
|
+
static const _TCHAR ow1[11] = { 46, 46, 83, 67, 46, 46, 46, 46, 66, 5, 0 };
|
48
|
+
static const _TCHAR ow2[11] = { 46, 46, 83, 67, 46, 46, 46, 46, -44, 5, 0 };
|
49
49
|
using namespace bzs::rtl;
|
50
50
|
|
51
51
|
class ownerNameSetter : public nstable
|
52
52
|
{
|
53
|
-
|
54
|
-
|
53
|
+
void onReadAfter(){};
|
54
|
+
void writeRecordData(){};
|
55
|
+
|
55
56
|
public:
|
56
|
-
|
57
|
-
|
57
|
+
ownerNameSetter(nsdatabase* pbe) : nstable(pbe){};
|
58
|
+
using nstable::open;
|
58
59
|
};
|
59
60
|
|
60
61
|
static const int BDFMAXBUFFER = 32384;
|
61
62
|
|
62
63
|
struct dbdimple
|
63
64
|
{
|
65
|
+
tabledef* tableDefs[TABLE_NUM_TMP + 1];
|
64
66
|
char keybuf[128];
|
65
67
|
tabledef* bdf;
|
66
|
-
|
67
|
-
bool noWriteMode;
|
68
|
-
short deftype;
|
69
|
-
_TCHAR userName[20];
|
70
|
-
tabledef* tableDefs[TABLE_NUM_TMP+1];
|
71
|
-
_TCHAR version[9];
|
68
|
+
void* relateData;
|
72
69
|
ushort_td maxid;
|
73
70
|
short tableCount;
|
74
|
-
void* relateData;
|
75
71
|
short openMode;
|
72
|
+
short deftype;
|
73
|
+
_TCHAR userName[20];
|
74
|
+
int bdfLen;
|
75
|
+
_TCHAR version[9];
|
76
|
+
bool noWriteMode;
|
76
77
|
|
77
|
-
dbdimple()
|
78
|
-
|
78
|
+
dbdimple()
|
79
|
+
: bdf(NULL), relateData(NULL), maxid(0), tableCount(0), openMode(1),
|
80
|
+
deftype(TYPE_SCHEMA_BDF), bdfLen(BDFMAXBUFFER), noWriteMode(false)
|
79
81
|
{
|
80
|
-
memset(tableDefs, 0, (TABLE_NUM_TMP+1)*sizeof(tabledef*));
|
82
|
+
memset(tableDefs, 0, (TABLE_NUM_TMP + 1) * sizeof(tabledef*));
|
81
83
|
_tcscpy(version, (const _TCHAR*)BDFFORMAT_VERSION);
|
82
84
|
}
|
83
85
|
};
|
84
86
|
|
85
|
-
dbdef::dbdef(nsdatabase
|
87
|
+
dbdef::dbdef(nsdatabase* pbe, short DefType) : nstable(pbe)
|
86
88
|
{
|
87
89
|
m_impl = new dbdimple();
|
88
90
|
m_impl->deftype = DefType;
|
89
91
|
m_keybuflen = 128;
|
90
92
|
m_keybuf = &m_impl->keybuf[0];
|
91
|
-
|
92
|
-
|
93
|
+
setShared();
|
93
94
|
}
|
94
95
|
|
95
|
-
dbdef::~dbdef()
|
96
|
+
dbdef::~dbdef()
|
96
97
|
{
|
97
|
-
|
98
|
-
|
98
|
+
if (m_impl->bdf)
|
99
|
+
free(m_impl->bdf);
|
99
100
|
|
100
101
|
for (int i = 0; i <= m_impl->tableCount; i++)
|
101
102
|
{
|
@@ -107,20 +108,38 @@ dbdef::~dbdef()
|
|
107
108
|
free(m_impl->tableDefs[TABLE_NUM_TMP]);
|
108
109
|
if (m_impl->relateData)
|
109
110
|
free(m_impl->relateData);
|
110
|
-
|
111
|
+
delete m_impl;
|
111
112
|
}
|
112
113
|
|
113
|
-
void dbdef::setDefType(short defType)
|
114
|
+
void dbdef::setDefType(short defType)
|
115
|
+
{
|
116
|
+
m_impl->deftype = defType;
|
117
|
+
}
|
114
118
|
|
115
|
-
short dbdef::tableCount() const
|
119
|
+
short dbdef::tableCount() const
|
120
|
+
{
|
121
|
+
return m_impl->tableCount;
|
122
|
+
}
|
116
123
|
|
117
|
-
void* dbdef::relateData() const
|
124
|
+
void* dbdef::relateData() const
|
125
|
+
{
|
126
|
+
return m_impl->relateData;
|
127
|
+
}
|
118
128
|
|
119
|
-
short dbdef::openMode() const
|
129
|
+
short dbdef::openMode() const
|
130
|
+
{
|
131
|
+
return m_impl->openMode;
|
132
|
+
}
|
120
133
|
|
121
|
-
int dbdef::version() const
|
134
|
+
int dbdef::version() const
|
135
|
+
{
|
136
|
+
return m_impl->version[7] - '0';
|
137
|
+
};
|
122
138
|
|
123
|
-
void dbdef::setVersion(int v)
|
139
|
+
void dbdef::setVersion(int v)
|
140
|
+
{
|
141
|
+
m_impl->version[7] = (char)v;
|
142
|
+
}
|
124
143
|
|
125
144
|
void* dbdef::allocRelateData(int size)
|
126
145
|
{
|
@@ -149,12 +168,12 @@ void dbdef::moveById(short id)
|
|
149
168
|
else
|
150
169
|
break;
|
151
170
|
}
|
152
|
-
|
153
171
|
}
|
154
172
|
|
155
173
|
bool dbdef::resizeReadBuf(void)
|
156
174
|
{
|
157
|
-
m_impl->bdf =
|
175
|
+
m_impl->bdf =
|
176
|
+
(tabledef*)realloc(m_impl->bdf, m_impl->bdfLen + BDFMAXBUFFER);
|
158
177
|
if (m_impl->bdf == NULL)
|
159
178
|
{
|
160
179
|
m_stat = STATUS_CANT_ALLOC_MEMORY;
|
@@ -167,24 +186,24 @@ bool dbdef::resizeReadBuf(void)
|
|
167
186
|
keydef* dbdef::getKeyDef(tabledef* p)
|
168
187
|
{
|
169
188
|
// keydefPos = size of tabledef �{ size of fielddef x number
|
170
|
-
return (keydef*)((char*)
|
189
|
+
return (keydef*)((char*)p + sizeof(tabledef) +
|
190
|
+
(p->fieldCount * sizeof(fielddef)));
|
171
191
|
}
|
172
192
|
|
173
193
|
fielddef* dbdef::getFieldDef(tabledef* p)
|
174
194
|
{
|
175
195
|
|
176
|
-
return (fielddef*)((char*)
|
196
|
+
return (fielddef*)((char*)p + sizeof(tabledef));
|
177
197
|
}
|
178
198
|
|
179
199
|
void dbdef::setRecordLen(short TableIndex)
|
180
200
|
{
|
181
|
-
|
201
|
+
tabledef* td = tableDefs(TableIndex);
|
202
|
+
td->maxRecordLen = getRecordLen(TableIndex);
|
182
203
|
|
183
204
|
// If valible length then specifing fixed length.
|
184
|
-
if ((
|
185
|
-
|
186
|
-
tableDefs(TableIndex)->fixedRecordLen = tableDefs(TableIndex)->maxRecordLen;
|
187
|
-
|
205
|
+
if ((td->fixedRecordLen == 0) || (td->flags.bit0 == false))
|
206
|
+
td->fixedRecordLen = td->maxRecordLen;
|
188
207
|
}
|
189
208
|
|
190
209
|
void dbdef::setCodePage(tabledef* td)
|
@@ -205,16 +224,12 @@ void dbdef::updateTableDef(short TableIndex, bool forPsqlDdf)
|
|
205
224
|
{
|
206
225
|
m_stat = STATUS_SUCCESS;
|
207
226
|
tabledef* td = tableDefs(TableIndex);
|
208
|
-
short i
|
209
|
-
short j;
|
210
|
-
short ret;
|
211
|
-
short Fnum;
|
227
|
+
short i, j, ret, Fnum;
|
212
228
|
uchar_td type;
|
213
229
|
|
214
230
|
td->optionFlags.bitA = false; // reset valiable type
|
215
231
|
|
216
|
-
|
217
|
-
for (; i >= 0; --i)
|
232
|
+
for (i = 0; i < td->fieldCount; ++i)
|
218
233
|
{
|
219
234
|
ret = fieldNumByName(TableIndex, td->fieldDefs[i].name());
|
220
235
|
if ((ret != -1) && (ret != i))
|
@@ -224,6 +239,10 @@ void dbdef::updateTableDef(short TableIndex, bool forPsqlDdf)
|
|
224
239
|
}
|
225
240
|
// Check field length.
|
226
241
|
type = td->fieldDefs[i].type;
|
242
|
+
|
243
|
+
// reset update indicator
|
244
|
+
td->fieldDefs[i].enableFlags.bitE = false;
|
245
|
+
|
227
246
|
ret = validLen(type, td->fieldDefs[i].len);
|
228
247
|
if (!ret)
|
229
248
|
{
|
@@ -233,26 +252,27 @@ void dbdef::updateTableDef(short TableIndex, bool forPsqlDdf)
|
|
233
252
|
// Note or Lvar type must be the last of fields.
|
234
253
|
if ((type == ft_note) || (type == ft_lvar))
|
235
254
|
{
|
236
|
-
if (i != td->fieldCount - 1)
|
255
|
+
if (i != td->fieldCount - 1)
|
256
|
+
{
|
237
257
|
m_stat = STATUS_LVAR_NOTE_NOT_LAST;
|
238
258
|
return;
|
239
259
|
}
|
240
260
|
}
|
241
261
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
if ((type == ft_myblob) || (type == ft_mytext))
|
247
|
-
td->optionFlags.bitB = true;
|
248
|
-
|
249
|
-
// If valiable length then cannot use blob.
|
250
|
-
if (td->flags.bit0 && td->optionFlags.bitB)
|
262
|
+
bool flag =
|
263
|
+
(td->flags.bit0 == true) && (i == (short)(td->fieldCount - 1));
|
264
|
+
if (flag && (type != ft_myvarbinary) && (type != ft_mywvarbinary) &&
|
265
|
+
(type != ft_note) && (type != ft_lvar))
|
251
266
|
{
|
252
|
-
m_stat =
|
267
|
+
m_stat = STATUS_INVALID_VARIABLETABLE;
|
253
268
|
return;
|
254
269
|
}
|
255
|
-
|
270
|
+
if ((type == ft_myvarchar) || (type == ft_mywvarchar) ||
|
271
|
+
(type == ft_myvarbinary) || (type == ft_mywvarbinary) ||
|
272
|
+
(type == ft_myfixedbinary))
|
273
|
+
td->optionFlags.bitA = true;
|
274
|
+
if ((type == ft_myblob) || (type == ft_mytext))
|
275
|
+
td->optionFlags.bitB = true;
|
256
276
|
}
|
257
277
|
|
258
278
|
// Check invalid key type
|
@@ -301,13 +321,12 @@ void dbdef::updateTableDef(short TableIndex, bool forPsqlDdf)
|
|
301
321
|
m_pdata = td;
|
302
322
|
m_buflen = totalDefLength(TableIndex);
|
303
323
|
cacheFieldPos(td);
|
304
|
-
td->formatVersion =
|
324
|
+
td->formatVersion = FORMAT_VERSON_CURRENT;
|
305
325
|
update();
|
306
326
|
m_pdata = m_impl->bdf;
|
307
327
|
m_buflen = m_impl->bdfLen;
|
308
328
|
}
|
309
329
|
}
|
310
|
-
|
311
330
|
}
|
312
331
|
|
313
332
|
void dbdef::deleteTable(short TableIndex)
|
@@ -332,7 +351,6 @@ void dbdef::deleteTable(short TableIndex)
|
|
332
351
|
del();
|
333
352
|
m_pdata = m_impl->bdf;
|
334
353
|
m_buflen = m_impl->bdfLen;
|
335
|
-
|
336
354
|
}
|
337
355
|
}
|
338
356
|
if (m_stat == STATUS_SUCCESS)
|
@@ -340,7 +358,6 @@ void dbdef::deleteTable(short TableIndex)
|
|
340
358
|
free(tableDefs(TableIndex));
|
341
359
|
m_impl->tableDefs[TableIndex] = NULL;
|
342
360
|
}
|
343
|
-
|
344
361
|
}
|
345
362
|
|
346
363
|
void dbdef::renumberFieldNum(short TableIndex, short Index, short op)
|
@@ -389,7 +406,8 @@ bool dbdef::isUsedField(short TableIndex, short DeleteIndex)
|
|
389
406
|
void dbdef::deleteField(short TableIndex, short DeleteIndex)
|
390
407
|
{
|
391
408
|
m_stat = STATUS_SUCCESS;
|
392
|
-
if (isUsedField(TableIndex, DeleteIndex) == true)
|
409
|
+
if (isUsedField(TableIndex, DeleteIndex) == true)
|
410
|
+
{
|
393
411
|
m_stat = STATUS_USE_KEYFIELD;
|
394
412
|
return;
|
395
413
|
}
|
@@ -401,12 +419,12 @@ void dbdef::deleteField(short TableIndex, short DeleteIndex)
|
|
401
419
|
else
|
402
420
|
{
|
403
421
|
memmove(&td->fieldDefs[DeleteIndex], &td->fieldDefs[DeleteIndex + 1],
|
404
|
-
|
422
|
+
totalDefLength(TableIndex) + (char*)td -
|
423
|
+
(char*)&(td->fieldDefs[DeleteIndex + 1]));
|
405
424
|
}
|
406
425
|
td->fieldCount--;
|
407
426
|
td->keyDefs = getKeyDef(tableDefs(TableIndex));
|
408
427
|
updateTableDef(TableIndex);
|
409
|
-
|
410
428
|
}
|
411
429
|
|
412
430
|
void dbdef::deleteKey(short TableIndex, short DeleteIndex)
|
@@ -416,14 +434,18 @@ void dbdef::deleteKey(short TableIndex, short DeleteIndex)
|
|
416
434
|
if (DeleteIndex != td->keyCount - 1)
|
417
435
|
{
|
418
436
|
memmove(&td->keyDefs[DeleteIndex], &td->keyDefs[DeleteIndex + 1],
|
419
|
-
|
437
|
+
totalDefLength(TableIndex) + (char*)td -
|
438
|
+
(char*)&(td->keyDefs[DeleteIndex + 1]));
|
420
439
|
}
|
421
440
|
td->keyCount--;
|
422
|
-
if ((td->primaryKeyNum == DeleteIndex) ||
|
441
|
+
if ((td->primaryKeyNum == DeleteIndex) ||
|
442
|
+
(td->primaryKeyNum > td->keyCount - 1))
|
423
443
|
td->primaryKeyNum = -1;
|
424
|
-
if ((td->parentKeyNum == DeleteIndex) ||
|
444
|
+
if ((td->parentKeyNum == DeleteIndex) ||
|
445
|
+
(td->parentKeyNum > td->keyCount - 1))
|
425
446
|
td->parentKeyNum = -1;
|
426
|
-
if ((td->replicaKeyNum == DeleteIndex) ||
|
447
|
+
if ((td->replicaKeyNum == DeleteIndex) ||
|
448
|
+
(td->replicaKeyNum > td->keyCount - 1))
|
427
449
|
td->replicaKeyNum = -1;
|
428
450
|
|
429
451
|
updateTableDef(TableIndex);
|
@@ -453,7 +475,8 @@ void dbdef::insertTable(tabledef* TableDef)
|
|
453
475
|
m_stat = STATUS_TOO_MANY_FIELDS;
|
454
476
|
return;
|
455
477
|
}
|
456
|
-
m_impl->tableDefs[TableDef->id] =
|
478
|
+
m_impl->tableDefs[TableDef->id] =
|
479
|
+
(tabledef*)malloc(USHRT_MAX /* sizeof(tabledef) */);
|
457
480
|
if (m_impl->tableDefs[TableDef->id] == NULL)
|
458
481
|
{
|
459
482
|
m_stat = STATUS_CANT_ALLOC_MEMORY;
|
@@ -468,7 +491,7 @@ void dbdef::insertTable(tabledef* TableDef)
|
|
468
491
|
m_impl->tableCount = TableDef->id;
|
469
492
|
return;
|
470
493
|
}
|
471
|
-
TableDef->formatVersion =
|
494
|
+
TableDef->formatVersion = FORMAT_VERSON_CURRENT;
|
472
495
|
if (m_impl->deftype == TYPE_SCHEMA_DDF)
|
473
496
|
saveDDF(TableDef->id, 2);
|
474
497
|
else
|
@@ -478,6 +501,8 @@ void dbdef::insertTable(tabledef* TableDef)
|
|
478
501
|
|
479
502
|
memcpy(m_keybuf, &TableDef->id, 2);
|
480
503
|
m_buflen = sizeof(tabledef);
|
504
|
+
if (isUseTransactd())
|
505
|
+
m_impl->bdf->varSize = m_buflen - 4;
|
481
506
|
insert();
|
482
507
|
m_pdata = m_impl->bdf;
|
483
508
|
m_buflen = m_impl->bdfLen;
|
@@ -511,7 +536,6 @@ bool dbdef::resizeAt(short TableIndex, bool key)
|
|
511
536
|
memcpy(p, def, totalDefLength(TableIndex));
|
512
537
|
free(def);
|
513
538
|
m_impl->tableDefs[TableIndex] = def = (tabledef*)p;
|
514
|
-
|
515
539
|
}
|
516
540
|
else
|
517
541
|
{
|
@@ -530,13 +554,12 @@ keydef* dbdef::insertKey(short TableIndex, short InsertIndex)
|
|
530
554
|
if (resizeAt(TableIndex, true) == false)
|
531
555
|
return NULL;
|
532
556
|
|
533
|
-
|
534
557
|
if (InsertIndex < tableDefs(TableIndex)->keyCount)
|
535
558
|
{
|
536
559
|
memmove(&tableDefs(TableIndex)->keyDefs[InsertIndex + 1],
|
537
|
-
|
538
|
-
|
539
|
-
|
560
|
+
&tableDefs(TableIndex)->keyDefs[InsertIndex],
|
561
|
+
totalDefLength(TableIndex) + (char*)tableDefs(TableIndex) -
|
562
|
+
(char*)&(tableDefs(TableIndex)->keyDefs[InsertIndex]));
|
540
563
|
}
|
541
564
|
tableDefs(TableIndex)->keyCount++;
|
542
565
|
memset(&(tableDefs(TableIndex)->keyDefs[InsertIndex]), 0, sizeof(keydef));
|
@@ -557,8 +580,10 @@ fielddef* dbdef::insertField(short TableIndex, short InsertIndex)
|
|
557
580
|
if ((InsertIndex < td->fieldCount) || (td->keyCount > 0))
|
558
581
|
{
|
559
582
|
|
560
|
-
memmove(&(td->fieldDefs[InsertIndex + 1]),
|
561
|
-
|
583
|
+
memmove(&(td->fieldDefs[InsertIndex + 1]),
|
584
|
+
&(td->fieldDefs[InsertIndex]),
|
585
|
+
totalDefLength(TableIndex) + (char*)td -
|
586
|
+
(char*)&(td->fieldDefs[InsertIndex]));
|
562
587
|
}
|
563
588
|
td->fieldCount++;
|
564
589
|
td->keyDefs = getKeyDef(td);
|
@@ -567,61 +592,85 @@ fielddef* dbdef::insertField(short TableIndex, short InsertIndex)
|
|
567
592
|
setRecordLen(TableIndex);
|
568
593
|
fielddef* fd = &(td->fieldDefs[InsertIndex]);
|
569
594
|
fd->setCharsetIndex(td->charsetIndex);
|
595
|
+
fd->setSchemaCodePage(td->schemaCodePage);
|
570
596
|
return fd;
|
571
597
|
}
|
572
598
|
|
573
599
|
int dbdef::totalDefLength(short TableIndex)
|
574
600
|
{
|
575
|
-
|
576
|
-
|
601
|
+
tabledef* td = tableDefs(TableIndex);
|
602
|
+
int len = (int)(sizeof(tabledef) + (sizeof(fielddef) * td->fieldCount) +
|
603
|
+
(sizeof(keydef) * td->keyCount));
|
604
|
+
if (isUseTransactd())
|
605
|
+
td->varSize = len - 4;
|
606
|
+
return len;
|
577
607
|
}
|
578
608
|
|
579
|
-
inline fielddef_t_my& dbdef::convert(fielddef_t_my& fd_my,
|
609
|
+
inline fielddef_t_my& dbdef::convert(fielddef_t_my& fd_my,
|
610
|
+
const fielddef_t_pv& fd_pv)
|
580
611
|
{
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
612
|
+
memset(&fd_my, 0, sizeof(fd_my));
|
613
|
+
strcpy(fd_my.m_name, fd_pv.m_name);
|
614
|
+
void* dest = (char*)&fd_my + sizeof(fd_my.m_name);
|
615
|
+
const void* src = (char*)&fd_pv + sizeof(fd_pv.m_name);
|
616
|
+
size_t size = sizeof(fd_my) - sizeof(fd_my.m_name);
|
617
|
+
memcpy(dest, src, size);
|
618
|
+
return fd_my;
|
588
619
|
}
|
589
620
|
|
590
|
-
|
621
|
+
inline int fixVariableLenBug(bool isUseTransactd, tabledef* src, size_t size)
|
591
622
|
{
|
592
|
-
|
593
|
-
|
623
|
+
if (isUseTransactd)
|
624
|
+
{ // A Transactd server format changed to nosupport FIXED_PLUS_VARIABLELEN
|
625
|
+
if (src->pageSize + 4 == (int)size)
|
626
|
+
{ // This is a chagned server
|
627
|
+
if (src->preAlloc &&
|
628
|
+
((src->preAlloc % 512 == 0) || (src->fieldCount > 255) ||
|
629
|
+
(src->keyCount > 127) || (src->fieldCount == 0)))
|
630
|
+
{
|
631
|
+
// memmove(((char*)src)+4, ((char*)src)+6, src->pageSize-2);
|
632
|
+
memmove(((char*)src) + 2, ((char*)src) + 4, src->pageSize);
|
633
|
+
size -= 2;
|
634
|
+
}
|
635
|
+
}
|
636
|
+
}
|
637
|
+
return (int)size;
|
638
|
+
}
|
594
639
|
|
640
|
+
size_t getNewVersionSize(tabledef* src)
|
641
|
+
{
|
642
|
+
return src->fieldCount * sizeof(fielddef) + sizeof(tabledef) +
|
643
|
+
src->keyCount * sizeof(keydef) + 1;
|
595
644
|
}
|
596
645
|
|
597
646
|
void dbdef::tableDefCopy(tabledef* dest, tabledef* src, size_t size)
|
598
647
|
{
|
599
|
-
|
648
|
+
|
649
|
+
if (src->formatVersion == FORMAT_VERSON_BTRV_DEF)
|
600
650
|
{
|
601
651
|
size_t len = 0;
|
602
652
|
memcpy(dest, src, sizeof(tabledef));
|
603
653
|
len += sizeof(tabledef);
|
604
654
|
fielddef_t_my* fd = (fielddef_t_my*)dbdef::getFieldDef(dest);
|
605
655
|
fielddef_t_pv* src_fd = (fielddef_t_pv*)dbdef::getFieldDef(src);
|
606
|
-
for (int i=0;i<dest->fieldCount
|
656
|
+
for (int i = 0; i < dest->fieldCount; ++i)
|
607
657
|
{
|
608
|
-
convert(*fd
|
658
|
+
convert(*fd, *src_fd);
|
609
659
|
len += sizeof(fielddef_t_pv);
|
610
660
|
++fd;
|
611
661
|
++src_fd;
|
612
662
|
}
|
613
663
|
memcpy(fd, src_fd, size - len);
|
614
|
-
dest->formatVersion =
|
664
|
+
dest->formatVersion = FORMAT_VERSON_CURRENT;
|
615
665
|
}
|
616
666
|
else
|
617
667
|
memcpy(dest, src, size);
|
618
|
-
|
619
668
|
}
|
620
669
|
|
621
670
|
tabledef** dbdef::tableDefPtr(int index)
|
622
671
|
{
|
623
|
-
|
624
|
-
|
672
|
+
tableDefs(index);
|
673
|
+
return &m_impl->tableDefs[index];
|
625
674
|
}
|
626
675
|
|
627
676
|
#pragma warn -8004
|
@@ -664,8 +713,11 @@ tabledef* dbdef::tableDefs(int index)
|
|
664
713
|
m_stat = 0;
|
665
714
|
return NULL;
|
666
715
|
}
|
716
|
+
m_datalen =
|
717
|
+
fixVariableLenBug(isUseTransactd(), (tabledef*)m_pdata, m_datalen);
|
667
718
|
|
668
|
-
m_impl->tableDefs[index] = def =
|
719
|
+
m_impl->tableDefs[index] = def =
|
720
|
+
(tabledef*)malloc(getNewVersionSize((tabledef*)m_pdata));
|
669
721
|
|
670
722
|
if (def == NULL)
|
671
723
|
{
|
@@ -675,11 +727,9 @@ tabledef* dbdef::tableDefs(int index)
|
|
675
727
|
tableDefCopy(def, (tabledef*)m_pdata, m_datalen);
|
676
728
|
def->fieldDefs = getFieldDef(def);
|
677
729
|
def->keyDefs = getKeyDef(def);
|
678
|
-
|
730
|
+
def->autoIncExSpace = ((database*)nsdb())->defaultAutoIncSpace();
|
679
731
|
|
680
732
|
setCodePage(def);
|
681
|
-
|
682
|
-
|
683
733
|
}
|
684
734
|
else if (def == (tabledef*)-1)
|
685
735
|
return NULL;
|
@@ -701,7 +751,7 @@ void dbdef::doOpen(const _TCHAR* FullPath, char_td mode, const _TCHAR* OnerName)
|
|
701
751
|
return;
|
702
752
|
}
|
703
753
|
|
704
|
-
//version check
|
754
|
+
// version check
|
705
755
|
m_impl->version[7] = '0';
|
706
756
|
nstable::doOpen(FullPath, mode, m_impl->version);
|
707
757
|
if (m_stat == STATUS_INVALID_OWNERNAME)
|
@@ -753,7 +803,7 @@ void dbdef::create(const _TCHAR* fullpath)
|
|
753
803
|
createDDF(fullpath);
|
754
804
|
return;
|
755
805
|
}
|
756
|
-
fileSpec
|
806
|
+
fileSpec* fs;
|
757
807
|
|
758
808
|
fs = (fileSpec*)malloc(512);
|
759
809
|
memset(fs, 512, 0x00);
|
@@ -762,17 +812,17 @@ void dbdef::create(const _TCHAR* fullpath)
|
|
762
812
|
fs->indexCount = 1;
|
763
813
|
fs->fileFlag.all = 1; // valiable length
|
764
814
|
fs->preAlloc = 10;
|
765
|
-
fs->keySpecs[0].keyPos = 1;
|
766
|
-
fs->keySpecs[0].keyLen = 2;
|
815
|
+
fs->keySpecs[0].keyPos = 1; // id
|
816
|
+
fs->keySpecs[0].keyLen = 2; // short
|
767
817
|
fs->keySpecs[0].keyFlag.all = 258; // changeable and extended key type
|
768
|
-
fs->keySpecs[0].keyType = 1;
|
818
|
+
fs->keySpecs[0].keyType = 1; // Integer
|
769
819
|
nsdb()->createTable(fs, 412, fullpath, 0);
|
770
820
|
free(fs);
|
771
821
|
if (nsdb()->stat() == 0)
|
772
822
|
{ // set owner name
|
773
823
|
ownerNameSetter* bao = new ownerNameSetter(nsdb());
|
774
824
|
bao->open(fullpath);
|
775
|
-
bao->setOwnerName((const _TCHAR*)
|
825
|
+
bao->setOwnerName((const _TCHAR*)BDFFORMAT_VERSION);
|
776
826
|
bao->release();
|
777
827
|
}
|
778
828
|
m_stat = nsdb()->stat();
|
@@ -788,13 +838,13 @@ ushort_td dbdef::getRecordLen(short TableIndex)
|
|
788
838
|
{
|
789
839
|
ushort_td ret = 0;
|
790
840
|
short i;
|
791
|
-
|
792
|
-
|
793
|
-
|
841
|
+
tabledef* td = tableDefs(TableIndex);
|
842
|
+
for (i = 0; i < td->fieldCount; i++)
|
843
|
+
ret += td->fieldDefs[i].len + td->fieldDefs[i].varLenBytes();
|
794
844
|
return ret;
|
795
845
|
}
|
796
846
|
|
797
|
-
ushort_td dbdef::getFieldPosition(tabledef
|
847
|
+
ushort_td dbdef::getFieldPosition(tabledef* TableDef, short FieldNum)
|
798
848
|
{
|
799
849
|
short i;
|
800
850
|
ushort_td pos = 1;
|
@@ -809,7 +859,7 @@ void dbdef::getFileSpec(fileSpec* fs, short TableIndex)
|
|
809
859
|
keydef* KeyDef;
|
810
860
|
short i, j, k = 0;
|
811
861
|
short FieldNum;
|
812
|
-
tabledef
|
862
|
+
tabledef* TableDef = tableDefs(TableIndex);
|
813
863
|
fs->recLen = TableDef->fixedRecordLen;
|
814
864
|
fs->pageSize = TableDef->pageSize;
|
815
865
|
fs->indexCount = TableDef->keyCount;
|
@@ -843,7 +893,8 @@ void dbdef::getFileSpec(fileSpec* fs, short TableIndex)
|
|
843
893
|
if (fs->fileFlag.bitA == true)
|
844
894
|
ks->keyNo = KeyDef->keyNumber;
|
845
895
|
else
|
846
|
-
ks->keyNo = 0;
|
896
|
+
ks->keyNo = 0;
|
897
|
+
;
|
847
898
|
ks->acsNo = 0;
|
848
899
|
k++;
|
849
900
|
}
|
@@ -888,21 +939,23 @@ void dbdef::renumberTable(short OldIndex, short NewIndex)
|
|
888
939
|
}
|
889
940
|
}
|
890
941
|
|
891
|
-
void dbdef::cacheFieldPos(tabledef
|
942
|
+
void dbdef::cacheFieldPos(tabledef* TableDef)
|
892
943
|
{
|
893
944
|
|
894
945
|
short i;
|
895
946
|
for (i = 0; i < TableDef->fieldCount; i++)
|
896
|
-
TableDef->fieldDefs[i].pos =
|
947
|
+
TableDef->fieldDefs[i].pos =
|
948
|
+
(ushort_td)(getFieldPosition(TableDef, i) - 1);
|
897
949
|
}
|
898
950
|
|
899
951
|
short dbdef::fieldNumByViewNum(short TableIndex, short index)
|
900
952
|
{
|
901
953
|
short i;
|
902
|
-
tabledef
|
954
|
+
tabledef* TableDef = tableDefs(TableIndex);
|
903
955
|
for (i = 0; i < TableDef->fieldCount; i++)
|
904
956
|
{
|
905
|
-
if ((TableDef->fieldDefs[i].viewNum == index) &&
|
957
|
+
if ((TableDef->fieldDefs[i].viewNum == index) &&
|
958
|
+
(TableDef->fieldDefs[i].enableFlags.bit0))
|
906
959
|
return i;
|
907
960
|
}
|
908
961
|
return -1;
|
@@ -911,7 +964,7 @@ short dbdef::fieldNumByViewNum(short TableIndex, short index)
|
|
911
964
|
short dbdef::findKeynumByFieldNum(short TableIndex, short index)
|
912
965
|
{
|
913
966
|
short i;
|
914
|
-
tabledef
|
967
|
+
tabledef* TableDef = tableDefs(TableIndex);
|
915
968
|
|
916
969
|
for (i = 0; i < TableDef->keyCount; i++)
|
917
970
|
{
|
@@ -961,64 +1014,81 @@ uint_td dbdef::fieldValidLength(eFieldQuery query, uchar_td FieldType)
|
|
961
1014
|
switch (FieldType)
|
962
1015
|
{
|
963
1016
|
case ft_string:
|
964
|
-
case ft_mychar:
|
1017
|
+
case ft_mychar:
|
1018
|
+
minlen = 1;
|
965
1019
|
maxlen = 255;
|
966
1020
|
defaultlen = 1;
|
967
1021
|
break;
|
968
1022
|
case ft_lstring:
|
969
|
-
case ft_zstring:
|
1023
|
+
case ft_zstring:
|
1024
|
+
minlen = 2;
|
970
1025
|
maxlen = 255;
|
971
1026
|
defaultlen = 2;
|
972
1027
|
break;
|
973
1028
|
case ft_myvarchar:
|
974
|
-
case ft_myvarbinary:
|
975
|
-
|
1029
|
+
case ft_myvarbinary:
|
1030
|
+
minlen = 1;
|
1031
|
+
maxlen = 65535;
|
976
1032
|
defaultlen = 2;
|
977
1033
|
break;
|
978
1034
|
case ft_myblob:
|
979
|
-
case ft_mytext:
|
1035
|
+
case ft_mytext:
|
1036
|
+
minlen = 9;
|
980
1037
|
maxlen = 12;
|
981
1038
|
defaultlen = 1;
|
982
1039
|
break;
|
983
1040
|
case ft_mywchar:
|
984
|
-
case ft_wstring:
|
1041
|
+
case ft_wstring:
|
1042
|
+
minlen = 2;
|
985
1043
|
maxlen = 255;
|
986
1044
|
defaultlen = 2;
|
987
1045
|
break;
|
988
|
-
case ft_wzstring:
|
1046
|
+
case ft_wzstring:
|
1047
|
+
minlen = 3;
|
989
1048
|
maxlen = 255;
|
990
1049
|
defaultlen = 2;
|
991
1050
|
break;
|
992
1051
|
case ft_mywvarchar:
|
993
|
-
case ft_mywvarbinary:
|
994
|
-
|
1052
|
+
case ft_mywvarbinary:
|
1053
|
+
minlen = 1;
|
1054
|
+
maxlen = 65535;
|
995
1055
|
defaultlen = 3;
|
996
1056
|
break;
|
997
|
-
|
998
|
-
|
1057
|
+
case ft_myfixedbinary:
|
1058
|
+
minlen = 256;
|
1059
|
+
maxlen = 60000;
|
1060
|
+
defaultlen = 1024;
|
1061
|
+
break;
|
1062
|
+
case ft_mydate:
|
1063
|
+
minlen = 3;
|
999
1064
|
maxlen = 3;
|
1000
1065
|
defaultlen = 3;
|
1001
1066
|
break;
|
1002
|
-
case ft_integer:
|
1067
|
+
case ft_integer:
|
1068
|
+
minlen = 1;
|
1003
1069
|
maxlen = 8;
|
1004
1070
|
defaultlen = 2;
|
1005
1071
|
break;
|
1006
1072
|
case ft_bfloat:
|
1007
|
-
case ft_float:
|
1073
|
+
case ft_float:
|
1074
|
+
minlen = 4;
|
1008
1075
|
maxlen = 8;
|
1009
1076
|
defaultlen = 4;
|
1010
1077
|
break;
|
1011
1078
|
case ft_date:
|
1012
|
-
case ft_time:
|
1079
|
+
case ft_time:
|
1080
|
+
minlen = 4;
|
1013
1081
|
maxlen = 4;
|
1014
1082
|
defaultlen = 4;
|
1015
1083
|
break;
|
1016
|
-
case ft_mytime:
|
1084
|
+
case ft_mytime:
|
1085
|
+
minlen = 3;
|
1017
1086
|
maxlen = 6;
|
1018
1087
|
defaultlen = 4;
|
1019
1088
|
break;
|
1020
1089
|
case ft_money:
|
1021
|
-
case ft_decimal:
|
1090
|
+
case ft_decimal:
|
1091
|
+
minlen = 1;
|
1022
1092
|
maxlen = 10;
|
1023
1093
|
defaultlen = 6;
|
1024
1094
|
if (FieldType == 5)
|
@@ -1026,13 +1096,15 @@ uint_td dbdef::fieldValidLength(eFieldQuery query, uchar_td FieldType)
|
|
1026
1096
|
else
|
1027
1097
|
dec = 2;
|
1028
1098
|
break;
|
1029
|
-
case ft_logical:
|
1099
|
+
case ft_logical:
|
1100
|
+
minlen = 1;
|
1030
1101
|
maxlen = 2;
|
1031
1102
|
defaultlen = 2;
|
1032
1103
|
break;
|
1033
1104
|
case ft_numericsts:
|
1034
1105
|
case ft_numericsa:
|
1035
|
-
case ft_numeric:
|
1106
|
+
case ft_numeric:
|
1107
|
+
minlen = 1;
|
1036
1108
|
maxlen = 15;
|
1037
1109
|
defaultlen = 6;
|
1038
1110
|
dec = 0;
|
@@ -1040,72 +1112,84 @@ uint_td dbdef::fieldValidLength(eFieldQuery query, uchar_td FieldType)
|
|
1040
1112
|
minlen = 2;
|
1041
1113
|
break;
|
1042
1114
|
|
1043
|
-
case ft_note:
|
1115
|
+
case ft_note:
|
1116
|
+
minlen = 2;
|
1044
1117
|
maxlen = 32761;
|
1045
1118
|
defaultlen = 2;
|
1046
1119
|
break;
|
1047
|
-
case ft_lvar:
|
1120
|
+
case ft_lvar:
|
1121
|
+
minlen = 5;
|
1048
1122
|
maxlen = 32761;
|
1049
1123
|
defaultlen = 5;
|
1050
1124
|
break;
|
1051
|
-
case ft_uinteger:
|
1125
|
+
case ft_uinteger:
|
1126
|
+
minlen = 1;
|
1052
1127
|
maxlen = 8;
|
1053
1128
|
defaultlen = 2;
|
1054
1129
|
break;
|
1055
1130
|
case ft_autoIncUnsigned:
|
1056
|
-
case ft_autoinc:
|
1131
|
+
case ft_autoinc:
|
1132
|
+
minlen = 2;
|
1057
1133
|
maxlen = 8;
|
1058
1134
|
defaultlen = 4;
|
1059
1135
|
break;
|
1060
|
-
case ft_bit:
|
1136
|
+
case ft_bit:
|
1137
|
+
minlen = 1;
|
1061
1138
|
maxlen = 1;
|
1062
1139
|
defaultlen = 1;
|
1063
1140
|
break;
|
1064
1141
|
case ft_timestamp:
|
1065
|
-
case ft_currency:
|
1142
|
+
case ft_currency:
|
1143
|
+
minlen = 8;
|
1066
1144
|
maxlen = 8;
|
1067
1145
|
defaultlen = 8;
|
1068
1146
|
break;
|
1069
|
-
case ft_mytimestamp:
|
1147
|
+
case ft_mytimestamp:
|
1148
|
+
minlen = 4;
|
1070
1149
|
maxlen = 7;
|
1071
1150
|
defaultlen = 7;
|
1072
1151
|
break;
|
1073
|
-
case ft_mydatetime:
|
1152
|
+
case ft_mydatetime:
|
1153
|
+
minlen = 5;
|
1074
1154
|
maxlen = 8;
|
1075
1155
|
defaultlen = 5;
|
1076
1156
|
break;
|
1077
1157
|
|
1078
|
-
case ft_nullindicator:
|
1158
|
+
case ft_nullindicator:
|
1159
|
+
minlen = 0;
|
1079
1160
|
maxlen = 0;
|
1080
1161
|
defaultlen = 0;
|
1081
1162
|
}
|
1082
1163
|
switch (query)
|
1083
1164
|
{
|
1084
|
-
case eMinlen:
|
1085
|
-
|
1086
|
-
case
|
1087
|
-
|
1165
|
+
case eMinlen:
|
1166
|
+
return minlen;
|
1167
|
+
case eMaxlen:
|
1168
|
+
return maxlen;
|
1169
|
+
case eDefaultlen:
|
1170
|
+
return defaultlen;
|
1171
|
+
case eDecimals:
|
1172
|
+
return dec;
|
1088
1173
|
}
|
1089
1174
|
return 0;
|
1090
|
-
|
1091
1175
|
}
|
1092
1176
|
|
1093
1177
|
bool dbdef::validLen(uchar_td FieldType, uint_td FieldLen)
|
1094
1178
|
{ // return valid length of field by field type.
|
1095
|
-
if ((FieldLen >= fieldValidLength(eMinlen, FieldType)) &&
|
1096
|
-
FieldType)))
|
1179
|
+
if ((FieldLen >= fieldValidLength(eMinlen, FieldType)) &&
|
1180
|
+
(FieldLen <= fieldValidLength(eMaxlen, FieldType)))
|
1097
1181
|
{
|
1098
1182
|
if ((FieldType == ft_integer) || (FieldType == ft_uinteger))
|
1099
1183
|
{
|
1100
|
-
if ((FieldLen == 1) || (FieldLen == 2) || (FieldLen == 4) ||
|
1184
|
+
if ((FieldLen == 1) || (FieldLen == 2) || (FieldLen == 4) ||
|
1185
|
+
(FieldLen == 8))
|
1101
1186
|
return true;
|
1102
1187
|
else
|
1103
1188
|
return false;
|
1104
|
-
|
1105
1189
|
}
|
1106
1190
|
else if ((FieldType == ft_autoinc) || (FieldType == ft_autoIncUnsigned))
|
1107
1191
|
{
|
1108
|
-
if ((FieldLen == 2) || (FieldLen == 4)|| (FieldLen == 8))
|
1192
|
+
if ((FieldLen == 2) || (FieldLen == 4) || (FieldLen == 8))
|
1109
1193
|
return true;
|
1110
1194
|
else
|
1111
1195
|
return false;
|
@@ -1125,8 +1209,8 @@ bool dbdef::validLen(uchar_td FieldType, uint_td FieldLen)
|
|
1125
1209
|
|
1126
1210
|
bool dbdef::isPassKey(uchar_td FieldType)
|
1127
1211
|
{
|
1128
|
-
if (FieldType ==
|
1129
|
-
return
|
1212
|
+
if (FieldType == ft_autoIncUnsigned)
|
1213
|
+
return true;
|
1130
1214
|
if (FieldType == ft_wstring)
|
1131
1215
|
return true;
|
1132
1216
|
if (FieldType == ft_wzstring)
|
@@ -1155,7 +1239,11 @@ bool dbdef::isPassKey(uchar_td FieldType)
|
|
1155
1239
|
return true;
|
1156
1240
|
if (FieldType == ft_mydatetime)
|
1157
1241
|
return true;
|
1242
|
+
if (FieldType == ft_myfixedbinary)
|
1243
|
+
return false;
|
1158
1244
|
|
1245
|
+
if (FieldType == ft_bit)
|
1246
|
+
return false;
|
1159
1247
|
if (FieldType > ft_numericsts)
|
1160
1248
|
return false;
|
1161
1249
|
if (FieldType == ft_note)
|
@@ -1165,7 +1253,10 @@ bool dbdef::isPassKey(uchar_td FieldType)
|
|
1165
1253
|
return true;
|
1166
1254
|
}
|
1167
1255
|
|
1168
|
-
void dbdef::autoMakeSchema()
|
1256
|
+
void dbdef::autoMakeSchema()
|
1257
|
+
{
|
1258
|
+
tdap(TD_AUTOMEKE_SCHEMA);
|
1259
|
+
}
|
1169
1260
|
|
1170
1261
|
void dbdef::createDDF(const _TCHAR* fullpath)
|
1171
1262
|
{
|
@@ -1201,7 +1292,6 @@ void dbdef::createDDF(const _TCHAR* fullpath)
|
|
1201
1292
|
fd->release();
|
1202
1293
|
if (id)
|
1203
1294
|
id->release();
|
1204
|
-
|
1205
1295
|
}
|
1206
1296
|
|
1207
1297
|
void dbdef::saveDDF(short TableIndex, short opration, bool forPsqlDdf)
|
@@ -1213,7 +1303,7 @@ void dbdef::saveDDF(short TableIndex, short opration, bool forPsqlDdf)
|
|
1213
1303
|
ushort_td keyid;
|
1214
1304
|
ushort_td segid;
|
1215
1305
|
ushort_td pos;
|
1216
|
-
const
|
1306
|
+
const _TCHAR* own[3];
|
1217
1307
|
|
1218
1308
|
m_stat = STATUS_SUCCESS;
|
1219
1309
|
tabledef* TableDef;
|
@@ -1228,9 +1318,9 @@ void dbdef::saveDDF(short TableIndex, short opration, bool forPsqlDdf)
|
|
1228
1318
|
{
|
1229
1319
|
if (m_impl->userName[0] != 0x00)
|
1230
1320
|
{
|
1231
|
-
own[0] = (const
|
1232
|
-
own[1] = (const
|
1233
|
-
own[2] = (const
|
1321
|
+
own[0] = (const _TCHAR*)m_impl->userName;
|
1322
|
+
own[1] = (const _TCHAR*)m_impl->userName;
|
1323
|
+
own[2] = (const _TCHAR*)m_impl->userName;
|
1234
1324
|
}
|
1235
1325
|
else
|
1236
1326
|
{
|
@@ -1238,11 +1328,14 @@ void dbdef::saveDDF(short TableIndex, short opration, bool forPsqlDdf)
|
|
1238
1328
|
own[1] = ow1;
|
1239
1329
|
own[2] = ow2;
|
1240
1330
|
}
|
1241
|
-
tb->open(((database*)nsdb())->rootDir(), (char_td)Mode,
|
1331
|
+
tb->open(((database*)nsdb())->rootDir(), (char_td)Mode,
|
1332
|
+
(const _TCHAR*)own[0]);
|
1242
1333
|
chOpen += tb->stat();
|
1243
|
-
fd->open(((database*)nsdb())->rootDir(), (char_td)Mode,
|
1334
|
+
fd->open(((database*)nsdb())->rootDir(), (char_td)Mode,
|
1335
|
+
(const _TCHAR*)own[1]);
|
1244
1336
|
chOpen += fd->stat();
|
1245
|
-
id->open(((database*)nsdb())->rootDir(), (char_td)Mode,
|
1337
|
+
id->open(((database*)nsdb())->rootDir(), (char_td)Mode,
|
1338
|
+
(const _TCHAR*)own[2]);
|
1246
1339
|
chOpen += id->stat();
|
1247
1340
|
if (chOpen)
|
1248
1341
|
{
|
@@ -1253,11 +1346,10 @@ void dbdef::saveDDF(short TableIndex, short opration, bool forPsqlDdf)
|
|
1253
1346
|
return;
|
1254
1347
|
}
|
1255
1348
|
|
1256
|
-
//erase all records
|
1349
|
+
// erase all records
|
1257
1350
|
nsdb()->beginTrn(200);
|
1258
1351
|
tb->setKeyNum(0);
|
1259
1352
|
|
1260
|
-
|
1261
1353
|
tb->setStat(0);
|
1262
1354
|
fd->setStat(0);
|
1263
1355
|
id->setStat(0);
|
@@ -1272,7 +1364,7 @@ void dbdef::saveDDF(short TableIndex, short opration, bool forPsqlDdf)
|
|
1272
1364
|
strcpy(tb->tablename, TableDef->tableNameA());
|
1273
1365
|
strcpy(tb->filename, TableDef->fileNameA());
|
1274
1366
|
if (forPsqlDdf)
|
1275
|
-
tb->flag = 0
|
1367
|
+
tb->flag = 0; // PSQL are reading flags from table files.
|
1276
1368
|
else
|
1277
1369
|
tb->flag = TableDef->flags.all;
|
1278
1370
|
if (tb->stat() == STATUS_SUCCESS)
|
@@ -1303,7 +1395,7 @@ void dbdef::saveDDF(short TableIndex, short opration, bool forPsqlDdf)
|
|
1303
1395
|
{
|
1304
1396
|
FieldDef = &TableDef->fieldDefs[fdid];
|
1305
1397
|
if (FieldDef->ddfid == 0)
|
1306
|
-
|
1398
|
+
FieldDef->ddfid = getDDFNewFieldIndex();
|
1307
1399
|
fd->fieldid = FieldDef->ddfid;
|
1308
1400
|
fd->fileid = tb->id;
|
1309
1401
|
strcpy(fd->name, FieldDef->nameA());
|
@@ -1317,7 +1409,7 @@ void dbdef::saveDDF(short TableIndex, short opration, bool forPsqlDdf)
|
|
1317
1409
|
fd->flag = 0;
|
1318
1410
|
fd->insert();
|
1319
1411
|
if (fd->stat())
|
1320
|
-
|
1412
|
+
goto JmpErr;
|
1321
1413
|
}
|
1322
1414
|
}
|
1323
1415
|
// delete keys.
|
@@ -1338,12 +1430,15 @@ void dbdef::saveDDF(short TableIndex, short opration, bool forPsqlDdf)
|
|
1338
1430
|
id->keyid = keyid;
|
1339
1431
|
for (segid = 0; segid < KeyDef->segmentCount; segid++)
|
1340
1432
|
{
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1433
|
+
id->fieldid =
|
1434
|
+
TableDef
|
1435
|
+
->fieldDefs[KeyDef->segments[segid].fieldNum]
|
1436
|
+
.ddfid;
|
1437
|
+
id->segmentnum = segid;
|
1438
|
+
id->flag = KeyDef->segments[segid].flags.all;
|
1439
|
+
id->insert();
|
1440
|
+
if (id->stat())
|
1441
|
+
goto JmpErr;
|
1347
1442
|
}
|
1348
1443
|
}
|
1349
1444
|
}
|
@@ -1363,7 +1458,6 @@ void dbdef::saveDDF(short TableIndex, short opration, bool forPsqlDdf)
|
|
1363
1458
|
fd->release();
|
1364
1459
|
if (id)
|
1365
1460
|
id->release();
|
1366
|
-
|
1367
1461
|
}
|
1368
1462
|
|
1369
1463
|
void dbdef::openDdf(const _TCHAR* dir, short Mode, const _TCHAR* OwnerName)
|
@@ -1419,7 +1513,7 @@ void dbdef::openDdf(const _TCHAR* dir, short Mode, const _TCHAR* OwnerName)
|
|
1419
1513
|
return;
|
1420
1514
|
}
|
1421
1515
|
|
1422
|
-
tb->setKeyNum(
|
1516
|
+
tb->setKeyNum(0);
|
1423
1517
|
tb->seekFirst();
|
1424
1518
|
while (tb->stat() == 0)
|
1425
1519
|
{ // Inser table
|
@@ -1439,7 +1533,6 @@ void dbdef::openDdf(const _TCHAR* dir, short Mode, const _TCHAR* OwnerName)
|
|
1439
1533
|
if (m_stat != 0)
|
1440
1534
|
break;
|
1441
1535
|
|
1442
|
-
|
1443
1536
|
fd->setKeyNum(1);
|
1444
1537
|
fd->fileid = tb->id;
|
1445
1538
|
fd->seekGreater(true);
|
@@ -1450,9 +1543,11 @@ void dbdef::openDdf(const _TCHAR* dir, short Mode, const _TCHAR* OwnerName)
|
|
1450
1543
|
|
1451
1544
|
if (fd->type != ft_nullindicator)
|
1452
1545
|
{
|
1453
|
-
for (FieldIndex = 0;
|
1546
|
+
for (FieldIndex = 0;
|
1547
|
+
FieldIndex < tableDefs(tbid)->fieldCount; FieldIndex++)
|
1454
1548
|
{
|
1455
|
-
if (tableDefs(tbid)->fieldDefs[FieldIndex].pos >
|
1549
|
+
if (tableDefs(tbid)->fieldDefs[FieldIndex].pos >
|
1550
|
+
fd->pos)
|
1456
1551
|
break;
|
1457
1552
|
}
|
1458
1553
|
FieldDef = insertField(tbid, FieldIndex);
|
@@ -1475,8 +1570,10 @@ void dbdef::openDdf(const _TCHAR* dir, short Mode, const _TCHAR* OwnerName)
|
|
1475
1570
|
|
1476
1571
|
KeyDef = &(tableDefs(tbid)->keyDefs[id->keyid]);
|
1477
1572
|
if (KeyDef->segmentCount < id->segmentnum + 1)
|
1478
|
-
KeyDef->segmentCount =
|
1479
|
-
|
1573
|
+
KeyDef->segmentCount =
|
1574
|
+
(uchar_td)(id->segmentnum + 1);
|
1575
|
+
KeyDef->segments[id->segmentnum].fieldNum =
|
1576
|
+
(uchar_td)FieldIndex;
|
1480
1577
|
KeyDef->segments[id->segmentnum].flags.all = id->flag;
|
1481
1578
|
id->seekNext();
|
1482
1579
|
}
|
@@ -1504,18 +1601,18 @@ void dbdef::openDdf(const _TCHAR* dir, short Mode, const _TCHAR* OwnerName)
|
|
1504
1601
|
}
|
1505
1602
|
}
|
1506
1603
|
|
1507
|
-
|
1508
1604
|
for (short i = tableDefs(tbid)->fieldCount - 1; i >= 0; i--)
|
1509
1605
|
{
|
1510
1606
|
short pos = tableDefs(tbid)->fieldDefs[i].pos;
|
1511
1607
|
short startPos = 0;
|
1512
1608
|
if (i > 0)
|
1513
1609
|
startPos = tableDefs(tbid)->fieldDefs[i - 1].pos +
|
1514
|
-
|
1610
|
+
tableDefs(tbid)->fieldDefs[i - 1].len;
|
1515
1611
|
if (tableDefs(tbid)->fieldDefs[i].len && (startPos != pos))
|
1516
1612
|
{
|
1517
1613
|
FieldDef = insertField(tbid, i);
|
1518
|
-
sprintf_s((char*)FieldDef->nameA(), FIELD_NAME_SIZE,
|
1614
|
+
sprintf_s((char*)FieldDef->nameA(), FIELD_NAME_SIZE,
|
1615
|
+
"NIS%d", i + 1);
|
1519
1616
|
|
1520
1617
|
FieldDef->type = ft_nullindicator;
|
1521
1618
|
FieldDef->len = 1;
|
@@ -1569,7 +1666,7 @@ ushort_td dbdef::getDDFNewFieldIndex()
|
|
1569
1666
|
for (j = 0; j < tableDefs(i)->fieldCount; j++)
|
1570
1667
|
{
|
1571
1668
|
if (tableDefs(i)->fieldDefs[j].ddfid > m_impl->maxid)
|
1572
|
-
|
1669
|
+
m_impl->maxid = tableDefs(i)->fieldDefs[j].ddfid;
|
1573
1670
|
}
|
1574
1671
|
}
|
1575
1672
|
}
|
@@ -1596,9 +1693,10 @@ void dbdef::pushBackup(short TableIndex)
|
|
1596
1693
|
|
1597
1694
|
blen = totalDefLength(TableIndex);
|
1598
1695
|
if (!tableDefs(TABLE_NUM_TMP))
|
1599
|
-
m_impl->tableDefs[TABLE_NUM_TMP] = (tabledef*)
|
1696
|
+
m_impl->tableDefs[TABLE_NUM_TMP] = (tabledef*)malloc(blen);
|
1600
1697
|
else
|
1601
|
-
m_impl->tableDefs[TABLE_NUM_TMP] =
|
1698
|
+
m_impl->tableDefs[TABLE_NUM_TMP] =
|
1699
|
+
(tabledef*)realloc(tableDefs(TABLE_NUM_TMP), blen);
|
1602
1700
|
if (!tableDefs(TABLE_NUM_TMP))
|
1603
1701
|
{
|
1604
1702
|
m_stat = STATUS_CANT_ALLOC_MEMORY;
|
@@ -1618,30 +1716,45 @@ bool dbdef::compAsBackup(short TableIndex)
|
|
1618
1716
|
int len2 = totalDefLength(TableIndex);
|
1619
1717
|
if (len != len2)
|
1620
1718
|
return true;
|
1621
|
-
|
1719
|
+
tabledef* tds = tableDefs(TableIndex);
|
1720
|
+
tabledef* tdo = tableDefs(TABLE_NUM_TMP);
|
1721
|
+
|
1722
|
+
if (memcmp(tds, tdo, ((char*)(&(tdo->fieldDefs))) - ((char*)tdo)))
|
1622
1723
|
return true;
|
1724
|
+
|
1725
|
+
for (int i = 0; i < tds->fieldCount; i++)
|
1726
|
+
{
|
1727
|
+
if (memcmp(&tds->fieldDefs[i], &tdo->fieldDefs[i], sizeof(fielddef)))
|
1728
|
+
return true;
|
1729
|
+
}
|
1730
|
+
for (int i = 0; i < tds->keyCount; i++)
|
1731
|
+
{
|
1732
|
+
if (memcmp(&tds->keyDefs[i], &tdo->keyDefs[i], sizeof(keydef)))
|
1733
|
+
return true;
|
1734
|
+
}
|
1623
1735
|
return false;
|
1624
1736
|
}
|
1625
1737
|
|
1626
1738
|
void dbdef::popBackup(short TableIndex)
|
1627
1739
|
{
|
1628
1740
|
int len = totalDefLength(TABLE_NUM_TMP);
|
1629
|
-
m_impl->tableDefs[TableIndex] =
|
1741
|
+
m_impl->tableDefs[TableIndex] =
|
1742
|
+
(tabledef*)realloc(tableDefs(TableIndex), len);
|
1630
1743
|
memcpy(tableDefs(TableIndex), tableDefs(TABLE_NUM_TMP), len);
|
1631
1744
|
tableDefs(TableIndex)->fieldDefs = getFieldDef(tableDefs(TableIndex));
|
1632
1745
|
tableDefs(TableIndex)->keyDefs = getKeyDef(tableDefs(TableIndex));
|
1633
1746
|
|
1634
1747
|
updateTableDef(TableIndex);
|
1635
1748
|
}
|
1749
|
+
|
1636
1750
|
void dbdef::reopen(char_td mode)
|
1637
1751
|
{
|
1638
1752
|
close();
|
1639
1753
|
open(uri(), mode, NULL);
|
1640
1754
|
}
|
1641
1755
|
|
1642
|
-
|
1643
|
-
}// namespace
|
1644
|
-
}// namespace
|
1645
|
-
}// namespace
|
1646
|
-
}// namespace
|
1647
|
-
}// namespace bzs
|
1756
|
+
} // namespace client
|
1757
|
+
} // namespace tdap
|
1758
|
+
} // namespace protocol
|
1759
|
+
} // namespace db
|
1760
|
+
} // namespace bzs
|