transactd 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/BUILD_UNIX-JA +174 -0
- data/BUILD_WIN-JA +256 -0
- data/CMakeLists.txt +96 -0
- data/COPYING +339 -0
- data/README +406 -0
- data/README-JA +424 -0
- data/bin/common/tdclc_32_1_0.dll +0 -0
- data/bin/common/tdclc_64_1_0.dll +0 -0
- data/build/common/check_for_link_iconv.cmake +73 -0
- data/build/common/copyifgreater.cmd +30 -0
- data/build/common/copyifgreater.js +290 -0
- data/build/common/get_boost_libs.cmake +106 -0
- data/build/common/get_ruby_path.cmake +115 -0
- data/build/common/options.cmake +127 -0
- data/build/common/smart_install.cmake +263 -0
- data/build/common/system.cmake +122 -0
- data/build/common/transactd.rc.in +52 -0
- data/build/common/transactd_cl_common.cmake +101 -0
- data/build/common/transactd_cl_output.cmake +93 -0
- data/build/common/transactd_common.cmake +237 -0
- data/build/common/transactd_required.cmake +28 -0
- data/build/swig/ruby/generate.cmake.in +35 -0
- data/build/swig/ruby/generate.cmd.in +19 -0
- data/build/swig/ruby/ruby.swg +101 -0
- data/build/swig/tdcl.i +188 -0
- data/build/tdclc/BUILDNUMBER.txt +1 -0
- data/build/tdclc/CMakeLists.txt +170 -0
- data/build/tdclc/tdclc_32.cbproj +181 -0
- data/build/tdclc/tdclc_64.cbproj +205 -0
- data/build/tdclcpp/BUILDNUMBER.txt +1 -0
- data/build/tdclcpp/CMakeLists.txt +142 -0
- data/build/tdclcpp/tdclcpp_bcb_32.cbproj +239 -0
- data/build/tdclcpp/tdclcpp_bcb_64.cbproj +304 -0
- data/build/tdclrb/BUILDNUMBER.txt +1 -0
- data/build/tdclrb/CMakeLists.txt +258 -0
- data/build/tdclrb/GEM_VERSION +3 -0
- data/build/tdclrb/bldgem/extconf.rb +123 -0
- data/build/tdclrb/gem/INSTALLLOG.win32 +9 -0
- data/build/tdclrb/gem/Makefile.win32-VS +65 -0
- data/build/tdclrb/gem/Makefile.win32-prebuilt +48 -0
- data/build/tdclrb/gem/detect.rb +31 -0
- data/build/tdclrb/gem/helper.rb +113 -0
- data/build/tdclrb/gem/transactd.rb +22 -0
- data/build/tdclrb/gem_output.cmake +44 -0
- data/source/bzs/db/IBlobBuffer.h +51 -0
- data/source/bzs/db/blobBuffer.h +177 -0
- data/source/bzs/db/blobStructs.h +85 -0
- data/source/bzs/db/engine/mysql/IReadRecords.h +52 -0
- data/source/bzs/db/engine/mysql/bookmark.h +195 -0
- data/source/bzs/db/engine/mysql/database.cpp +1882 -0
- data/source/bzs/db/engine/mysql/database.h +465 -0
- data/source/bzs/db/engine/mysql/dbManager.cpp +303 -0
- data/source/bzs/db/engine/mysql/dbManager.h +143 -0
- data/source/bzs/db/engine/mysql/errorMessage.cpp +75 -0
- data/source/bzs/db/engine/mysql/errorMessage.h +43 -0
- data/source/bzs/db/engine/mysql/fieldAccess.h +158 -0
- data/source/bzs/db/engine/mysql/mydebuglog.cpp +349 -0
- data/source/bzs/db/engine/mysql/mydebuglog.h +89 -0
- data/source/bzs/db/engine/mysql/mysqlInternal.h +171 -0
- data/source/bzs/db/engine/mysql/mysqlThd.cpp +169 -0
- data/source/bzs/db/engine/mysql/mysqlThd.h +35 -0
- data/source/bzs/db/engine/mysql/percentageKey.h +260 -0
- data/source/bzs/db/protocol/ICommandExecuter.h +49 -0
- data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +689 -0
- data/source/bzs/db/protocol/hs/hsCommandExecuter.h +228 -0
- data/source/bzs/db/protocol/tdap/btrDate.cpp +437 -0
- data/source/bzs/db/protocol/tdap/btrDate.h +227 -0
- data/source/bzs/db/protocol/tdap/client/bulkInsert.h +127 -0
- data/source/bzs/db/protocol/tdap/client/client.cpp +106 -0
- data/source/bzs/db/protocol/tdap/client/client.h +292 -0
- data/source/bzs/db/protocol/tdap/client/connMgr.cpp +144 -0
- data/source/bzs/db/protocol/tdap/client/connMgr.h +82 -0
- data/source/bzs/db/protocol/tdap/client/database.cpp +863 -0
- data/source/bzs/db/protocol/tdap/client/database.h +118 -0
- data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +100 -0
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +1640 -0
- data/source/bzs/db/protocol/tdap/client/dbDef.h +135 -0
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +434 -0
- data/source/bzs/db/protocol/tdap/client/errorMessage.cpp +92 -0
- data/source/bzs/db/protocol/tdap/client/errorMessage_ja.cpp +98 -0
- data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +174 -0
- data/source/bzs/db/protocol/tdap/client/fieldDDF.h +91 -0
- data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +140 -0
- data/source/bzs/db/protocol/tdap/client/fileDDF.h +86 -0
- data/source/bzs/db/protocol/tdap/client/filter.cpp +527 -0
- data/source/bzs/db/protocol/tdap/client/filter.h +154 -0
- data/source/bzs/db/protocol/tdap/client/indexDDF.cpp +137 -0
- data/source/bzs/db/protocol/tdap/client/indexDDF.h +84 -0
- data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +724 -0
- data/source/bzs/db/protocol/tdap/client/nsDatabase.h +123 -0
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +899 -0
- data/source/bzs/db/protocol/tdap/client/nsTable.h +199 -0
- data/source/bzs/db/protocol/tdap/client/request.h +198 -0
- data/source/bzs/db/protocol/tdap/client/sharedData.cpp +58 -0
- data/source/bzs/db/protocol/tdap/client/sharedData.h +56 -0
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +574 -0
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +53 -0
- data/source/bzs/db/protocol/tdap/client/stringConverter.h +627 -0
- data/source/bzs/db/protocol/tdap/client/table.cpp +2613 -0
- data/source/bzs/db/protocol/tdap/client/table.h +221 -0
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +1096 -0
- data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +179 -0
- data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +40 -0
- data/source/bzs/db/protocol/tdap/client/trnsctcl.def +11 -0
- data/source/bzs/db/protocol/tdap/myDateTime.cpp +500 -0
- data/source/bzs/db/protocol/tdap/mysql/characterset.cpp +184 -0
- data/source/bzs/db/protocol/tdap/mysql/characterset.h +60 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +284 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +53 -0
- data/source/bzs/db/protocol/tdap/mysql/debuglog.cpp +383 -0
- data/source/bzs/db/protocol/tdap/mysql/debuglog.h +106 -0
- data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +680 -0
- data/source/bzs/db/protocol/tdap/mysql/request.h +202 -0
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +1020 -0
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +141 -0
- data/source/bzs/db/protocol/tdap/tdapRequest.h +190 -0
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +295 -0
- data/source/bzs/db/protocol/tdap/tdapSchema.h +558 -0
- data/source/bzs/db/protocol/tdap/tdapcapi.h +423 -0
- data/source/bzs/db/transactd/appBuilderImple.h +55 -0
- data/source/bzs/db/transactd/appModule.cpp +183 -0
- data/source/bzs/db/transactd/appModule.h +80 -0
- data/source/bzs/db/transactd/connManager.cpp +201 -0
- data/source/bzs/db/transactd/connManager.h +60 -0
- data/source/bzs/db/transactd/connectionRecord.h +69 -0
- data/source/bzs/db/transactd/transactd.cpp +325 -0
- data/source/bzs/env/compiler.h +135 -0
- data/source/bzs/env/crosscompile.cpp +130 -0
- data/source/bzs/env/crosscompile.h +150 -0
- data/source/bzs/env/fileopen.h +36 -0
- data/source/bzs/env/mbcswchrLinux.cpp +40 -0
- data/source/bzs/env/mbcswchrLinux.h +88 -0
- data/source/bzs/env/tstring.h +183 -0
- data/source/bzs/example/changeSchema.cpp +117 -0
- data/source/bzs/example/changeSchema_c.cpp +78 -0
- data/source/bzs/example/connection_pool_c.cpp +171 -0
- data/source/bzs/example/createDatabase.cpp +305 -0
- data/source/bzs/example/createDatabase_c.cpp +202 -0
- data/source/bzs/example/deleteRecords.cpp +87 -0
- data/source/bzs/example/deleteRecords_c.cpp +57 -0
- data/source/bzs/example/dropDatabase.cpp +59 -0
- data/source/bzs/example/dropDatabase_c.cpp +34 -0
- data/source/bzs/example/insertRecords.cpp +212 -0
- data/source/bzs/example/insertRecords_c.cpp +153 -0
- data/source/bzs/example/readRecords.cpp +141 -0
- data/source/bzs/example/readRecords_c.cpp +107 -0
- data/source/bzs/example/updateRecords.cpp +99 -0
- data/source/bzs/example/updateRecords_c.cpp +71 -0
- data/source/bzs/example/update_with_transaction.cpp +104 -0
- data/source/bzs/example/update_with_transaction_c.cpp +80 -0
- data/source/bzs/netsvc/client/tcpClient.cpp +226 -0
- data/source/bzs/netsvc/client/tcpClient.h +489 -0
- data/source/bzs/netsvc/server/IAppModule.h +94 -0
- data/source/bzs/netsvc/server/iserver.h +65 -0
- data/source/bzs/netsvc/server/serverCpt.cpp +522 -0
- data/source/bzs/netsvc/server/serverCpt.h +88 -0
- data/source/bzs/netsvc/server/serverPipe.cpp +705 -0
- data/source/bzs/netsvc/server/serverPipe.h +96 -0
- data/source/bzs/netsvc/server/serverTpool.cpp +416 -0
- data/source/bzs/netsvc/server/serverTpool.h +84 -0
- data/source/bzs/rtl/benchmark.cpp +96 -0
- data/source/bzs/rtl/benchmark.h +65 -0
- data/source/bzs/rtl/datetime.cpp +375 -0
- data/source/bzs/rtl/datetime.h +53 -0
- data/source/bzs/rtl/debuglog.cpp +106 -0
- data/source/bzs/rtl/debuglog.h +97 -0
- data/source/bzs/rtl/exception.h +116 -0
- data/source/bzs/rtl/stl_uty.cpp +35 -0
- data/source/bzs/rtl/stl_uty.h +29 -0
- data/source/bzs/rtl/stringBuffers.cpp +101 -0
- data/source/bzs/rtl/stringBuffers.h +58 -0
- data/source/bzs/rtl/strtrim.cpp +135 -0
- data/source/bzs/rtl/strtrim.h +46 -0
- data/source/bzs/test/tdclatl/bench_tdclatl.js +445 -0
- data/source/bzs/test/tdclrb/bench_tdclcpp.rb +375 -0
- data/source/bzs/test/tdclrb/prepare.rb +226 -0
- data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +172 -0
- data/source/bzs/test/tdclrb/transactd_kanjischema_spec.rb +208 -0
- data/source/bzs/test/tdclrb/transactd_spec.rb +1536 -0
- data/source/bzs/test/transactdBench/transactdBench.cpp +430 -0
- data/source/bzs/test/transactdBench/transactdBench2.cpp +342 -0
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +2030 -0
- data/source/global/tdclatl/Database.cpp +503 -0
- data/source/global/tdclatl/Database.h +139 -0
- data/source/global/tdclatl/DbDef.cpp +242 -0
- data/source/global/tdclatl/DbDef.h +79 -0
- data/source/global/tdclatl/Field.cpp +92 -0
- data/source/global/tdclatl/Field.h +59 -0
- data/source/global/tdclatl/FieldDef.cpp +238 -0
- data/source/global/tdclatl/FieldDef.h +87 -0
- data/source/global/tdclatl/Flags.cpp +111 -0
- data/source/global/tdclatl/Flags.h +55 -0
- data/source/global/tdclatl/KeyDef.cpp +51 -0
- data/source/global/tdclatl/KeyDef.h +55 -0
- data/source/global/tdclatl/KeySegment.cpp +55 -0
- data/source/global/tdclatl/Table.cpp +600 -0
- data/source/global/tdclatl/Table.h +144 -0
- data/source/global/tdclatl/TableDef.cpp +291 -0
- data/source/global/tdclatl/TableDef.h +86 -0
- data/source/global/tdclatl/TdVersion.cpp +74 -0
- data/source/global/tdclatl/TdVersion.h +54 -0
- data/source/global/tdclatl/_IDatabaseEvents_CP.h +113 -0
- data/source/global/tdclatl/dllmain.cpp +30 -0
- data/source/global/tdclatl/dllmain.h +27 -0
- data/source/global/tdclatl/keySegment.h +57 -0
- data/source/global/tdclatl/resource.h +0 -0
- data/source/global/tdclatl/stdafx.cpp +2 -0
- data/source/global/tdclatl/stdafx.h +25 -0
- data/source/global/tdclatl/targetver.h +4 -0
- data/source/global/tdclatl/tdclatl.cpp +68 -0
- data/source/global/tdclatl/tdclatl.def +10 -0
- data/source/global/tdclatl/tdclatl.idl +1035 -0
- data/source/linux/charsetConvert.h +112 -0
- data/source/linux/linuxTypes.h +33 -0
- data/source/linux/tchar.h +428 -0
- data/transactd.gemspec +97 -0
- metadata +267 -0
@@ -0,0 +1,2030 @@
|
|
1
|
+
/* =================================================================
|
2
|
+
Copyright (C) 2013 BizStation Corp All rights reserved.
|
3
|
+
|
4
|
+
This program is free software; you can redistribute it and/or
|
5
|
+
modify it under the terms of the GNU General Public License
|
6
|
+
as published by the Free Software Foundation; either version 2
|
7
|
+
of the License, or (at your option) any later version.
|
8
|
+
|
9
|
+
This program is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
GNU General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU General Public License
|
15
|
+
along with this program; if not, write to the Free Software
|
16
|
+
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
17
|
+
02111-1307, USA.
|
18
|
+
================================================================= */
|
19
|
+
//#define BOOST_TEST_MAIN
|
20
|
+
//#define BOOST_TEST_MODULE
|
21
|
+
|
22
|
+
#include <boost/test/included/unit_test.hpp>
|
23
|
+
#include <bzs/db/protocol/tdap/client/database.h>
|
24
|
+
#include <bzs/db/protocol/tdap/client/table.h>
|
25
|
+
#include <bzs/db/protocol/tdap/client/dbDef.h>
|
26
|
+
#include <bzs/db/protocol/tdap/mysql/characterset.h>
|
27
|
+
#include <bzs/db/protocol/tdap/tdapcapi.h>
|
28
|
+
#include <bzs/db/protocol/tdap/client/stringConverter.h>
|
29
|
+
#include <stdio.h>
|
30
|
+
|
31
|
+
using namespace bzs::db::protocol::tdap::client;
|
32
|
+
using namespace bzs::db::protocol::tdap;
|
33
|
+
using namespace std;
|
34
|
+
|
35
|
+
#define PROTOCOL _T("tdap")
|
36
|
+
static _TCHAR HOSTNAME[MAX_PATH] =
|
37
|
+
{_T("127.0.0.1")};
|
38
|
+
#define DBNAME _T("test")
|
39
|
+
#define BDFNAME _T("test.bdf")
|
40
|
+
// #define ISOLATION_REPEATABLE_READ
|
41
|
+
#define ISOLATION_READ_COMMITTED
|
42
|
+
|
43
|
+
static const short fdi_id = 0;
|
44
|
+
static const short fdi_name = 1;
|
45
|
+
boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]);
|
46
|
+
|
47
|
+
boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[])
|
48
|
+
{
|
49
|
+
for (int i = 1; i < argc; ++i)
|
50
|
+
{
|
51
|
+
if (strstr(argv[i], "--host=") == argv[i])
|
52
|
+
{
|
53
|
+
#ifdef _UNICODE
|
54
|
+
MultiByteToWideChar(CP_ACP, (CP_ACP == CP_UTF8) ? 0 : MB_PRECOMPOSED, argv[i] + 7, -1, HOSTNAME, MAX_PATH);
|
55
|
+
#else
|
56
|
+
strcpy_s(HOSTNAME, MAX_PATH, argv[i] + 7);
|
57
|
+
#endif
|
58
|
+
|
59
|
+
}
|
60
|
+
}
|
61
|
+
return 0;
|
62
|
+
}
|
63
|
+
|
64
|
+
static _TCHAR g_uri[MAX_PATH];
|
65
|
+
|
66
|
+
const _TCHAR* makeUri(const _TCHAR* protocol, const _TCHAR* host, const _TCHAR* dbname, const _TCHAR* dbfile = NULL)
|
67
|
+
{
|
68
|
+
if (dbfile)
|
69
|
+
_stprintf_s(g_uri, MAX_PATH, _T("%s://%s/%s?dbfile=%s"), protocol, host, dbname, dbfile);
|
70
|
+
else
|
71
|
+
_stprintf_s(g_uri, MAX_PATH, _T("%s://%s/%s"), protocol, host, dbname);
|
72
|
+
return g_uri;
|
73
|
+
|
74
|
+
}
|
75
|
+
|
76
|
+
class fixture
|
77
|
+
{
|
78
|
+
mutable database* m_db;
|
79
|
+
|
80
|
+
public:
|
81
|
+
fixture() : m_db(NULL)
|
82
|
+
{
|
83
|
+
m_db = database::create();
|
84
|
+
if (!m_db)
|
85
|
+
printf("Error database::create()\n");
|
86
|
+
}
|
87
|
+
|
88
|
+
~fixture()
|
89
|
+
{
|
90
|
+
if (m_db)
|
91
|
+
database::destroy(m_db);
|
92
|
+
}
|
93
|
+
|
94
|
+
::database* db() const {return m_db;}
|
95
|
+
};
|
96
|
+
|
97
|
+
table* openTable(database* db)
|
98
|
+
{
|
99
|
+
|
100
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, DBNAME, BDFNAME), TYPE_SCHEMA_BDF, TD_OPEN_NORMAL);
|
101
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "open 1" << db->stat());
|
102
|
+
table* tb = db->openTable(_T("user"));
|
103
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "openTable" << db->stat());
|
104
|
+
return tb;
|
105
|
+
}
|
106
|
+
|
107
|
+
void testDropDatabase(database* db)
|
108
|
+
{
|
109
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, DBNAME, BDFNAME));
|
110
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "DropDatabase 1");
|
111
|
+
|
112
|
+
db->drop();
|
113
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "drop 2");
|
114
|
+
}
|
115
|
+
|
116
|
+
void testClone(database* db)
|
117
|
+
{
|
118
|
+
database* db2 = db->clone();
|
119
|
+
BOOST_CHECK_MESSAGE(db2 != NULL, "createNewDataBase stat = " << db->stat());
|
120
|
+
if (db2)
|
121
|
+
database::destroy(db2);
|
122
|
+
}
|
123
|
+
|
124
|
+
void testCreateNewDataBase(database* db)
|
125
|
+
{
|
126
|
+
|
127
|
+
db->create(makeUri(PROTOCOL, HOSTNAME, DBNAME, BDFNAME));
|
128
|
+
if (db->stat() == STATUS_TABLE_EXISTS_ERROR)
|
129
|
+
{
|
130
|
+
testDropDatabase(db);
|
131
|
+
db->create(makeUri(PROTOCOL, HOSTNAME, DBNAME, BDFNAME));
|
132
|
+
}
|
133
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "createNewDataBase stat = " << db->stat());
|
134
|
+
// create table
|
135
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, DBNAME, BDFNAME), TYPE_SCHEMA_BDF, TD_OPEN_NORMAL);
|
136
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "createNewDataBase 1 stat = " << db->stat());
|
137
|
+
|
138
|
+
dbdef* def = db->dbDef();
|
139
|
+
if (def)
|
140
|
+
{
|
141
|
+
tabledef td;
|
142
|
+
memset(&td, 0, sizeof(tabledef));
|
143
|
+
td.setTableName(_T("user"));
|
144
|
+
td.setFileName(_T("user.dat"));
|
145
|
+
td.id = 1;
|
146
|
+
td.primaryKeyNum = -1;
|
147
|
+
td.parentKeyNum = -1;
|
148
|
+
td.replicaKeyNum = -1;
|
149
|
+
td.pageSize = 2048;
|
150
|
+
def->insertTable(&td);
|
151
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "insertTable stat = " << def->stat());
|
152
|
+
|
153
|
+
fielddef* fd = def->insertField(1, 0);
|
154
|
+
fd->setName(_T("id"));
|
155
|
+
fd->type = ft_integer;
|
156
|
+
fd->len = (ushort_td)4;
|
157
|
+
def->updateTableDef(1);
|
158
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 1 stat = " << def->stat());
|
159
|
+
|
160
|
+
fd = def->insertField(1, 1);
|
161
|
+
fd->setName(_T("name"));
|
162
|
+
fd->type = ft_zstring;
|
163
|
+
fd->len = (ushort_td)33;
|
164
|
+
def->updateTableDef(1);
|
165
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 2 stat = " << def->stat());
|
166
|
+
|
167
|
+
keydef* kd = def->insertKey(1, 0);
|
168
|
+
kd->segments[0].fieldNum = 0;
|
169
|
+
kd->segments[0].flags.bit8 = 1; // extended key type
|
170
|
+
kd->segments[0].flags.bit1 = 1; // changeable
|
171
|
+
kd->segmentCount = 1;
|
172
|
+
|
173
|
+
def->updateTableDef(1);
|
174
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 3 stat = " << def->stat());
|
175
|
+
|
176
|
+
}
|
177
|
+
|
178
|
+
}
|
179
|
+
|
180
|
+
void testVersion(database* db)
|
181
|
+
{
|
182
|
+
db->connect(makeUri(PROTOCOL, HOSTNAME, DBNAME));
|
183
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "Version connect stat = " << db->stat());
|
184
|
+
if (0 == db->stat())
|
185
|
+
{
|
186
|
+
btrVersions vv;
|
187
|
+
db->getBtrVersion(&vv);
|
188
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "Version");
|
189
|
+
if (_tcscmp(PROTOCOL, _T("tdap")) == 0)
|
190
|
+
{
|
191
|
+
BOOST_CHECK_MESSAGE(atoi(CPP_INTERFACE_VER_MAJOR) == vv.versions[0].majorVersion,
|
192
|
+
"clent_Major = " << vv.versions[0].majorVersion);
|
193
|
+
BOOST_CHECK_MESSAGE(atoi(CPP_INTERFACE_VER_MINOR) == vv.versions[0].minorVersion,
|
194
|
+
"clent_Miner = " << vv.versions[0].minorVersion);
|
195
|
+
BOOST_CHECK_MESSAGE((int)'N' == (int)vv.versions[0].type, "clent_Type = " << vv.versions[0].type);
|
196
|
+
|
197
|
+
BOOST_CHECK_MESSAGE(((5 == vv.versions[1].majorVersion)||(10 == vv.versions[1].majorVersion)),
|
198
|
+
"mysql_server_Major = " << vv.versions[1].majorVersion);
|
199
|
+
BOOST_CHECK_MESSAGE(((5 <= vv.versions[1].minorVersion)||(0 == vv.versions[1].minorVersion)),
|
200
|
+
"mysql_server_Miner = " << vv.versions[1].minorVersion);
|
201
|
+
BOOST_CHECK_MESSAGE((int)'M' == (int)vv.versions[1].type, "mysql_server_Type = " << vv.versions[1].type);
|
202
|
+
|
203
|
+
BOOST_CHECK_MESSAGE(TRANSACTD_VER_MAJOR == vv.versions[2].majorVersion,
|
204
|
+
"server_Major = " << vv.versions[2].majorVersion);
|
205
|
+
BOOST_CHECK_MESSAGE(TRANSACTD_VER_MINOR == vv.versions[2].minorVersion,
|
206
|
+
"server_Miner = " << vv.versions[2].minorVersion);
|
207
|
+
BOOST_CHECK_MESSAGE((int)'T' == (int)vv.versions[2].type, "server_Type = " << vv.versions[2].type);
|
208
|
+
}
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
void testInsert(database* db)
|
213
|
+
{
|
214
|
+
table* tb = openTable(db);
|
215
|
+
|
216
|
+
if (tb->recordCount() == 0)
|
217
|
+
{
|
218
|
+
tb->clearBuffer();
|
219
|
+
tb->setFV((short)0, _T("1"));
|
220
|
+
tb->setFV((short)1, _T("kosaka"));
|
221
|
+
tb->insert();
|
222
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "insert");
|
223
|
+
}
|
224
|
+
|
225
|
+
db->beginTrn();
|
226
|
+
int n = 1;
|
227
|
+
tb->seekLast();
|
228
|
+
if (tb->stat() == 0)
|
229
|
+
n = tb->getFVint(fdi_id) + 1;
|
230
|
+
tb->beginBulkInsert(BULKBUFSIZE);
|
231
|
+
for (int i = n; i < 20002 + n - 1; i++)
|
232
|
+
{
|
233
|
+
tb->clearBuffer();
|
234
|
+
tb->setFV((short)0, i);
|
235
|
+
tb->setFV((short)1, i);
|
236
|
+
if (i == 87170)
|
237
|
+
i = 87170;
|
238
|
+
tb->insert();
|
239
|
+
|
240
|
+
}
|
241
|
+
tb->commitBulkInsert();
|
242
|
+
db->endTrn();
|
243
|
+
|
244
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "Insert2");
|
245
|
+
tb->release();
|
246
|
+
}
|
247
|
+
|
248
|
+
void testFind(database* db)
|
249
|
+
{
|
250
|
+
|
251
|
+
table* tb = openTable(db);
|
252
|
+
tb->setKeyNum(0);
|
253
|
+
tb->clearBuffer();
|
254
|
+
tb->setFilter(_T("id >= 10 and id < 20000"), 1, 0);
|
255
|
+
int v = 10;
|
256
|
+
tb->setFV((short)0, v);
|
257
|
+
tb->find(table::findForword);
|
258
|
+
int i = v;
|
259
|
+
while (i < 20000)
|
260
|
+
{
|
261
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "find stat");
|
262
|
+
BOOST_CHECK_MESSAGE(i == tb->getFVint(fdi_id), "find value " << i);
|
263
|
+
tb->findNext(true); // 11 ~ 19
|
264
|
+
++i;
|
265
|
+
}
|
266
|
+
|
267
|
+
// backforword
|
268
|
+
tb->clearBuffer();
|
269
|
+
v = 19999;
|
270
|
+
tb->setFV((short)0, v);
|
271
|
+
tb->find(table::findBackForword);
|
272
|
+
i = v;
|
273
|
+
while (i >= 10)
|
274
|
+
{
|
275
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "find stat");
|
276
|
+
BOOST_CHECK_MESSAGE(i == tb->getFVint(fdi_id), "find value " << i);
|
277
|
+
tb->findPrev(true); // 11 ~ 19
|
278
|
+
--i;
|
279
|
+
}
|
280
|
+
|
281
|
+
v = 20000;
|
282
|
+
tb->setFV((short)0, v);
|
283
|
+
tb->find(table::findForword);
|
284
|
+
BOOST_CHECK_MESSAGE(STATUS_EOF == tb->stat(), "find stat");
|
285
|
+
tb->release();
|
286
|
+
}
|
287
|
+
|
288
|
+
void testFindNext(database* db)
|
289
|
+
{
|
290
|
+
table* tb = openTable(db);
|
291
|
+
tb->setKeyNum(0);
|
292
|
+
tb->clearBuffer();
|
293
|
+
tb->setFilter(_T("id >= 10 and id < 20000"), 1, 0);
|
294
|
+
int v = 10;
|
295
|
+
tb->setFV((short)0, v);
|
296
|
+
tb->seekGreater(true);
|
297
|
+
BOOST_CHECK_MESSAGE(v == tb->getFVint(fdi_id), "findNext GetGreater");
|
298
|
+
for (int i = v + 1; i < 20000; i++)
|
299
|
+
{
|
300
|
+
tb->findNext(true); // 11 ~ 19
|
301
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "findNext stat()");
|
302
|
+
BOOST_CHECK_MESSAGE(i == tb->getFVint(fdi_id), "findNext value");
|
303
|
+
|
304
|
+
}
|
305
|
+
tb->release();
|
306
|
+
}
|
307
|
+
|
308
|
+
void testGetPercentage(database* db)
|
309
|
+
{
|
310
|
+
table* tb = openTable(db);
|
311
|
+
tb->clearBuffer();
|
312
|
+
int vv = 10001;
|
313
|
+
tb->setFV((short)0, vv);
|
314
|
+
tb->seek();
|
315
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "GetEqual");
|
316
|
+
percentage_td per = tb->getPercentage();
|
317
|
+
|
318
|
+
BOOST_CHECK_MESSAGE(true == (1200 > abs(5000 - per)), "GetPercentage");
|
319
|
+
tb->release();
|
320
|
+
}
|
321
|
+
|
322
|
+
void testMovePercentage(database* db)
|
323
|
+
{
|
324
|
+
table* tb = openTable(db);
|
325
|
+
tb->clearBuffer();
|
326
|
+
tb->seekByPercentage(5000); // 50%
|
327
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "MovePercentage");
|
328
|
+
// If mainus is less than 500 then ok.
|
329
|
+
BOOST_CHECK_MESSAGE(true == (3000 > abs(10001 - tb->getFVint(fdi_id))), "MovePercentage 1");
|
330
|
+
tb->release();
|
331
|
+
}
|
332
|
+
|
333
|
+
void testGetEqual(database* db)
|
334
|
+
{
|
335
|
+
table* tb = openTable(db);
|
336
|
+
db->beginSnapshot();
|
337
|
+
for (int i = 2; i < 20002; i++)
|
338
|
+
{
|
339
|
+
tb->clearBuffer();
|
340
|
+
tb->setFV((short)0, i);
|
341
|
+
|
342
|
+
tb->seek();
|
343
|
+
BOOST_CHECK_MESSAGE(i == tb->getFVint(fdi_id), "GetEqual");
|
344
|
+
|
345
|
+
}
|
346
|
+
db->endSnapshot();
|
347
|
+
tb->release();
|
348
|
+
}
|
349
|
+
|
350
|
+
void testGetNext(database* db)
|
351
|
+
{
|
352
|
+
table* tb = openTable(db);
|
353
|
+
for (int j = 0; j < 1; j++)
|
354
|
+
{
|
355
|
+
db->beginSnapshot();
|
356
|
+
int vv = 2;
|
357
|
+
tb->clearBuffer();
|
358
|
+
tb->setFV(fdi_id, vv);
|
359
|
+
tb->seek();
|
360
|
+
BOOST_CHECK_MESSAGE(vv == tb->getFVint(fdi_id), "GetNext");
|
361
|
+
|
362
|
+
for (int i = 3; i < 20002; i++)
|
363
|
+
tb->seekNext();
|
364
|
+
db->endSnapshot();
|
365
|
+
}
|
366
|
+
tb->release();
|
367
|
+
}
|
368
|
+
|
369
|
+
void testGetPrevious(database* db)
|
370
|
+
{
|
371
|
+
table* tb = openTable(db);
|
372
|
+
db->beginSnapshot();
|
373
|
+
int vv = 20001;
|
374
|
+
tb->clearBuffer();
|
375
|
+
tb->setFV((short)0, vv);
|
376
|
+
tb->seek();
|
377
|
+
BOOST_CHECK_MESSAGE(vv == tb->getFVint(fdi_id), "GetPrevious");
|
378
|
+
for (int i = 20000; i > 1; i--)
|
379
|
+
{
|
380
|
+
tb->seekPrev();
|
381
|
+
BOOST_CHECK_MESSAGE(i == tb->getFVint(fdi_id), "GetPrevious I");
|
382
|
+
}
|
383
|
+
tb->seekPrev();
|
384
|
+
BOOST_CHECK_MESSAGE(_tstring(_T("kosaka")) == _tstring(tb->getFVstr(1)), "GetPrevious kosaka");
|
385
|
+
|
386
|
+
db->endSnapshot();
|
387
|
+
tb->release();
|
388
|
+
}
|
389
|
+
|
390
|
+
void testGetGreater(database* db)
|
391
|
+
{
|
392
|
+
table* tb = openTable(db);
|
393
|
+
int vv = 15000;
|
394
|
+
tb->clearBuffer();
|
395
|
+
tb->setFV(fdi_id, vv);
|
396
|
+
tb->seekGreater(true);
|
397
|
+
BOOST_CHECK_MESSAGE(vv == tb->getFVint(fdi_id), "GetGreater true");
|
398
|
+
tb->seekNext();
|
399
|
+
BOOST_CHECK_MESSAGE(vv + 1 == tb->getFVint(fdi_id), "GetGreater GetNext");
|
400
|
+
|
401
|
+
vv = 14000;
|
402
|
+
tb->clearBuffer();
|
403
|
+
tb->setFV((short)0, vv);
|
404
|
+
tb->seekGreater(false);
|
405
|
+
BOOST_CHECK_MESSAGE(vv + 1 == tb->getFVint(fdi_id), "GetGreater false");
|
406
|
+
tb->seekPrev();
|
407
|
+
BOOST_CHECK_MESSAGE(vv == tb->getFVint(fdi_id), "GetGreater GetPrevious");
|
408
|
+
tb->release();
|
409
|
+
}
|
410
|
+
|
411
|
+
void testGetLessThan(database* db)
|
412
|
+
{
|
413
|
+
table* tb = openTable(db);
|
414
|
+
int vv = 15000;
|
415
|
+
tb->clearBuffer();
|
416
|
+
tb->setFV(fdi_id, vv);
|
417
|
+
tb->seekLessThan(true);
|
418
|
+
BOOST_CHECK_MESSAGE(vv == tb->getFVint(fdi_id), "GetLessThan true");
|
419
|
+
|
420
|
+
tb->seekNext();
|
421
|
+
BOOST_CHECK_MESSAGE(vv + 1 == tb->getFVint(fdi_id), "GetLessThan GetNext");
|
422
|
+
|
423
|
+
vv = 14000;
|
424
|
+
tb->clearBuffer();
|
425
|
+
tb->setFV(fdi_id, vv);
|
426
|
+
tb->seekLessThan(false);
|
427
|
+
BOOST_CHECK_MESSAGE(vv - 1 == tb->getFVint(fdi_id), "GetLessThan false");
|
428
|
+
tb->seekPrev();
|
429
|
+
BOOST_CHECK_MESSAGE(vv - 2 == tb->getFVint(fdi_id), "GetLessThan GetPrevious");
|
430
|
+
tb->release();
|
431
|
+
}
|
432
|
+
|
433
|
+
void testGetFirst(database* db)
|
434
|
+
{
|
435
|
+
table* tb = openTable(db);
|
436
|
+
tb->clearBuffer();
|
437
|
+
tb->seekFirst();
|
438
|
+
BOOST_CHECK_MESSAGE(_tstring(_T("kosaka")) == _tstring(tb->getFVstr(1)), "GetFirst");
|
439
|
+
tb->release();
|
440
|
+
}
|
441
|
+
|
442
|
+
void testGetLast(database* db)
|
443
|
+
{
|
444
|
+
table* tb = openTable(db);
|
445
|
+
tb->clearBuffer();
|
446
|
+
tb->seekLast();
|
447
|
+
BOOST_CHECK_MESSAGE(20002 == tb->getFVint(fdi_id), "GetLast");
|
448
|
+
tb->release();
|
449
|
+
}
|
450
|
+
|
451
|
+
void testMovePosition(database* db)
|
452
|
+
{
|
453
|
+
table* tb = openTable(db);
|
454
|
+
tb->clearBuffer();
|
455
|
+
int vv = 15000;
|
456
|
+
tb->clearBuffer();
|
457
|
+
tb->setFV(fdi_id, vv);
|
458
|
+
tb->seekLessThan(true);
|
459
|
+
BOOST_CHECK_MESSAGE(vv == tb->getFVint(fdi_id), "GetLessThan ");
|
460
|
+
|
461
|
+
bookmark_td pos = tb->bookmark();
|
462
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "GetBookMark");
|
463
|
+
|
464
|
+
vv = 14000;
|
465
|
+
tb->clearBuffer();
|
466
|
+
tb->setFV(fdi_id, vv);
|
467
|
+
tb->seekLessThan(false);
|
468
|
+
BOOST_CHECK_MESSAGE(vv - 1 == tb->getFVint(fdi_id), "GetLessThan false");
|
469
|
+
tb->seekPrev();
|
470
|
+
BOOST_CHECK_MESSAGE(vv - 2 == tb->getFVint(fdi_id), "GetLessThan GetPrevious");
|
471
|
+
|
472
|
+
tb->seekByBookmark(pos);
|
473
|
+
BOOST_CHECK_MESSAGE(15000 == tb->getFVint(fdi_id), "MovePosition");
|
474
|
+
tb->release();
|
475
|
+
}
|
476
|
+
|
477
|
+
void testUpdate(database* db)
|
478
|
+
{
|
479
|
+
table* tb = openTable(db);
|
480
|
+
|
481
|
+
db->beginTrn();
|
482
|
+
// test of ncc
|
483
|
+
int v = 5;
|
484
|
+
tb->clearBuffer();
|
485
|
+
tb->setFV(fdi_id, v);
|
486
|
+
tb->seek();
|
487
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "GetEqual U");
|
488
|
+
v = 30000;
|
489
|
+
tb->setFV(fdi_id, v);
|
490
|
+
tb->update(table::changeCurrentNcc); // 5 -> 30000 cur 5
|
491
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "UpDate00");
|
492
|
+
tb->seekNext(); // next 5
|
493
|
+
BOOST_CHECK_MESSAGE(6 == tb->getFVint(fdi_id), "UpDate0");
|
494
|
+
v = 19999;
|
495
|
+
tb->setFV(fdi_id, v);
|
496
|
+
tb->seek();
|
497
|
+
BOOST_CHECK_MESSAGE(v == tb->getFVint(fdi_id), "UpDate1");
|
498
|
+
v = 5;
|
499
|
+
tb->setFV(fdi_id, v);
|
500
|
+
tb->update(table::changeCurrentCc); // 19999 -> 5 cur 5
|
501
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "UpDate11");
|
502
|
+
tb->seekNext();
|
503
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "UpDate21");
|
504
|
+
BOOST_CHECK_MESSAGE(6 == tb->getFVint(fdi_id), "UpDate2");
|
505
|
+
v = 19999;
|
506
|
+
tb->setFV(fdi_id, v);
|
507
|
+
tb->update(table::changeCurrentCc); // 6 -> 19999 cur 19999
|
508
|
+
tb->seekPrev(); // prev 19999
|
509
|
+
BOOST_CHECK_MESSAGE(v - 1 == tb->getFVint(fdi_id), "UpDate3");
|
510
|
+
v = 10;
|
511
|
+
tb->clearBuffer();
|
512
|
+
tb->setFV(fdi_id, v);
|
513
|
+
tb->seek();
|
514
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "GetEqual U10");
|
515
|
+
tb->seekNext();
|
516
|
+
BOOST_CHECK_MESSAGE(11 == tb->getFVint(fdi_id), "GetEqual Next");
|
517
|
+
for (int i = 10; i < 19999; i++)
|
518
|
+
{
|
519
|
+
tb->clearBuffer();
|
520
|
+
tb->setFV(fdi_id, i);
|
521
|
+
|
522
|
+
tb->seek();
|
523
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "GetEqual U");
|
524
|
+
int v = i + 1;
|
525
|
+
tb->setFV((short)1, v);
|
526
|
+
tb->update();
|
527
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "UpDate");
|
528
|
+
}
|
529
|
+
db->endTrn();
|
530
|
+
|
531
|
+
// check update in key
|
532
|
+
v = 8;
|
533
|
+
tb->setFV(fdi_id, v);
|
534
|
+
tb->setFV(fdi_name, _T("ABC"));
|
535
|
+
tb->update(table::changeInKey);
|
536
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "update changeInKey");
|
537
|
+
|
538
|
+
tb->clearBuffer();
|
539
|
+
tb->setFV(fdi_id, v);
|
540
|
+
tb->seek();
|
541
|
+
BOOST_CHECK_MESSAGE(_tcscmp(_T("ABC"), tb->getFVstr(fdi_name)) == 0, "update changeInKey2");
|
542
|
+
tb->release();
|
543
|
+
}
|
544
|
+
|
545
|
+
void testSnapShot(database* db)
|
546
|
+
{
|
547
|
+
database* db2 = database::create();
|
548
|
+
db2->connect(makeUri(PROTOCOL, HOSTNAME, DBNAME), true);
|
549
|
+
BOOST_CHECK_MESSAGE(0 == db2->stat(), "connect");
|
550
|
+
table* tb = openTable(db);
|
551
|
+
table* tb2 = openTable(db2);
|
552
|
+
|
553
|
+
db->beginSnapshot();
|
554
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "beginSnapShot");
|
555
|
+
tb->setKeyNum(0);
|
556
|
+
tb->seekFirst();
|
557
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "seekFirst");
|
558
|
+
int firstValue = tb->getFVint(fdi_name);
|
559
|
+
tb->seekNext();
|
560
|
+
/* -------------------------------------------------- */
|
561
|
+
// Change data by another connection
|
562
|
+
tb2->setKeyNum(0);
|
563
|
+
tb2->seekFirst();
|
564
|
+
BOOST_CHECK_MESSAGE(0 == tb2->stat(), "tb2->seekFirst");
|
565
|
+
tb2->setFV(fdi_name, tb2->getFVint(fdi_name) + 1);
|
566
|
+
tb2->update();
|
567
|
+
#ifdef ISOLATION_READ_COMMITTED
|
568
|
+
BOOST_CHECK_MESSAGE(0 == tb2->stat(), "tb2->update(");
|
569
|
+
#else
|
570
|
+
#ifdef ISOLATION_REPEATABLE_READ
|
571
|
+
BOOST_CHECK_MESSAGE(STATUS_LOCK_ERROR == tb2->stat(), "tb2->update(");
|
572
|
+
#endif
|
573
|
+
#endif
|
574
|
+
/* -------------------------------------------------- */
|
575
|
+
|
576
|
+
tb->seekFirst();
|
577
|
+
int secondValue = tb->getFVint(fdi_name);
|
578
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "secondValue");
|
579
|
+
db->endSnapshot();
|
580
|
+
|
581
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "endSnapShot");
|
582
|
+
#ifdef ISOLATION_READ_COMMITTED
|
583
|
+
BOOST_CHECK_MESSAGE(secondValue != firstValue, "repeatableRead");
|
584
|
+
#else
|
585
|
+
BOOST_CHECK_MESSAGE(secondValue == firstValue, "repeatableRead");
|
586
|
+
#endif
|
587
|
+
|
588
|
+
/* -------------------------------------------------- */
|
589
|
+
tb->release();
|
590
|
+
tb2->release();
|
591
|
+
database::destroy(db2);
|
592
|
+
}
|
593
|
+
|
594
|
+
void testConflict(database* db)
|
595
|
+
{
|
596
|
+
database* db2 = database::create();
|
597
|
+
db2->connect(makeUri(PROTOCOL, HOSTNAME, DBNAME), true);
|
598
|
+
BOOST_CHECK_MESSAGE(0 == db2->stat(), "connect");
|
599
|
+
table* tb = openTable(db);
|
600
|
+
table* tb2 = openTable(db2);
|
601
|
+
|
602
|
+
tb->setKeyNum(0);
|
603
|
+
tb->seekFirst();
|
604
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "tb->seekFirst");
|
605
|
+
/* --------------------------------------------------
|
606
|
+
Change Index field
|
607
|
+
-------------------------------------------------- */
|
608
|
+
// Change data by another connection
|
609
|
+
tb2->setKeyNum(0);
|
610
|
+
tb2->seekFirst();
|
611
|
+
BOOST_CHECK_MESSAGE(0 == tb2->stat(), "tb2->seekFirst");
|
612
|
+
tb2->setFV(fdi_id, tb2->getFVint(fdi_id) - 10);
|
613
|
+
tb2->update();
|
614
|
+
BOOST_CHECK_MESSAGE(0 == tb2->stat(), "tb2->update(");
|
615
|
+
/* -------------------------------------------------- */
|
616
|
+
// Change same record data by original connection
|
617
|
+
tb->setFV(fdi_id, tb->getFVint(fdi_id) - 8);
|
618
|
+
tb->update();
|
619
|
+
BOOST_CHECK_MESSAGE(STATUS_CHANGE_CONFLICT == tb->stat(), "tb->update(");
|
620
|
+
/* -------------------------------------------------- */
|
621
|
+
|
622
|
+
/* --------------------------------------------------
|
623
|
+
Change Non index field
|
624
|
+
-------------------------------------------------- */
|
625
|
+
// Change data by another connection
|
626
|
+
tb->seekFirst();
|
627
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "tb->seekFirst");
|
628
|
+
tb2->seekFirst();
|
629
|
+
BOOST_CHECK_MESSAGE(0 == tb2->stat(), "tb2->seekFirst");
|
630
|
+
tb2->setFV(fdi_name, tb2->getFVint(fdi_name) - 10);
|
631
|
+
tb2->update();
|
632
|
+
BOOST_CHECK_MESSAGE(0 == tb2->stat(), "tb2->update(");
|
633
|
+
/* -------------------------------------------------- */
|
634
|
+
// Change same record data by original connection
|
635
|
+
tb->setFV(fdi_name, tb->getFVint(fdi_name) - 8);
|
636
|
+
tb->update();
|
637
|
+
BOOST_CHECK_MESSAGE(STATUS_CHANGE_CONFLICT == tb->stat(), "tb->update(");
|
638
|
+
/* -------------------------------------------------- */
|
639
|
+
tb->release();
|
640
|
+
tb2->release();
|
641
|
+
database::destroy(db2);
|
642
|
+
}
|
643
|
+
|
644
|
+
void testTransactionLock(database* db)
|
645
|
+
{
|
646
|
+
|
647
|
+
database* db2 = database::create();
|
648
|
+
db2->connect(makeUri(PROTOCOL, HOSTNAME, DBNAME), true);
|
649
|
+
BOOST_CHECK_MESSAGE(0 == db2->stat(), "connect");
|
650
|
+
table* tb = openTable(db);
|
651
|
+
table* tb2 = openTable(db2);
|
652
|
+
|
653
|
+
// ------------------------------------------------------
|
654
|
+
// Read test that single record lock with read
|
655
|
+
// ------------------------------------------------------
|
656
|
+
db->beginTrn(LOCK_SINGLE_NOWAIT);
|
657
|
+
tb->setKeyNum(0);
|
658
|
+
tb->seekFirst();
|
659
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "tb->seekFirst");
|
660
|
+
|
661
|
+
// unlock first record.
|
662
|
+
tb->seekNext();
|
663
|
+
|
664
|
+
tb2->seekFirst();
|
665
|
+
BOOST_CHECK_MESSAGE(0 == tb2->stat(), "tb->seekFirst");
|
666
|
+
|
667
|
+
db2->beginTrn();
|
668
|
+
tb2->setKeyNum(0);
|
669
|
+
tb2->seekFirst();
|
670
|
+
BOOST_CHECK_MESSAGE(0 == tb2->stat(), "tb->seekFirst");
|
671
|
+
db2->endTrn();
|
672
|
+
db->endTrn();
|
673
|
+
|
674
|
+
// ------------------------------------------------------
|
675
|
+
// Can't read test that multi record lock with read
|
676
|
+
// ------------------------------------------------------
|
677
|
+
db->beginTrn(LOCK_MULTI_NOWAIT);
|
678
|
+
tb->setKeyNum(0);
|
679
|
+
tb->seekFirst();
|
680
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "tb->seekFirst");
|
681
|
+
|
682
|
+
// move from first record.
|
683
|
+
tb->seekNext();
|
684
|
+
|
685
|
+
// The no transaction user can not read .
|
686
|
+
tb2->seekFirst();
|
687
|
+
BOOST_CHECK_MESSAGE(STATUS_LOCK_ERROR == tb2->stat(), "tb->seekFirst");
|
688
|
+
|
689
|
+
// The second transaction user can not lock same record.
|
690
|
+
db2->beginTrn();
|
691
|
+
tb2->setKeyNum(0);
|
692
|
+
tb2->seekFirst();
|
693
|
+
BOOST_CHECK_MESSAGE(STATUS_LOCK_ERROR == tb2->stat(), "tb->seekFirst");
|
694
|
+
db2->endTrn();
|
695
|
+
db->endTrn();
|
696
|
+
|
697
|
+
// ------------------------------------------------------
|
698
|
+
// Can't read test that single record lock with change
|
699
|
+
// ------------------------------------------------------
|
700
|
+
db->beginTrn(LOCK_SINGLE_NOWAIT);
|
701
|
+
tb->setKeyNum(0);
|
702
|
+
tb->seekFirst();
|
703
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "tb->seekFirst");
|
704
|
+
tb->setFV(fdi_name, _T("ABC"));
|
705
|
+
tb->update();
|
706
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "update");
|
707
|
+
|
708
|
+
// move from first record.
|
709
|
+
tb->seekNext();
|
710
|
+
|
711
|
+
tb2->seekFirst();
|
712
|
+
BOOST_CHECK_MESSAGE(STATUS_LOCK_ERROR == tb2->stat(), "tb->seekFirst");
|
713
|
+
|
714
|
+
db2->beginTrn();
|
715
|
+
tb2->setKeyNum(0);
|
716
|
+
tb2->seekFirst();
|
717
|
+
BOOST_CHECK_MESSAGE(STATUS_LOCK_ERROR == tb2->stat(), "tb->seekFirst");
|
718
|
+
db2->endTrn();
|
719
|
+
db->endTrn();
|
720
|
+
|
721
|
+
// ------------------------------------------------------
|
722
|
+
// Abort test that Single record lock transaction
|
723
|
+
// ------------------------------------------------------
|
724
|
+
db->beginTrn(LOCK_SINGLE_NOWAIT);
|
725
|
+
tb->setKeyNum(0);
|
726
|
+
tb->seekFirst();
|
727
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "tb->seekFirst");
|
728
|
+
tb->setFV(fdi_name, _T("EFG"));
|
729
|
+
tb->update();
|
730
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "update");
|
731
|
+
|
732
|
+
// move from first record.
|
733
|
+
tb->seekNext();
|
734
|
+
db->abortTrn();
|
735
|
+
|
736
|
+
tb2->setKeyNum(0);
|
737
|
+
tb2->seekFirst();
|
738
|
+
BOOST_CHECK_MESSAGE(_tcscmp(tb2->getFVstr(fdi_name), _T("ABC")) == 0, "tb->seekFirst");
|
739
|
+
|
740
|
+
tb->release();
|
741
|
+
tb2->release();
|
742
|
+
database::destroy(db2);
|
743
|
+
}
|
744
|
+
|
745
|
+
void testInsert2(database* db)
|
746
|
+
{
|
747
|
+
table* tb = openTable(db);
|
748
|
+
int v = 40000;
|
749
|
+
db->beginTrn();
|
750
|
+
tb->clearBuffer();
|
751
|
+
tb->setFV(fdi_id, v);
|
752
|
+
tb->insert();
|
753
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "insert");
|
754
|
+
v = 10;
|
755
|
+
tb->clearBuffer();
|
756
|
+
tb->setFV((short)0, v);
|
757
|
+
tb->seek();
|
758
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "GetEqual Ins");
|
759
|
+
tb->seekNext();
|
760
|
+
BOOST_CHECK_MESSAGE(11 == tb->getFVint(fdi_id), "GetEqual InsNext");
|
761
|
+
db->endTrn();
|
762
|
+
tb->release();
|
763
|
+
|
764
|
+
|
765
|
+
}
|
766
|
+
|
767
|
+
void testDelete(database* db)
|
768
|
+
{
|
769
|
+
table* tb = openTable(db);
|
770
|
+
|
771
|
+
// estimate number
|
772
|
+
int count = tb->recordCount(true);
|
773
|
+
bool c = (abs(count - 20003) < 3000);
|
774
|
+
BOOST_CHECK_MESSAGE(c == true, "RecordCount1");
|
775
|
+
if (!c)
|
776
|
+
{
|
777
|
+
char tmp[256];
|
778
|
+
sprintf_s(tmp, 256, "true record count = 20003 as estimate recordCount count = %d ", count);
|
779
|
+
BOOST_CHECK_MESSAGE(false, tmp);
|
780
|
+
}
|
781
|
+
// true number
|
782
|
+
BOOST_CHECK_MESSAGE((uint_td)20003 == tb->recordCount(false), "RecordCount2");
|
783
|
+
int vv = 15001;
|
784
|
+
tb->clearBuffer();
|
785
|
+
tb->setFV(fdi_id, vv);
|
786
|
+
tb->seek();
|
787
|
+
BOOST_CHECK_MESSAGE(vv == tb->getFVint(fdi_id), "GetEqual");
|
788
|
+
tb->del();
|
789
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "Delete");
|
790
|
+
tb->setFV((short)0, vv);
|
791
|
+
tb->seek();
|
792
|
+
BOOST_CHECK_MESSAGE(4 == tb->stat(), "GetEqual");
|
793
|
+
|
794
|
+
// check update in key
|
795
|
+
vv = 8;
|
796
|
+
tb->setFV(fdi_id, vv);
|
797
|
+
tb->del(table::inkey);
|
798
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "delete changeInKey");
|
799
|
+
|
800
|
+
tb->clearBuffer();
|
801
|
+
tb->setFV(fdi_id, vv);
|
802
|
+
tb->seek();
|
803
|
+
BOOST_CHECK_MESSAGE(tb->stat() == STATUS_NOT_FOUND_TI, "delete changeInKey2");
|
804
|
+
|
805
|
+
db->beginTrn();
|
806
|
+
tb->stepFirst();
|
807
|
+
while (tb->stat() == 0)
|
808
|
+
{
|
809
|
+
tb->del();
|
810
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "Delete");
|
811
|
+
tb->stepNext();
|
812
|
+
}
|
813
|
+
BOOST_CHECK_MESSAGE(9 == tb->stat(), "StepNext");
|
814
|
+
db->endTrn();
|
815
|
+
BOOST_CHECK_MESSAGE((uint_td)0 == tb->recordCount(false), "RecordCount");
|
816
|
+
tb->release();
|
817
|
+
|
818
|
+
}
|
819
|
+
|
820
|
+
void testSetOwner(database* db)
|
821
|
+
{
|
822
|
+
table* tb = openTable(db);
|
823
|
+
tb->setOwnerName(_T("ABCDEFG"));
|
824
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "SetOwner");
|
825
|
+
tb->clearOwnerName();
|
826
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "SetOwner");
|
827
|
+
tb->release();
|
828
|
+
}
|
829
|
+
|
830
|
+
void testDropIndex(database* db)
|
831
|
+
{
|
832
|
+
table* tb = openTable(db);
|
833
|
+
tb->dropIndex(false);
|
834
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "DropIndex");
|
835
|
+
tb->release();
|
836
|
+
|
837
|
+
}
|
838
|
+
|
839
|
+
void testLogin(database* db)
|
840
|
+
{
|
841
|
+
if (_tcscmp(PROTOCOL, _T("tdap")) != 0)
|
842
|
+
return;
|
843
|
+
|
844
|
+
db->connect(makeUri(PROTOCOL, HOSTNAME, _T("")));
|
845
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "connect");
|
846
|
+
if (db->stat() == 0)
|
847
|
+
{
|
848
|
+
// second connection
|
849
|
+
database* db2 = database::create();
|
850
|
+
db2->connect(makeUri(PROTOCOL, HOSTNAME, _T("")), true);
|
851
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "new connection connect");
|
852
|
+
database::destroy(db2);
|
853
|
+
|
854
|
+
db->disconnect(makeUri(PROTOCOL, HOSTNAME, _T("")));
|
855
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "disconnect");
|
856
|
+
|
857
|
+
}
|
858
|
+
// invalid host name
|
859
|
+
db->connect(makeUri(PROTOCOL, _T("localhost123"), _T("")));
|
860
|
+
bool f = (db->stat() == ERROR_TD_INVALID_CLINETHOST) || (db->stat() == ERROR_TD_HOSTNAME_NOT_FOUND);
|
861
|
+
BOOST_CHECK_MESSAGE(f, "bad host stat =" << db->stat());
|
862
|
+
if (!f)
|
863
|
+
{
|
864
|
+
|
865
|
+
#ifndef _UNICODE
|
866
|
+
TCHAR buf[256];
|
867
|
+
sprintf_s(buf, 256, "bad host db->stat()=%d", db->stat());
|
868
|
+
BOOST_MESSAGE(buf);
|
869
|
+
#endif
|
870
|
+
}
|
871
|
+
testCreateNewDataBase(db);
|
872
|
+
db->disconnect(makeUri(PROTOCOL, HOSTNAME, DBNAME));
|
873
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "databese disconnect");
|
874
|
+
|
875
|
+
// true database name
|
876
|
+
db->connect(makeUri(PROTOCOL, HOSTNAME, DBNAME));
|
877
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "databese ");
|
878
|
+
if (db->stat() == 0)
|
879
|
+
{
|
880
|
+
db->disconnect(makeUri(PROTOCOL, HOSTNAME, DBNAME));
|
881
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "databese disconnect");
|
882
|
+
}
|
883
|
+
// invalid database name
|
884
|
+
testDropDatabase(db);
|
885
|
+
db->disconnect(makeUri(PROTOCOL, HOSTNAME, DBNAME));
|
886
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "databese disconnect");
|
887
|
+
|
888
|
+
db->connect(makeUri(PROTOCOL, HOSTNAME, DBNAME));
|
889
|
+
BOOST_CHECK_MESSAGE(25000 + 1049 == db->stat(), "bad databese connect");
|
890
|
+
|
891
|
+
db->disconnect(makeUri(PROTOCOL, HOSTNAME, DBNAME));
|
892
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "bad databese disconnect");
|
893
|
+
|
894
|
+
}
|
895
|
+
|
896
|
+
// ------------------------------------------------------------------------
|
897
|
+
|
898
|
+
// ------------------------------------------------------------------------
|
899
|
+
void doCreateVarTable(database* db, int id, const _TCHAR* name, char fieldType, int charset)
|
900
|
+
{
|
901
|
+
// create table
|
902
|
+
dbdef* def = db->dbDef();
|
903
|
+
tabledef td;
|
904
|
+
memset(&td, 0, sizeof(td));
|
905
|
+
td.setTableName(name);
|
906
|
+
_TCHAR buf[267];
|
907
|
+
_tcscpy_s(buf, 100, name);
|
908
|
+
_tcscat_s(buf, 100, _T(".dat"));
|
909
|
+
td.setFileName(buf);
|
910
|
+
td.id = id;
|
911
|
+
td.keyCount = 0;
|
912
|
+
td.fieldCount = 0;
|
913
|
+
td.flags.all = 0;
|
914
|
+
td.primaryKeyNum = -1;
|
915
|
+
td.parentKeyNum = -1;
|
916
|
+
td.replicaKeyNum = -1;
|
917
|
+
|
918
|
+
td.pageSize = 2048;
|
919
|
+
|
920
|
+
td.charsetIndex = charset;
|
921
|
+
|
922
|
+
def->insertTable(&td);
|
923
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "insertTable");
|
924
|
+
|
925
|
+
fielddef* fd = def->insertField(id, 0);
|
926
|
+
fd->setName(_T("id"));
|
927
|
+
fd->type = ft_integer;
|
928
|
+
fd->len = (ushort_td)4;
|
929
|
+
def->updateTableDef(id);
|
930
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 1");
|
931
|
+
|
932
|
+
fd = def->insertField(id, 1);
|
933
|
+
fd->setName(_T("name"));
|
934
|
+
fd->type = fieldType;
|
935
|
+
if (fieldType == ft_mywvarchar)
|
936
|
+
fd->len = (ushort_td)1 + mysql::charsize(CHARSET_UTF16LE) * 3; // max 3 char len byte
|
937
|
+
else if (fieldType == ft_mywvarbinary)
|
938
|
+
fd->len = (ushort_td)1 + mysql::charsize(CHARSET_UTF16LE) * 3; // max 6 char len byte
|
939
|
+
else if (fieldType == ft_myvarchar)
|
940
|
+
{
|
941
|
+
if (charset == CHARSET_CP932)
|
942
|
+
fd->len = (ushort_td)1 + mysql::charsize(CHARSET_CP932) * 3; // max 6 char len byte
|
943
|
+
else if (charset == CHARSET_UTF8B4)
|
944
|
+
fd->len = (ushort_td)1 + mysql::charsize(CHARSET_UTF8B4) * 3; // max 6 char len byte
|
945
|
+
}
|
946
|
+
else
|
947
|
+
fd->len = (ushort_td)7; // max 6 char len byte
|
948
|
+
def->updateTableDef(id);
|
949
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 2");
|
950
|
+
|
951
|
+
fd = def->insertField(id, 2);
|
952
|
+
fd->setName(_T("groupid"));
|
953
|
+
fd->type = ft_integer;
|
954
|
+
fd->len = (ushort_td)4;
|
955
|
+
def->updateTableDef(id);
|
956
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 3");
|
957
|
+
|
958
|
+
keydef* kd = def->insertKey(id, 0);
|
959
|
+
|
960
|
+
kd->segments[0].fieldNum = 0;
|
961
|
+
kd->segments[0].flags.bit8 = 1; // extended key type
|
962
|
+
kd->segments[0].flags.bit1 = 1; // changeable
|
963
|
+
kd->segmentCount = 1;
|
964
|
+
|
965
|
+
def->updateTableDef(id);
|
966
|
+
|
967
|
+
kd = def->insertKey(id, 1);
|
968
|
+
|
969
|
+
kd->segments[0].fieldNum = 1;
|
970
|
+
kd->segments[0].flags.bit8 = 1; // extended key type
|
971
|
+
kd->segments[0].flags.bit1 = 1; // changeable
|
972
|
+
kd->segments[0].flags.bit0 = 1; // duplicateable
|
973
|
+
kd->segments[0].flags.bit4 = 1; // not last segmnet
|
974
|
+
kd->segments[1].fieldNum = 2;
|
975
|
+
kd->segments[1].flags.bit8 = 1; // extended key type
|
976
|
+
kd->segments[1].flags.bit1 = 1; // changeable
|
977
|
+
kd->segments[1].flags.bit0 = 1; // duplicateable
|
978
|
+
kd->segmentCount = 2;
|
979
|
+
|
980
|
+
def->updateTableDef(id);
|
981
|
+
|
982
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 4");
|
983
|
+
table* tb = db->openTable(id);
|
984
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "openTable");
|
985
|
+
if (tb)
|
986
|
+
tb->release();
|
987
|
+
|
988
|
+
}
|
989
|
+
|
990
|
+
bool isUtf16leSupport(database* db)
|
991
|
+
{
|
992
|
+
btrVersions vv;
|
993
|
+
db->getBtrVersion(&vv);
|
994
|
+
if ((int)'M' == (int)vv.versions[1].type)
|
995
|
+
{
|
996
|
+
if (vv.versions[1].majorVersion > 5)
|
997
|
+
return true;
|
998
|
+
if (vv.versions[1].minorVersion > 5)
|
999
|
+
return true;
|
1000
|
+
return false;
|
1001
|
+
}
|
1002
|
+
return true;
|
1003
|
+
}
|
1004
|
+
|
1005
|
+
void testCreateDataBaseVar(database* db)
|
1006
|
+
{
|
1007
|
+
if (_tcscmp(PROTOCOL, _T("tdap")) != 0)
|
1008
|
+
return;
|
1009
|
+
|
1010
|
+
db->create(makeUri(PROTOCOL, HOSTNAME, _T("testvar"), BDFNAME));
|
1011
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "createNewDataBase stat = " << db->stat());
|
1012
|
+
if (0 == db->stat())
|
1013
|
+
{
|
1014
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, _T("testvar"), BDFNAME), 0, 0);
|
1015
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "createNewDataBase 1");
|
1016
|
+
|
1017
|
+
if (0 == db->stat())
|
1018
|
+
{
|
1019
|
+
doCreateVarTable(db, 1, _T("user1"), ft_myvarchar, CHARSET_CP932);
|
1020
|
+
doCreateVarTable(db, 2, _T("user2"), ft_myvarbinary, CHARSET_CP932);
|
1021
|
+
if (isUtf16leSupport(db))
|
1022
|
+
doCreateVarTable(db, 3, _T("user3"), ft_mywvarchar, CHARSET_CP932);
|
1023
|
+
doCreateVarTable(db, 4, _T("user4"), ft_mywvarbinary, CHARSET_CP932);
|
1024
|
+
doCreateVarTable(db, 5, _T("user5"), ft_myvarchar, CHARSET_UTF8B4);
|
1025
|
+
db->close();
|
1026
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, _T("testvar"), TRANSACTD_SCHEMANAME), 0, 0);
|
1027
|
+
}
|
1028
|
+
}
|
1029
|
+
|
1030
|
+
}
|
1031
|
+
|
1032
|
+
void testDropDataBaseVar(database* db)
|
1033
|
+
{
|
1034
|
+
if (_tcscmp(PROTOCOL, _T("tdap")) != 0)
|
1035
|
+
return;
|
1036
|
+
|
1037
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, _T("testvar"), BDFNAME));
|
1038
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "open stat = " << db->stat());
|
1039
|
+
if (0 == db->stat())
|
1040
|
+
{
|
1041
|
+
db->drop();
|
1042
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "DropDataBaseVar");
|
1043
|
+
}
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
void dump(const char* p, int size)
|
1047
|
+
{
|
1048
|
+
std::string s;
|
1049
|
+
char tmp[100];
|
1050
|
+
for (int i = 0; i < size; i += 16)
|
1051
|
+
{
|
1052
|
+
for (int j = 0; j < 16; j++)
|
1053
|
+
{
|
1054
|
+
printf(tmp, "%02X ", *((unsigned char*)(p + i + j)));
|
1055
|
+
s.append(tmp);
|
1056
|
+
}
|
1057
|
+
s.append(" ");
|
1058
|
+
|
1059
|
+
for (int j = 0; j < 16; j++)
|
1060
|
+
{
|
1061
|
+
printf(tmp, "%c", *((unsigned char*)(p + i + j)));
|
1062
|
+
s.append(tmp);
|
1063
|
+
}
|
1064
|
+
s.append("\n");
|
1065
|
+
}
|
1066
|
+
}
|
1067
|
+
|
1068
|
+
void doTestverField(table* tb, bool unicodeField, bool varCharField)
|
1069
|
+
{
|
1070
|
+
// Set Wide Get Wide
|
1071
|
+
#ifdef _WIN32
|
1072
|
+
tb->setFVW(2, L"68");
|
1073
|
+
#else
|
1074
|
+
tb->setFV(2, "68");
|
1075
|
+
#endif
|
1076
|
+
|
1077
|
+
#ifdef _WIN32
|
1078
|
+
// too long string
|
1079
|
+
tb->setFVW(1, L"1234567");
|
1080
|
+
if (varCharField)
|
1081
|
+
{
|
1082
|
+
BOOST_CHECK_MESSAGE(wstring(tb->getFVWstr(1)) == wstring(L"123"), "Get Set W1");
|
1083
|
+
if (wstring(tb->getFVWstr(1)) != wstring(L"123"))
|
1084
|
+
dump((const char*)tb->getFVWstr(1), 7);
|
1085
|
+
}
|
1086
|
+
else
|
1087
|
+
BOOST_CHECK_MESSAGE(wstring(tb->getFVWstr(1)) == wstring(L"123456"), "Get Set W1");
|
1088
|
+
BOOST_CHECK_MESSAGE(wstring(tb->getFVWstr(2)) == wstring(L"68"), "Orverrun 1");
|
1089
|
+
// short
|
1090
|
+
tb->setFVW(1, L"12 ");
|
1091
|
+
BOOST_CHECK_MESSAGE(wstring(tb->getFVWstr(1)) == wstring(L"12 "), "Get Set W2");
|
1092
|
+
BOOST_CHECK_MESSAGE(wstring(tb->getFVWstr(2)) == wstring(L"68"), "Orverrun 2");
|
1093
|
+
// too long lanji
|
1094
|
+
|
1095
|
+
if (unicodeField)
|
1096
|
+
{
|
1097
|
+
|
1098
|
+
tb->setFVW(1, L"あいうえお\xD867\xDE3D"); // kanji that "aiueohokke"
|
1099
|
+
if (varCharField)
|
1100
|
+
BOOST_CHECK_MESSAGE(wstring(tb->getFVWstr(1)) == wstring(L"あいう"), "Get Set W3");
|
1101
|
+
else
|
1102
|
+
BOOST_CHECK_MESSAGE(wstring(tb->getFVWstr(1)) == wstring(L"あいうえお"), "Get Set W3");
|
1103
|
+
}
|
1104
|
+
else
|
1105
|
+
{
|
1106
|
+
tb->setFVW(1, L"0松本市"); // kanji that "matumostoshi"
|
1107
|
+
BOOST_CHECK_MESSAGE(wstring(tb->getFVWstr(1)) == wstring(L"0松本"), "Get Set W3");
|
1108
|
+
}
|
1109
|
+
BOOST_CHECK_MESSAGE(wstring(tb->getFVWstr(2)) == wstring(L"68"), "Orverrun 2");
|
1110
|
+
#endif
|
1111
|
+
|
1112
|
+
// Set Ansi Get Wide
|
1113
|
+
// too long string
|
1114
|
+
tb->setFVA(1, "1234567");
|
1115
|
+
if (varCharField)
|
1116
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("123"), "Get Set A1");
|
1117
|
+
else
|
1118
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("123456"), "Get Set A1");
|
1119
|
+
|
1120
|
+
#ifdef _WIN32
|
1121
|
+
BOOST_CHECK_MESSAGE(wstring(tb->getFVWstr(2)) == wstring(L"68"), "Orverrun 1");
|
1122
|
+
#else
|
1123
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(2)) == string("68"), "Orverrun 1");
|
1124
|
+
#endif
|
1125
|
+
// short string
|
1126
|
+
tb->setFVA(1, "13 ");
|
1127
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("13 "), "Get Set A2");
|
1128
|
+
#ifdef _WIN32
|
1129
|
+
BOOST_CHECK_MESSAGE(wstring(tb->getFVWstr(2)) == wstring(L"68"), "Orverrun 2");
|
1130
|
+
#else
|
1131
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(2)) == string("68"), "Orverrun 2");
|
1132
|
+
#endif
|
1133
|
+
// too long lanji
|
1134
|
+
|
1135
|
+
if (unicodeField)
|
1136
|
+
{
|
1137
|
+
#ifdef LINUX
|
1138
|
+
tb->setFVA(1, "あいうえお𩸽"); // kanji that "aiueohokke"
|
1139
|
+
if (varCharField)
|
1140
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("あいう"), "Get Set A3");
|
1141
|
+
else
|
1142
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("あいうえお"), "Get Set A3");
|
1143
|
+
#endif
|
1144
|
+
}
|
1145
|
+
else
|
1146
|
+
{
|
1147
|
+
tb->setFVA(1, "0松本市"); // kanji that "matumostoshi"
|
1148
|
+
bool f = string(tb->getFVAstr(1)) == string("0松本");
|
1149
|
+
BOOST_CHECK_MESSAGE(f, "Get Set A3");
|
1150
|
+
if (!f)
|
1151
|
+
BOOST_MESSAGE(tb->getFVAstr(1));
|
1152
|
+
|
1153
|
+
}
|
1154
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(2)) == string("68"), "Orverrun 2");
|
1155
|
+
|
1156
|
+
// Set Wide Get Ansi
|
1157
|
+
#ifdef _WIN32
|
1158
|
+
// too long string
|
1159
|
+
tb->setFVW(1, L"1234567");
|
1160
|
+
if (varCharField)
|
1161
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("123"), "GetA Set W1");
|
1162
|
+
else
|
1163
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("123456"), "GetA Set W1");
|
1164
|
+
|
1165
|
+
BOOST_CHECK_MESSAGE(wstring(tb->getFVWstr(2)) == wstring(L"68"), "Orverrun 1");
|
1166
|
+
|
1167
|
+
// short string
|
1168
|
+
tb->setFVW(1, L"23 ");
|
1169
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("23 "), "GetA Set W2");
|
1170
|
+
|
1171
|
+
BOOST_CHECK_MESSAGE(wstring(tb->getFVWstr(2)) == wstring(L"68"), "Orverrun 2");
|
1172
|
+
|
1173
|
+
// too long lanji
|
1174
|
+
if (unicodeField)
|
1175
|
+
{
|
1176
|
+
|
1177
|
+
tb->setFVW(1, L"あいうえお\xD867\xDE3D"); // kanji that "aiueohokke"
|
1178
|
+
if (varCharField)
|
1179
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("あいう"), "GetA Set W3");
|
1180
|
+
else
|
1181
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("あいうえお"), "GetA Set W3");
|
1182
|
+
}
|
1183
|
+
else
|
1184
|
+
{
|
1185
|
+
tb->setFVW(1, L"0松本市"); // kanji that "matumostoshi"
|
1186
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("0松本"), "GetA Set W3");
|
1187
|
+
}
|
1188
|
+
BOOST_CHECK_MESSAGE(wstring(tb->getFVWstr(2)) == wstring(L"68"), "Orverrun 2");
|
1189
|
+
#endif
|
1190
|
+
// Set Ansi Get Ansi
|
1191
|
+
// too long string
|
1192
|
+
tb->setFVA(1, "1234567");
|
1193
|
+
if (varCharField)
|
1194
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("123"), "GetA Set A1");
|
1195
|
+
else
|
1196
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("123456"), "GetA Set A1");
|
1197
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(2)) == string("68"), "Orverrun 1");
|
1198
|
+
// short string
|
1199
|
+
tb->setFVA(1, "13 ");
|
1200
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("13 "), "GetA Set A2");
|
1201
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(2)) == string("68"), "Orverrun 2");
|
1202
|
+
|
1203
|
+
// too long lanji
|
1204
|
+
if (unicodeField)
|
1205
|
+
{
|
1206
|
+
#ifdef LINUX
|
1207
|
+
tb->setFVA(1, "あいうえお𩸽"); // kanji that "aiueohokke"
|
1208
|
+
if (varCharField)
|
1209
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("あいう"), "Get Set A3");
|
1210
|
+
else
|
1211
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("あいうえお"), "Get Set A3");
|
1212
|
+
#endif
|
1213
|
+
}
|
1214
|
+
else
|
1215
|
+
{
|
1216
|
+
tb->setFVA(1, "0松本市"); // kanji that "matumostoshi"
|
1217
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(1)) == string("0松本"), "GetA Set A3");
|
1218
|
+
}
|
1219
|
+
BOOST_CHECK_MESSAGE(string(tb->getFVAstr(2)) == string("68"), "Orverrun 2");
|
1220
|
+
|
1221
|
+
}
|
1222
|
+
|
1223
|
+
void testVarField(database* db)
|
1224
|
+
{
|
1225
|
+
if (_tcscmp(PROTOCOL, _T("tdap")) != 0)
|
1226
|
+
return;
|
1227
|
+
|
1228
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, _T("testvar"), BDFNAME));
|
1229
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "open 1");
|
1230
|
+
table* tb = db->openTable(_T("user1"));
|
1231
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "openTable");
|
1232
|
+
BOOST_MESSAGE("Start acp varchar");
|
1233
|
+
doTestverField(tb, false, true);
|
1234
|
+
tb->release();
|
1235
|
+
|
1236
|
+
tb = db->openTable(_T("user2"));
|
1237
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "openTable2");
|
1238
|
+
BOOST_MESSAGE("Start acp varbinary");
|
1239
|
+
doTestverField(tb, false, false);
|
1240
|
+
tb->release();
|
1241
|
+
|
1242
|
+
if (isUtf16leSupport(db))
|
1243
|
+
{
|
1244
|
+
tb = db->openTable(_T("user3"));
|
1245
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "openTable3");
|
1246
|
+
BOOST_MESSAGE("Start unicode varchar");
|
1247
|
+
doTestverField(tb, true, true);
|
1248
|
+
tb->release();
|
1249
|
+
}
|
1250
|
+
tb = db->openTable(_T("user4"));
|
1251
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "openTable4");
|
1252
|
+
BOOST_MESSAGE("Start unicode varbinary");
|
1253
|
+
doTestverField(tb, true, false);
|
1254
|
+
tb->release();
|
1255
|
+
|
1256
|
+
tb = db->openTable(_T("user5"));
|
1257
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "openTable5");
|
1258
|
+
BOOST_MESSAGE("Start utf8 varchar");
|
1259
|
+
doTestverField(tb, true, true);
|
1260
|
+
|
1261
|
+
tb->release();
|
1262
|
+
|
1263
|
+
}
|
1264
|
+
|
1265
|
+
void doVarInsert(database* db, const _TCHAR* name, unsigned int codePage, const _TCHAR* str, int start, int end,
|
1266
|
+
bool bulk)
|
1267
|
+
{
|
1268
|
+
_TCHAR buf[256];
|
1269
|
+
table* tb = db->openTable(name);
|
1270
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "openTable");
|
1271
|
+
if (bulk)
|
1272
|
+
tb->beginBulkInsert(BULKBUFSIZE);
|
1273
|
+
int v;
|
1274
|
+
|
1275
|
+
for (int i = start; i <= end; i++)
|
1276
|
+
{
|
1277
|
+
tb->clearBuffer();
|
1278
|
+
tb->setFV((short)0, i);
|
1279
|
+
_stprintf_s(buf, 256, _T("%s%d"), str, i);
|
1280
|
+
tb->setFV((short)1, buf);
|
1281
|
+
v = i + 10;
|
1282
|
+
tb->setFV((short)2, v);
|
1283
|
+
tb->insert();
|
1284
|
+
|
1285
|
+
}
|
1286
|
+
if (bulk)
|
1287
|
+
tb->commitBulkInsert();
|
1288
|
+
tb->release();
|
1289
|
+
}
|
1290
|
+
|
1291
|
+
void testVarInsert(database* db)
|
1292
|
+
{
|
1293
|
+
if (_tcscmp(PROTOCOL, _T("tdap")) != 0)
|
1294
|
+
return;
|
1295
|
+
|
1296
|
+
int start = 1;
|
1297
|
+
bool bulk = false;
|
1298
|
+
const _TCHAR* str = _T("漢字文字のテスト"); // too long kanji
|
1299
|
+
const _TCHAR* str2 = _T("123");
|
1300
|
+
|
1301
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, _T("testvar"), BDFNAME));
|
1302
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "open 1");
|
1303
|
+
if (0 == db->stat())
|
1304
|
+
{
|
1305
|
+
bool utf16leSupport = isUtf16leSupport(db);
|
1306
|
+
|
1307
|
+
doVarInsert(db, _T("user1"), CP_ACP, str, start, start, bulk);
|
1308
|
+
doVarInsert(db, _T("user2"), CP_ACP, str, start, start, bulk);
|
1309
|
+
if (utf16leSupport)
|
1310
|
+
doVarInsert(db, _T("user3"), CP_ACP, str, start, start, bulk);
|
1311
|
+
doVarInsert(db, _T("user4"), CP_ACP, str, start, start, bulk);
|
1312
|
+
doVarInsert(db, _T("user5"), CP_UTF8, str, start, start, bulk);
|
1313
|
+
|
1314
|
+
++start;
|
1315
|
+
doVarInsert(db, _T("user1"), CP_ACP, str2, start, start, bulk);
|
1316
|
+
doVarInsert(db, _T("user2"), CP_ACP, str2, start, start, bulk);
|
1317
|
+
if (utf16leSupport)
|
1318
|
+
doVarInsert(db, _T("user3"), CP_ACP, str2, start, start, bulk);
|
1319
|
+
doVarInsert(db, _T("user4"), CP_ACP, str2, start, start, bulk);
|
1320
|
+
doVarInsert(db, _T("user5"), CP_UTF8, str2, start, start, bulk);
|
1321
|
+
|
1322
|
+
++start;
|
1323
|
+
bulk = true;
|
1324
|
+
int end = 1000;
|
1325
|
+
doVarInsert(db, _T("user1"), CP_ACP, _T(""), start, end, bulk);
|
1326
|
+
doVarInsert(db, _T("user2"), CP_ACP, _T(""), start, end, bulk);
|
1327
|
+
if (utf16leSupport)
|
1328
|
+
doVarInsert(db, _T("user3"), CP_ACP, _T(""), start, end, bulk);
|
1329
|
+
doVarInsert(db, _T("user4"), CP_ACP, _T(""), start, end, bulk);
|
1330
|
+
doVarInsert(db, _T("user5"), CP_UTF8, _T(""), start, end, bulk);
|
1331
|
+
}
|
1332
|
+
|
1333
|
+
}
|
1334
|
+
|
1335
|
+
void doVarRead(database* db, const _TCHAR* name, unsigned int codePage, const _TCHAR* str, int num, char_td key)
|
1336
|
+
{
|
1337
|
+
|
1338
|
+
table* tb = db->openTable(name);
|
1339
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "openTable");
|
1340
|
+
tb->clearBuffer();
|
1341
|
+
tb->setKeyNum(key);
|
1342
|
+
|
1343
|
+
if (key == 0)
|
1344
|
+
tb->setFV((short)0, num);
|
1345
|
+
else
|
1346
|
+
{
|
1347
|
+
int v = num + 10;
|
1348
|
+
tb->setFV((short)1, str);
|
1349
|
+
tb->setFV((short)2, v);
|
1350
|
+
}
|
1351
|
+
tb->seek();
|
1352
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "GetEqual var stat");
|
1353
|
+
|
1354
|
+
// test read of var field
|
1355
|
+
bool f = _tstring(str) == _tstring(tb->getFVstr(1));
|
1356
|
+
BOOST_CHECK_MESSAGE(f, "GetEqual var field1");
|
1357
|
+
|
1358
|
+
// test read of second field
|
1359
|
+
BOOST_CHECK_MESSAGE((int)(num + 10) == tb->getFVint(2), "GetEqual var field2");
|
1360
|
+
|
1361
|
+
tb->release();
|
1362
|
+
|
1363
|
+
}
|
1364
|
+
|
1365
|
+
void testVarRead(database* db)
|
1366
|
+
{
|
1367
|
+
if (_tcscmp(PROTOCOL, _T("tdap")) != 0)
|
1368
|
+
return;
|
1369
|
+
|
1370
|
+
const _TCHAR* str = _T("漢字文");
|
1371
|
+
const _TCHAR* str3 = _T("漢字文字のテ");
|
1372
|
+
const _TCHAR* str2 = _T("123");
|
1373
|
+
const _TCHAR* str4 = _T("1232");
|
1374
|
+
|
1375
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, _T("testvar"), BDFNAME));
|
1376
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "open 1");
|
1377
|
+
if (0 == db->stat())
|
1378
|
+
{
|
1379
|
+
bool utf16leSupport = isUtf16leSupport(db);
|
1380
|
+
int num = 1;
|
1381
|
+
char_td key = 0;
|
1382
|
+
// too long string
|
1383
|
+
|
1384
|
+
doVarRead(db, _T("user1"), CP_ACP, str, num, key);
|
1385
|
+
doVarRead(db, _T("user2"), CP_ACP, str, num, key);
|
1386
|
+
if (utf16leSupport)
|
1387
|
+
doVarRead(db, _T("user3"), CP_ACP, str, num, key);
|
1388
|
+
doVarRead(db, _T("user4"), CP_ACP, str3, num, key);
|
1389
|
+
doVarRead(db, _T("user5"), CP_UTF8, str, num, key);
|
1390
|
+
// short string
|
1391
|
+
++num;
|
1392
|
+
doVarRead(db, _T("user1"), CP_ACP, str2, num, key);
|
1393
|
+
doVarRead(db, _T("user2"), CP_ACP, str4, num, key);
|
1394
|
+
if (utf16leSupport)
|
1395
|
+
doVarRead(db, _T("user3"), CP_ACP, str2, num, key);
|
1396
|
+
doVarRead(db, _T("user4"), CP_ACP, str4, num, key);
|
1397
|
+
doVarRead(db, _T("user5"), CP_UTF8, str2, num, key);
|
1398
|
+
|
1399
|
+
key = 1;
|
1400
|
+
doVarRead(db, _T("user1"), CP_ACP, _T("120"), 120, key);
|
1401
|
+
doVarRead(db, _T("user2"), CP_ACP, _T("120"), 120, key);
|
1402
|
+
if (utf16leSupport)
|
1403
|
+
doVarRead(db, _T("user3"), CP_ACP, _T("120"), 120, key);
|
1404
|
+
doVarRead(db, _T("user4"), CP_ACP, _T("120"), 120, key);
|
1405
|
+
doVarRead(db, _T("user5"), CP_UTF8, _T("120"), 120, key);
|
1406
|
+
}
|
1407
|
+
}
|
1408
|
+
|
1409
|
+
void doVarFilter(database* db, const _TCHAR* name, unsigned int codePage, const _TCHAR* str, int num, char_td key)
|
1410
|
+
{
|
1411
|
+
table* tb = db->openTable(name);
|
1412
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "openTable");
|
1413
|
+
tb->clearBuffer();
|
1414
|
+
tb->setKeyNum(key);
|
1415
|
+
|
1416
|
+
if (key == 0)
|
1417
|
+
{
|
1418
|
+
_TCHAR buf[120];
|
1419
|
+
_stprintf_s(buf, 120, _T("id > %d and id <= %d"), num, num + 10);
|
1420
|
+
tb->setFilter(buf, 0, 10);
|
1421
|
+
|
1422
|
+
// find forword
|
1423
|
+
tb->setFV((short)0, num);
|
1424
|
+
tb->seekGreater(true);
|
1425
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "GetGreater var stat");
|
1426
|
+
for (int i = num + 1; i <= num + 10; i++)
|
1427
|
+
{
|
1428
|
+
tb->findNext();
|
1429
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "GetGreater var stat");
|
1430
|
+
// test read of var field
|
1431
|
+
BOOST_CHECK_MESSAGE(i == tb->getFVint(1), "findNext");
|
1432
|
+
// test read of second field
|
1433
|
+
BOOST_CHECK_MESSAGE((int)(i + 10) == tb->getFVint(2), "GetEqual var field2");
|
1434
|
+
}
|
1435
|
+
|
1436
|
+
// find previous
|
1437
|
+
int v = num + 10;
|
1438
|
+
tb->setFilter(buf, 0, 10);
|
1439
|
+
tb->setFV(fdi_id, v);
|
1440
|
+
tb->seekLessThan(true);
|
1441
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "GetPrevious var stat");
|
1442
|
+
BOOST_CHECK_MESSAGE(v == tb->getFVint(fdi_id), "GetPrevious");
|
1443
|
+
for (int i = num + 10; i > num; i--)
|
1444
|
+
{
|
1445
|
+
tb->findPrev(false);
|
1446
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "FindPrev var stat");
|
1447
|
+
// test read of var field
|
1448
|
+
BOOST_CHECK_MESSAGE(i == tb->getFVint(1), "FindPrev");
|
1449
|
+
// test read of second field
|
1450
|
+
BOOST_CHECK_MESSAGE((int)(i + 10) == tb->getFVint(2), "FindPrev var field2");
|
1451
|
+
}
|
1452
|
+
|
1453
|
+
// test record count
|
1454
|
+
BOOST_CHECK_MESSAGE((uint_td)10 == tb->recordCount(), "GetEqual var field2");
|
1455
|
+
}
|
1456
|
+
else
|
1457
|
+
{
|
1458
|
+
int v = num + 10;
|
1459
|
+
tb->setFV((short)1, str);
|
1460
|
+
tb->setFV((short)2, v);
|
1461
|
+
}
|
1462
|
+
tb->release();
|
1463
|
+
|
1464
|
+
}
|
1465
|
+
|
1466
|
+
void testFilterVar(database* db)
|
1467
|
+
{
|
1468
|
+
if (_tcscmp(PROTOCOL, _T("tdap")) != 0)
|
1469
|
+
return;
|
1470
|
+
|
1471
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, _T("testvar"), BDFNAME));
|
1472
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "open 1");
|
1473
|
+
if (0 == db->stat())
|
1474
|
+
{
|
1475
|
+
const _TCHAR* str = _T("漢字文");
|
1476
|
+
const _TCHAR* str3 = _T("漢字文字のテ");
|
1477
|
+
const _TCHAR* str2 = _T("123");
|
1478
|
+
const _TCHAR* str4 = _T("1232");
|
1479
|
+
bool utf16leSupport = isUtf16leSupport(db);
|
1480
|
+
|
1481
|
+
int num = 10;
|
1482
|
+
char_td key = 0;
|
1483
|
+
doVarFilter(db, _T("user1"), CP_ACP, str, num, key);
|
1484
|
+
doVarFilter(db, _T("user2"), CP_ACP, str, num, key);
|
1485
|
+
if (utf16leSupport)
|
1486
|
+
doVarFilter(db, _T("user3"), CP_ACP, str, num, key);
|
1487
|
+
doVarFilter(db, _T("user4"), CP_ACP, str3, num, key);
|
1488
|
+
doVarFilter(db, _T("user5"), CP_UTF8, str, num, key);
|
1489
|
+
|
1490
|
+
#ifdef _UNICODE
|
1491
|
+
// short string
|
1492
|
+
++num;
|
1493
|
+
doVarFilter(db, L"user1", CP_ACP, str2, num, key);
|
1494
|
+
doVarFilter(db, L"user2", CP_ACP, str4, num, key);
|
1495
|
+
if (utf16leSupport)
|
1496
|
+
doVarFilter(db, L"user3", CP_ACP, str2, num, key);
|
1497
|
+
doVarFilter(db, L"user4", CP_ACP, str4, num, key);
|
1498
|
+
doVarFilter(db, L"user5", CP_UTF8, str2, num, key);
|
1499
|
+
#endif
|
1500
|
+
|
1501
|
+
key = 1;
|
1502
|
+
doVarFilter(db, _T("user1"), CP_ACP, _T("120"), 120, key);
|
1503
|
+
doVarFilter(db, _T("user2"), CP_ACP, _T("120"), 120, key);
|
1504
|
+
if (utf16leSupport)
|
1505
|
+
doVarFilter(db, _T("user3"), CP_ACP, _T("120"), 120, key);
|
1506
|
+
doVarFilter(db, _T("user4"), CP_ACP, _T("120"), 120, key);
|
1507
|
+
doVarFilter(db, _T("user5"), CP_UTF8, _T("120"), 120, key);
|
1508
|
+
}
|
1509
|
+
|
1510
|
+
}
|
1511
|
+
// ------------------------------------------------------------------------
|
1512
|
+
|
1513
|
+
// ------------------------------------------------------------------------
|
1514
|
+
|
1515
|
+
void stringFileterCreateTable(database* db, int id, const _TCHAR* name, uchar_td type, uchar_td type2)
|
1516
|
+
{
|
1517
|
+
// create table
|
1518
|
+
|
1519
|
+
dbdef* def = db->dbDef();
|
1520
|
+
tabledef td;
|
1521
|
+
memset(&td, 0, sizeof(td));
|
1522
|
+
td.setTableName(name);
|
1523
|
+
_TCHAR buf[267];
|
1524
|
+
_tcscpy_s(buf, 100, name);
|
1525
|
+
_tcscat_s(buf, 100, _T(".dat"));
|
1526
|
+
td.setFileName(buf);
|
1527
|
+
td.id = id;
|
1528
|
+
td.primaryKeyNum = -1;
|
1529
|
+
td.parentKeyNum = -1;
|
1530
|
+
td.replicaKeyNum = -1;
|
1531
|
+
td.pageSize = 2048;
|
1532
|
+
td.charsetIndex = CHARSET_UTF8B4;
|
1533
|
+
// td.charsetIndex = CHARSET_CP932;
|
1534
|
+
|
1535
|
+
def->insertTable(&td);
|
1536
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "insertTable");
|
1537
|
+
|
1538
|
+
fielddef* fd = def->insertField(id, 0);
|
1539
|
+
fd->setName(_T("id"));
|
1540
|
+
fd->type = ft_integer;
|
1541
|
+
fd->len = (ushort_td)4;
|
1542
|
+
def->updateTableDef(id);
|
1543
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 1");
|
1544
|
+
|
1545
|
+
fd = def->insertField(id, 1);
|
1546
|
+
fd->setName(_T("name"));
|
1547
|
+
fd->type = type;
|
1548
|
+
fd->len = 44;
|
1549
|
+
if (fd->varLenBytes())
|
1550
|
+
{
|
1551
|
+
fd->len = fd->varLenBytes() + 44;
|
1552
|
+
fd->keylen = fd->len;
|
1553
|
+
}
|
1554
|
+
if (fd->blobLenBytes())
|
1555
|
+
{
|
1556
|
+
fd->len = 12; // 8+4
|
1557
|
+
|
1558
|
+
}
|
1559
|
+
|
1560
|
+
fd->keylen = fd->len;
|
1561
|
+
def->updateTableDef(id);
|
1562
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 2");
|
1563
|
+
|
1564
|
+
fd = def->insertField(id, 2);
|
1565
|
+
fd->setName(_T("namew"));
|
1566
|
+
fd->type = type2;
|
1567
|
+
fd->len = 44;
|
1568
|
+
if (fd->varLenBytes())
|
1569
|
+
{
|
1570
|
+
fd->len = fd->varLenBytes() + 44;
|
1571
|
+
fd->keylen = fd->len;
|
1572
|
+
}
|
1573
|
+
if (fd->blobLenBytes())
|
1574
|
+
{
|
1575
|
+
fd->len = 12; // 8+4
|
1576
|
+
|
1577
|
+
}
|
1578
|
+
fd->keylen = fd->len;
|
1579
|
+
def->updateTableDef(id);
|
1580
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 3");
|
1581
|
+
|
1582
|
+
keydef* kd = def->insertKey(id, 0);
|
1583
|
+
kd->segments[0].fieldNum = 0;
|
1584
|
+
kd->segments[0].flags.bit8 = 1; // extended key type
|
1585
|
+
kd->segments[0].flags.bit1 = 1; // changeable
|
1586
|
+
kd->segmentCount = 1;
|
1587
|
+
def->updateTableDef(id);
|
1588
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 4");
|
1589
|
+
|
1590
|
+
kd = def->insertKey(id, 1);
|
1591
|
+
kd->segments[0].fieldNum = 1;
|
1592
|
+
kd->segments[0].flags.bit8 = 1; // extended key type
|
1593
|
+
kd->segments[0].flags.bit1 = 1; // changeable
|
1594
|
+
kd->segments[0].flags.bit0 = 1; // duplicateable
|
1595
|
+
kd->segmentCount = 1;
|
1596
|
+
def->updateTableDef(id);
|
1597
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 5");
|
1598
|
+
|
1599
|
+
kd = def->insertKey(id, 2);
|
1600
|
+
kd->segments[0].fieldNum = 2;
|
1601
|
+
kd->segments[0].flags.bit8 = 1; // extended key type
|
1602
|
+
kd->segments[0].flags.bit1 = 1; // changeable
|
1603
|
+
kd->segments[0].flags.bit0 = 1; // duplicateable
|
1604
|
+
kd->segmentCount = 1;
|
1605
|
+
def->updateTableDef(id);
|
1606
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 6");
|
1607
|
+
|
1608
|
+
}
|
1609
|
+
|
1610
|
+
void doInsertStringFileter(table* tb)
|
1611
|
+
{
|
1612
|
+
tb->clearBuffer();
|
1613
|
+
int id = 1;
|
1614
|
+
tb->setFV(_T("id"), id);
|
1615
|
+
tb->setFV(_T("name"), _T("あいうえおかきくこ"));
|
1616
|
+
tb->setFV(_T("namew"), _T("あいうえおかきくこ"));
|
1617
|
+
tb->insert();
|
1618
|
+
|
1619
|
+
tb->clearBuffer();
|
1620
|
+
id = 2;
|
1621
|
+
tb->setFV(_T("id"), id);
|
1622
|
+
tb->setFV(_T("name"), _T("A123456"));
|
1623
|
+
tb->setFV(_T("namew"), _T("A123456"));
|
1624
|
+
tb->insert();
|
1625
|
+
|
1626
|
+
tb->clearBuffer();
|
1627
|
+
id = 3;
|
1628
|
+
tb->setFV(_T("id"), id);
|
1629
|
+
tb->setFV(_T("name"), _T("あいがあればOKです"));
|
1630
|
+
tb->setFV(_T("namew"), _T("あいがあればOKです"));
|
1631
|
+
tb->insert();
|
1632
|
+
|
1633
|
+
tb->clearBuffer();
|
1634
|
+
id = 4;
|
1635
|
+
tb->setFV(_T("id"), id);
|
1636
|
+
tb->setFV(_T("name"), _T("おはようございます"));
|
1637
|
+
tb->setFV(_T("namew"), _T("おはようございます"));
|
1638
|
+
tb->insert();
|
1639
|
+
|
1640
|
+
tb->clearBuffer();
|
1641
|
+
id = 5;
|
1642
|
+
tb->setFV(_T("id"), id);
|
1643
|
+
tb->setFV(_T("name"), _T("おめでとうございます。"));
|
1644
|
+
tb->setFV(_T("namew"), _T("おめでとうございます。"));
|
1645
|
+
tb->insert();
|
1646
|
+
|
1647
|
+
}
|
1648
|
+
|
1649
|
+
void doTestReadSF(table* tb)
|
1650
|
+
{
|
1651
|
+
tb->setKeyNum(0);
|
1652
|
+
tb->clearBuffer();
|
1653
|
+
int id = 1;
|
1654
|
+
tb->setFV(_T("id"), id);
|
1655
|
+
tb->seek();
|
1656
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
|
1657
|
+
BOOST_CHECK_MESSAGE(_tstring(_T("あいうえおかきくこ")) == _tstring(tb->getFVstr(1)), "doTestReadSF2");
|
1658
|
+
|
1659
|
+
id = 3;
|
1660
|
+
tb->setFV(_T("id"), id);
|
1661
|
+
tb->seek();
|
1662
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF3");
|
1663
|
+
BOOST_CHECK_MESSAGE(_tstring(_T("あいがあればOKです")) == _tstring(tb->getFVstr(1)), "doTestReadSF4");
|
1664
|
+
|
1665
|
+
tb->setKeyNum(1);
|
1666
|
+
tb->clearBuffer();
|
1667
|
+
tb->setFV(_T("name"), _T("A123456"));
|
1668
|
+
tb->seek();
|
1669
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF5");
|
1670
|
+
BOOST_CHECK_MESSAGE(_tstring(_T("A123456")) == _tstring(tb->getFVstr(1)), "doTestReadSF6");
|
1671
|
+
|
1672
|
+
tb->setKeyNum(2);
|
1673
|
+
tb->clearBuffer();
|
1674
|
+
tb->setFV(_T("namew"), _T("A123456"));
|
1675
|
+
tb->seek();
|
1676
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF5");
|
1677
|
+
BOOST_CHECK_MESSAGE(_tstring(_T("A123456")) == _tstring(tb->getFVstr(2)), "doTestReadSF6");
|
1678
|
+
|
1679
|
+
}
|
1680
|
+
|
1681
|
+
void doTestSF(table* tb)
|
1682
|
+
{
|
1683
|
+
tb->setKeyNum(0);
|
1684
|
+
tb->clearBuffer();
|
1685
|
+
|
1686
|
+
tb->setFilter(_T("name = 'あい*'"), 0, 10);
|
1687
|
+
tb->seekFirst();
|
1688
|
+
tb->findNext(false);
|
1689
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
|
1690
|
+
BOOST_CHECK_MESSAGE(_tstring(_T("あいうえおかきくこ")) == _tstring(tb->getFVstr(1)), "doTestReadSF2");
|
1691
|
+
BOOST_CHECK_MESSAGE(2 == (int)tb->recordCount(), "doTestReadSF2");
|
1692
|
+
|
1693
|
+
tb->setFilter(_T("name <> 'あい*'"), 0, 10);
|
1694
|
+
BOOST_CHECK_MESSAGE(3 == (int)tb->recordCount(), "doTestReadSF2");
|
1695
|
+
|
1696
|
+
tb->setFilter(_T("name = 'あい'"), 0, 10);
|
1697
|
+
BOOST_CHECK_MESSAGE(0 == (int)tb->recordCount(), "doTestReadSF2");
|
1698
|
+
|
1699
|
+
tb->setFilter(_T("name <> ''"), 0, 10);
|
1700
|
+
BOOST_CHECK_MESSAGE(5 == (int)tb->recordCount(), "doTestReadSF2");
|
1701
|
+
|
1702
|
+
}
|
1703
|
+
|
1704
|
+
void doTestStringFileter(database* db, int id, const _TCHAR* name, uchar_td type, uchar_td type2)
|
1705
|
+
{
|
1706
|
+
|
1707
|
+
stringFileterCreateTable(db, id, name, type, type2);
|
1708
|
+
table* tb = db->openTable(id);
|
1709
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "openTable");
|
1710
|
+
|
1711
|
+
doInsertStringFileter(tb);
|
1712
|
+
doTestReadSF(tb);
|
1713
|
+
doTestSF(tb);
|
1714
|
+
tb->release();
|
1715
|
+
}
|
1716
|
+
|
1717
|
+
void testStringFileter(database* db)
|
1718
|
+
{
|
1719
|
+
db->create(makeUri(PROTOCOL, HOSTNAME, _T("testString"), BDFNAME));
|
1720
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "createNewDataBase");
|
1721
|
+
|
1722
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, _T("testString"), BDFNAME), 0, 0);
|
1723
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "createNewDataBase 1");
|
1724
|
+
|
1725
|
+
doTestStringFileter(db, 1, _T("zstring"), ft_zstring, ft_wzstring);
|
1726
|
+
if (isUtf16leSupport(db))
|
1727
|
+
doTestStringFileter(db, 2, _T("myvarchar"), ft_myvarchar, ft_mywvarchar);
|
1728
|
+
else
|
1729
|
+
doTestStringFileter(db, 2, _T("myvarchar"), ft_myvarchar, ft_myvarchar);
|
1730
|
+
|
1731
|
+
doTestStringFileter(db, 3, _T("mytext"), ft_mytext, ft_myblob);
|
1732
|
+
|
1733
|
+
db->close();
|
1734
|
+
|
1735
|
+
}
|
1736
|
+
|
1737
|
+
void testDropDataBaseStr(database* db)
|
1738
|
+
{
|
1739
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, _T("testString"), BDFNAME), 0, 0);
|
1740
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "createNewDataBase 1");
|
1741
|
+
db->drop();
|
1742
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "DropDataBaseTestString stat=" << db->stat());
|
1743
|
+
|
1744
|
+
}
|
1745
|
+
// ------------------------------------------------------------------------
|
1746
|
+
|
1747
|
+
_TCHAR dbNmae[50] =
|
1748
|
+
{_T("テスト")};
|
1749
|
+
_TCHAR bdfNmae[50] =
|
1750
|
+
{_T("構成.bdf")};
|
1751
|
+
_TCHAR tableNmae[50] =
|
1752
|
+
{_T("漢字テーブル")};
|
1753
|
+
_TCHAR fdName1[50] =
|
1754
|
+
{_T("番号")};
|
1755
|
+
_TCHAR fdName2[50] =
|
1756
|
+
{_T("名前")};
|
1757
|
+
|
1758
|
+
bool nameInited = false;
|
1759
|
+
|
1760
|
+
void initKanjiName()
|
1761
|
+
{
|
1762
|
+
|
1763
|
+
#if (!defined(_UNICODE) && defined(_WIN32))
|
1764
|
+
if (!nameInited)
|
1765
|
+
{
|
1766
|
+
wchar_t tmp[50];
|
1767
|
+
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, dbNmae, -1, tmp, 50);
|
1768
|
+
WideCharToMultiByte(CP_UTF8, 0, tmp, -1, dbNmae, 50, NULL, NULL);
|
1769
|
+
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, bdfNmae, -1, tmp, 50);
|
1770
|
+
WideCharToMultiByte(CP_UTF8, 0, tmp, -1, bdfNmae, 50, NULL, NULL);
|
1771
|
+
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, tableNmae, -1, tmp, 50);
|
1772
|
+
WideCharToMultiByte(CP_UTF8, 0, tmp, -1, tableNmae, 50, NULL, NULL);
|
1773
|
+
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, fdName1, -1, tmp, 50);
|
1774
|
+
WideCharToMultiByte(CP_UTF8, 0, tmp, -1, fdName1, 50, NULL, NULL);
|
1775
|
+
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, fdName2, -1, tmp, 50);
|
1776
|
+
WideCharToMultiByte(CP_UTF8, 0, tmp, -1, fdName2, 50, NULL, NULL);
|
1777
|
+
nameInited = true;
|
1778
|
+
}
|
1779
|
+
#endif
|
1780
|
+
|
1781
|
+
}
|
1782
|
+
|
1783
|
+
void testDropDatabaseKanji(database* db)
|
1784
|
+
{
|
1785
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, dbNmae, bdfNmae));
|
1786
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "DropDataBaseKanji 1");
|
1787
|
+
|
1788
|
+
db->drop();
|
1789
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "DropDataBaseKanji 2");
|
1790
|
+
}
|
1791
|
+
|
1792
|
+
void testKnajiCreateSchema(database* db)
|
1793
|
+
{
|
1794
|
+
initKanjiName();
|
1795
|
+
db->create(makeUri(PROTOCOL, HOSTNAME, dbNmae, bdfNmae));
|
1796
|
+
if (db->stat() == STATUS_TABLE_EXISTS_ERROR)
|
1797
|
+
{
|
1798
|
+
testDropDatabaseKanji(db);
|
1799
|
+
db->create(makeUri(PROTOCOL, HOSTNAME, dbNmae, bdfNmae));
|
1800
|
+
}
|
1801
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "createKanjiDatabase stat = " << db->stat());
|
1802
|
+
// create table
|
1803
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, dbNmae, bdfNmae), TYPE_SCHEMA_BDF, TD_OPEN_NORMAL);
|
1804
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "createKanjiDatabase 1 stat = " << db->stat());
|
1805
|
+
|
1806
|
+
dbdef* def = db->dbDef();
|
1807
|
+
if (def)
|
1808
|
+
{
|
1809
|
+
tabledef td;
|
1810
|
+
memset(&td, 0, sizeof(tabledef));
|
1811
|
+
#ifndef _UNICODE
|
1812
|
+
td.schemaCodePage = CP_UTF8;
|
1813
|
+
#endif
|
1814
|
+
td.setTableName(tableNmae);
|
1815
|
+
td.setFileName(tableNmae);
|
1816
|
+
td.id = 1;
|
1817
|
+
td.primaryKeyNum = -1;
|
1818
|
+
td.parentKeyNum = -1;
|
1819
|
+
td.replicaKeyNum = -1;
|
1820
|
+
td.pageSize = 2048;
|
1821
|
+
|
1822
|
+
def->insertTable(&td);
|
1823
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "insertTable stat = " << def->stat());
|
1824
|
+
|
1825
|
+
fielddef* fd = def->insertField(1, 0);
|
1826
|
+
fd->setName(fdName1);
|
1827
|
+
fd->type = ft_integer;
|
1828
|
+
fd->len = (ushort_td)4;
|
1829
|
+
def->updateTableDef(1);
|
1830
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 1 stat = " << def->stat());
|
1831
|
+
|
1832
|
+
fd = def->insertField(1, 1);
|
1833
|
+
fd->setName(fdName2);
|
1834
|
+
fd->type = ft_zstring;
|
1835
|
+
fd->len = (ushort_td)33;
|
1836
|
+
def->updateTableDef(1);
|
1837
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 2 stat = " << def->stat());
|
1838
|
+
|
1839
|
+
keydef* kd = def->insertKey(1, 0);
|
1840
|
+
kd->segments[0].fieldNum = 0;
|
1841
|
+
kd->segments[0].flags.bit8 = 1; // extended key type
|
1842
|
+
kd->segments[0].flags.bit1 = 1; // changeable
|
1843
|
+
kd->segmentCount = 1;
|
1844
|
+
|
1845
|
+
def->updateTableDef(1);
|
1846
|
+
BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 3 stat = " << def->stat());
|
1847
|
+
|
1848
|
+
}
|
1849
|
+
}
|
1850
|
+
|
1851
|
+
table* openKnajiTable(database* db)
|
1852
|
+
{
|
1853
|
+
|
1854
|
+
db->open(makeUri(PROTOCOL, HOSTNAME, dbNmae, bdfNmae), TYPE_SCHEMA_BDF, TD_OPEN_NORMAL);
|
1855
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "openKnajiTable 1");
|
1856
|
+
table* tb = db->openTable(tableNmae);
|
1857
|
+
BOOST_CHECK_MESSAGE(0 == db->stat(), "openKnajiTable 2");
|
1858
|
+
return tb;
|
1859
|
+
}
|
1860
|
+
|
1861
|
+
void testInsertKanji(database* db)
|
1862
|
+
{
|
1863
|
+
table* tb = openKnajiTable(db);
|
1864
|
+
|
1865
|
+
tb->clearBuffer();
|
1866
|
+
tb->setFV(fdName1, _T("1"));
|
1867
|
+
tb->setFV(fdName2, _T("小坂"));
|
1868
|
+
tb->insert();
|
1869
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "insert 1");
|
1870
|
+
|
1871
|
+
tb->clearBuffer();
|
1872
|
+
tb->setFV(fdName1, _T("2"));
|
1873
|
+
tb->setFV(fdName2, _T("矢口"));
|
1874
|
+
tb->insert();
|
1875
|
+
BOOST_CHECK_MESSAGE(0 == tb->stat(), "insert 2");
|
1876
|
+
tb->release();
|
1877
|
+
|
1878
|
+
}
|
1879
|
+
|
1880
|
+
void testGetEqualKanji(database* db)
|
1881
|
+
{
|
1882
|
+
table* tb = openKnajiTable(db);
|
1883
|
+
tb->clearBuffer();
|
1884
|
+
tb->setFV((short)0, 1);
|
1885
|
+
tb->seek();
|
1886
|
+
BOOST_CHECK_MESSAGE(1 == tb->getFVint(fdName1), "GetEqual id 1");
|
1887
|
+
BOOST_CHECK_MESSAGE(_tcscmp(tb->getFVstr(fdName2), _T("小坂")) == 0, "GetEqual name 2");
|
1888
|
+
|
1889
|
+
tb->setFV((short)0, 2);
|
1890
|
+
tb->seek();
|
1891
|
+
BOOST_CHECK_MESSAGE(2 == tb->getFVint(fdName1), "GetEqual id 2");
|
1892
|
+
BOOST_CHECK_MESSAGE(_tcscmp(tb->getFVstr(fdName2), _T("矢口")) == 0, "GetEqual name 2");
|
1893
|
+
tb->release();
|
1894
|
+
|
1895
|
+
}
|
1896
|
+
|
1897
|
+
// ------------------------------------------------------------------------
|
1898
|
+
BOOST_AUTO_TEST_SUITE(btrv_nativ)
|
1899
|
+
|
1900
|
+
BOOST_FIXTURE_TEST_CASE(createNewDataBase, fixture)
|
1901
|
+
{
|
1902
|
+
const _TCHAR* uri = makeUri(PROTOCOL, HOSTNAME, DBNAME, BDFNAME);
|
1903
|
+
_tprintf(_T("URI = %s\n"), uri);
|
1904
|
+
if (db()->open(makeUri(PROTOCOL, HOSTNAME, DBNAME, BDFNAME)))
|
1905
|
+
db()->drop();
|
1906
|
+
testCreateNewDataBase(db());
|
1907
|
+
}
|
1908
|
+
BOOST_FIXTURE_TEST_CASE(clone, fixture) {testClone(db());}
|
1909
|
+
|
1910
|
+
BOOST_FIXTURE_TEST_CASE(version, fixture) {testVersion(db());}
|
1911
|
+
|
1912
|
+
BOOST_FIXTURE_TEST_CASE(insert, fixture) {testInsert(db());}
|
1913
|
+
|
1914
|
+
BOOST_FIXTURE_TEST_CASE(find, fixture) {testFind(db());}
|
1915
|
+
|
1916
|
+
BOOST_FIXTURE_TEST_CASE(findNext, fixture) {testFindNext(db());}
|
1917
|
+
|
1918
|
+
BOOST_FIXTURE_TEST_CASE(getPercentage, fixture) {testGetPercentage(db());}
|
1919
|
+
|
1920
|
+
BOOST_FIXTURE_TEST_CASE(movePercentage, fixture) {testMovePercentage(db());}
|
1921
|
+
|
1922
|
+
BOOST_FIXTURE_TEST_CASE(getEqual, fixture) {testGetEqual(db());}
|
1923
|
+
|
1924
|
+
BOOST_FIXTURE_TEST_CASE(getNext, fixture) {testGetNext(db());}
|
1925
|
+
|
1926
|
+
BOOST_FIXTURE_TEST_CASE(getPrevious, fixture) {testGetPrevious(db());}
|
1927
|
+
|
1928
|
+
BOOST_FIXTURE_TEST_CASE(getGreater, fixture) {testGetGreater(db());}
|
1929
|
+
|
1930
|
+
BOOST_FIXTURE_TEST_CASE(getLessThan, fixture) {testGetLessThan(db());}
|
1931
|
+
|
1932
|
+
BOOST_FIXTURE_TEST_CASE(getFirst, fixture) {testGetFirst(db());}
|
1933
|
+
|
1934
|
+
BOOST_FIXTURE_TEST_CASE(getLast, fixture) {testGetLast(db());}
|
1935
|
+
|
1936
|
+
BOOST_FIXTURE_TEST_CASE(movePosition, fixture) {testMovePosition(db());}
|
1937
|
+
|
1938
|
+
BOOST_FIXTURE_TEST_CASE(update, fixture) {testUpdate(db());}
|
1939
|
+
|
1940
|
+
BOOST_FIXTURE_TEST_CASE(snapShot, fixture) {testSnapShot(db());}
|
1941
|
+
|
1942
|
+
BOOST_FIXTURE_TEST_CASE(conflict, fixture) {testConflict(db());}
|
1943
|
+
|
1944
|
+
BOOST_FIXTURE_TEST_CASE(transactionLock, fixture) {testTransactionLock(db());}
|
1945
|
+
|
1946
|
+
BOOST_FIXTURE_TEST_CASE(insert2, fixture) {testInsert2(db());}
|
1947
|
+
|
1948
|
+
BOOST_FIXTURE_TEST_CASE(delete_, fixture) {testDelete(db());}
|
1949
|
+
|
1950
|
+
BOOST_FIXTURE_TEST_CASE(setOwner, fixture) {testSetOwner(db());}
|
1951
|
+
|
1952
|
+
BOOST_FIXTURE_TEST_CASE(dropIndex, fixture) {testDropIndex(db());}
|
1953
|
+
|
1954
|
+
BOOST_FIXTURE_TEST_CASE(dropDatabase, fixture) {testDropDatabase(db());}
|
1955
|
+
|
1956
|
+
BOOST_FIXTURE_TEST_CASE(connect, fixture) {testLogin(db());}
|
1957
|
+
BOOST_AUTO_TEST_SUITE_END()
|
1958
|
+
|
1959
|
+
// ------------------------------------------------------------------------
|
1960
|
+
|
1961
|
+
// ------------------------------------------------------------------------
|
1962
|
+
#ifdef LINUX
|
1963
|
+
#include <bzs/env/mbcswchrLinux.h>
|
1964
|
+
|
1965
|
+
BOOST_AUTO_TEST_SUITE(convert)
|
1966
|
+
BOOST_AUTO_TEST_CASE(u8tombc)
|
1967
|
+
{
|
1968
|
+
char mbc[256];
|
1969
|
+
char u8[256] = "123";
|
1970
|
+
|
1971
|
+
bzs::env::u8tombc(u8, -1, mbc, 256);
|
1972
|
+
BOOST_CHECK_MESSAGE(!strcmp(mbc, u8), u8);
|
1973
|
+
|
1974
|
+
strcpy(u8, "漢字");
|
1975
|
+
char mbcKanji[20] =
|
1976
|
+
{0x8A, 0xBF, 0x8E, 0x9A, 0x00};
|
1977
|
+
bzs::env::u8tombc(u8, -1, mbc, 256);
|
1978
|
+
BOOST_CHECK_MESSAGE(!strcmp(mbc, mbcKanji), u8);
|
1979
|
+
|
1980
|
+
memset(u8, 0, 256);
|
1981
|
+
bzs::env::mbctou8(mbc, -1, u8, 256);
|
1982
|
+
BOOST_CHECK_MESSAGE(!strcmp(u8, "漢字"), "漢字2");
|
1983
|
+
}
|
1984
|
+
|
1985
|
+
BOOST_AUTO_TEST_SUITE_END()
|
1986
|
+
#endif
|
1987
|
+
// ------------------------------------------------------------------------
|
1988
|
+
|
1989
|
+
// ------------------------------------------------------------------------
|
1990
|
+
BOOST_AUTO_TEST_SUITE(var_field)
|
1991
|
+
|
1992
|
+
BOOST_FIXTURE_TEST_CASE(createDataBaseVar, fixture) {testCreateDataBaseVar(db());}
|
1993
|
+
|
1994
|
+
BOOST_FIXTURE_TEST_CASE(varField, fixture) {testVarField(db());}
|
1995
|
+
|
1996
|
+
BOOST_FIXTURE_TEST_CASE(varInsert, fixture) {testVarInsert(db());}
|
1997
|
+
|
1998
|
+
BOOST_FIXTURE_TEST_CASE(varRead, fixture) {testVarRead(db());}
|
1999
|
+
|
2000
|
+
BOOST_FIXTURE_TEST_CASE(filterVar, fixture) {testFilterVar(db());}
|
2001
|
+
|
2002
|
+
BOOST_FIXTURE_TEST_CASE(dropDataBaseVar, fixture) {testDropDataBaseVar(db());}
|
2003
|
+
|
2004
|
+
BOOST_AUTO_TEST_SUITE_END()
|
2005
|
+
// ------------------------------------------------------------------------
|
2006
|
+
|
2007
|
+
// ------------------------------------------------------------------------
|
2008
|
+
BOOST_AUTO_TEST_SUITE(filter)
|
2009
|
+
|
2010
|
+
BOOST_FIXTURE_TEST_CASE(stringFileter, fixture) {testStringFileter(db());}
|
2011
|
+
|
2012
|
+
BOOST_FIXTURE_TEST_CASE(dropDataBaseStr, fixture) {testDropDataBaseStr(db());}
|
2013
|
+
|
2014
|
+
BOOST_AUTO_TEST_SUITE_END()
|
2015
|
+
// ------------------------------------------------------------------------
|
2016
|
+
|
2017
|
+
// ------------------------------------------------------------------------
|
2018
|
+
BOOST_AUTO_TEST_SUITE(kanjiSchema)
|
2019
|
+
|
2020
|
+
BOOST_FIXTURE_TEST_CASE(knajiCreateSchema, fixture) {testKnajiCreateSchema(db());}
|
2021
|
+
|
2022
|
+
BOOST_FIXTURE_TEST_CASE(insertKanji, fixture) {testInsertKanji(db());}
|
2023
|
+
|
2024
|
+
BOOST_FIXTURE_TEST_CASE(getEqualKanji, fixture) {testGetEqualKanji(db());}
|
2025
|
+
|
2026
|
+
BOOST_FIXTURE_TEST_CASE(dropDatabaseKanji, fixture) {testDropDatabaseKanji(db());}
|
2027
|
+
|
2028
|
+
BOOST_FIXTURE_TEST_CASE(fuga, fixture) {BOOST_CHECK_EQUAL(2 * 3, 6);}
|
2029
|
+
BOOST_AUTO_TEST_SUITE_END()
|
2030
|
+
// ------------------------------------------------------------------------
|