transactd 2.1.0 → 2.2.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/bin/common/tdclc_32_2_2.dll +0 -0
- data/bin/common/tdclc_64_2_2.dll +0 -0
- data/build/swig/ruby/generate.cmd +45 -0
- data/build/swig/ruby/generate.sh +40 -0
- data/build/swig/ruby/tdclrb_wrap.cpp +406 -969
- data/build/swig/tdcl.i +88 -0
- data/build/tdclc/CMakeLists.txt +5 -1
- 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 +1 -1
- data/build/tdclrb/tdclrb.rc +4 -4
- data/source/bzs/db/engine/mysql/database.cpp +165 -74
- data/source/bzs/db/engine/mysql/database.h +19 -5
- data/source/bzs/db/engine/mysql/dbManager.cpp +33 -11
- data/source/bzs/db/engine/mysql/dbManager.h +6 -1
- data/source/bzs/db/engine/mysql/mydebuglog.h +12 -0
- data/source/bzs/db/engine/mysql/mysqlInternal.h +10 -3
- data/source/bzs/db/engine/mysql/mysqlThd.cpp +20 -8
- data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +12 -7
- data/source/bzs/db/protocol/hs/hsCommandExecuter.h +1 -1
- data/source/bzs/db/protocol/tdap/client/activeTableImple.h +1 -0
- data/source/bzs/db/protocol/tdap/client/client.cpp +17 -15
- data/source/bzs/db/protocol/tdap/client/client.h +102 -30
- data/source/bzs/db/protocol/tdap/client/connectionPool.cpp +1 -1
- data/source/bzs/db/protocol/tdap/client/database.cpp +32 -10
- data/source/bzs/db/protocol/tdap/client/database.h +1 -0
- data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +0 -2
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +2 -0
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +47 -42
- data/source/bzs/db/protocol/tdap/client/fields.h +3 -1
- data/source/bzs/db/protocol/tdap/client/filter.h +3 -3
- data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +18 -2
- data/source/bzs/db/protocol/tdap/client/nsDatabase.h +3 -2
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +14 -6
- data/source/bzs/db/protocol/tdap/client/nsTable.h +12 -12
- data/source/bzs/db/protocol/tdap/client/recordsetImple.h +6 -3
- data/source/bzs/db/protocol/tdap/client/request.h +1 -0
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +101 -64
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +3 -0
- data/source/bzs/db/protocol/tdap/client/stringConverter.h +9 -13
- data/source/bzs/db/protocol/tdap/client/table.cpp +73 -56
- data/source/bzs/db/protocol/tdap/client/table.h +8 -8
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +52 -100
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +8 -1
- data/source/bzs/db/protocol/tdap/mysql/request.h +6 -0
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +349 -189
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +28 -12
- data/source/bzs/db/protocol/tdap/tdapRequest.h +5 -4
- data/source/bzs/db/protocol/tdap/tdapSchema.h +6 -1
- data/source/bzs/db/protocol/tdap/tdapcapi.h +29 -4
- data/source/bzs/db/protocol/tdap/uri.h +297 -0
- data/source/bzs/db/transactd/appModule.cpp +41 -16
- data/source/bzs/db/transactd/appModule.h +1 -2
- data/source/bzs/db/transactd/transactd.cpp +37 -14
- data/source/bzs/env/crosscompile.h +1 -3
- data/source/bzs/example/queryData.cpp +2 -2
- data/source/bzs/netsvc/client/iconnection.h +3 -1
- data/source/bzs/netsvc/client/tcpClient.cpp +75 -28
- data/source/bzs/netsvc/client/tcpClient.h +94 -62
- data/source/bzs/netsvc/server/IAppModule.h +2 -2
- data/source/bzs/netsvc/server/serverCpt.cpp +17 -10
- data/source/bzs/netsvc/server/serverPipe.cpp +26 -19
- data/source/bzs/netsvc/server/serverTpool.cpp +8 -2
- data/source/bzs/rtl/debuglog.cpp +21 -5
- data/source/bzs/rtl/debuglog.h +1 -1
- data/source/bzs/test/tdclphp/transactd_Test.php +183 -37
- data/source/bzs/test/tdclphp/transactd_pool_Test.php +1 -2
- data/source/bzs/test/tdclrb/transactd_spec.rb +183 -39
- data/source/bzs/test/transactdBench/scaling_bench.cpp +3 -3
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +172 -57
- data/source/global/boost/sha1.hpp +223 -0
- data/source/global/tdclatl/ConnectParams.cpp +2 -2
- data/source/global/tdclatl/ConnectParams.h +1 -1
- data/source/global/tdclatl/Database.cpp +18 -0
- data/source/global/tdclatl/Database.h +5 -0
- data/source/global/tdclatl/tdclatl.idl +23 -1
- data/source/linux/linuxTypes.h +2 -0
- metadata +8 -6
- data/bin/common/tdclc_32_2_1.dll +0 -0
- data/bin/common/tdclc_64_2_1.dll +0 -0
- data/source/bzs/db/protocol/tdap/client/memRecordset.cpp +0 -448
- data/source/bzs/db/protocol/tdap/client/memRecordset.h +0 -159
|
@@ -313,7 +313,6 @@ public:
|
|
|
313
313
|
moveBlobRow(m_row);
|
|
314
314
|
|
|
315
315
|
m_tb->m_fddefs->strBufs()->clear();
|
|
316
|
-
multiRecordAlocator* mra = m_tb->m_impl->mraPtr;
|
|
317
316
|
const tabledef* td = m_tb->tableDef();
|
|
318
317
|
ushort_td fieldCount = m_filter->fieldCount();
|
|
319
318
|
|
|
@@ -432,7 +431,7 @@ multiRecordAlocator* table::mra() const
|
|
|
432
431
|
|
|
433
432
|
uchar_td table::charset() const
|
|
434
433
|
{
|
|
435
|
-
return m_tableDef->charsetIndex;
|
|
434
|
+
return (*m_tableDef)->charsetIndex;
|
|
436
435
|
}
|
|
437
436
|
|
|
438
437
|
bool table::trimPadChar() const
|
|
@@ -830,12 +829,12 @@ void table::btrvSeekMulti()
|
|
|
830
829
|
int rowOffset = 0;
|
|
831
830
|
for (int i = 0; i < (int)seeks.size(); ++i)
|
|
832
831
|
{
|
|
833
|
-
|
|
834
|
-
m_impl->mraPtr->init(1, recordLen, type, this);
|
|
835
|
-
type = mra_nextrows;
|
|
832
|
+
|
|
836
833
|
seeks[i].writeBuffer((uchar_td*)m_impl->keybuf, true, transactd);
|
|
837
834
|
if (hasManyJoin)
|
|
838
835
|
{
|
|
836
|
+
m_impl->mraPtr->init(1, recordLen, type, this);
|
|
837
|
+
type = mra_nextrows;
|
|
839
838
|
tdap((ushort_td)(TD_KEY_OR_AFTER));
|
|
840
839
|
if (!checkStatus(m_stat))
|
|
841
840
|
return;
|
|
@@ -1137,19 +1136,19 @@ void table::getKeySpec(keySpec* ks, bool SpecifyKeyNum)
|
|
|
1137
1136
|
keydef* KeyDef;
|
|
1138
1137
|
short FieldNum;
|
|
1139
1138
|
int j;
|
|
1140
|
-
|
|
1141
|
-
KeyDef = &
|
|
1139
|
+
tabledef* td = (*m_tableDef);
|
|
1140
|
+
KeyDef = &td->keyDefs[m_keynum];
|
|
1142
1141
|
for (j = 0; j < KeyDef->segmentCount; j++)
|
|
1143
1142
|
{
|
|
1144
1143
|
FieldNum = KeyDef->segments[j].fieldNum;
|
|
1145
|
-
ks[j].keyPos = (ushort_td)(
|
|
1146
|
-
ks[j].keyLen =
|
|
1144
|
+
ks[j].keyPos = (ushort_td)(td->fieldDefs[FieldNum].pos + 1);
|
|
1145
|
+
ks[j].keyLen = td->fieldDefs[FieldNum].len;
|
|
1147
1146
|
ks[j].keyFlag.all = KeyDef->segments[j].flags.all;
|
|
1148
1147
|
ks[j].keyCount = 0;
|
|
1149
|
-
ks[j].keyType =
|
|
1148
|
+
ks[j].keyType = td->fieldDefs[FieldNum].type;
|
|
1150
1149
|
|
|
1151
1150
|
if (ks[j].keyFlag.bit3 == true)
|
|
1152
|
-
ks[j].nullValue =
|
|
1151
|
+
ks[j].nullValue = td->fieldDefs[FieldNum].nullValue;
|
|
1153
1152
|
else
|
|
1154
1153
|
ks[j].nullValue = 0;
|
|
1155
1154
|
ks[j].reserve2[0] = 0;
|
|
@@ -1166,25 +1165,40 @@ void table::getKeySpec(keySpec* ks, bool SpecifyKeyNum)
|
|
|
1166
1165
|
|
|
1167
1166
|
void table::doCreateIndex(bool SpecifyKeyNum)
|
|
1168
1167
|
{
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1168
|
+
SpecifyKeyNum = false;
|
|
1169
|
+
if (isUseTransactd())
|
|
1170
|
+
{
|
|
1171
|
+
uint_td len = m_datalen;
|
|
1172
|
+
m_pdata = (*m_tableDef);
|
|
1173
|
+
m_datalen = (*m_tableDef)->varSize + 4;
|
|
1174
|
+
// tdclc check datalen, m_pdata is tabledef if bigger than sizeof(keySpec) * 8
|
|
1175
|
+
if (m_datalen <= sizeof(keySpec) * 8)
|
|
1176
|
+
m_datalen = sizeof(keySpec) * 8 + 10;
|
|
1177
|
+
nstable::doCreateIndex(SpecifyKeyNum);
|
|
1178
|
+
m_pdata = m_impl->dataBak;
|
|
1179
|
+
m_datalen = len;
|
|
1180
|
+
}
|
|
1181
|
+
else
|
|
1182
|
+
{
|
|
1183
|
+
int segmentCount = (*m_tableDef)->keyDefs[m_keynum].segmentCount;
|
|
1184
|
+
keySpec* ks = (keySpec*)malloc(sizeof(keySpec) * segmentCount);
|
|
1185
|
+
memset(ks, 0, sizeof(keySpec) * segmentCount);
|
|
1186
|
+
getKeySpec(ks, SpecifyKeyNum);
|
|
1187
|
+
m_pdata = ks;
|
|
1188
|
+
m_datalen = sizeof(keySpec) * segmentCount;//max 16 * 8 =128byte
|
|
1189
|
+
nstable::doCreateIndex(SpecifyKeyNum);
|
|
1190
|
+
m_pdata = m_impl->dataBak;
|
|
1191
|
+
free(ks);
|
|
1192
|
+
}
|
|
1179
1193
|
}
|
|
1180
1194
|
|
|
1181
1195
|
void table::smartUpdate()
|
|
1182
1196
|
{
|
|
1183
1197
|
if (!m_impl->smartUpDate)
|
|
1184
|
-
m_impl->smartUpDate = malloc(m_tableDef->maxRecordLen);
|
|
1198
|
+
m_impl->smartUpDate = malloc((*m_tableDef)->maxRecordLen);
|
|
1185
1199
|
if (m_impl->smartUpDate)
|
|
1186
1200
|
{
|
|
1187
|
-
memcpy(m_impl->smartUpDate, data(), m_tableDef->maxRecordLen);
|
|
1201
|
+
memcpy(m_impl->smartUpDate, data(), (*m_tableDef)->maxRecordLen);
|
|
1188
1202
|
m_impl->smartUpDateFlag = true;
|
|
1189
1203
|
}
|
|
1190
1204
|
else
|
|
@@ -1193,9 +1207,9 @@ void table::smartUpdate()
|
|
|
1193
1207
|
|
|
1194
1208
|
bool table::isUniqeKey(char_td keynum)
|
|
1195
1209
|
{
|
|
1196
|
-
if ((keynum >= 0) && (keynum < m_tableDef->keyCount))
|
|
1210
|
+
if ((keynum >= 0) && (keynum < (*m_tableDef)->keyCount))
|
|
1197
1211
|
{
|
|
1198
|
-
keydef* kd = &m_tableDef->keyDefs[m_keynum];
|
|
1212
|
+
keydef* kd = &(*m_tableDef)->keyDefs[m_keynum];
|
|
1199
1213
|
return !(kd->segments[0].flags.bit0);
|
|
1200
1214
|
}
|
|
1201
1215
|
return false;
|
|
@@ -1228,7 +1242,7 @@ bool table::onUpdateCheck(eUpdateType type)
|
|
|
1228
1242
|
else if (m_impl->smartUpDateFlag)
|
|
1229
1243
|
{
|
|
1230
1244
|
m_stat = 0;
|
|
1231
|
-
if (memcmp(m_impl->smartUpDate, data(), m_tableDef->maxRecordLen) == 0)
|
|
1245
|
+
if (memcmp(m_impl->smartUpDate, data(), (*m_tableDef)->maxRecordLen) == 0)
|
|
1232
1246
|
{
|
|
1233
1247
|
m_impl->smartUpDateFlag = false;
|
|
1234
1248
|
return false;
|
|
@@ -1291,7 +1305,7 @@ void* table::attachBuffer(void* NewPtr, bool unpack, size_t size)
|
|
|
1291
1305
|
m_impl->bfAtcPtr = m_pdata;
|
|
1292
1306
|
oldptr = m_pdata;
|
|
1293
1307
|
m_pdata = NewPtr;
|
|
1294
|
-
ushort_td len = m_tableDef->maxRecordLen;
|
|
1308
|
+
ushort_td len = (*m_tableDef)->maxRecordLen;
|
|
1295
1309
|
if (unpack)
|
|
1296
1310
|
len = unPack((char*)m_pdata, size);
|
|
1297
1311
|
m_datalen = len;
|
|
@@ -1305,27 +1319,28 @@ void table::dettachBuffer()
|
|
|
1305
1319
|
m_impl->bfAtcPtr = NULL;
|
|
1306
1320
|
}
|
|
1307
1321
|
|
|
1308
|
-
void table::init(tabledef
|
|
1322
|
+
void table::init(tabledef** Def, short fnum, bool regularDir)
|
|
1309
1323
|
{
|
|
1310
1324
|
doInit(Def, fnum, regularDir);
|
|
1311
1325
|
}
|
|
1312
1326
|
|
|
1313
|
-
void table::doInit(tabledef
|
|
1327
|
+
void table::doInit(tabledef** Def, short fnum, bool /*regularDir*/)
|
|
1314
1328
|
{
|
|
1315
1329
|
m_tableDef = Def;
|
|
1316
|
-
|
|
1317
|
-
m_fddefs->
|
|
1318
|
-
|
|
1330
|
+
tabledef* td = *m_tableDef;
|
|
1331
|
+
m_fddefs->addAllFileds(td);
|
|
1332
|
+
m_fddefs->cv()->setCodePage(mysql::codePage(td->charsetIndex));
|
|
1333
|
+
ushort_td len = td->maxRecordLen;
|
|
1319
1334
|
if (len == 0)
|
|
1320
1335
|
{
|
|
1321
1336
|
m_stat = STATUS_INVALID_RECLEN;
|
|
1322
1337
|
return;
|
|
1323
1338
|
}
|
|
1324
1339
|
|
|
1325
|
-
for (short i = 0; i <
|
|
1340
|
+
for (short i = 0; i < td->keyCount; i++)
|
|
1326
1341
|
{
|
|
1327
|
-
if (
|
|
1328
|
-
m_impl->keyNumIndex[
|
|
1342
|
+
if (td->flags.bitA == true)
|
|
1343
|
+
m_impl->keyNumIndex[td->keyDefs[i].keyNumber] = (char)i;
|
|
1329
1344
|
else
|
|
1330
1345
|
m_impl->keyNumIndex[i] = (char)i;
|
|
1331
1346
|
}
|
|
@@ -1337,10 +1352,10 @@ void table::doInit(tabledef* Def, short fnum, bool /*regularDir*/)
|
|
|
1337
1352
|
|
|
1338
1353
|
keylen_td table::writeKeyDataTo(uchar_td* to, int keySize)
|
|
1339
1354
|
{
|
|
1340
|
-
if (m_tableDef->keyCount)
|
|
1355
|
+
if ((*m_tableDef)->keyCount)
|
|
1341
1356
|
{
|
|
1342
1357
|
keydef& keydef =
|
|
1343
|
-
m_tableDef->keyDefs[(short)m_impl->keyNumIndex[m_keynum]];
|
|
1358
|
+
(*m_tableDef)->keyDefs[(short)m_impl->keyNumIndex[m_keynum]];
|
|
1344
1359
|
uchar_td* start = to;
|
|
1345
1360
|
if (keySize == 0)
|
|
1346
1361
|
keySize = keydef.segmentCount;
|
|
@@ -1348,7 +1363,7 @@ keylen_td table::writeKeyDataTo(uchar_td* to, int keySize)
|
|
|
1348
1363
|
for (int j = 0; j < keySize; j++)
|
|
1349
1364
|
{
|
|
1350
1365
|
int fdnum = keydef.segments[j].fieldNum;
|
|
1351
|
-
fielddef& fd = m_tableDef->fieldDefs[fdnum];
|
|
1366
|
+
fielddef& fd = (*m_tableDef)->fieldDefs[fdnum];
|
|
1352
1367
|
uchar_td* from = (uchar_td*)m_pdata + fd.pos;
|
|
1353
1368
|
to = fd.keyCopy(to, from);
|
|
1354
1369
|
}
|
|
@@ -1367,9 +1382,9 @@ uint_td table::pack(char* ptr, size_t size)
|
|
|
1367
1382
|
char* pos = ptr;
|
|
1368
1383
|
char* end = pos + size;
|
|
1369
1384
|
int movelen;
|
|
1370
|
-
for (int i = 0; i < m_tableDef->fieldCount; i++)
|
|
1385
|
+
for (int i = 0; i < (*m_tableDef)->fieldCount; i++)
|
|
1371
1386
|
{
|
|
1372
|
-
fielddef& fd = m_tableDef->fieldDefs[i];
|
|
1387
|
+
fielddef& fd = (*m_tableDef)->fieldDefs[i];
|
|
1373
1388
|
if (fd.type == ft_myfixedbinary)
|
|
1374
1389
|
{
|
|
1375
1390
|
memmove(pos + 2, pos, fd.len - 2); // move as size pace in the field
|
|
@@ -1398,15 +1413,16 @@ uint_td table::pack(char* ptr, size_t size)
|
|
|
1398
1413
|
|
|
1399
1414
|
uint_td table::doGetWriteImageLen()
|
|
1400
1415
|
{
|
|
1416
|
+
tabledef* td = (*m_tableDef);
|
|
1401
1417
|
if (!blobFieldUsed() && !valiableFormatType() &&
|
|
1402
|
-
(
|
|
1403
|
-
return
|
|
1418
|
+
(td->flags.bit0 == false))
|
|
1419
|
+
return td->maxRecordLen;
|
|
1404
1420
|
// Make blob pointer list
|
|
1405
1421
|
if (blobFieldUsed())
|
|
1406
1422
|
{
|
|
1407
|
-
for (ushort_td i = 0; i <
|
|
1423
|
+
for (ushort_td i = 0; i < td->fieldCount; i++)
|
|
1408
1424
|
{
|
|
1409
|
-
fielddef& fd =
|
|
1425
|
+
fielddef& fd = td->fieldDefs[i];
|
|
1410
1426
|
uint_td bytes = fd.blobLenBytes();
|
|
1411
1427
|
if (bytes)
|
|
1412
1428
|
{
|
|
@@ -1421,21 +1437,21 @@ uint_td table::doGetWriteImageLen()
|
|
|
1421
1437
|
addSendBlob(NULL);
|
|
1422
1438
|
|
|
1423
1439
|
if (valiableFormatType())
|
|
1424
|
-
return pack((char*)m_pdata,
|
|
1440
|
+
return pack((char*)m_pdata, td->maxRecordLen);
|
|
1425
1441
|
else
|
|
1426
1442
|
{
|
|
1427
|
-
fielddef* fd = &
|
|
1443
|
+
fielddef* fd = &td->fieldDefs[td->fieldCount - 1];
|
|
1428
1444
|
size_t len = 0;
|
|
1429
1445
|
short* pos;
|
|
1430
1446
|
|
|
1431
1447
|
if (fd->type == ft_note)
|
|
1432
|
-
len = strlen((char*)fieldPtr((short)(
|
|
1448
|
+
len = strlen((char*)fieldPtr((short)(td->fieldCount - 1))) +
|
|
1433
1449
|
1;
|
|
1434
1450
|
else if (fd->type == ft_lvar)
|
|
1435
1451
|
{
|
|
1436
1452
|
// xx................xx.............00
|
|
1437
1453
|
// ln--data----------ln-----data----00
|
|
1438
|
-
pos = (short*)fieldPtr((short)(
|
|
1454
|
+
pos = (short*)fieldPtr((short)(td->fieldCount - 1));
|
|
1439
1455
|
while (*pos)
|
|
1440
1456
|
{
|
|
1441
1457
|
len += 2; // size
|
|
@@ -1457,11 +1473,12 @@ uint_td table::unPack(char* ptr, size_t size)
|
|
|
1457
1473
|
{
|
|
1458
1474
|
char* pos = ptr;
|
|
1459
1475
|
const char* end = pos + size;
|
|
1460
|
-
|
|
1476
|
+
tabledef* td = *m_tableDef;
|
|
1477
|
+
const char* max = pos + td->maxRecordLen;
|
|
1461
1478
|
int movelen;
|
|
1462
|
-
for (int i = 0; i <
|
|
1479
|
+
for (int i = 0; i < td->fieldCount; i++)
|
|
1463
1480
|
{
|
|
1464
|
-
fielddef& fd =
|
|
1481
|
+
fielddef& fd = td->fieldDefs[i];
|
|
1465
1482
|
if (fd.type == ft_myfixedbinary)
|
|
1466
1483
|
{
|
|
1467
1484
|
int dl = *((unsigned short*)(pos));
|
|
@@ -1547,7 +1564,7 @@ void table::setBlobFieldPointer(char* ptr, const blobHeader* hd)
|
|
|
1547
1564
|
const blobField* f = hd->nextField;
|
|
1548
1565
|
for (int i = 0; i < hd->fieldCount; i++)
|
|
1549
1566
|
{
|
|
1550
|
-
fielddef& fd = m_tableDef->fieldDefs[f->fieldNum];
|
|
1567
|
+
fielddef& fd = (*m_tableDef)->fieldDefs[f->fieldNum];
|
|
1551
1568
|
char* fdptr = ptr + fd.pos;
|
|
1552
1569
|
int sizeByte = fd.blobLenBytes();
|
|
1553
1570
|
memcpy(fdptr, &f->size, sizeByte);
|
|
@@ -1574,8 +1591,8 @@ void table::onReadAfter()
|
|
|
1574
1591
|
const blobHeader* hd = getBlobHeader();
|
|
1575
1592
|
setBlobFieldPointer((char*)m_pdata, hd);
|
|
1576
1593
|
}
|
|
1577
|
-
if (m_tableDef->maxRecordLen - m_datalen > 0)
|
|
1578
|
-
memset((char*)m_pdata + m_datalen, 0, m_tableDef->maxRecordLen - m_datalen);
|
|
1594
|
+
if ((*m_tableDef)->maxRecordLen - m_datalen > 0)
|
|
1595
|
+
memset((char*)m_pdata + m_datalen, 0, (*m_tableDef)->maxRecordLen - m_datalen);
|
|
1579
1596
|
}
|
|
1580
1597
|
|
|
1581
1598
|
short table::fieldNumByName(const _TCHAR* name)
|
|
@@ -1849,7 +1866,7 @@ void* table::getFVbin(short index, uint_td& size)
|
|
|
1849
1866
|
|
|
1850
1867
|
bool table::checkIndex(short index) const
|
|
1851
1868
|
{
|
|
1852
|
-
if ((index >= m_tableDef->fieldCount) || (index < 0))
|
|
1869
|
+
if ((index >= (*m_tableDef)->fieldCount) || (index < 0))
|
|
1853
1870
|
{
|
|
1854
1871
|
m_stat = STATUS_INVARID_FIELD_IDX;
|
|
1855
1872
|
return false;
|
|
@@ -1881,7 +1898,7 @@ void table::moveBookmarksId(long id)
|
|
|
1881
1898
|
|
|
1882
1899
|
short_td table::doBtrvErr(HWND hWnd, _TCHAR* retbuf)
|
|
1883
1900
|
{
|
|
1884
|
-
return nstable::tdapErr(hWnd, m_stat, m_tableDef->tableName(), retbuf);
|
|
1901
|
+
return nstable::tdapErr(hWnd, m_stat, (*m_tableDef)->tableName(), retbuf);
|
|
1885
1902
|
}
|
|
1886
1903
|
|
|
1887
1904
|
/* For keyValueDescription */
|
|
@@ -87,7 +87,7 @@ class DLLLIB table : public nstable
|
|
|
87
87
|
|
|
88
88
|
struct tbimpl* m_impl;
|
|
89
89
|
class fielddefs* m_fddefs;
|
|
90
|
-
tabledef
|
|
90
|
+
tabledef** m_tableDef;
|
|
91
91
|
|
|
92
92
|
uchar_td charset() const;
|
|
93
93
|
bool checkIndex(short index) const;
|
|
@@ -138,12 +138,12 @@ protected:
|
|
|
138
138
|
|
|
139
139
|
void onInsertAfter(int beforeResult); // orverride
|
|
140
140
|
bool isUniqeKey(char_td keynum); // orverride
|
|
141
|
-
void init(tabledef
|
|
141
|
+
void init(tabledef** def, short filenum, bool regularDir);
|
|
142
142
|
void* attachBuffer(void* newPtr, bool unpack = false, size_t size = 0);
|
|
143
143
|
void dettachBuffer();
|
|
144
144
|
bool doPrepare();
|
|
145
145
|
|
|
146
|
-
virtual void doInit(tabledef
|
|
146
|
+
virtual void doInit(tabledef** def, short filenum, bool regularDir);
|
|
147
147
|
|
|
148
148
|
virtual void onRecordCounting(size_t count, bool& complate){};
|
|
149
149
|
|
|
@@ -152,18 +152,18 @@ protected:
|
|
|
152
152
|
public:
|
|
153
153
|
using nstable::eFindType;
|
|
154
154
|
|
|
155
|
-
inline const tabledef* tableDef() const { return m_tableDef; };
|
|
155
|
+
inline const tabledef* tableDef() const { return *m_tableDef; };
|
|
156
156
|
inline const tabledef** tableDefPtr() const
|
|
157
157
|
{
|
|
158
|
-
return const_cast<const tabledef**>(
|
|
159
|
-
}
|
|
158
|
+
return const_cast<const tabledef**>(m_tableDef);
|
|
159
|
+
}
|
|
160
160
|
|
|
161
161
|
inline bool valiableFormatType() const
|
|
162
162
|
{
|
|
163
|
-
return m_tableDef->optionFlags.bitA;
|
|
163
|
+
return (*m_tableDef)->optionFlags.bitA;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
inline bool blobFieldUsed() const { return m_tableDef->optionFlags.bitB; }
|
|
166
|
+
inline bool blobFieldUsed() const { return (*m_tableDef)->optionFlags.bitB; }
|
|
167
167
|
|
|
168
168
|
bool logicalToString() const;
|
|
169
169
|
void setLogicalToString(bool v);
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
#include <boost/noncopyable.hpp>
|
|
24
24
|
#include <iterator>
|
|
25
25
|
#include <stdio.h>
|
|
26
|
+
#include <bzs/db/protocol/tdap/uri.h>
|
|
26
27
|
|
|
27
28
|
#if defined(__GNUC__)
|
|
28
29
|
#if (!defined(__clang__) && \
|
|
@@ -74,14 +75,27 @@ class connectParams
|
|
|
74
75
|
|
|
75
76
|
public:
|
|
76
77
|
inline connectParams(const _TCHAR* protocol, const _TCHAR* hostOrIp,
|
|
77
|
-
const _TCHAR* dbname, const _TCHAR* schemaTable
|
|
78
|
+
const _TCHAR* dbname, const _TCHAR* schemaTable
|
|
79
|
+
,const _TCHAR* userName=NULL, const _TCHAR* passwd=NULL)
|
|
78
80
|
: m_type(TYPE_SCHEMA_BDF), m_mode(TD_OPEN_READONLY)
|
|
79
81
|
{
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
_TCHAR dbf[MAX_PATH]={0x00};
|
|
83
|
+
if (schemaTable && schemaTable[0])
|
|
84
|
+
{
|
|
85
|
+
const _TCHAR* ext = _T(".bdf");
|
|
86
|
+
if (_tcscmp(schemaTable, TRANSACTD_SCHEMANAME)==0)
|
|
87
|
+
ext = _T("");
|
|
88
|
+
_stprintf_s(dbf, MAX_PATH, _T("dbfile=%s%s"), schemaTable, ext);
|
|
89
|
+
}
|
|
90
|
+
if (userName == NULL || (userName[0] == 0x00))
|
|
91
|
+
_stprintf_s(m_buf, MAX_PATH, _T("%s://%s/%s?%s"), protocol,
|
|
92
|
+
hostOrIp, dbname, dbf);
|
|
93
|
+
else
|
|
94
|
+
{
|
|
95
|
+
if (!passwd) passwd = _T("");
|
|
96
|
+
_stprintf_s(m_buf, MAX_PATH, _T("%s://%s@%s/%s?%s&pwd=%s"),
|
|
97
|
+
protocol, userName, hostOrIp, dbname, dbf, passwd);
|
|
98
|
+
}
|
|
85
99
|
}
|
|
86
100
|
inline explicit connectParams(const _TCHAR* uri)
|
|
87
101
|
: m_type(TYPE_SCHEMA_BDF), m_mode(TD_OPEN_READONLY)
|
|
@@ -106,65 +120,16 @@ public:
|
|
|
106
120
|
m_type = v;
|
|
107
121
|
}
|
|
108
122
|
|
|
109
|
-
inline const _TCHAR* uri() const
|
|
123
|
+
inline const _TCHAR* uri(bool noPasswd=false) const
|
|
124
|
+
{
|
|
125
|
+
return m_buf;
|
|
126
|
+
}
|
|
110
127
|
|
|
111
128
|
inline char_td mode() const { return m_mode; };
|
|
112
129
|
|
|
113
130
|
inline short type() const { return m_type; };
|
|
114
131
|
};
|
|
115
132
|
|
|
116
|
-
inline const _TCHAR* host(const _TCHAR* uri, _TCHAR* buf, size_t size)
|
|
117
|
-
{
|
|
118
|
-
buf[0] = 0x00;
|
|
119
|
-
const _TCHAR* st = _tcsstr(uri, _T("://"));
|
|
120
|
-
if (st)
|
|
121
|
-
{
|
|
122
|
-
const _TCHAR* en = _tcsstr(st + 3, _T("/"));
|
|
123
|
-
if (en)
|
|
124
|
-
{
|
|
125
|
-
_tcsncpy_s(buf, size, st + 3, en - (st + 3));
|
|
126
|
-
buf[en - (st + 3)] = 0x00;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return buf;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
inline const _TCHAR* dbname(const _TCHAR* uri, _TCHAR* buf, size_t size)
|
|
133
|
-
{
|
|
134
|
-
buf[0] = 0x00;
|
|
135
|
-
const _TCHAR* st = _tcsstr(uri, _T("://"));
|
|
136
|
-
if (st)
|
|
137
|
-
{
|
|
138
|
-
st = _tcsstr(st + 3, _T("/"));
|
|
139
|
-
if (st)
|
|
140
|
-
{
|
|
141
|
-
const _TCHAR* en = _tcsstr(st + 1, _T("?"));
|
|
142
|
-
if (en)
|
|
143
|
-
{
|
|
144
|
-
_tcsncpy_s(buf, size, st + 1, en - (st + 1));
|
|
145
|
-
buf[en - (st + 1)] = 0x00;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return buf;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
inline const _TCHAR* schemaTable(const _TCHAR* uri, _TCHAR* buf, size_t size)
|
|
153
|
-
{
|
|
154
|
-
buf[0] = 0x00;
|
|
155
|
-
const _TCHAR* st = _tcsrchr(uri, _T('='));
|
|
156
|
-
if (st)
|
|
157
|
-
{
|
|
158
|
-
const _TCHAR* en = _tcsrchr(uri, _T('.'));
|
|
159
|
-
if (en)
|
|
160
|
-
{
|
|
161
|
-
_tcsncpy_s(buf, size, st + 1, en - (st + 1));
|
|
162
|
-
buf[en - (st + 1)] = 0x00;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return buf;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
133
|
/* databaseManager interface
|
|
169
134
|
If use some databases, implemnt a this interface and set the activeTable
|
|
170
135
|
constructor
|
|
@@ -206,7 +171,7 @@ class tableIterator
|
|
|
206
171
|
ushort_td m_lockBias;
|
|
207
172
|
|
|
208
173
|
public:
|
|
209
|
-
inline tableIterator(table& tb, ushort_td lockBias =
|
|
174
|
+
inline tableIterator(table& tb, ushort_td lockBias = LOCK_BIAS_DEFAULT) : m_tb(tb), m_fds(tb),m_lockBias(lockBias)
|
|
210
175
|
{
|
|
211
176
|
readStatusCheck(tb, _T("tableIterator"));
|
|
212
177
|
}
|
|
@@ -312,7 +277,7 @@ typedef filterdIterator<indexRvIterator> filterdIndexRvIterator;
|
|
|
312
277
|
typedef filterdIterator<stepRvIterator> filterdStepRvIterator;
|
|
313
278
|
typedef filterdIterator<findRvIterator> filterdFindRvIterator;
|
|
314
279
|
|
|
315
|
-
inline indexIterator readIndex(table_ptr tb, eIndexOpType op, ushort_td lockBias =
|
|
280
|
+
inline indexIterator readIndex(table_ptr tb, eIndexOpType op, ushort_td lockBias = LOCK_BIAS_DEFAULT)
|
|
316
281
|
{
|
|
317
282
|
|
|
318
283
|
switch (op)
|
|
@@ -336,7 +301,7 @@ inline indexIterator readIndex(table_ptr tb, eIndexOpType op, ushort_td lockBias
|
|
|
336
301
|
return indexIterator(*tb, lockBias);
|
|
337
302
|
}
|
|
338
303
|
|
|
339
|
-
inline indexRvIterator readIndexRv(table_ptr tb, eIndexOpType op, ushort_td lockBias =
|
|
304
|
+
inline indexRvIterator readIndexRv(table_ptr tb, eIndexOpType op, ushort_td lockBias = LOCK_BIAS_DEFAULT)
|
|
340
305
|
{
|
|
341
306
|
|
|
342
307
|
switch (op)
|
|
@@ -362,7 +327,7 @@ inline indexRvIterator readIndexRv(table_ptr tb, eIndexOpType op, ushort_td lock
|
|
|
362
327
|
|
|
363
328
|
template <class T>
|
|
364
329
|
inline indexIterator readIndex(table_ptr tb, eIndexOpType op, char_td keynum,
|
|
365
|
-
T func, ushort_td lockBias =
|
|
330
|
+
T func, ushort_td lockBias = LOCK_BIAS_DEFAULT)
|
|
366
331
|
{
|
|
367
332
|
tb->setKeyNum(keynum);
|
|
368
333
|
if (&func)
|
|
@@ -375,7 +340,7 @@ inline indexIterator readIndex(table_ptr tb, eIndexOpType op, char_td keynum,
|
|
|
375
340
|
|
|
376
341
|
template <class T>
|
|
377
342
|
inline indexRvIterator readIndexRv(table_ptr tb, eIndexOpType op,
|
|
378
|
-
char_td keynum, T func, ushort_td lockBias =
|
|
343
|
+
char_td keynum, T func, ushort_td lockBias = LOCK_BIAS_DEFAULT)
|
|
379
344
|
{
|
|
380
345
|
tb->setKeyNum(keynum);
|
|
381
346
|
if (&func)
|
|
@@ -550,13 +515,13 @@ inline indexRvIterator readIndexRv_v(table_ptr tb, eIndexOpType op,
|
|
|
550
515
|
}
|
|
551
516
|
/** @endcond */
|
|
552
517
|
|
|
553
|
-
inline stepIterator readStep(table_ptr tb, ushort_td lockBias =
|
|
518
|
+
inline stepIterator readStep(table_ptr tb, ushort_td lockBias = LOCK_BIAS_DEFAULT)
|
|
554
519
|
{
|
|
555
520
|
tb->stepFirst(lockBias);
|
|
556
521
|
return stepIterator(*tb, lockBias);
|
|
557
522
|
}
|
|
558
523
|
|
|
559
|
-
inline stepRvIterator readStepRv(table_ptr tb, ushort_td lockBias =
|
|
524
|
+
inline stepRvIterator readStepRv(table_ptr tb, ushort_td lockBias = LOCK_BIAS_DEFAULT)
|
|
560
525
|
{
|
|
561
526
|
tb->stepLast(lockBias);
|
|
562
527
|
return stepRvIterator(*tb, lockBias);
|
|
@@ -826,28 +791,6 @@ inline database_ptr createDatabaseObject()
|
|
|
826
791
|
return p;
|
|
827
792
|
}
|
|
828
793
|
|
|
829
|
-
template <class Database_Ptr, class ConnectParam_type>
|
|
830
|
-
inline void connect(Database_Ptr db, const ConnectParam_type& connPrams,
|
|
831
|
-
bool newConnection)
|
|
832
|
-
{
|
|
833
|
-
db->connect(connPrams.uri(), newConnection);
|
|
834
|
-
if (db->stat())
|
|
835
|
-
nstable::throwError(
|
|
836
|
-
(std::_tstring(_T("Connect database ")) + connPrams.uri()).c_str(),
|
|
837
|
-
db->stat());
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
/*template <>
|
|
841
|
-
inline void connect(idatabaseManager* db, const connectParams& connPrams, bool
|
|
842
|
-
newConnection)
|
|
843
|
-
{
|
|
844
|
-
db->connect(connPrams, newConnection);
|
|
845
|
-
if (db->stat())
|
|
846
|
-
nstable::throwError((std::_tstring(_T("Connect database ")) +
|
|
847
|
-
connPrams.uri()).c_str(), db->stat());
|
|
848
|
-
|
|
849
|
-
}*/
|
|
850
|
-
|
|
851
794
|
template <class Database_Ptr>
|
|
852
795
|
inline void disconnect(Database_Ptr db, const connectParams& connPrams)
|
|
853
796
|
{
|
|
@@ -865,14 +808,29 @@ template <class Database_Ptr> inline void disconnect(Database_Ptr db)
|
|
|
865
808
|
nstable::throwError(_T("Disconnect database "), db->stat());
|
|
866
809
|
}
|
|
867
810
|
|
|
811
|
+
template <class Database_Ptr>
|
|
812
|
+
inline void throwDbError(Database_Ptr db, const _TCHAR* caption, const _TCHAR* uri)
|
|
813
|
+
{
|
|
814
|
+
TCHAR tmp[MAX_PATH];
|
|
815
|
+
tdap::stripPasswd(uri, tmp, MAX_PATH);
|
|
816
|
+
nstable::throwError((std::_tstring(caption) + tmp).c_str(), db->stat());
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
template <class Database_Ptr, class ConnectParam_type>
|
|
820
|
+
inline void connect(Database_Ptr db, const ConnectParam_type& connPrams,
|
|
821
|
+
bool newConnection)
|
|
822
|
+
{
|
|
823
|
+
db->connect(connPrams.uri(), newConnection);
|
|
824
|
+
if (db->stat())
|
|
825
|
+
throwDbError(db, _T("Connect database : "), connPrams.uri());
|
|
826
|
+
}
|
|
827
|
+
|
|
868
828
|
template <class Database_Ptr>
|
|
869
829
|
inline void createDatabase(Database_Ptr db, const connectParams& connPrams)
|
|
870
830
|
{
|
|
871
831
|
db->create(connPrams.uri());
|
|
872
832
|
if (db->stat())
|
|
873
|
-
|
|
874
|
-
(std::_tstring(_T("Create database ")) + connPrams.uri()).c_str(),
|
|
875
|
-
db->stat());
|
|
833
|
+
throwDbError(db, _T("Create database : "), connPrams.uri());
|
|
876
834
|
}
|
|
877
835
|
|
|
878
836
|
template <class Database_Ptr>
|
|
@@ -880,8 +838,7 @@ inline void createDatabase(Database_Ptr db, const _TCHAR* uri)
|
|
|
880
838
|
{
|
|
881
839
|
db->create(uri);
|
|
882
840
|
if (db->stat())
|
|
883
|
-
|
|
884
|
-
(std::_tstring(_T("Create database ")) + uri).c_str(), db->stat());
|
|
841
|
+
throwDbError(db, _T("Create database : "), uri);
|
|
885
842
|
}
|
|
886
843
|
|
|
887
844
|
template <class Database_Ptr, class ConnectParam_type>
|
|
@@ -889,9 +846,7 @@ inline void openDatabase(Database_Ptr db, const ConnectParam_type& connPrams)
|
|
|
889
846
|
{
|
|
890
847
|
db->open(connPrams.uri(), connPrams.type(), connPrams.mode());
|
|
891
848
|
if (db->stat())
|
|
892
|
-
|
|
893
|
-
(std::_tstring(_T("Open database ")) + connPrams.uri()).c_str(),
|
|
894
|
-
db->stat());
|
|
849
|
+
throwDbError(db, _T("Open database : "), connPrams.uri());
|
|
895
850
|
}
|
|
896
851
|
|
|
897
852
|
template <class Database_Ptr>
|
|
@@ -902,9 +857,7 @@ inline void openDatabase(Database_Ptr db, const _TCHAR* uri,
|
|
|
902
857
|
{
|
|
903
858
|
db->open(uri, schemaType, mode, dir, ownername);
|
|
904
859
|
if (db->stat())
|
|
905
|
-
|
|
906
|
-
(std::_tstring(_T("Open database ")) + std::_tstring(uri)).c_str(),
|
|
907
|
-
db->stat());
|
|
860
|
+
throwDbError(db, _T("Open database : "), uri);
|
|
908
861
|
}
|
|
909
862
|
|
|
910
863
|
template <class Database_Ptr>
|
|
@@ -1002,7 +955,6 @@ inline void insertTable(dbdef* def, short id, const _TCHAR* name,
|
|
|
1002
955
|
inline fielddef* insertField(dbdef* def, short tableid, short fieldNum,
|
|
1003
956
|
const _TCHAR* name, uchar_td type, ushort_td len)
|
|
1004
957
|
{
|
|
1005
|
-
|
|
1006
958
|
fielddef* fd = def->insertField(tableid, fieldNum);
|
|
1007
959
|
if (def->stat() != 0)
|
|
1008
960
|
nstable::throwError(
|
|
@@ -104,6 +104,10 @@ uchar_td convFieldType(enum enum_field_types type, uint flags, bool binary,
|
|
|
104
104
|
if ((flags & UNSIGNED_FLAG) || (type == MYSQL_TYPE_YEAR))
|
|
105
105
|
return ft_uinteger;
|
|
106
106
|
return ft_integer;
|
|
107
|
+
case MYSQL_TYPE_ENUM:
|
|
108
|
+
return ft_integer;
|
|
109
|
+
case MYSQL_TYPE_SET:
|
|
110
|
+
return ft_uinteger;
|
|
107
111
|
case MYSQL_TYPE_FLOAT:
|
|
108
112
|
case MYSQL_TYPE_DOUBLE:
|
|
109
113
|
return ft_float;
|
|
@@ -187,9 +191,10 @@ short schemaBuilder::insertMetaRecord(table* mtb, table* src, int id)
|
|
|
187
191
|
fd.setName(src->fieldName(i));
|
|
188
192
|
fd.len = src->fieldLen(i); // filed->pack_length();
|
|
189
193
|
fd.pos = pos;
|
|
190
|
-
fd.type = convFieldType(src->
|
|
194
|
+
fd.type = convFieldType(src->fieldRealType(i), src->fieldFlags(i),
|
|
191
195
|
isBinary(src->fieldCharset(i)),
|
|
192
196
|
isUnicode(src->fieldCharset(i)));
|
|
197
|
+
fd.setCharsetIndex(charsetIndex(src->fieldCharset(i).csname));
|
|
193
198
|
pos += fd.len;
|
|
194
199
|
datalen =
|
|
195
200
|
copyToRecordImage(rec.get(), &fd, sizeof(fielddef), datalen);
|
|
@@ -281,6 +286,8 @@ short schemaBuilder::execute(database* db, table* mtb)
|
|
|
281
286
|
filename_to_tablename(it->path().stem().string().c_str(), path,
|
|
282
287
|
FN_REFLEN);
|
|
283
288
|
table* tb = db->openTable(path, TD_OPEN_READONLY, NULL);
|
|
289
|
+
if (!tb)
|
|
290
|
+
return db->stat();
|
|
284
291
|
if (!tb->isView())
|
|
285
292
|
{
|
|
286
293
|
if ((stat = insertMetaRecord(mtb, tb, ++id)) != 0)
|
|
@@ -43,6 +43,9 @@ class request : public bzs::db::protocol::tdap::request
|
|
|
43
43
|
{
|
|
44
44
|
public:
|
|
45
45
|
ushort_td cid;
|
|
46
|
+
#ifdef DEBUG_LOG_ERR
|
|
47
|
+
const char* m_readBuffer;
|
|
48
|
+
#endif
|
|
46
49
|
void clear()
|
|
47
50
|
{
|
|
48
51
|
bzs::db::protocol::tdap::request::clear();
|
|
@@ -131,6 +134,9 @@ public:
|
|
|
131
134
|
inline void parse(const char* p)
|
|
132
135
|
{
|
|
133
136
|
clear();
|
|
137
|
+
#ifdef DEBUG_LOG_ERR
|
|
138
|
+
m_readBuffer = p;
|
|
139
|
+
#endif
|
|
134
140
|
p += sizeof(unsigned int);
|
|
135
141
|
paramMask = *((ushort_td*)p);
|
|
136
142
|
p += sizeof(ushort_td);
|