transactd 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/common/tdclc_32_3_2.dll +0 -0
- data/bin/common/{tdclc_64_3_1.dll → tdclc_64_3_2.dll} +0 -0
- data/build/swig/ruby/ruby.swg +3 -0
- data/build/swig/ruby/tdclrb_wrap.cpp +2413 -126
- data/build/swig/tdcl.i +120 -9
- data/build/tdclc/tdclc.cbproj +4 -1
- data/build/tdclc/tdclc.rc +4 -4
- data/build/tdclcpp/tdclcpp.rc +4 -4
- data/build/tdclcpp/tdclcpp_bc.cbproj +8 -1
- data/build/tdclrb/tdclrb.rc +4 -4
- data/source/bzs/db/engine/mysql/database.cpp +138 -130
- data/source/bzs/db/engine/mysql/database.h +43 -48
- data/source/bzs/db/engine/mysql/dbManager.cpp +81 -96
- data/source/bzs/db/engine/mysql/dbManager.h +13 -22
- data/source/bzs/db/engine/mysql/mysqlInternal.h +157 -291
- data/source/bzs/db/engine/mysql/mysqlProtocol.cpp +425 -0
- data/source/bzs/db/engine/mysql/mysqlProtocol.h +72 -0
- data/source/bzs/db/engine/mysql/mysqlThd.cpp +8 -6
- data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +7 -3
- data/source/bzs/db/protocol/hs/hsCommandExecuter.h +1 -0
- data/source/bzs/db/protocol/tdap/client/client.h +22 -8
- data/source/bzs/db/protocol/tdap/client/connMgr.cpp +225 -21
- data/source/bzs/db/protocol/tdap/client/connMgr.h +42 -16
- data/source/bzs/db/protocol/tdap/client/database.cpp +58 -15
- data/source/bzs/db/protocol/tdap/client/database.h +3 -3
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +93 -85
- data/source/bzs/db/protocol/tdap/client/dbDef.h +1 -2
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +9 -5
- data/source/bzs/db/protocol/tdap/client/filter.h +2 -2
- data/source/bzs/db/protocol/tdap/client/groupComp.h +2 -2
- data/source/bzs/db/protocol/tdap/client/memRecord.cpp +1 -1
- data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +71 -12
- data/source/bzs/db/protocol/tdap/client/nsDatabase.h +7 -1
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +35 -2
- data/source/bzs/db/protocol/tdap/client/nsTable.h +1 -0
- data/source/bzs/db/protocol/tdap/client/recordset.cpp +5 -1
- data/source/bzs/db/protocol/tdap/client/recordset.h +15 -0
- data/source/bzs/db/protocol/tdap/client/recordsetImple.h +21 -16
- data/source/bzs/db/protocol/tdap/client/serializer.cpp +32 -11
- data/source/bzs/db/protocol/tdap/client/serializer.h +4 -1
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +3 -2
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +3 -0
- data/source/bzs/db/protocol/tdap/client/table.cpp +18 -14
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +8 -3
- data/source/bzs/db/protocol/tdap/mysql/characterset.cpp +1 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +83 -43
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +3 -1
- data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +7 -7
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +247 -137
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +9 -9
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +1 -4
- data/source/bzs/db/protocol/tdap/tdapSchema.h +3 -7
- data/source/bzs/db/protocol/tdap/tdapcapi.h +23 -3
- data/source/bzs/db/protocol/tdap/uri.h +40 -0
- data/source/bzs/db/transactd/appModule.cpp +14 -5
- data/source/bzs/db/transactd/appModule.h +10 -1
- data/source/bzs/db/transactd/connManager.cpp +93 -48
- data/source/bzs/db/transactd/connManager.h +10 -7
- data/source/bzs/db/transactd/connectionRecord.h +114 -19
- data/source/bzs/env/tstring.h +2 -0
- data/source/bzs/example/changeSchema.cpp +1 -1
- data/source/bzs/example/changeSchema_c.cpp +1 -1
- data/source/bzs/example/insertRecords.cpp +2 -1
- data/source/bzs/example/insertRecords_c.cpp +2 -1
- data/source/bzs/example/queryData.cpp +5 -2
- data/source/bzs/netsvc/server/IAppModule.h +6 -0
- data/source/bzs/test/tdclatl/test_v3.js +75 -0
- data/source/bzs/test/tdclphp/transactd_v3_Test.php +104 -7
- data/source/bzs/test/tdclrb/transactd_v3_spec.rb +84 -0
- data/source/bzs/test/trdclengn/testField.h +66 -6
- data/source/bzs/test/trdclengn/test_tdclcpp_v3.cpp +10 -1
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +85 -0
- data/source/bzs/test/trdclengn/testbase.h +1 -1
- data/source/global/tdclatl/BinlogPos.cpp +64 -0
- data/source/global/tdclatl/BinlogPos.h +84 -0
- data/source/global/tdclatl/ConnMgr.cpp +285 -0
- data/source/global/tdclatl/ConnMgr.h +83 -0
- data/source/global/tdclatl/ConnRecord.cpp +123 -0
- data/source/global/tdclatl/ConnRecord.h +69 -0
- data/source/global/tdclatl/ConnRecords.cpp +57 -0
- data/source/global/tdclatl/ConnRecords.h +55 -0
- data/source/global/tdclatl/Database.cpp +36 -0
- data/source/global/tdclatl/Database.h +4 -0
- data/source/global/tdclatl/Table.cpp +14 -1
- data/source/global/tdclatl/Table.h +1 -0
- data/source/global/tdclatl/resource.h +0 -0
- data/source/global/tdclatl/tdclatl.idl +148 -4
- metadata +14 -4
- data/bin/common/tdclc_32_3_1.dll +0 -0
@@ -21,6 +21,7 @@
|
|
21
21
|
#include "recordsetReader.h"
|
22
22
|
#include <bzs/db/blobBuffer.h>
|
23
23
|
#include <bzs/db/engine/mysql/database.h>
|
24
|
+
#include <bzs/db/engine/mysql/mysqlProtocol.h>
|
24
25
|
#include <bzs/db/engine/mysql/errorMessage.h>
|
25
26
|
#include <bzs/db/engine/mysql/mydebuglog.h>
|
26
27
|
#include <bzs/netsvc/server/IAppModule.h> //lookup for result value
|
@@ -211,38 +212,8 @@ void dumpStdErr(int op, request& req, table* tb)
|
|
211
212
|
}
|
212
213
|
}
|
213
214
|
|
214
|
-
//-------------------------------------------------------------
|
215
|
-
// class dbExecuter
|
216
|
-
//-------------------------------------------------------------
|
217
215
|
#define MYSQL_ERROR_OFFSET 25000
|
218
|
-
|
219
|
-
: dbManager(), m_readHandler(new ReadRecordsHandler()),
|
220
|
-
m_blobBuffer(new blobBuffer()), m_mod(mod)
|
221
|
-
{
|
222
|
-
m_scramble[0] = 0x00;
|
223
|
-
}
|
224
|
-
|
225
|
-
dbExecuter::~dbExecuter()
|
226
|
-
{
|
227
|
-
delete m_blobBuffer;
|
228
|
-
delete m_readHandler;
|
229
|
-
}
|
230
|
-
|
231
|
-
void dbExecuter::releaseDatabase(request& req, int op)
|
232
|
-
{
|
233
|
-
req.paramMask = 0;
|
234
|
-
if ((op == TD_RESET_CLIENT) && (req.keyNum != 0))
|
235
|
-
req.result = 1;
|
236
|
-
else
|
237
|
-
dbManager::releaseDatabase(req.cid);
|
238
|
-
}
|
239
|
-
|
240
|
-
std::string dbExecuter::makeSQLcreateTable(const request& req)
|
241
|
-
{
|
242
|
-
return (const char*)req.data;
|
243
|
-
}
|
244
|
-
|
245
|
-
int dbExecuter::errorCode(int ha_error)
|
216
|
+
int errorCode(int ha_error)
|
246
217
|
{ // see mysqld_error.h or my_base.h or dbManager.h share/errmsg.txt
|
247
218
|
|
248
219
|
if (ha_error < HA_ERR_FIRST)
|
@@ -276,10 +247,43 @@ int dbExecuter::errorCode(int ha_error)
|
|
276
247
|
else if(ha_error == ER_NO_SUCH_TABLE)
|
277
248
|
return STATUS_TABLE_NOTOPEN;
|
278
249
|
else if(ha_error == ER_SPECIFIC_ACCESS_DENIED_ERROR)
|
279
|
-
return STATUS_ACCESS_DENIED;
|
250
|
+
return STATUS_ACCESS_DENIED;
|
251
|
+
else if(ha_error == ER_TABLEACCESS_DENIED_ERROR)
|
252
|
+
return STATUS_ACCESS_DENIED;
|
280
253
|
return MYSQL_ERROR_OFFSET + ha_error;
|
281
254
|
}
|
282
255
|
|
256
|
+
//-------------------------------------------------------------
|
257
|
+
// class dbExecuter
|
258
|
+
//-------------------------------------------------------------
|
259
|
+
|
260
|
+
dbExecuter::dbExecuter(netsvc::server::IAppModule* mod)
|
261
|
+
: dbManager(mod), m_readHandler(new ReadRecordsHandler()),
|
262
|
+
m_blobBuffer(new blobBuffer())
|
263
|
+
{
|
264
|
+
m_scramble[0] = 0x00;
|
265
|
+
}
|
266
|
+
|
267
|
+
dbExecuter::~dbExecuter()
|
268
|
+
{
|
269
|
+
delete m_blobBuffer;
|
270
|
+
delete m_readHandler;
|
271
|
+
}
|
272
|
+
|
273
|
+
void dbExecuter::releaseDatabase(request& req, int op)
|
274
|
+
{
|
275
|
+
req.paramMask = 0;
|
276
|
+
if ((op == TD_RESET_CLIENT) && (req.keyNum != 0))
|
277
|
+
req.result = 1;
|
278
|
+
else
|
279
|
+
dbManager::releaseDatabase(req.cid);
|
280
|
+
}
|
281
|
+
|
282
|
+
std::string dbExecuter::makeSQLcreateTable(const request& req)
|
283
|
+
{
|
284
|
+
return (const char*)req.data;
|
285
|
+
}
|
286
|
+
|
283
287
|
bool isMetaDb(const request& req)
|
284
288
|
{
|
285
289
|
char buf[MAX_PATH];
|
@@ -321,7 +325,7 @@ inline bool dbExecuter::doAuthentication(request& req, database* db)
|
|
321
325
|
if (strcmp(g_auth_type, AUTH_TYPE_MYSQL_STR)==0)
|
322
326
|
{
|
323
327
|
ret = false;
|
324
|
-
char host[MAX_HOSTNAME];
|
328
|
+
char host[MAX_HOSTNAME] = {0x00};
|
325
329
|
char *user = 0x00;
|
326
330
|
char *pwd = 0x00;
|
327
331
|
bool pwdRecieved = getUserPasswd(req, user, pwd);
|
@@ -336,11 +340,14 @@ inline bool dbExecuter::doAuthentication(request& req, database* db)
|
|
336
340
|
ret = (FALSE == check_scramble((const unsigned char*)pwd, (const char*)m_scramble, p));
|
337
341
|
if (ret)
|
338
342
|
{
|
339
|
-
|
340
|
-
|
343
|
+
m_mod->setUser(user);
|
344
|
+
m_mod->setHost(host);
|
345
|
+
if (host[0])
|
346
|
+
db->setGrant(host, user, db->name().c_str());
|
341
347
|
}
|
342
348
|
}
|
343
|
-
}
|
349
|
+
}else
|
350
|
+
m_mod->skipGrants(true);
|
344
351
|
m_authChecked = ret;
|
345
352
|
return ret;
|
346
353
|
}
|
@@ -391,9 +398,8 @@ bool dbExecuter::connect(request& req)
|
|
391
398
|
bool ret = getDatabaseWithAuth(req, &db, true);
|
392
399
|
if (ret && (req.result == 0) && db)
|
393
400
|
{
|
394
|
-
|
395
|
-
|
396
|
-
req.result = ddl_execSql(db->thd(), dbSqlname);
|
401
|
+
if (!db->existsDatabase())
|
402
|
+
req.result = ERROR_NO_DATABASE;
|
397
403
|
}
|
398
404
|
if (db && (!ret || req.result))
|
399
405
|
dbManager::releaseDatabase(req.cid);
|
@@ -415,7 +421,7 @@ inline bool dbExecuter::doCreateTable(request& req)
|
|
415
421
|
if (((req.keyNum == CR_SUBOP_CREATE_DBONLY) || (req.keyNum == 0)) &&
|
416
422
|
(db->existsDatabase() == false))
|
417
423
|
{
|
418
|
-
req.result = ddl_createDataBase(
|
424
|
+
req.result = ddl_createDataBase(dbSqlname);
|
419
425
|
if (req.result == ER_DB_CREATE_EXISTS + MYSQL_ERROR_OFFSET)
|
420
426
|
req.result = 0;
|
421
427
|
}
|
@@ -423,7 +429,9 @@ inline bool dbExecuter::doCreateTable(request& req)
|
|
423
429
|
{
|
424
430
|
if (req.result == 0)
|
425
431
|
{
|
426
|
-
|
432
|
+
std::string dbname = db->name();
|
433
|
+
dbManager::releaseDatabase(req.cid);
|
434
|
+
req.result = ddl_dropDataBase(dbname, dbSqlname, req.cid);
|
427
435
|
if (ER_DB_DROP_EXISTS+ MYSQL_ERROR_OFFSET == req.result) req.result = 0;
|
428
436
|
}
|
429
437
|
return ret;
|
@@ -431,55 +439,51 @@ inline bool dbExecuter::doCreateTable(request& req)
|
|
431
439
|
}
|
432
440
|
if (req.result == 0)
|
433
441
|
{ // table operation
|
434
|
-
|
442
|
+
std::string tableSqlName = getTableName(req, FOR_SQL);
|
443
|
+
std::string tableName = getTableName(req);
|
444
|
+
if (req.keyNum == CR_SUBOP_DROP) // -128 is delete
|
435
445
|
{
|
436
|
-
|
437
|
-
|
438
|
-
if (req.
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
reqold
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
reqold
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
else
|
467
|
-
{
|
468
|
-
if (req.
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
if (req.
|
473
|
-
|
474
|
-
req.result = ddl_dropTable(db, tableName, dbSqlname,
|
475
|
-
tableSqlName);
|
476
|
-
if (req.result == ER_BAD_TABLE_ERROR + MYSQL_ERROR_OFFSET)
|
477
|
-
req.result = 0;
|
478
|
-
}
|
479
|
-
if (req.result == 0)
|
480
|
-
req.result =
|
481
|
-
ddl_execSql(db->thd(), makeSQLcreateTable(req));
|
446
|
+
req.result = ddl_dropTable(db, tableName, dbSqlname,
|
447
|
+
tableSqlName);
|
448
|
+
if (req.result == ER_BAD_TABLE_ERROR + MYSQL_ERROR_OFFSET)
|
449
|
+
req.result = 0;
|
450
|
+
}
|
451
|
+
else if (req.keyNum == CR_SUBOP_RENAME)
|
452
|
+
{ // rename new is keybuf
|
453
|
+
request reqold;
|
454
|
+
reqold.keybuf = req.data;
|
455
|
+
reqold.keylen = *req.datalen;
|
456
|
+
req.result = ddl_renameTable(
|
457
|
+
db, getTableName(reqold), /*oldname*/
|
458
|
+
dbSqlname, getTableName(reqold, FOR_SQL), /*oldname*/
|
459
|
+
tableSqlName /*newName*/);
|
460
|
+
}
|
461
|
+
else if (req.keyNum == CR_SUBOP_SWAPNAME)
|
462
|
+
{ // swap name name2 = keybuf
|
463
|
+
request reqold;
|
464
|
+
reqold.keybuf = req.data;
|
465
|
+
reqold.keylen = *req.datalen;
|
466
|
+
req.result = ddl_replaceTable(
|
467
|
+
db, getTableName(reqold), /*oldname*/
|
468
|
+
tableName, /*newName*/
|
469
|
+
dbSqlname, getTableName(reqold, FOR_SQL), /*oldname*/
|
470
|
+
tableSqlName /*newName*/);
|
471
|
+
}
|
472
|
+
else if (req.keyNum != CR_SUBOP_CREATE_DBONLY)
|
473
|
+
{ // create
|
474
|
+
if (req.data == NULL)
|
475
|
+
req.result = 1;
|
476
|
+
else
|
477
|
+
{ //-1 is overwrite
|
478
|
+
if (req.keyNum == CR_SUB_FLAG_EXISTCHECK && tableName.size())
|
479
|
+
{
|
480
|
+
req.result = ddl_dropTable(db, tableName, dbSqlname,
|
481
|
+
tableSqlName);
|
482
|
+
if (req.result == ER_BAD_TABLE_ERROR + MYSQL_ERROR_OFFSET)
|
483
|
+
req.result = 0;
|
482
484
|
}
|
485
|
+
if (req.result == 0)
|
486
|
+
req.result = ddl_createTable(db, makeSQLcreateTable(req).c_str());
|
483
487
|
}
|
484
488
|
}
|
485
489
|
}
|
@@ -513,7 +517,7 @@ inline bool dbExecuter::doOpenTable(request& req, char* buf, bool reconnect)
|
|
513
517
|
}
|
514
518
|
}
|
515
519
|
// if error occured that throw no exception
|
516
|
-
tb = db->openTable(getTableName(req), mode, getOwnerName(req));
|
520
|
+
tb = db->openTable(getTableName(req), mode, getOwnerName(req), getDatabaseName(req, false));
|
517
521
|
if (db->stat())
|
518
522
|
req.result = (short_td)errorCode(db->stat());
|
519
523
|
}
|
@@ -1072,7 +1076,7 @@ inline void dbExecuter::doDelete(request& req)
|
|
1072
1076
|
inline void dbExecuter::doInsertBulk(request& req)
|
1073
1077
|
{
|
1074
1078
|
m_tb = getTable(req.pbk->handle, SQLCOM_INSERT);
|
1075
|
-
if (m_tb->setKeyNum(m_tb->keyNumByMakeOrder(req.keyNum)))
|
1079
|
+
if ((req.keyNum == -1) || m_tb->setKeyNum(m_tb->keyNumByMakeOrder(req.keyNum)))
|
1076
1080
|
{
|
1077
1081
|
ushort_td* n = (ushort_td*)req.data;
|
1078
1082
|
ushort_td ret = 0;
|
@@ -1094,7 +1098,6 @@ inline void dbExecuter::doInsertBulk(request& req)
|
|
1094
1098
|
m_tb->clearBuffer();
|
1095
1099
|
m_tb->setRecordFromPacked(pos + sizeof(ushort_td), len,
|
1096
1100
|
req.blobHeader);
|
1097
|
-
|
1098
1101
|
if (i == *n - 1)
|
1099
1102
|
m_tb->insert((req.keyNum != -1));
|
1100
1103
|
else
|
@@ -1119,6 +1122,75 @@ inline void dbExecuter::doInsertBulk(request& req)
|
|
1119
1122
|
req.paramMask |= P_MASK_PB_ERASE_BM;
|
1120
1123
|
}
|
1121
1124
|
|
1125
|
+
inline void dbExecuter::doGetSchema(request& req, netsvc::server::netWriter* nw)
|
1126
|
+
{
|
1127
|
+
nw->setClientBuffferSize(*req.datalen);
|
1128
|
+
nw->beginExt(false);
|
1129
|
+
char* p = nw->curPtr() - sizeof(unsigned short);// orver write row space
|
1130
|
+
if (req.keyNum == SC_SUBOP_VIEW_BY_SQL)
|
1131
|
+
{// Return SQL statement as show create view.
|
1132
|
+
TABLE_LIST tables; char key[256];
|
1133
|
+
const char* keyPtr = key;
|
1134
|
+
database* db = getDatabaseCid(req.cid);
|
1135
|
+
std::string dbname = db->name();
|
1136
|
+
THD* thd = db->thd();
|
1137
|
+
std::string name = getTableName(req);
|
1138
|
+
tables.init_one_table(dbname.c_str(), dbname.size(), name.c_str(),
|
1139
|
+
name.size(), name.c_str(), TL_READ);
|
1140
|
+
uint key_length= cp_get_table_def_key(thd, &tables, &keyPtr);
|
1141
|
+
if (!cp_tdc_open_view(thd, &tables, name.c_str(), key, key_length, OPEN_VIEW_NO_PARSE))
|
1142
|
+
{
|
1143
|
+
unsigned int len = (unsigned int)(tables.view_body_utf8.length + 17 + name.size());
|
1144
|
+
if (len <= *req.datalen)
|
1145
|
+
{
|
1146
|
+
char* p = nw->curPtr() - sizeof(unsigned short);// orver write row space
|
1147
|
+
sprintf_s(p, *req.datalen, "CREATE VIEW %s as %s", name.c_str(), tables.view_body_utf8.str);
|
1148
|
+
p[len] = 0x00;
|
1149
|
+
nw->asyncWrite(NULL, len+1, netsvc::server::netWriter::curSeekOnly);
|
1150
|
+
nw->writeHeadar(P_MASK_DATA | P_MASK_DATALEN, 0);
|
1151
|
+
}
|
1152
|
+
else
|
1153
|
+
nw->writeHeadar(0, STATUS_BUFFERTOOSMALL);
|
1154
|
+
}else
|
1155
|
+
nw->writeHeadar(0, STATUS_TABLE_NOTOPEN);
|
1156
|
+
}
|
1157
|
+
else if (req.keyNum == SC_SUBOP_BY_SQL)
|
1158
|
+
{// Return SQL statement as show create table.
|
1159
|
+
String s;
|
1160
|
+
m_tb = getTable(req.pbk->handle);
|
1161
|
+
m_tb->getCreateSql(&s);
|
1162
|
+
unsigned int len = (unsigned int)s.length();
|
1163
|
+
if (len+1 <= *req.datalen)
|
1164
|
+
{
|
1165
|
+
char* p = nw->curPtr() - sizeof(unsigned short);// orver write row space
|
1166
|
+
memcpy(p, s.ptr(), len);
|
1167
|
+
p[len] = 0x00;
|
1168
|
+
nw->asyncWrite(NULL, len+1, netsvc::server::netWriter::curSeekOnly);
|
1169
|
+
nw->writeHeadar(P_MASK_DATA | P_MASK_DATALEN, (short_td)errorCode(m_tb->stat()));
|
1170
|
+
}
|
1171
|
+
else
|
1172
|
+
nw->writeHeadar(0, STATUS_BUFFERTOOSMALL);
|
1173
|
+
m_tb->unUse();
|
1174
|
+
}
|
1175
|
+
else
|
1176
|
+
{// Return tabledef image binary.
|
1177
|
+
database* db = getDatabaseCid(req.cid);
|
1178
|
+
std::string name = getTableName(req);
|
1179
|
+
schemaBuilder sb;
|
1180
|
+
protocol::tdap::tabledef* td = sb.getTabledef(db, name.c_str(),
|
1181
|
+
(unsigned char*)p, *req.datalen);
|
1182
|
+
if (td)
|
1183
|
+
{
|
1184
|
+
nw->asyncWrite(NULL, td->varSize + sizeof(unsigned short), netsvc::server::netWriter::curSeekOnly);
|
1185
|
+
nw->writeHeadar(P_MASK_DATA | P_MASK_DATALEN, (short_td)errorCode(db->stat()));
|
1186
|
+
}
|
1187
|
+
else
|
1188
|
+
nw->writeHeadar(0, errorCodeSht(sb.stat()));
|
1189
|
+
}
|
1190
|
+
unsigned int* totalLen = (unsigned int*)nw->ptr();
|
1191
|
+
nw->datalen = *totalLen = nw->resultLen();
|
1192
|
+
}
|
1193
|
+
|
1122
1194
|
/**
|
1123
1195
|
@result
|
1124
1196
|
2byte recordLength
|
@@ -1201,7 +1273,6 @@ int dbExecuter::commandExec(request& req, netsvc::server::netWriter* nw)
|
|
1201
1273
|
|
1202
1274
|
if ((op >= TD_KEY_EQUAL_KO) && (op <= TD_KEY_LAST_KO))
|
1203
1275
|
op -= 50;
|
1204
|
-
|
1205
1276
|
try
|
1206
1277
|
{
|
1207
1278
|
posblk* pbk = req.pbk;
|
@@ -1292,8 +1363,16 @@ int dbExecuter::commandExec(request& req, netsvc::server::netWriter* nw)
|
|
1292
1363
|
binlogPos bpos;
|
1293
1364
|
memset(&bpos, 0, sizeof(binlogPos));
|
1294
1365
|
database* db = getDatabaseCid(req.cid);
|
1366
|
+
THD* thd = NULL;
|
1367
|
+
#ifdef NOTUSE_BINLOG_VAR
|
1368
|
+
if (withSnapshot)
|
1369
|
+
{
|
1370
|
+
thd = getThd();
|
1371
|
+
db->use();
|
1372
|
+
}
|
1373
|
+
#endif
|
1295
1374
|
transactionResult = db->beginSnapshot(
|
1296
|
-
getIsolationLevel(opTrn), withSnapshot ? &bpos : NULL);
|
1375
|
+
getIsolationLevel(opTrn), withSnapshot ? &bpos : NULL, thd);
|
1297
1376
|
req.result = errorCodeSht(db->stat());
|
1298
1377
|
if (transactionResult && withSnapshot)
|
1299
1378
|
{
|
@@ -1518,9 +1597,8 @@ int dbExecuter::commandExec(request& req, netsvc::server::netWriter* nw)
|
|
1518
1597
|
{ // Key name of multi byte charctor is not supported. Use only ascii.
|
1519
1598
|
database* db = getDatabaseCid(req.cid);
|
1520
1599
|
m_tb = getTable(req.pbk->handle);
|
1521
|
-
req.result =
|
1522
|
-
|
1523
|
-
m_tb->keyName(m_tb->keyNumByMakeOrder(req.keyNum))));
|
1600
|
+
req.result = ddl_dropIndex(db, m_tb->name(),
|
1601
|
+
m_tb->keyName(m_tb->keyNumByMakeOrder(req.keyNum)));
|
1524
1602
|
break;
|
1525
1603
|
}
|
1526
1604
|
case TD_GETDIRECTORY:
|
@@ -1569,35 +1647,17 @@ int dbExecuter::commandExec(request& req, netsvc::server::netWriter* nw)
|
|
1569
1647
|
std::string s("%@%");
|
1570
1648
|
s += (const char*)#
|
1571
1649
|
s += (const char*)req.keybuf;
|
1572
|
-
req.result =
|
1573
|
-
db->thd(),
|
1574
|
-
makeSQLChangeTableComment(db->name(), m_tb->name(), s.c_str()));
|
1650
|
+
req.result = ddl_tableComment(db, m_tb->name(), s.c_str());
|
1575
1651
|
break;
|
1576
1652
|
}
|
1577
1653
|
case TD_ACL_RELOAD:
|
1578
1654
|
req.result = getDatabaseCid(req.cid)->aclReload();
|
1579
1655
|
break;
|
1580
1656
|
case TD_GET_SCHEMA:
|
1581
|
-
{
|
1582
|
-
database* db = getDatabaseCid(req.cid);
|
1583
|
-
nw->setClientBuffferSize(*(req.datalen));
|
1584
|
-
nw->beginExt(false);
|
1585
|
-
char* p = nw->curPtr() - sizeof(unsigned short);// orver write row space
|
1586
|
-
schemaBuilder sb;
|
1587
|
-
protocol::tdap::tabledef* td = sb.getTabledef(db, getTableName(req).c_str(),
|
1588
|
-
(unsigned char*)p, *req.datalen);
|
1589
|
-
if (td)
|
1590
1657
|
{
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1658
|
+
doGetSchema(req, nw);
|
1659
|
+
return EXECUTE_RESULT_SUCCESS;
|
1594
1660
|
}
|
1595
|
-
else
|
1596
|
-
nw->writeHeadar(0, errorCodeSht(sb.stat()));
|
1597
|
-
unsigned int* totalLen = (unsigned int*)nw->ptr();
|
1598
|
-
nw->datalen = *totalLen = nw->resultLen();
|
1599
|
-
return EXECUTE_RESULT_SUCCESS;
|
1600
|
-
}
|
1601
1661
|
case TD_STORE_TEST:
|
1602
1662
|
{
|
1603
1663
|
m_tb = getTable(req.pbk->handle, SQLCOM_UPDATE);
|
@@ -1763,16 +1823,19 @@ connMgrExecuter::connMgrExecuter(request& req, unsigned __int64 parent)
|
|
1763
1823
|
{
|
1764
1824
|
}
|
1765
1825
|
|
1766
|
-
int serialize(request& req, char* buf, size_t& size, const
|
1826
|
+
int serialize(request& req, char* buf, size_t& size, const connection::records& records, short stat)
|
1767
1827
|
{
|
1768
1828
|
req.reset();
|
1769
|
-
req.paramMask = P_MASK_DATA | P_MASK_DATALEN;
|
1829
|
+
req.paramMask = P_MASK_DATA | P_MASK_DATALEN | P_MASK_KEYBUF;
|
1770
1830
|
if (records.size())
|
1771
1831
|
req.data = (void*)&records[0];
|
1772
1832
|
else
|
1773
1833
|
req.paramMask = P_MASK_DATALEN;
|
1774
|
-
|
1834
|
+
int len = sizeof(record);
|
1835
|
+
req.resultLen = (uint_td)(len * records.size());
|
1775
1836
|
req.result = stat;
|
1837
|
+
req.keylen = 4;
|
1838
|
+
req.keybuf = &len;
|
1776
1839
|
size = req.serialize(NULL, buf);
|
1777
1840
|
return EXECUTE_RESULT_SUCCESS;
|
1778
1841
|
}
|
@@ -1781,25 +1844,50 @@ int connMgrExecuter::read(char* buf, size_t& size)
|
|
1781
1844
|
{
|
1782
1845
|
connManager st(m_modHandle);
|
1783
1846
|
unsigned __int64* mod = (unsigned __int64*)m_req.keybuf;
|
1784
|
-
|
1847
|
+
const connection::records& records = st.getRecords(mod[0], (int)mod[1]);
|
1848
|
+
return serialize(m_req, buf, size, records, st.stat());
|
1785
1849
|
}
|
1786
1850
|
|
1787
|
-
int connMgrExecuter::
|
1851
|
+
int connMgrExecuter::definedDatabases(char* buf, size_t& size)
|
1788
1852
|
{
|
1789
1853
|
connManager st(m_modHandle);
|
1790
|
-
|
1854
|
+
const connection::records& records = st.definedDatabases();
|
1855
|
+
return serialize(m_req, buf, size, records, st.stat());
|
1791
1856
|
}
|
1792
1857
|
|
1793
1858
|
int connMgrExecuter::systemVariables(char* buf, size_t& size)
|
1794
1859
|
{
|
1795
1860
|
connManager st(m_modHandle);
|
1796
|
-
|
1861
|
+
const connection::records& records = st.systemVariables();
|
1862
|
+
return serialize(m_req, buf, size, records, st.stat());
|
1863
|
+
}
|
1864
|
+
|
1865
|
+
int connMgrExecuter::schemaTables(char* buf, size_t& size)
|
1866
|
+
{
|
1867
|
+
connManager st(m_modHandle);
|
1868
|
+
const connection::records& records = st.schemaTables((const char*)m_req.keybuf);
|
1869
|
+
return serialize(m_req, buf, size, records, st.stat());
|
1870
|
+
}
|
1871
|
+
|
1872
|
+
int connMgrExecuter::definedTables(char* buf, size_t& size)
|
1873
|
+
{
|
1874
|
+
connManager st(m_modHandle);
|
1875
|
+
const connection::records& records = st.definedTables((const char*)m_req.keybuf, TABLE_TYPE_NORMAL_TABLE);
|
1876
|
+
return serialize(m_req, buf, size, records, st.stat());
|
1797
1877
|
}
|
1798
1878
|
|
1799
|
-
int connMgrExecuter::
|
1879
|
+
int connMgrExecuter::definedViews(char* buf, size_t& size)
|
1800
1880
|
{
|
1801
1881
|
connManager st(m_modHandle);
|
1802
|
-
|
1882
|
+
const connection::records& records = st.definedTables((const char*)m_req.keybuf, TABLE_TYPE_VIEW);
|
1883
|
+
return serialize(m_req, buf, size, records, st.stat());
|
1884
|
+
}
|
1885
|
+
|
1886
|
+
int connMgrExecuter::slaveStatus(char* buf, size_t& size)
|
1887
|
+
{
|
1888
|
+
connManager st(m_modHandle);
|
1889
|
+
const connection::records& records = st.readSlaveStatus();
|
1890
|
+
return serialize(m_req, buf, size, records, st.stat());
|
1803
1891
|
}
|
1804
1892
|
|
1805
1893
|
int connMgrExecuter::disconnectOne(char* buf, size_t& size)
|
@@ -1823,19 +1911,41 @@ int connMgrExecuter::disconnectAll(char* buf, size_t& size)
|
|
1823
1911
|
|
1824
1912
|
int connMgrExecuter::commandExec(netsvc::server::netWriter* nw)
|
1825
1913
|
{
|
1826
|
-
if (m_req.keyNum ==
|
1827
|
-
return read(nw->ptr(), nw->datalen);
|
1828
|
-
else if (m_req.keyNum == TD_STSTCS_DISCONNECT_ONE)
|
1914
|
+
if (m_req.keyNum == TD_STSTCS_DISCONNECT_ONE)
|
1829
1915
|
return disconnectOne(nw->ptr(), nw->datalen);
|
1830
|
-
|
1916
|
+
if (m_req.keyNum == TD_STSTCS_DISCONNECT_ALL)
|
1831
1917
|
return disconnectAll(nw->ptr(), nw->datalen);
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1918
|
+
|
1919
|
+
if (*m_req.datalen == (uint_td)63976)
|
1920
|
+
{
|
1921
|
+
switch (m_req.keyNum)
|
1922
|
+
{
|
1923
|
+
case TD_STSTCS_READ:
|
1924
|
+
return read(nw->ptr(), nw->datalen);
|
1925
|
+
case TD_STSTCS_DATABASE_LIST:
|
1926
|
+
return definedDatabases(nw->ptr(), nw->datalen);
|
1927
|
+
case TD_STSTCS_SYSTEM_VARIABLES:
|
1928
|
+
return systemVariables(nw->ptr(), nw->datalen);
|
1929
|
+
case TD_STSTCS_SCHEMA_TABLE_LIST:
|
1930
|
+
return schemaTables(nw->ptr(), nw->datalen);
|
1931
|
+
case TD_STSTCS_TABLE_LIST:
|
1932
|
+
return definedTables(nw->ptr(), nw->datalen);
|
1933
|
+
case TD_STSTCS_VIEW_LIST:
|
1934
|
+
return definedViews(nw->ptr(), nw->datalen);
|
1935
|
+
case TD_STSTCS_SLAVE_STATUS:
|
1936
|
+
return slaveStatus(nw->ptr(), nw->datalen);
|
1937
|
+
default:
|
1938
|
+
m_req.reset();
|
1939
|
+
m_req.result = STATUS_NOSUPPORT_OP;
|
1940
|
+
break;
|
1941
|
+
}
|
1942
|
+
}else
|
1943
|
+
{
|
1944
|
+
m_req.reset();
|
1945
|
+
m_req.result = SERVER_CLIENT_NOT_COMPATIBLE;
|
1946
|
+
}
|
1947
|
+
nw->datalen = m_req.serialize(NULL, nw->ptr());
|
1948
|
+
return EXECUTE_RESULT_SUCCESS;
|
1839
1949
|
}
|
1840
1950
|
|
1841
1951
|
// ---------------------------------------------------------------------------
|
@@ -58,7 +58,7 @@ struct extRequestSeeks;
|
|
58
58
|
|
59
59
|
std::string getDatabaseName(const request& req, bool forSql = false);
|
60
60
|
std::string getTableName(const request& req, bool forSql = false);
|
61
|
-
|
61
|
+
int errorCode(int ha_error);
|
62
62
|
bool isMetaDb(const request& req);
|
63
63
|
|
64
64
|
class dbExecuter : public engine::mysql::dbManager
|
@@ -66,7 +66,6 @@ class dbExecuter : public engine::mysql::dbManager
|
|
66
66
|
ReadRecordsHandler* m_readHandler;
|
67
67
|
blobBuffer* m_blobBuffer;
|
68
68
|
unsigned char m_scramble[MYSQL_SCRAMBLE_LENGTH+1];
|
69
|
-
netsvc::server::IAppModule* m_mod;
|
70
69
|
void releaseDatabase(request& req, int op);
|
71
70
|
std::string makeSQLcreateTable(const request& req);
|
72
71
|
bool connect(request& req);
|
@@ -86,6 +85,7 @@ class dbExecuter : public engine::mysql::dbManager
|
|
86
85
|
inline void doDelete(request& req);
|
87
86
|
inline void doDeleteKey(request& req);
|
88
87
|
inline void doInsertBulk(request& req);
|
88
|
+
inline void doGetSchema(request& req, netsvc::server::netWriter* nw);
|
89
89
|
inline void doStat(request& req);
|
90
90
|
inline short seekEach(extRequestSeeks* ereq, bool noBookMark);
|
91
91
|
inline short seekBookmarkEach(extRequestSeeks* ereq, bool noBookmark);
|
@@ -96,11 +96,8 @@ public:
|
|
96
96
|
~dbExecuter();
|
97
97
|
int commandExec(request& req, netsvc::server::netWriter* nw);
|
98
98
|
size_t getAcceptMessage(char* message, size_t size);
|
99
|
-
int errorCode(int ha_error);
|
100
|
-
inline short_td errorCodeSht(int ha_error)
|
101
|
-
{
|
102
|
-
return (short_td)errorCode(ha_error);
|
103
|
-
}
|
99
|
+
inline int errorCode(int ha_error) { return tdap::mysql::errorCode(ha_error);}
|
100
|
+
inline short_td errorCodeSht(int ha_error) { return (short_td)tdap::mysql::errorCode(ha_error);}
|
104
101
|
netsvc::server::IAppModule* mod() { return m_mod; };
|
105
102
|
};
|
106
103
|
|
@@ -111,8 +108,11 @@ class connMgrExecuter
|
|
111
108
|
request& m_req;
|
112
109
|
__int64 m_modHandle;
|
113
110
|
|
114
|
-
int
|
115
|
-
int
|
111
|
+
int definedDatabases(char* buf, size_t& size);
|
112
|
+
int schemaTables(char* buf, size_t& size);
|
113
|
+
int definedTables(char* buf, size_t& size);
|
114
|
+
int definedViews(char* buf, size_t& size);
|
115
|
+
int slaveStatus(char* buf, size_t& size);
|
116
116
|
int systemVariables(char* buf, size_t& size);
|
117
117
|
int read(char* buf, size_t& size);
|
118
118
|
int disconnectOne(char* buf, size_t& size);
|
@@ -784,8 +784,6 @@ bool tabledef::operator==(const tabledef& r) const
|
|
784
784
|
(keyCount == r.keyCount) &&
|
785
785
|
(version == r.version) &&
|
786
786
|
(charsetIndex == r.charsetIndex) &&
|
787
|
-
(m_nullfields == r.m_nullfields) &&
|
788
|
-
(m_nullbytes == r.m_nullbytes) &&
|
789
787
|
(flags.all == r.flags.all) &&
|
790
788
|
(primaryKeyNum == r.primaryKeyNum) &&
|
791
789
|
(parentKeyNum == r.parentKeyNum) &&
|
@@ -953,8 +951,7 @@ void tabledef::calcReclordlen(bool force)
|
|
953
951
|
// If valible length then specifing fixed length.
|
954
952
|
if ((fixedRecordLen == 0) || (flags.bit0 == false))
|
955
953
|
fixedRecordLen = m_maxRecordLen;
|
956
|
-
}
|
957
|
-
;//assert(0);
|
954
|
+
}
|
958
955
|
}
|
959
956
|
|
960
957
|
uint_td tabledef::unPack(char* ptr, size_t size) const
|
@@ -796,14 +796,14 @@ private:
|
|
796
796
|
* If datalen!=0xff then From is none field formated (string) type.
|
797
797
|
*/
|
798
798
|
inline uchar_td* keyCopy(uchar_td* to, const uchar_td* from, ushort_td datalen,
|
799
|
-
bool isNull)
|
799
|
+
bool isNull, bool transactd)
|
800
800
|
{
|
801
801
|
ushort_td keylen = maxKeylen(); // size of max key segmnet for mysql
|
802
802
|
ushort_td keyVarlen = varLenByteForKey(); // size of var sizeByte for record.
|
803
803
|
ushort_td copylen = std::min<ushort_td>(keylen, datalen);
|
804
804
|
|
805
805
|
memset(to, 0x00, keylen + 1); //clear plus null byte
|
806
|
-
if (isNullable())
|
806
|
+
if (isNullable() && transactd)
|
807
807
|
{
|
808
808
|
// mysql only
|
809
809
|
if (isNull)
|
@@ -1166,11 +1166,7 @@ private:
|
|
1166
1166
|
bool isNullKey(const keydef& key) const;
|
1167
1167
|
uint_td pack(char* ptr, size_t size) const;
|
1168
1168
|
short findKeynumByFieldNum(short fieldNum) const;
|
1169
|
-
inline ushort_td recordlenServer() const
|
1170
|
-
{
|
1171
|
-
if (optionFlags.bitC) return m_maxRecordLen + 2;
|
1172
|
-
return m_maxRecordLen;
|
1173
|
-
}
|
1169
|
+
inline ushort_td recordlenServer() const {return m_maxRecordLen;}
|
1174
1170
|
bool isNeedNis(const keydef& key) const;
|
1175
1171
|
bool isNULLFieldFirstKeySegField(const keydef& key) const;
|
1176
1172
|
bool isNullValueZeroAll(const keydef& key) const;
|