transactd 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/{BUILD_UNIX-JA → BUILD_UNIX-JA.md} +6 -6
- data/CMakeLists.txt +20 -15
- data/{README-JA → README-JA.md} +23 -23
- data/{README → README.md} +22 -24
- data/RELEASE_NOTE +120 -0
- data/RELEASE_NOTE-JA +110 -0
- data/bin/common/tdclc_32_2_4.dll +0 -0
- data/bin/common/tdclc_64_2_4.dll +0 -0
- data/build/common/get_ruby_path.cmake +1 -1
- data/build/swig/ruby/tdclrb_wrap.cpp +1319 -830
- data/build/swig/tdcl.i +22 -2
- data/build/tdclc/tdclc.cbproj +1 -1
- data/build/tdclc/tdclc.rc +4 -4
- data/build/tdclcpp/tdclcpp.rc +4 -4
- data/build/tdclcpp/tdclcpp_bc.cbproj +2 -1
- data/build/tdclrb/CMakeLists.txt +6 -1
- data/build/tdclrb/bldgem/extconf.rb +5 -1
- data/build/tdclrb/tdclrb.rc +4 -4
- data/source/bzs/db/engine/mysql/database.cpp +44 -40
- data/source/bzs/db/engine/mysql/database.h +28 -8
- data/source/bzs/db/engine/mysql/dbManager.cpp +2 -0
- data/source/bzs/db/engine/mysql/dbManager.h +2 -7
- data/source/bzs/db/engine/mysql/mysqlInternal.h +79 -7
- data/source/bzs/db/protocol/hs/hsCommandExecuter.h +5 -1
- data/source/bzs/db/protocol/tdap/client/activeTable.cpp +32 -8
- data/source/bzs/db/protocol/tdap/client/activeTable.h +17 -4
- data/source/bzs/db/protocol/tdap/client/activeTableImple.h +10 -4
- data/source/bzs/db/protocol/tdap/client/client.cpp +51 -6
- data/source/bzs/db/protocol/tdap/client/client.h +41 -11
- data/source/bzs/db/protocol/tdap/client/connMgr.cpp +51 -15
- data/source/bzs/db/protocol/tdap/client/connMgr.h +6 -1
- data/source/bzs/db/protocol/tdap/client/database.cpp +26 -5
- data/source/bzs/db/protocol/tdap/client/database.h +3 -2
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +38 -28
- data/source/bzs/db/protocol/tdap/client/dbDef.h +1 -1
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +2 -32
- data/source/bzs/db/protocol/tdap/client/field.cpp +0 -1
- data/source/bzs/db/protocol/tdap/client/filter.h +60 -33
- data/source/bzs/db/protocol/tdap/client/groupQuery.cpp +2 -5
- data/source/bzs/db/protocol/tdap/client/memRecord.cpp +9 -0
- data/source/bzs/db/protocol/tdap/client/memRecord.h +1 -0
- data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +99 -48
- data/source/bzs/db/protocol/tdap/client/nsDatabase.h +5 -2
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +76 -26
- data/source/bzs/db/protocol/tdap/client/nsTable.h +6 -4
- data/source/bzs/db/protocol/tdap/client/request.h +28 -11
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +19 -11
- data/source/bzs/db/protocol/tdap/client/table.cpp +157 -70
- data/source/bzs/db/protocol/tdap/client/table.h +20 -5
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +57 -4
- data/source/bzs/db/protocol/tdap/client/trdormapi.h +55 -20
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +65 -31
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +2 -0
- data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +24 -36
- data/source/bzs/db/protocol/tdap/mysql/request.h +1 -1
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +98 -18
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +12 -7
- data/source/bzs/db/protocol/tdap/tdapRequest.h +3 -8
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +1 -9
- data/source/bzs/db/protocol/tdap/tdapSchema.h +31 -1
- data/source/bzs/db/protocol/tdap/tdapcapi.h +49 -6
- data/source/bzs/db/protocol/tdap/uri.h +41 -6
- data/source/bzs/db/transactd/appModule.cpp +0 -1
- data/source/bzs/db/transactd/appModule.h +0 -2
- data/source/bzs/db/transactd/connManager.cpp +202 -33
- data/source/bzs/db/transactd/connManager.h +11 -4
- data/source/bzs/db/transactd/connectionRecord.h +19 -5
- data/source/bzs/db/transactd/transactd.cpp +39 -8
- data/source/bzs/env/crosscompile.cpp +1 -1
- data/source/bzs/example/queryData.cpp +1 -1
- data/source/bzs/netsvc/client/iconnection.h +2 -0
- data/source/bzs/netsvc/client/tcpClient.cpp +48 -26
- data/source/bzs/netsvc/client/tcpClient.h +171 -106
- data/source/bzs/netsvc/server/IAppModule.h +0 -1
- data/source/bzs/netsvc/server/serverPipe.cpp +5 -1
- data/source/bzs/netsvc/server/serverPipe.h +2 -1
- data/source/bzs/test/tdclatl/test_query_atl.js +105 -0
- data/source/bzs/test/tdclphp/transactd_Test.php +129 -11
- data/source/bzs/test/tdclrb/transactd_spec.rb +74 -2
- data/source/bzs/test/transactdBench/scaling_bench.cpp +1 -1
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +45 -20
- data/source/global/tdclatl/Bookmark.cpp +28 -0
- data/source/global/tdclatl/Bookmark.h +65 -0
- data/source/global/tdclatl/Database.cpp +2 -2
- data/source/global/tdclatl/Database.h +1 -3
- data/source/global/tdclatl/DbDef.cpp +6 -0
- data/source/global/tdclatl/DbDef.h +1 -0
- data/source/global/tdclatl/QueryBase.cpp +29 -0
- data/source/global/tdclatl/QueryBase.h +4 -0
- data/source/global/tdclatl/Record.cpp +14 -2
- data/source/global/tdclatl/Record.h +1 -1
- data/source/global/tdclatl/Table.cpp +80 -16
- data/source/global/tdclatl/Table.h +23 -8
- data/source/global/tdclatl/_IDatabaseEvents_CP.h +39 -0
- data/source/global/tdclatl/activeTable.cpp +2 -2
- data/source/global/tdclatl/activeTable.h +1 -1
- data/source/global/tdclatl/tdclatl.idl +64 -14
- metadata +12 -12
- data/bin/common/tdclc_32_2_3.dll +0 -0
- data/bin/common/tdclc_64_2_3.dll +0 -0
- data/build/tdclcpp/BUILDNUMBER.txt +0 -1
- data/build/tdclrb/BUILDNUMBER.txt +0 -1
- /data/{BUILD_WIN-JA → BUILD_WIN-JA.md} +0 -0
- /data/{README_ORMSRCGEN-JA → README_ORMSRCGEN-JA.md} +0 -0
- /data/{README_ORMSRCGEN → README_ORMSRCGEN.md} +0 -0
|
@@ -49,6 +49,10 @@
|
|
|
49
49
|
#endif
|
|
50
50
|
#include <my_config.h>
|
|
51
51
|
#include <mysql_version.h>
|
|
52
|
+
#if defined(MARIADB_BASE_VERSION) && (MYSQL_VERSION_ID > 100000)
|
|
53
|
+
#define MARIADDB_10_0 MYSQL_VERSION_ID
|
|
54
|
+
#endif
|
|
55
|
+
|
|
52
56
|
#include <sql/sql_const.h>
|
|
53
57
|
#include "my_global.h"
|
|
54
58
|
#include <math.h>
|
|
@@ -80,9 +84,8 @@ extern "C" {
|
|
|
80
84
|
#include "sql/sql_cache.h"
|
|
81
85
|
#if (MYSQL_VERSION_ID < 50700)
|
|
82
86
|
#include "sql/structs.h"
|
|
83
|
-
#endif
|
|
84
|
-
|
|
85
87
|
#include "sql/sql_priv.h"
|
|
88
|
+
#endif
|
|
86
89
|
#include "sql/unireg.h"
|
|
87
90
|
#include "sql/lock.h"
|
|
88
91
|
#include "sql/key.h"
|
|
@@ -92,6 +95,7 @@ extern "C" {
|
|
|
92
95
|
#include "sql/sql_table.h"
|
|
93
96
|
#include "sql/sql_db.h"
|
|
94
97
|
#include "sql_acl.h"
|
|
98
|
+
#include "sql/sql_show.h"
|
|
95
99
|
#include "mysqld_error.h"
|
|
96
100
|
#include <password.h>
|
|
97
101
|
|
|
@@ -135,25 +139,25 @@ extern "C" {
|
|
|
135
139
|
#define THD_NOT_KILLED NOT_KILLED
|
|
136
140
|
#endif
|
|
137
141
|
|
|
138
|
-
#if (MYSQL_VERSION_ID < 50600) // MySQL and MariaDB both
|
|
142
|
+
#if (MYSQL_VERSION_ID < 50600) // MySQL and MariaDB both 5.5
|
|
139
143
|
#define user_defined_key_parts key_parts
|
|
140
144
|
#define MDL_SHARED_UPGRADABLE MDL_SHARED_WRITE
|
|
141
145
|
#define cp_get_sql_error() stmt_da->sql_errno()
|
|
142
146
|
#define cp_isOk() stmt_da->is_ok()
|
|
143
147
|
#define cp_set_overwrite_status(A) stmt_da->can_overwrite_status = A
|
|
144
|
-
#elif((MYSQL_VERSION_NUM > 50700) && !defined(MARIADB_BASE_VERSION))
|
|
148
|
+
#elif((MYSQL_VERSION_NUM > 50700) && !defined(MARIADB_BASE_VERSION)) // MySQL 5.7
|
|
145
149
|
#define cp_get_sql_error() get_stmt_da()->mysql_errno()
|
|
146
150
|
#define query_cache_invalidate3(A, B, C) query_cache.invalidate(A, B, C)
|
|
147
151
|
#define cp_isOk() get_stmt_da()->is_ok()
|
|
148
152
|
#define cp_set_overwrite_status(A) get_stmt_da()->set_overwrite_status(A)
|
|
149
|
-
#else
|
|
153
|
+
#else // MySQL 5.6 Mariadb 10.0
|
|
150
154
|
#define cp_get_sql_error() get_stmt_da()->sql_errno()
|
|
151
155
|
#define cp_isOk() get_stmt_da()->is_ok()
|
|
152
156
|
#define cp_set_overwrite_status(A) get_stmt_da()->set_overwrite_status(A)
|
|
153
157
|
|
|
154
158
|
#endif
|
|
155
159
|
|
|
156
|
-
#if (MYSQL_VERSION_NUM < 50600) // MySQL Only
|
|
160
|
+
#if (MYSQL_VERSION_NUM < 50600) // MySQL 5.5 Only
|
|
157
161
|
#define ha_index_next index_next
|
|
158
162
|
#define ha_index_prev index_prev
|
|
159
163
|
#define ha_index_first index_first
|
|
@@ -161,6 +165,15 @@ extern "C" {
|
|
|
161
165
|
#define ha_index_next_same index_next_same
|
|
162
166
|
#define ha_rnd_next rnd_next
|
|
163
167
|
#define ha_rnd_pos rnd_pos
|
|
168
|
+
# if (MYSQL_VERSION_NUM >= 50544)
|
|
169
|
+
# define FINDFILE_6PRAMS
|
|
170
|
+
# endif
|
|
171
|
+
#endif // MySQL 5.5 Only
|
|
172
|
+
|
|
173
|
+
#if ((MYSQL_VERSION_NUM > 50600) && (MYSQL_VERSION_NUM < 50700)) // MySQL 5.6 Only
|
|
174
|
+
# if (MYSQL_VERSION_NUM >= 50625)
|
|
175
|
+
# define FINDFILE_6PRAMS
|
|
176
|
+
# endif
|
|
164
177
|
#endif
|
|
165
178
|
|
|
166
179
|
#if ((MYSQL_VERSION_NUM < 50600) || defined(MARIADB_BASE_VERSION))
|
|
@@ -407,7 +420,7 @@ inline int cp_thread_set_THR_THD(THD* thd)
|
|
|
407
420
|
my_pthread_setspecific_ptr(THR_THD, thd);
|
|
408
421
|
return 0;
|
|
409
422
|
}
|
|
410
|
-
|
|
423
|
+
/*
|
|
411
424
|
inline void cp_set_transaction_duration_for_all_locks(THD* thd)
|
|
412
425
|
{
|
|
413
426
|
thd->mdl_context.set_transaction_duration_for_all_locks();
|
|
@@ -423,7 +436,66 @@ inline void cp_open_error_release(THD* thd, TABLE_LIST& tables)
|
|
|
423
436
|
{
|
|
424
437
|
thd->mdl_context.release_lock(tables.mdl_request.ticket);
|
|
425
438
|
}
|
|
439
|
+
*/
|
|
440
|
+
|
|
441
|
+
inline void cp_set_transaction_duration_for_all_locks(THD* thd)
|
|
442
|
+
{
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
inline void cp_set_mdl_request_types(TABLE_LIST& tables, short mode)
|
|
446
|
+
{
|
|
447
|
+
if (mode == -2 /* TD_OPEN_READONLY */)
|
|
448
|
+
tables.mdl_request.set_type(MDL_SHARED_READ);
|
|
449
|
+
else if (mode == -4 /* TD_OPEN_EXCLUSIVE */)
|
|
450
|
+
tables.mdl_request.set_type(MDL_SHARED_NO_READ_WRITE);
|
|
451
|
+
else if (mode == -6 /* TD_OPEN_READONLY_EXCLUSIVE */)
|
|
452
|
+
tables.mdl_request.set_type(MDL_SHARED_READ);
|
|
453
|
+
else
|
|
454
|
+
tables.mdl_request.set_type(MDL_SHARED_WRITE);
|
|
455
|
+
|
|
456
|
+
tables.mdl_request.duration = MDL_TRANSACTION;
|
|
457
|
+
}
|
|
426
458
|
|
|
459
|
+
inline void cp_open_error_release(THD* thd, TABLE_LIST& tables)
|
|
460
|
+
{
|
|
461
|
+
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
#endif
|
|
466
|
+
|
|
467
|
+
/* find_files is static function in maridb.
|
|
468
|
+
make_db_list function is not static, but it is not list in sql_show.h.
|
|
469
|
+
*/
|
|
470
|
+
|
|
471
|
+
#ifdef MARIADDB_10_0
|
|
472
|
+
typedef Dynamic_array<LEX_STRING*> SQL_Strings;
|
|
473
|
+
typedef struct st_lookup_field_values
|
|
474
|
+
{
|
|
475
|
+
LEX_STRING db_value, table_value;
|
|
476
|
+
bool wild_db_value, wild_table_value;
|
|
477
|
+
} LOOKUP_FIELD_VALUES;
|
|
478
|
+
|
|
479
|
+
extern int make_db_list(THD *thd, Dynamic_array<LEX_STRING*> *files,
|
|
480
|
+
LOOKUP_FIELD_VALUES *lookup_field_vals);
|
|
481
|
+
inline int db_list(THD *thd, SQL_Strings *files)
|
|
482
|
+
{
|
|
483
|
+
LOOKUP_FIELD_VALUES lv;
|
|
484
|
+
memset(&lv, 0 ,sizeof(LOOKUP_FIELD_VALUES));
|
|
485
|
+
return make_db_list(thd, files, &lv);
|
|
486
|
+
}
|
|
487
|
+
#else
|
|
488
|
+
typedef List<LEX_STRING> SQL_Strings;
|
|
489
|
+
inline int db_list(THD *thd, SQL_Strings *files)
|
|
490
|
+
{
|
|
491
|
+
#ifdef FINDFILE_6PRAMS
|
|
492
|
+
MEM_ROOT tmp_mem_root;
|
|
493
|
+
init_sql_alloc(&tmp_mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
|
|
494
|
+
return find_files(thd, files, NullS, mysql_data_home, "", true, &tmp_mem_root);
|
|
495
|
+
#else
|
|
496
|
+
return find_files(thd, files, NullS, mysql_data_home, "", true);
|
|
497
|
+
#endif
|
|
498
|
+
}
|
|
427
499
|
#endif
|
|
428
500
|
|
|
429
501
|
#endif // BZS_DB_ENGINE_MYSQL_MYSQLINTERNAL_H
|
|
@@ -213,8 +213,12 @@ public:
|
|
|
213
213
|
return m_dbExec->commandExec(m_requests, nw);
|
|
214
214
|
}
|
|
215
215
|
void cleanup(){};
|
|
216
|
+
|
|
216
217
|
bool isShutDown() { return m_dbExec->isShutDown(); }
|
|
217
|
-
|
|
218
|
+
|
|
219
|
+
const engine::mysql::databases& dbs() const { return m_dbExec->dbs(); }
|
|
220
|
+
|
|
221
|
+
boost::mutex& mutex() { return m_dbExec->mutex(); }
|
|
218
222
|
};
|
|
219
223
|
|
|
220
224
|
} // namespace hs
|
|
@@ -49,13 +49,27 @@ activeTable::activeTable(dbmanager_ptr& mgr, const _TCHAR* tableName)
|
|
|
49
49
|
{
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
activeTable::activeTable(database_ptr& db, const _TCHAR* tableName
|
|
53
|
-
|
|
52
|
+
activeTable::activeTable(database_ptr& db, const _TCHAR* tableName,
|
|
53
|
+
short mode)
|
|
54
|
+
: m_imple(new activeTableImple(db, tableName, mode))
|
|
54
55
|
{
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
activeTable::activeTable(database* db, const _TCHAR* tableName
|
|
58
|
-
|
|
58
|
+
activeTable::activeTable(database* db, const _TCHAR* tableName,
|
|
59
|
+
short mode)
|
|
60
|
+
: m_imple(new activeTableImple(db, tableName, mode))
|
|
61
|
+
{
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
activeTable::activeTable(database_ptr& db, short tableIndex,
|
|
65
|
+
short mode)
|
|
66
|
+
: m_imple(new activeTableImple(db, tableIndex, mode))
|
|
67
|
+
{
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
activeTable::activeTable(database* db, short tableIndex,
|
|
71
|
+
short mode)
|
|
72
|
+
: m_imple(new activeTableImple(db, tableIndex, mode))
|
|
59
73
|
{
|
|
60
74
|
}
|
|
61
75
|
|
|
@@ -192,14 +206,24 @@ activeTable* activeTable::create(dbmanager_ptr& mgr, const _TCHAR* tableName)
|
|
|
192
206
|
return new activeTable(mgr, tableName);
|
|
193
207
|
}
|
|
194
208
|
|
|
195
|
-
activeTable* activeTable::create(database_ptr& db, const _TCHAR* tableName)
|
|
209
|
+
activeTable* activeTable::create(database_ptr& db, const _TCHAR* tableName, short mode)
|
|
210
|
+
{
|
|
211
|
+
return new activeTable(db, tableName, mode);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
activeTable* activeTable::create(database* db, const _TCHAR* tableName, short mode)
|
|
215
|
+
{
|
|
216
|
+
return new activeTable(db, tableName, mode);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
activeTable* activeTable::create(database_ptr& db, short tableIndex, short mode)
|
|
196
220
|
{
|
|
197
|
-
return new activeTable(db,
|
|
221
|
+
return new activeTable(db, tableIndex, mode);
|
|
198
222
|
}
|
|
199
223
|
|
|
200
|
-
activeTable* activeTable::create(database* db,
|
|
224
|
+
activeTable* activeTable::create(database* db, short tableIndex, short mode)
|
|
201
225
|
{
|
|
202
|
-
return new activeTable(db,
|
|
226
|
+
return new activeTable(db, tableIndex, mode);
|
|
203
227
|
}
|
|
204
228
|
|
|
205
229
|
void activeTable::release()
|
|
@@ -94,8 +94,14 @@ class DLLLIB activeTable
|
|
|
94
94
|
public:
|
|
95
95
|
explicit activeTable(idatabaseManager* mgr, const _TCHAR* tableName);
|
|
96
96
|
explicit activeTable(dbmanager_ptr& mgr, const _TCHAR* tableName);
|
|
97
|
-
explicit activeTable(database_ptr& db, const _TCHAR* tableName
|
|
98
|
-
|
|
97
|
+
explicit activeTable(database_ptr& db, const _TCHAR* tableName,
|
|
98
|
+
short mode = TD_OPEN_NORMAL);
|
|
99
|
+
explicit activeTable(database* db, const _TCHAR* tableName,
|
|
100
|
+
short mode = TD_OPEN_NORMAL);
|
|
101
|
+
explicit activeTable(database_ptr& db, short tableIndex,
|
|
102
|
+
short mode = TD_OPEN_NORMAL);
|
|
103
|
+
explicit activeTable(database* db, short tableIndex,
|
|
104
|
+
short mode = TD_OPEN_NORMAL);
|
|
99
105
|
|
|
100
106
|
~activeTable();
|
|
101
107
|
|
|
@@ -319,8 +325,15 @@ public:
|
|
|
319
325
|
|
|
320
326
|
static activeTable* create(idatabaseManager* mgr, const _TCHAR* tableName);
|
|
321
327
|
static activeTable* create(dbmanager_ptr& mgr, const _TCHAR* tableName);
|
|
322
|
-
static activeTable* create(database_ptr& db, const _TCHAR* tableName
|
|
323
|
-
|
|
328
|
+
static activeTable* create(database_ptr& db, const _TCHAR* tableName,
|
|
329
|
+
short mode = TD_OPEN_NORMAL);
|
|
330
|
+
static activeTable* create(database* db, const _TCHAR* tableName,
|
|
331
|
+
short mode = TD_OPEN_NORMAL);
|
|
332
|
+
static activeTable* create(database_ptr& db, short tableIndex,
|
|
333
|
+
short mode = TD_OPEN_NORMAL);
|
|
334
|
+
static activeTable* create(database* db, short tableIndex,
|
|
335
|
+
short mode = TD_OPEN_NORMAL);
|
|
336
|
+
|
|
324
337
|
void release();
|
|
325
338
|
void releaseTable();
|
|
326
339
|
};
|
|
@@ -360,11 +360,17 @@ public:
|
|
|
360
360
|
explicit activeTableImple(idatabaseManager* mgr, const _TCHAR* tableName)
|
|
361
361
|
: baseClass_type(mgr, tableName), m_record(NULL){};
|
|
362
362
|
|
|
363
|
-
explicit activeTableImple(database_ptr& db, const _TCHAR* tableName)
|
|
364
|
-
: baseClass_type(db, tableName), m_record(NULL){};
|
|
363
|
+
explicit activeTableImple(database_ptr& db, const _TCHAR* tableName, short mode)
|
|
364
|
+
: baseClass_type(db, tableName, mode), m_record(NULL){};
|
|
365
365
|
|
|
366
|
-
explicit activeTableImple(database* db, const _TCHAR* tableName)
|
|
367
|
-
: baseClass_type(db, tableName), m_record(NULL){};
|
|
366
|
+
explicit activeTableImple(database* db, const _TCHAR* tableName, short mode)
|
|
367
|
+
: baseClass_type(db, tableName, mode), m_record(NULL){};
|
|
368
|
+
|
|
369
|
+
explicit activeTableImple(database_ptr& db, short tableIndex, short mode)
|
|
370
|
+
: baseClass_type(db, tableIndex, mode), m_record(NULL){};
|
|
371
|
+
|
|
372
|
+
explicit activeTableImple(database* db, short tableIndex, short mode)
|
|
373
|
+
: baseClass_type(db, tableIndex, mode), m_record(NULL){};
|
|
368
374
|
|
|
369
375
|
~activeTableImple()
|
|
370
376
|
{
|
|
@@ -41,6 +41,48 @@ tls_key g_tlsiID;
|
|
|
41
41
|
__THREAD client* __THREAD_BCB g_client = NULL;
|
|
42
42
|
#endif
|
|
43
43
|
|
|
44
|
+
#if defined(__BCPLUSPLUS__)
|
|
45
|
+
#pragma warn -8004
|
|
46
|
+
#endif
|
|
47
|
+
short errorCode(const boost::system::error_code& e)
|
|
48
|
+
{
|
|
49
|
+
short ret = 0;
|
|
50
|
+
switch (e.value())
|
|
51
|
+
{
|
|
52
|
+
case 11004:
|
|
53
|
+
case 11001:
|
|
54
|
+
ret = ERROR_TD_HOSTNAME_NOT_FOUND;
|
|
55
|
+
break;
|
|
56
|
+
case 10060:
|
|
57
|
+
case 10057: //blocking fire wall
|
|
58
|
+
case 110: //connect: Connection timed out
|
|
59
|
+
case 121: //timeout sema
|
|
60
|
+
case 11: //EAGAIN
|
|
61
|
+
ret = ERROR_TD_NET_TIMEOUT;
|
|
62
|
+
break;
|
|
63
|
+
case 32: //write:brokn pipe
|
|
64
|
+
case 111: //connect: Connection refused
|
|
65
|
+
case 10061:
|
|
66
|
+
ret = ERROR_TD_CONNECTION_FAILURE;
|
|
67
|
+
break;
|
|
68
|
+
case 104: //write: Connection reset by peer
|
|
69
|
+
case 10054:
|
|
70
|
+
ret = ERROR_TD_NET_REMOTE_DISCONNECT;
|
|
71
|
+
break;
|
|
72
|
+
case 232:
|
|
73
|
+
case 109:
|
|
74
|
+
case 2:
|
|
75
|
+
case 1:
|
|
76
|
+
ret = ERROR_TD_INVALID_CLINETHOST;
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
ret = ERROR_TD_NET_OTHER;
|
|
80
|
+
}
|
|
81
|
+
return ret;
|
|
82
|
+
}
|
|
83
|
+
#if defined(__BCPLUSPLUS__)
|
|
84
|
+
#pragma warn .8004
|
|
85
|
+
#endif
|
|
44
86
|
|
|
45
87
|
int client::getServerCharsetIndex()
|
|
46
88
|
{
|
|
@@ -68,13 +110,16 @@ int client::getServerCharsetIndex()
|
|
|
68
110
|
char* p = con()->sendBuffer(m_req.sendLenEstimate());
|
|
69
111
|
unsigned int size = req.serialize(p);
|
|
70
112
|
p = con()->asyncWriteRead(size);
|
|
71
|
-
|
|
72
|
-
if (req.result == 0)
|
|
113
|
+
if (!con()->error())
|
|
73
114
|
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
115
|
+
req.parse(p, false);
|
|
116
|
+
if (req.result == 0 && req.resultLen)
|
|
117
|
+
{
|
|
118
|
+
if (!checkVersion(ver))
|
|
119
|
+
return -1;
|
|
120
|
+
c->setCharsetServer(mysql::charsetIndex(ver.cherserServer));
|
|
121
|
+
return c->charsetServer();
|
|
122
|
+
}
|
|
78
123
|
}
|
|
79
124
|
return -1;
|
|
80
125
|
}
|
|
@@ -53,6 +53,14 @@ namespace client
|
|
|
53
53
|
class client;
|
|
54
54
|
void setClientThread(client* v);
|
|
55
55
|
|
|
56
|
+
#define PORT_BUFSIZE 16
|
|
57
|
+
|
|
58
|
+
struct endpoint_t
|
|
59
|
+
{
|
|
60
|
+
char host[MAX_PATH];
|
|
61
|
+
char port[PORT_BUFSIZE];
|
|
62
|
+
};
|
|
63
|
+
|
|
56
64
|
/* client class
|
|
57
65
|
This instance is created for each thread.
|
|
58
66
|
*/
|
|
@@ -107,6 +115,12 @@ class client
|
|
|
107
115
|
return hostName(uri, tmp, MAX_PATH);
|
|
108
116
|
}
|
|
109
117
|
|
|
118
|
+
endpoint_t* endPoint(const char* uri, endpoint_t* ep)
|
|
119
|
+
{
|
|
120
|
+
tdap::endPoint(uri, ep->host, MAX_PATH, ep->port, PORT_BUFSIZE);
|
|
121
|
+
return ep;
|
|
122
|
+
}
|
|
123
|
+
|
|
110
124
|
std::string getTableName(const char* uri)
|
|
111
125
|
{
|
|
112
126
|
if (uri)
|
|
@@ -134,6 +148,7 @@ class client
|
|
|
134
148
|
{
|
|
135
149
|
//Implements handshake here
|
|
136
150
|
handshale_t* hst = (handshale_t*)c->read();
|
|
151
|
+
if (c->error()) return false;
|
|
137
152
|
bool auth = (hst->size == sizeof(handshale_t));
|
|
138
153
|
bool min = (hst->size == (sizeof(handshale_t)
|
|
139
154
|
- sizeof(hst->scramble)));
|
|
@@ -238,10 +253,11 @@ public:
|
|
|
238
253
|
{
|
|
239
254
|
if (!m_req.cid->con)
|
|
240
255
|
{
|
|
241
|
-
|
|
242
|
-
|
|
256
|
+
endpoint_t ep;
|
|
257
|
+
endPoint((const char*)m_req.keybuf, &ep);
|
|
258
|
+
if (ep.host[0] == 0x00)
|
|
243
259
|
m_preResult = ERROR_TD_HOSTNAME_NOT_FOUND;
|
|
244
|
-
bzs::netsvc::client::connection* c = m_cons->connect(host,
|
|
260
|
+
bzs::netsvc::client::connection* c = m_cons->connect(ep.host, ep.port,
|
|
245
261
|
client::handshakeCallback, this);
|
|
246
262
|
if (c)
|
|
247
263
|
{
|
|
@@ -315,11 +331,17 @@ public:
|
|
|
315
331
|
m_preResult = ERROR_TD_NOT_CONNECTED;
|
|
316
332
|
return;
|
|
317
333
|
}
|
|
318
|
-
|
|
334
|
+
endpoint_t ep;
|
|
335
|
+
endPoint((const char*)m_req.keybuf, &ep);
|
|
336
|
+
|
|
319
337
|
m_preResult = ERROR_TD_HOSTNAME_NOT_FOUND;
|
|
320
|
-
if (host ==
|
|
321
|
-
|
|
338
|
+
if (ep.host[0] == 0x00) return;
|
|
339
|
+
|
|
340
|
+
if (!m_cons->reconnect(c, ep.host, ep.port, handshakeCallback, this))
|
|
341
|
+
{
|
|
342
|
+
m_preResult = errorCode(m_cons->connectError());
|
|
322
343
|
return;
|
|
344
|
+
}
|
|
323
345
|
m_connecting = true;
|
|
324
346
|
if (getServerCharsetIndex() == -1)
|
|
325
347
|
m_preResult = SERVER_CLIENT_NOT_COMPATIBLE;
|
|
@@ -338,23 +360,29 @@ public:
|
|
|
338
360
|
{
|
|
339
361
|
if (con())
|
|
340
362
|
disconnect();
|
|
341
|
-
|
|
342
|
-
|
|
363
|
+
endpoint_t ep;
|
|
364
|
+
endPoint((const char*)m_req.keybuf, &ep);
|
|
365
|
+
if (ep.host[0] == 0x00)
|
|
343
366
|
m_preResult = ERROR_TD_HOSTNAME_NOT_FOUND;
|
|
344
367
|
bzs::netsvc::client::connection* c = m_cons->connect(
|
|
345
|
-
host, handshakeCallback, this,
|
|
368
|
+
ep.host, ep.port, handshakeCallback, this,
|
|
346
369
|
(m_req.keyNum == LG_SUBOP_NEWCONNECT));
|
|
347
370
|
if (c)
|
|
348
371
|
{
|
|
349
372
|
setCon(c); // if error throw exception
|
|
350
373
|
m_connecting = true;
|
|
351
374
|
if (getServerCharsetIndex() == -1)
|
|
352
|
-
|
|
375
|
+
{
|
|
376
|
+
if (c->error() || (m_req.resultLen == 0))
|
|
377
|
+
m_preResult = ERROR_TD_INVALID_CLINETHOST;
|
|
378
|
+
else
|
|
379
|
+
m_preResult = SERVER_CLIENT_NOT_COMPATIBLE;
|
|
380
|
+
}
|
|
353
381
|
else
|
|
354
382
|
buildDualChasetKeybuf();
|
|
355
383
|
}
|
|
356
384
|
else
|
|
357
|
-
m_preResult =
|
|
385
|
+
m_preResult = errorCode(m_cons->connectError());
|
|
358
386
|
}
|
|
359
387
|
else if (m_req.keyNum == LG_SUBOP_DISCONNECT)
|
|
360
388
|
{
|
|
@@ -395,11 +423,13 @@ public:
|
|
|
395
423
|
c->setDirectReadHandler(&m_req);
|
|
396
424
|
p = c->asyncWriteRead(size);
|
|
397
425
|
c->setDirectReadHandler(NULL);
|
|
426
|
+
if (c->error()) return errorCode(c->error());
|
|
398
427
|
}else
|
|
399
428
|
{
|
|
400
429
|
if (m_req.paramMask & P_MASK_DATALEN)
|
|
401
430
|
c->setReadBufferSizeIf(*m_req.datalen);
|
|
402
431
|
p = c->asyncWriteRead(size);
|
|
432
|
+
if (c->error()) return errorCode(c->error());
|
|
403
433
|
m_req.parse(p, ex);
|
|
404
434
|
}
|
|
405
435
|
}
|
|
@@ -35,6 +35,10 @@ namespace client
|
|
|
35
35
|
connMgr::connMgr(database* db) : nstable(db)
|
|
36
36
|
{
|
|
37
37
|
m_db = db;
|
|
38
|
+
m_keybuf = &m_params[0];
|
|
39
|
+
m_params[0] = 0;
|
|
40
|
+
m_params[1] = 0;
|
|
41
|
+
m_keylen = sizeof(m_params);
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
connMgr::~connMgr()
|
|
@@ -73,48 +77,74 @@ void connMgr::allocBuffer()
|
|
|
73
77
|
m_pdata = (void*)&m_records[0];
|
|
74
78
|
memset(m_pdata, 0, m_datalen);
|
|
75
79
|
setIsOpen(true);
|
|
76
|
-
|
|
77
|
-
m_params[0] = 0;
|
|
78
|
-
m_params[1] = 0;
|
|
79
|
-
m_keylen = sizeof(m_params);
|
|
80
|
+
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
const connMgr::records& connMgr::
|
|
83
|
+
const connMgr::records& connMgr::getRecords()
|
|
83
84
|
{
|
|
84
85
|
allocBuffer();
|
|
85
|
-
m_keynum = TD_STSTCS_READ;
|
|
86
86
|
tdap(TD_STASTISTICS);
|
|
87
87
|
if (m_stat == 0)
|
|
88
88
|
m_records.resize(m_datalen / sizeof(connMgr::record));
|
|
89
89
|
return m_records;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
const connMgr::records& connMgr::
|
|
92
|
+
const connMgr::records& connMgr::definedDatabases()
|
|
93
93
|
{
|
|
94
|
+
m_keynum = TD_STSTCS_DATABASE_LIST;
|
|
95
|
+
return getRecords();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const connMgr::records& connMgr::schemaTables(const char* dbname)
|
|
99
|
+
{
|
|
100
|
+
m_keynum = TD_STSTCS_SCHEMA_TABLE_LIST;
|
|
94
101
|
allocBuffer();
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
102
|
+
char tmp[128];
|
|
103
|
+
strcpy_s(tmp, 128, dbname);
|
|
104
|
+
m_keybuf = tmp;
|
|
105
|
+
m_keylen = 128;
|
|
98
106
|
tdap(TD_STASTISTICS);
|
|
99
107
|
if (m_stat == 0)
|
|
100
108
|
m_records.resize(m_datalen / sizeof(connMgr::record));
|
|
109
|
+
m_keybuf = &m_params[0];
|
|
110
|
+
m_keylen = sizeof(m_params);
|
|
101
111
|
return m_records;
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const connMgr::records& connMgr::sysvars()
|
|
116
|
+
{
|
|
117
|
+
m_keynum = TD_STSTCS_SYSTEM_VARIABLES;
|
|
118
|
+
return getRecords();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const connMgr::records& connMgr::connections()
|
|
122
|
+
{
|
|
123
|
+
m_keynum = TD_STSTCS_READ;
|
|
124
|
+
m_params[0] = 0;
|
|
125
|
+
m_params[1] = 0;
|
|
126
|
+
return getRecords();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const connMgr::records& connMgr::databases(__int64 connid)
|
|
130
|
+
{
|
|
131
|
+
m_keynum = TD_STSTCS_READ;
|
|
132
|
+
m_params[0] = connid;
|
|
133
|
+
m_params[1] = -1;
|
|
134
|
+
return getRecords();
|
|
102
135
|
}
|
|
103
136
|
|
|
104
137
|
const connMgr::records& connMgr::tables(__int64 connid, int dbid)
|
|
105
138
|
{
|
|
106
|
-
allocBuffer();
|
|
107
139
|
m_keynum = TD_STSTCS_READ;
|
|
108
140
|
m_params[0] = connid;
|
|
109
141
|
m_params[1] = dbid;
|
|
110
|
-
|
|
111
|
-
if (m_stat == 0)
|
|
112
|
-
m_records.resize(m_datalen / sizeof(connMgr::record));
|
|
113
|
-
return m_records;
|
|
142
|
+
return getRecords();
|
|
114
143
|
}
|
|
115
144
|
|
|
116
145
|
void connMgr::disconnectOne(__int64 connid)
|
|
117
146
|
{
|
|
147
|
+
allocBuffer();
|
|
118
148
|
m_keynum = TD_STSTCS_DISCONNECT_ONE;
|
|
119
149
|
record& rec = m_records[0];
|
|
120
150
|
rec.conId = connid;
|
|
@@ -132,6 +162,12 @@ short_td connMgr::stat()
|
|
|
132
162
|
return m_stat;
|
|
133
163
|
}
|
|
134
164
|
|
|
165
|
+
|
|
166
|
+
connMgr* connMgr::create(database* db)
|
|
167
|
+
{
|
|
168
|
+
return new connMgr(db);
|
|
169
|
+
}
|
|
170
|
+
|
|
135
171
|
} // namespace client
|
|
136
172
|
} // namespace tdap
|
|
137
173
|
} // namespace protocol
|
|
@@ -51,7 +51,7 @@ private:
|
|
|
51
51
|
void allocBuffer();
|
|
52
52
|
void writeRecordData(){};
|
|
53
53
|
void onReadAfter(){};
|
|
54
|
-
|
|
54
|
+
const records& getRecords();
|
|
55
55
|
~connMgr();
|
|
56
56
|
|
|
57
57
|
public:
|
|
@@ -59,6 +59,9 @@ public:
|
|
|
59
59
|
|
|
60
60
|
void connect(const _TCHAR* uri);
|
|
61
61
|
void disconnect();
|
|
62
|
+
const records& definedDatabases();
|
|
63
|
+
const records& schemaTables(const char* dbname);
|
|
64
|
+
const records& sysvars();
|
|
62
65
|
const records& connections();
|
|
63
66
|
const records& databases(__int64 connid);
|
|
64
67
|
const records& tables(__int64 connid, int dbid);
|
|
@@ -68,6 +71,8 @@ public:
|
|
|
68
71
|
|
|
69
72
|
database* db() const;
|
|
70
73
|
using nstable::tdapErr;
|
|
74
|
+
using nstable::release;
|
|
75
|
+
static connMgr* create(database* db);
|
|
71
76
|
};
|
|
72
77
|
|
|
73
78
|
#pragma warning(default : 4251)
|