transactd 3.5.0 → 3.6.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_5.dll → tdclc_32_3_6.dll} +0 -0
- data/bin/common/tdclc_64_3_6.dll +0 -0
- data/build/swig/ruby/tdclrb_wrap.cpp +12524 -24430
- data/build/swig/tdcl.i +5 -0
- 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 +210 -184
- data/source/bzs/db/engine/mysql/database.h +276 -105
- data/source/bzs/db/engine/mysql/mysqlInternal.h +37 -0
- data/source/bzs/db/engine/mysql/mysqlProtocol.cpp +1 -0
- data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +4 -4
- data/source/bzs/db/protocol/tdap/client/activeTable.h +1 -1
- data/source/bzs/db/protocol/tdap/client/activeTableImple.h +1 -0
- data/source/bzs/db/protocol/tdap/client/connMgr.cpp +1 -1
- data/source/bzs/db/protocol/tdap/client/database.cpp +7 -4
- data/source/bzs/db/protocol/tdap/client/database.h +6 -1
- data/source/bzs/db/protocol/tdap/client/databaseManager.h +2 -2
- data/source/bzs/db/protocol/tdap/client/dbDef.cpp +21 -9
- data/source/bzs/db/protocol/tdap/client/dbDef.h +1 -1
- data/source/bzs/db/protocol/tdap/client/dllmain.cpp +10 -2
- data/source/bzs/db/protocol/tdap/client/field.cpp +29 -5
- data/source/bzs/db/protocol/tdap/client/field.h +3 -1
- data/source/bzs/db/protocol/tdap/client/fieldNameAlias.cpp +5 -0
- data/source/bzs/db/protocol/tdap/client/fieldNameAlias.h +1 -0
- data/source/bzs/db/protocol/tdap/client/fields.h +9 -2
- data/source/bzs/db/protocol/tdap/client/groupQuery.cpp +8 -4
- data/source/bzs/db/protocol/tdap/client/memRecord.cpp +18 -5
- data/source/bzs/db/protocol/tdap/client/memRecord.h +2 -2
- data/source/bzs/db/protocol/tdap/client/nsTable.cpp +46 -13
- data/source/bzs/db/protocol/tdap/client/nsTable.h +5 -0
- data/source/bzs/db/protocol/tdap/client/recordset.cpp +5 -0
- data/source/bzs/db/protocol/tdap/client/recordset.h +1 -0
- data/source/bzs/db/protocol/tdap/client/recordsetImple.h +6 -2
- data/source/bzs/db/protocol/tdap/client/request.h +46 -38
- data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +2 -3
- data/source/bzs/db/protocol/tdap/client/stringConverter.h +29 -13
- data/source/bzs/db/protocol/tdap/client/table.cpp +60 -10
- data/source/bzs/db/protocol/tdap/client/table.h +4 -1
- data/source/bzs/db/protocol/tdap/client/trdboostapi.h +18 -1
- data/source/bzs/db/protocol/tdap/client/trdormapi.h +10 -4
- data/source/bzs/db/protocol/tdap/fieldComp.h +1 -1
- data/source/bzs/db/protocol/tdap/mysql/characterset.h +1 -0
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +11 -4
- data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +2 -1
- data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +52 -94
- data/source/bzs/db/protocol/tdap/mysql/request.h +20 -13
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +92 -60
- data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +4 -4
- data/source/bzs/db/protocol/tdap/tdapRequest.h +11 -0
- data/source/bzs/db/protocol/tdap/tdapSchema.cpp +83 -34
- data/source/bzs/db/protocol/tdap/tdapSchema.h +5 -1
- data/source/bzs/db/protocol/tdap/tdapcapi.h +7 -3
- data/source/bzs/example/ormap_c.cpp +2 -2
- data/source/bzs/netsvc/server/serverPipe.cpp +35 -1
- data/source/bzs/test/tdclatl/test_v3.js +48 -1
- data/source/bzs/test/tdclphp/bench.php +89 -76
- data/source/bzs/test/tdclphp/transactd_Test.php +691 -687
- data/source/bzs/test/tdclphp/transactd_blob_Test.php +46 -43
- data/source/bzs/test/tdclphp/transactd_datetime_Test.php +46 -43
- data/source/bzs/test/tdclphp/transactd_kanjischema_Test.php +33 -33
- data/source/bzs/test/tdclphp/transactd_pool_Test.php +29 -25
- data/source/bzs/test/tdclphp/transactd_v3_Test.php +653 -183
- data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +40 -4
- data/source/bzs/test/tdclrb/transactd_fetch_spec.rb +785 -0
- data/source/bzs/test/tdclrb/transactd_pool_spec.rb +21 -1
- data/source/bzs/test/tdclrb/transactd_setget_spec.rb +450 -0
- data/source/bzs/test/tdclrb/transactd_spec.rb +14 -2
- data/source/bzs/test/tdclrb/transactd_v3_spec.rb +1192 -11
- data/source/bzs/test/trdclengn/testField.h +522 -1
- data/source/bzs/test/trdclengn/test_tdclcpp_v3.cpp +37 -1
- data/source/bzs/test/trdclengn/test_trdclengn.cpp +62 -4
- data/source/global/tdclatl/RecordsetQuery.cpp +2 -1
- data/source/global/tdclatl/RecordsetQuery.h +1 -1
- data/source/global/tdclatl/Table.cpp +17 -0
- data/source/global/tdclatl/Table.h +3 -1
- data/source/global/tdclatl/tdclatl.idl +7 -2
- data/transactd.gemspec +1 -1
- metadata +7 -5
- data/bin/common/tdclc_64_3_5.dll +0 -0
@@ -152,53 +152,61 @@ public:
|
|
152
152
|
}
|
153
153
|
if (P_MASK_PB_ERASE_BM & paramMask)
|
154
154
|
pbk->bookmarkLen = 0;
|
155
|
-
|
156
|
-
if (
|
157
|
-
{
|
158
|
-
uint_td tmp = *((uint_td*)p);
|
159
|
-
if (*datalen < tmp)
|
160
|
-
{
|
161
|
-
result = STATUS_BUFFERTOOSMALL;
|
162
|
-
return ;
|
163
|
-
}
|
164
|
-
else
|
165
|
-
*datalen = tmp;
|
166
|
-
p += sizeof(uint_td);
|
167
|
-
}
|
168
|
-
|
169
|
-
/*if (P_MASK_FINALDATALEN & paramMask)
|
170
|
-
{
|
171
|
-
memset(data, 0, *datalen);
|
172
|
-
if (*datalen < segmentDataLen)
|
173
|
-
result = STATUS_BUFFERTOOSMALL;
|
174
|
-
else
|
175
|
-
*datalen = segmentDataLen;
|
176
|
-
}*/
|
177
|
-
#ifdef USE_DATA_COMPRESS
|
178
|
-
if (P_MASK_USELZSS & paramMask)
|
155
|
+
|
156
|
+
if (P_MASK_DB_AINC_VAL & paramMask)
|
179
157
|
{
|
180
|
-
|
181
|
-
memcpy(
|
182
|
-
p += sizeof(unsigned int);
|
183
|
-
unsigned int decompSize = bzs::rtl::lzssDecode(p, data);
|
184
|
-
p += compSize;
|
158
|
+
autoIncPackInfo* ai = (autoIncPackInfo*)p;
|
159
|
+
memcpy(((char*)data) + ai->pos, &ai->value, ai->len);
|
185
160
|
}
|
186
161
|
else
|
187
|
-
#endif
|
188
|
-
if (P_MASK_DATA & paramMask)
|
189
162
|
{
|
190
|
-
if (
|
163
|
+
if (P_MASK_DATALEN & paramMask)
|
191
164
|
{
|
192
|
-
|
193
|
-
|
165
|
+
uint_td tmp = *((uint_td*)p);
|
166
|
+
if (*datalen < tmp)
|
167
|
+
{
|
168
|
+
result = STATUS_BUFFERTOOSMALL;
|
169
|
+
return ;
|
170
|
+
}
|
171
|
+
else
|
172
|
+
*datalen = tmp;
|
173
|
+
p += sizeof(uint_td);
|
194
174
|
}
|
195
|
-
|
196
|
-
p += *datalen;
|
175
|
+
|
197
176
|
/*if (P_MASK_FINALDATALEN & paramMask)
|
198
177
|
{
|
199
|
-
|
200
|
-
|
178
|
+
memset(data, 0, *datalen);
|
179
|
+
if (*datalen < segmentDataLen)
|
180
|
+
result = STATUS_BUFFERTOOSMALL;
|
181
|
+
else
|
182
|
+
*datalen = segmentDataLen;
|
201
183
|
}*/
|
184
|
+
#ifdef USE_DATA_COMPRESS
|
185
|
+
if (P_MASK_USELZSS & paramMask)
|
186
|
+
{
|
187
|
+
unsigned int compSize;
|
188
|
+
memcpy(&compSize, p, sizeof(unsigned int));
|
189
|
+
p += sizeof(unsigned int);
|
190
|
+
unsigned int decompSize = bzs::rtl::lzssDecode(p, data);
|
191
|
+
p += compSize;
|
192
|
+
}
|
193
|
+
else
|
194
|
+
#endif
|
195
|
+
if (P_MASK_DATA & paramMask)
|
196
|
+
{
|
197
|
+
if (ex)
|
198
|
+
{
|
199
|
+
if (pbk->allocFunc && pbk->tb)
|
200
|
+
data = pbk->allocFunc(pbk->tb, *datalen);
|
201
|
+
}
|
202
|
+
memcpy(data, p, *datalen);
|
203
|
+
p += *datalen;
|
204
|
+
/*if (P_MASK_FINALDATALEN & paramMask)
|
205
|
+
{
|
206
|
+
memcpy(data, &rows, 2);
|
207
|
+
p += sizeof(unsigned int);
|
208
|
+
}*/
|
209
|
+
}
|
202
210
|
}
|
203
211
|
if (P_MASK_KEYBUF & paramMask)
|
204
212
|
{
|
@@ -436,9 +436,8 @@ std::string& sqlBuilder::getKey(const tabledef* td, std::vector<std::string>& fd
|
|
436
436
|
_ltoa_s(key.keyNumber, buf, 20, 10);
|
437
437
|
else
|
438
438
|
_ltoa_s(index, buf, 20, 10);
|
439
|
-
if (
|
440
|
-
|
441
|
-
s += " PRIMARY KEY ";
|
439
|
+
if (td->primaryKeyNum == index)
|
440
|
+
s += " PRIMARY KEY";
|
442
441
|
else
|
443
442
|
{
|
444
443
|
if (key.segments[0].flags.bit0 == false)
|
@@ -211,6 +211,11 @@ class stringConverter
|
|
211
211
|
{
|
212
212
|
unsigned int m_codePage;
|
213
213
|
unsigned int m_exec_codePage;
|
214
|
+
|
215
|
+
inline bool isNotSameCodePage() const
|
216
|
+
{
|
217
|
+
return (m_codePage != m_exec_codePage);
|
218
|
+
}
|
214
219
|
|
215
220
|
public:
|
216
221
|
stringConverter(unsigned int src_codPage, unsigned int exec_codePage)
|
@@ -341,9 +346,17 @@ public:
|
|
341
346
|
return size;
|
342
347
|
}
|
343
348
|
|
344
|
-
|
349
|
+
template <typename store_type, typename T>
|
350
|
+
inline bool isNeedConvert()
|
345
351
|
{
|
346
|
-
|
352
|
+
/* unicode field is no binary*/
|
353
|
+
bool forceUnicodeFrom = (typeid(WCHAR) == typeid(store_type) && (typeid(T) == typeid(char)));
|
354
|
+
bool notBinaryData = m_codePage != 0;
|
355
|
+
bool notSameUnicodeType = (typeid(T) != typeid(store_type));
|
356
|
+
bool charButNotSameCodepage = (isNotSameCodePage() && (typeid(T) == typeid(char)));
|
357
|
+
return forceUnicodeFrom ||
|
358
|
+
(notBinaryData && (notSameUnicodeType || charButNotSameCodepage));
|
359
|
+
|
347
360
|
}
|
348
361
|
};
|
349
362
|
|
@@ -540,9 +553,7 @@ void store(char* ptr, const T* data, const fielddef& fd, stringConverter* cv)
|
|
540
553
|
strPtr[0] = 0x00;
|
541
554
|
else
|
542
555
|
{
|
543
|
-
|
544
|
-
if ((typeid(T) != typeid(store_type)) ||
|
545
|
-
(cv->isNeedConvert() && (typeid(T) == typeid(char))))
|
556
|
+
if (cv->isNeedConvert<store_type, T>())
|
546
557
|
len = cv->convert(strPtr, maxlen, data, len);
|
547
558
|
else
|
548
559
|
{
|
@@ -585,6 +596,8 @@ template <class T> T* trim(T* src, T* end, int padChar)
|
|
585
596
|
#pragma warn -8008
|
586
597
|
#pragma warn -8066
|
587
598
|
|
599
|
+
|
600
|
+
|
588
601
|
template <class _SF, typename store_type, typename T>
|
589
602
|
const T* read(char* ptr, ::bzs::rtl::stringBuffer* strBufs, const fielddef& fd,
|
590
603
|
stringConverter* cv, bool isTrimPadChar = false)
|
@@ -595,8 +608,7 @@ const T* read(char* ptr, ::bzs::rtl::stringBuffer* strBufs, const fielddef& fd,
|
|
595
608
|
T* result = (T*)(ptr + offset);
|
596
609
|
// convert
|
597
610
|
size_t len;
|
598
|
-
if (
|
599
|
-
(cv->isNeedConvert() && (typeid(T) == typeid(char))))
|
611
|
+
if (cv->isNeedConvert<store_type, T>())
|
600
612
|
{
|
601
613
|
len = dataLen(fd, (const uchar_td*)ptr) / sizeof(store_type);
|
602
614
|
size_t olen =
|
@@ -637,8 +649,7 @@ char* blobStore(char* ptr, const T* data, const fielddef& fd,
|
|
637
649
|
: UINT_MAX;
|
638
650
|
if (len != 0)
|
639
651
|
{
|
640
|
-
if (
|
641
|
-
(cv->isNeedConvert() && (typeid(T) == typeid(char))))
|
652
|
+
if (cv->isNeedConvert<char, T>())
|
642
653
|
{
|
643
654
|
maxlen = std::min<size_t>(maxlen, len * 2 * sizeof(T) + 1);
|
644
655
|
p = new char[maxlen];
|
@@ -655,7 +666,7 @@ char* blobStore(char* ptr, const T* data, const fielddef& fd,
|
|
655
666
|
memset(ptr, 0, fd.len);
|
656
667
|
memcpy(ptr, &len, offset);
|
657
668
|
if (p)
|
658
|
-
memcpy(ptr + offset, &
|
669
|
+
memcpy(ptr + offset, &p, sizeof(char*));
|
659
670
|
return p;
|
660
671
|
}
|
661
672
|
#pragma warn -8004
|
@@ -671,14 +682,19 @@ const T* readBlob(char* ptr, ::bzs::rtl::stringBuffer* strBufs,
|
|
671
682
|
char** pc = (char**)(ptr + offset);
|
672
683
|
size_t olen = len * 2 + 1;
|
673
684
|
result = strBufs->getPtr<T>(olen);
|
674
|
-
if (
|
675
|
-
|
685
|
+
if (cv->isNeedConvert<char, T>())
|
686
|
+
{
|
676
687
|
len = cv->revert(result, olen, *pc, len);
|
688
|
+
result[len] = 0x00;
|
689
|
+
}
|
677
690
|
else if (((T*)(*pc))[len] != 0x00)
|
691
|
+
{
|
678
692
|
memcpy(result, *pc, len);
|
693
|
+
result[len] = 0x00;
|
694
|
+
}
|
679
695
|
else
|
680
696
|
result = (T*)*pc;
|
681
|
-
|
697
|
+
|
682
698
|
|
683
699
|
}else
|
684
700
|
{
|
@@ -175,6 +175,7 @@ class recordCache
|
|
175
175
|
unsigned int m_len;
|
176
176
|
unsigned int m_unpackLen;
|
177
177
|
unsigned int m_rowCount;
|
178
|
+
unsigned int m_invalidRows;
|
178
179
|
uchar_td* m_bookmark;
|
179
180
|
uchar_td* m_ptr;
|
180
181
|
uchar_td* m_tmpPtr;
|
@@ -192,6 +193,7 @@ public:
|
|
192
193
|
{
|
193
194
|
m_filter = NULL;
|
194
195
|
m_row = 0;
|
196
|
+
m_invalidRows = 0;
|
195
197
|
m_rowCount = 0;
|
196
198
|
m_ptr = NULL;
|
197
199
|
m_len = 0;
|
@@ -218,7 +220,7 @@ public:
|
|
218
220
|
// blob pointer is allready point to next row
|
219
221
|
if (m_hd)
|
220
222
|
{
|
221
|
-
while (row - m_hd->curRow)
|
223
|
+
while (row - m_invalidRows - m_hd->curRow)
|
222
224
|
{
|
223
225
|
for (int j = 0; j < m_hd->fieldCount; ++j)
|
224
226
|
m_hd->nextField = (blobField*)m_hd->nextField->next();
|
@@ -400,14 +402,16 @@ public:
|
|
400
402
|
|
401
403
|
if ((m_len == 0) && m_filter->isSeeksMode() && fieldCount)
|
402
404
|
{
|
403
|
-
|
405
|
+
++m_invalidRows;
|
404
406
|
m_seekMultiStat = STATUS_NOT_FOUND_TI;
|
407
|
+
m_tb->fields().setInvalidMemblock(0);
|
405
408
|
memset(m_tmpPtr, 0, td->recordlen());
|
406
409
|
return m_tmpPtr;
|
407
410
|
}
|
408
411
|
else
|
409
412
|
{
|
410
413
|
m_seekMultiStat = 0;
|
414
|
+
m_tb->fields().setInvalidMemblock(-1);
|
411
415
|
if (m_filter->fieldSelected())
|
412
416
|
{
|
413
417
|
int selNullbytes = m_filter->selectedNullbytes();
|
@@ -930,7 +934,7 @@ void table::btrvSeekMulti()
|
|
930
934
|
int rowOffset = 0;
|
931
935
|
for (int i = 0; i < (int)seeks.size(); ++i)
|
932
936
|
{
|
933
|
-
|
937
|
+
memset(m_impl->keybuf, 0, MAX_KEYLEN);
|
934
938
|
seeks[i].writeBuffer((uchar_td*)m_impl->keybuf, true, transactd);
|
935
939
|
if (hasManyJoin)
|
936
940
|
{
|
@@ -1083,6 +1087,7 @@ void table::find(eFindType type)
|
|
1083
1087
|
{
|
1084
1088
|
type = m_impl->filterPtr->direction();
|
1085
1089
|
op =(type == findForword) ? TD_KEY_NEXT_MULTI : TD_KEY_PREV_MULTI;
|
1090
|
+
m_impl->filterPtr->resetReaded();
|
1086
1091
|
m_stat = 0;
|
1087
1092
|
}
|
1088
1093
|
else if (m_impl->filterPtr->isSeeksMode())
|
@@ -1294,6 +1299,7 @@ void table::setFilter(const _TCHAR* str, ushort_td RejectCount,
|
|
1294
1299
|
void table::clearBuffer(eNullReset resetType)
|
1295
1300
|
{
|
1296
1301
|
m_impl->rc->reset();
|
1302
|
+
m_impl->fields.setInvalidMemblock(-1);
|
1297
1303
|
m_pdata = m_impl->dataBak;
|
1298
1304
|
tabledef* td = (*m_tableDef);
|
1299
1305
|
if (td->isMysqlNullMode() && td->defaultImage)
|
@@ -1406,12 +1412,19 @@ bool table::onUpdateCheck(eUpdateType type)
|
|
1406
1412
|
{
|
1407
1413
|
if (isUseTransactd() == false)
|
1408
1414
|
{
|
1415
|
+
__int64 v = updateConflictCheck() ? getUpdateStampValue() : 0;
|
1409
1416
|
// backup update data
|
1410
1417
|
smartUpdate();
|
1411
1418
|
seek();
|
1412
1419
|
m_impl->smartUpDateFlag = false;
|
1413
1420
|
if (m_stat)
|
1414
1421
|
return false;
|
1422
|
+
|
1423
|
+
if (v && v != getUpdateStampValue())
|
1424
|
+
{
|
1425
|
+
m_stat = STATUS_CHANGE_CONFLICT;
|
1426
|
+
return false;
|
1427
|
+
}
|
1415
1428
|
memcpy(m_pdata, m_impl->smartUpDate, m_datalen);
|
1416
1429
|
}
|
1417
1430
|
}
|
@@ -1452,6 +1465,27 @@ bool table::onDeleteCheck(bool inkey)
|
|
1452
1465
|
return true;
|
1453
1466
|
}
|
1454
1467
|
|
1468
|
+
bool table::getUpdateStampEnable() const
|
1469
|
+
{
|
1470
|
+
return (tableDef()->m_utimeFieldNum != 0xffff);
|
1471
|
+
}
|
1472
|
+
|
1473
|
+
__int64 table::getUpdateStampValue() const
|
1474
|
+
{
|
1475
|
+
const tabledef* td = tableDef();
|
1476
|
+
if (td->m_utimeFieldNum != 0xffff)
|
1477
|
+
{
|
1478
|
+
void* p = fieldPtr(td->m_utimeFieldNum);
|
1479
|
+
__int64 v = 0;
|
1480
|
+
memcpy(&v, p, td->fieldDefs[td->m_utimeFieldNum].len);
|
1481
|
+
return v;
|
1482
|
+
}else
|
1483
|
+
m_stat = STATUS_INVARID_FIELD_IDX;
|
1484
|
+
/*else if(isUseTransactd() == false)
|
1485
|
+
return getRecordHash();*/
|
1486
|
+
return 0;
|
1487
|
+
}
|
1488
|
+
|
1455
1489
|
ushort_td table::doCommitBulkInsert(bool autoCommit)
|
1456
1490
|
{
|
1457
1491
|
ushort_td ret = nstable::doCommitBulkInsert(autoCommit);
|
@@ -1519,7 +1553,7 @@ void table::doInit(tabledef** Def, short fnum, bool /*regularDir*/, bool mysqlnu
|
|
1519
1553
|
tabledef* td = *m_tableDef;
|
1520
1554
|
|
1521
1555
|
incTabledefRefCount(td, mysqlnull);
|
1522
|
-
m_fddefs->
|
1556
|
+
m_fddefs->addAllFields(td);
|
1523
1557
|
m_fddefs->cv()->setCodePage(mysql::codePage(td->charsetIndex));
|
1524
1558
|
ushort_td len = td->recordlen();
|
1525
1559
|
if (len == 0)
|
@@ -2028,7 +2062,7 @@ bool table::checkIndex(short index) const
|
|
2028
2062
|
return true;
|
2029
2063
|
}
|
2030
2064
|
|
2031
|
-
unsigned int table::getRecordHash()
|
2065
|
+
unsigned int table::getRecordHash() const
|
2032
2066
|
{
|
2033
2067
|
return hash((const char*)fieldPtr(0), datalen());
|
2034
2068
|
}
|
@@ -2079,12 +2113,13 @@ bool table::setSeekValueField(int row)
|
|
2079
2113
|
// Check uniqe key
|
2080
2114
|
if (kd->segments[0].flags.bit0)
|
2081
2115
|
return false;
|
2082
|
-
|
2116
|
+
|
2083
2117
|
const uchar_td* ptr = (const uchar_td*)keyValues[row].data;
|
2084
2118
|
const uchar_td* data;
|
2085
2119
|
ushort_td dataSize;
|
2086
2120
|
if (ptr)
|
2087
2121
|
{
|
2122
|
+
fields().setInvalidMemblock(-1);
|
2088
2123
|
for (int j = 0; j < kd->segmentCount; ++j)
|
2089
2124
|
{
|
2090
2125
|
short filedNum = kd->segments[j].fieldNum;
|
@@ -2100,6 +2135,7 @@ bool table::setSeekValueField(int row)
|
|
2100
2135
|
else
|
2101
2136
|
setFV(filedNum, _T(""));
|
2102
2137
|
}
|
2138
|
+
fields().setInvalidMemblock(0);
|
2103
2139
|
}
|
2104
2140
|
else
|
2105
2141
|
return false;
|
@@ -2110,17 +2146,24 @@ void table::keyValueDescription(_TCHAR* buf, int bufsize)
|
|
2110
2146
|
{
|
2111
2147
|
|
2112
2148
|
std::_tstring s;
|
2113
|
-
|
2149
|
+
short st = stat() ;
|
2150
|
+
if (st == STATUS_NOT_FOUND_TI || st == 0)
|
2114
2151
|
{
|
2115
|
-
|
2152
|
+
bool invalid = fields().isInvalidRecord();
|
2153
|
+
fields().setInvalidMemblock(-1);
|
2116
2154
|
for (int i = 0; i < tableDef()->keyDefs[(int)keyNum()].segmentCount; i++)
|
2117
2155
|
{
|
2118
2156
|
short fnum = tableDef()->keyDefs[(int)keyNum()].segments[i].fieldNum;
|
2119
2157
|
s += std::_tstring(tableDef()->fieldDefs[fnum].name()) + _T(" = ") +
|
2120
2158
|
getFVstr(fnum) + _T("\n");
|
2121
2159
|
}
|
2160
|
+
if (invalid)
|
2161
|
+
{
|
2162
|
+
fields().setInvalidMemblock(0);
|
2163
|
+
st = STATUS_NOT_FOUND_TI;
|
2164
|
+
}
|
2122
2165
|
}
|
2123
|
-
else if (
|
2166
|
+
else if (st == STATUS_DUPPLICATE_KEYVALUE)
|
2124
2167
|
{
|
2125
2168
|
_TCHAR tmp[50];
|
2126
2169
|
for (int j = 0; j < tableDef()->keyCount; j++)
|
@@ -2137,7 +2180,7 @@ void table::keyValueDescription(_TCHAR* buf, int bufsize)
|
|
2137
2180
|
}
|
2138
2181
|
|
2139
2182
|
_stprintf_s(buf, bufsize, _T("table:%s\nstat:%d\n%s"),
|
2140
|
-
tableDef()->tableName(),
|
2183
|
+
tableDef()->tableName(), st, s.c_str());
|
2141
2184
|
}
|
2142
2185
|
|
2143
2186
|
short table::getCurProcFieldCount() const
|
@@ -2154,6 +2197,13 @@ short table::getCurProcFieldIndex(short index) const
|
|
2154
2197
|
return m_impl->filterPtr->selectFieldIndexes()[index];
|
2155
2198
|
}
|
2156
2199
|
|
2200
|
+
void table::setAlias(const _TCHAR* orign, const _TCHAR* alias)
|
2201
|
+
{
|
2202
|
+
short index = fieldNumByName(orign);
|
2203
|
+
if (index != -1)
|
2204
|
+
const_cast<fielddefs*>(fields().fieldDefs())->addAliasName(index, alias);
|
2205
|
+
}
|
2206
|
+
|
2157
2207
|
//-------------------------------------------------------------------
|
2158
2208
|
// class queryBase
|
2159
2209
|
//-------------------------------------------------------------------
|
@@ -128,6 +128,8 @@ class DLLLIB table : public nstable
|
|
128
128
|
void* doDdba(uint_td size);
|
129
129
|
bool isReadContinue(ushort_td& op);
|
130
130
|
void incTabledefRefCount(tabledef* td, bool mysqlMullmode);
|
131
|
+
__int64 getUpdateStampValue() const;// orverride
|
132
|
+
bool getUpdateStampEnable() const;// orverride
|
131
133
|
|
132
134
|
protected:
|
133
135
|
explicit table(nsdatabase* pbe); // Inheritance is impossible
|
@@ -199,7 +201,7 @@ public:
|
|
199
201
|
void moveBookmarks(unsigned int index);
|
200
202
|
bookmark_td bookmarks(unsigned int index) const;
|
201
203
|
void clearBuffer(eNullReset resetType = defaultNull);
|
202
|
-
unsigned int getRecordHash();
|
204
|
+
unsigned int getRecordHash() const;
|
203
205
|
void smartUpdate();
|
204
206
|
|
205
207
|
void setMra(multiRecordAlocator* p);
|
@@ -328,6 +330,7 @@ public:
|
|
328
330
|
void setOnRecordCount(const recordCountFn v);
|
329
331
|
recordCountFn onRecordCount() const;
|
330
332
|
client::fields& fields();
|
333
|
+
void setAlias(const _TCHAR* orign, const _TCHAR* alias);
|
331
334
|
};
|
332
335
|
|
333
336
|
#define KEYVALUE_PTR 0
|
@@ -81,10 +81,27 @@ public:
|
|
81
81
|
,const _TCHAR* userName=NULL, const _TCHAR* passwd=NULL)
|
82
82
|
: m_type(TYPE_SCHEMA_BDF), m_mode(TD_OPEN_READONLY)
|
83
83
|
{
|
84
|
+
if (!protocol || !hostOrIp || !dbname) return;
|
85
|
+
|
84
86
|
_TCHAR dbf[MAX_PATH]={0x00};
|
87
|
+
const _TCHAR* ext = _T(".bdf");
|
88
|
+
if (protocol[0] == 'b')
|
89
|
+
{ // btrv include file extension
|
90
|
+
if (_tcscmp(schemaTable, _T("file")) == 0 ||
|
91
|
+
_tcscmp(schemaTable, _T("FILE")) == 0)
|
92
|
+
{
|
93
|
+
ext = _T(".ddf");
|
94
|
+
m_type = TYPE_SCHEMA_DDF;
|
95
|
+
}
|
96
|
+
if (_tcsstr(schemaTable, _T(".ddf")) || _tcsstr(schemaTable, _T(".DDF")))
|
97
|
+
{
|
98
|
+
m_type = TYPE_SCHEMA_DDF;
|
99
|
+
ext = _T("");
|
100
|
+
}
|
101
|
+
}
|
85
102
|
if (schemaTable && schemaTable[0])
|
86
103
|
{
|
87
|
-
|
104
|
+
|
88
105
|
if (_tcscmp(schemaTable, TRANSACTD_SCHEMANAME)==0)
|
89
106
|
ext = _T("");
|
90
107
|
_stprintf_s(dbf, MAX_PATH, _T("dbfile=%s%s"), schemaTable, ext);
|
@@ -733,6 +733,7 @@ public:
|
|
733
733
|
|
734
734
|
#endif
|
735
735
|
|
736
|
+
/* one-to-one relation only */
|
736
737
|
template <class Container>
|
737
738
|
void readEach(Container& mdls, queryBase& q, bool sorted = false,
|
738
739
|
bzs::rtl::exception * e = NULL)
|
@@ -781,7 +782,8 @@ public:
|
|
781
782
|
(m_map.compKeyValue(mdlb, mdl, m_tb->keyNum()) == true)))
|
782
783
|
{
|
783
784
|
m_tb->findNext();
|
784
|
-
if (m_tb->stat() !=
|
785
|
+
if ((m_tb->stat() != STATUS_SUCCESS) &&
|
786
|
+
(m_tb->stat() != STATUS_NOT_FOUND_TI))
|
785
787
|
{
|
786
788
|
_TCHAR buf[8192];
|
787
789
|
m_tb->keyValueDescription(buf, 8192);
|
@@ -799,6 +801,7 @@ public:
|
|
799
801
|
}
|
800
802
|
}
|
801
803
|
|
804
|
+
/* one-to-one relation only */
|
802
805
|
template <class BaseContainer, class T2>
|
803
806
|
void readEach(BaseContainer& mdls, T* (T2::*func)() const, queryBase& q)
|
804
807
|
{
|
@@ -808,6 +811,7 @@ public:
|
|
808
811
|
readEach(*refList, q, true, NULL);
|
809
812
|
}
|
810
813
|
|
814
|
+
/* one-to-one relation only */
|
811
815
|
template <class BaseContainer, class T2>
|
812
816
|
void readEach(BaseContainer& mdls, T* (T2::*func)() const, queryBase& q,
|
813
817
|
bzs::rtl::exception& e)
|
@@ -818,7 +822,7 @@ public:
|
|
818
822
|
readEach(*refList, q, true, &e);
|
819
823
|
}
|
820
824
|
|
821
|
-
/* No use field select */
|
825
|
+
/* No use field select. one-to-one relation only */
|
822
826
|
template <class Container>
|
823
827
|
void readEach(Container& mdls, bool sorted = false,
|
824
828
|
bzs::rtl::exception * e = NULL)
|
@@ -838,7 +842,8 @@ public:
|
|
838
842
|
{
|
839
843
|
m_map.setKeyValues(mdl, fds, m_tb->keyNum());
|
840
844
|
readIndex(m_tb, eSeekEqual);
|
841
|
-
if (m_tb->stat() !=
|
845
|
+
if ((m_tb->stat() != STATUS_SUCCESS) &&
|
846
|
+
(m_tb->stat() != STATUS_NOT_FOUND_TI))
|
842
847
|
{
|
843
848
|
_TCHAR buf[8192];
|
844
849
|
m_tb->keyValueDescription(buf, 8192);
|
@@ -856,7 +861,7 @@ public:
|
|
856
861
|
}
|
857
862
|
}
|
858
863
|
|
859
|
-
/* No use field select */
|
864
|
+
/* No use field select. one-to-one relation only */
|
860
865
|
template <class BaseContainer, class T2>
|
861
866
|
void readEach(BaseContainer& mdls, T* (T2::*func)() const)
|
862
867
|
{
|
@@ -866,6 +871,7 @@ public:
|
|
866
871
|
readEach(*refList, true, NULL);
|
867
872
|
}
|
868
873
|
|
874
|
+
/* one-to-one relation only */
|
869
875
|
template <class BaseContainer, class T2>
|
870
876
|
void readEach(BaseContainer& mdls, T* (T2::*func)() const,
|
871
877
|
bzs::rtl::exception& e)
|
@@ -43,7 +43,7 @@ namespace tdap
|
|
43
43
|
namespace mysql
|
44
44
|
{
|
45
45
|
|
46
|
-
schemaBuilder::schemaBuilder(
|
46
|
+
schemaBuilder::schemaBuilder(unsigned char binFdCharset): m_stat(0), m_binFdCharset(binFdCharset)
|
47
47
|
{
|
48
48
|
}
|
49
49
|
|
@@ -175,7 +175,7 @@ tabledef* schemaBuilder::getTabledef(engine::mysql::table* src, int id,
|
|
175
175
|
td.keyCount = (uchar_td)src->keys();
|
176
176
|
td.charsetIndex = charsetIndex(src->charset().csname);
|
177
177
|
td.primaryKeyNum =
|
178
|
-
(src->primarykeyNum() < td.keyCount) ? kc.
|
178
|
+
(src->primarykeyNum() < td.keyCount) ? kc.keyNumByMakeOrder(src->primarykeyNum()) : -1;
|
179
179
|
#ifdef USE_BTRV_VARIABLE_LEN
|
180
180
|
td.flags.bit0 = (src->recordFormatType() & RF_FIXED_PLUS_VALIABLE_LEN);
|
181
181
|
if (src->recordFormatType() & RF_FIXED_PLUS_VALIABLE_LEN)
|
@@ -232,6 +232,9 @@ tabledef* schemaBuilder::getTabledef(engine::mysql::table* src, int id,
|
|
232
232
|
fd.setPadCharSettings(false, true);
|
233
233
|
if (f->has_charset())
|
234
234
|
fd.setCharsetIndex(charsetIndex(f->charset()->csname));
|
235
|
+
else if (fd.type == ft_string || fd.type == ft_lstring
|
236
|
+
|| fd.type == ft_myvarbinary || fd.type == ft_myblob)
|
237
|
+
fd.setCharsetIndex(m_binFdCharset);
|
235
238
|
|
236
239
|
if ((fd.type == ft_mydatetime || fd.type == ft_mytimestamp) && (f->val_real() == 0))
|
237
240
|
{// No constant value
|
@@ -342,7 +345,7 @@ short schemaBuilder::insertMetaRecord(table* mtb, table* src, int id, bool nouse
|
|
342
345
|
|
343
346
|
tabledef* td = getTabledef(src, id, nouseNullkey, rec.get(), 65000);
|
344
347
|
mtb->clearBuffer();
|
345
|
-
mtb->setRecordFromPacked(rec.get(), td->varSize + 4, NULL);
|
348
|
+
mtb->setRecordFromPacked(rec.get(), td->varSize + 4, NULL, NULL);
|
346
349
|
mtb->insert(true);
|
347
350
|
return mtb->stat();
|
348
351
|
}
|
@@ -393,12 +396,15 @@ table* getTable(database* db, const char *name)
|
|
393
396
|
void schemaBuilder::listTable(database* db, std::vector<std::string>& tables, int type)
|
394
397
|
{
|
395
398
|
char path[FN_REFLEN + 1];
|
399
|
+
tables.clear();
|
396
400
|
build_table_filename(path, sizeof(path) - 1, db->name().c_str(), "", "", 0);
|
397
401
|
std::string s = path;
|
398
402
|
fs::path p = s;
|
403
|
+
if (exists(p) == false) return;
|
404
|
+
|
399
405
|
fs::directory_iterator it(p);
|
400
406
|
fs::directory_iterator end;
|
401
|
-
|
407
|
+
|
402
408
|
|
403
409
|
for (fs::directory_iterator it(p); it != end; ++it)
|
404
410
|
{
|
@@ -456,6 +462,7 @@ short schemaBuilder::execute(database* db, table* mtb, bool nouseNullkey)
|
|
456
462
|
|
457
463
|
std::string s = path;
|
458
464
|
fs::path p = s;
|
465
|
+
if (exists(p) == false) return STATUS_TABLE_NOTOPEN;
|
459
466
|
fs::directory_iterator it(p);
|
460
467
|
fs::directory_iterator end;
|
461
468
|
int id = 0;
|
@@ -49,8 +49,9 @@ class schemaBuilder
|
|
49
49
|
short insertMetaRecord(engine::mysql::table* mtb, engine::mysql::table* src,
|
50
50
|
int id, bool nouseNullkey);
|
51
51
|
short m_stat;
|
52
|
+
unsigned char m_binFdCharset;
|
52
53
|
public:
|
53
|
-
schemaBuilder();
|
54
|
+
schemaBuilder(unsigned char binFdCharset);
|
54
55
|
~schemaBuilder();
|
55
56
|
short stat() const { return m_stat;}
|
56
57
|
tabledef* getTabledef(engine::mysql::table* src, int id, bool nouseNullkey, uchar* rec, size_t size);
|