transactd 2.4.5 → 3.0.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.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/CMakeLists.txt +1 -1
  3. data/README-JA.md +52 -529
  4. data/README.md +52 -523
  5. data/bin/common/tdclc_32_3_0.dll +0 -0
  6. data/bin/common/tdclc_64_3_0.dll +0 -0
  7. data/build/common/system.cmake +2 -1
  8. data/build/common/transactd_cl_common.cmake +3 -6
  9. data/build/swig/ruby/ruby.swg +85 -28
  10. data/build/swig/ruby/tdclrb_wrap.cpp +3195 -1578
  11. data/build/swig/tdcl.i +161 -5
  12. data/build/tdclc/CMakeLists.txt +1 -0
  13. data/build/tdclc/tdclc.cbproj +7 -1
  14. data/build/tdclc/tdclc.rc +4 -4
  15. data/build/tdclcpp/tdclcpp.rc +4 -4
  16. data/build/tdclcpp/tdclcpp_bc.cbproj +2 -5
  17. data/build/tdclrb/tdclrb.rc +4 -4
  18. data/source/bzs/db/blobStructs.h +1 -1
  19. data/source/bzs/db/engine/mysql/database.cpp +199 -74
  20. data/source/bzs/db/engine/mysql/database.h +47 -18
  21. data/source/bzs/db/engine/mysql/dbManager.cpp +1 -0
  22. data/source/bzs/db/engine/mysql/mysqlInternal.h +32 -8
  23. data/source/bzs/db/protocol/tdap/btrDate.cpp +110 -75
  24. data/source/bzs/db/protocol/tdap/btrDate.h +46 -21
  25. data/source/bzs/db/protocol/tdap/client/activeTable.cpp +18 -18
  26. data/source/bzs/db/protocol/tdap/client/activeTable.h +25 -25
  27. data/source/bzs/db/protocol/tdap/client/activeTableImple.h +10 -4
  28. data/source/bzs/db/protocol/tdap/client/client.cpp +6 -5
  29. data/source/bzs/db/protocol/tdap/client/client.h +82 -15
  30. data/source/bzs/db/protocol/tdap/client/database.cpp +531 -142
  31. data/source/bzs/db/protocol/tdap/client/database.h +19 -6
  32. data/source/bzs/db/protocol/tdap/client/dbDef.cpp +461 -408
  33. data/source/bzs/db/protocol/tdap/client/dbDef.h +11 -17
  34. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +61 -13
  35. data/source/bzs/db/protocol/tdap/client/field.cpp +1592 -1398
  36. data/source/bzs/db/protocol/tdap/client/field.h +110 -121
  37. data/source/bzs/db/protocol/tdap/client/fields.h +40 -10
  38. data/source/bzs/db/protocol/tdap/client/filter.h +69 -55
  39. data/source/bzs/db/protocol/tdap/client/groupQuery.cpp +296 -164
  40. data/source/bzs/db/protocol/tdap/client/groupQuery.h +77 -25
  41. data/source/bzs/db/protocol/tdap/client/memRecord.cpp +31 -13
  42. data/source/bzs/db/protocol/tdap/client/memRecord.h +31 -21
  43. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +1 -1
  44. data/source/bzs/db/protocol/tdap/client/nsDatabase.h +4 -1
  45. data/source/bzs/db/protocol/tdap/client/nsTable.cpp +69 -24
  46. data/source/bzs/db/protocol/tdap/client/nsTable.h +3 -1
  47. data/source/bzs/db/protocol/tdap/client/recordset.cpp +1 -0
  48. data/source/bzs/db/protocol/tdap/client/recordsetImple.h +46 -27
  49. data/source/bzs/db/protocol/tdap/client/request.h +2 -1
  50. data/source/bzs/db/protocol/tdap/client/serializer.cpp +44 -9
  51. data/source/bzs/db/protocol/tdap/client/serializer.h +1 -1
  52. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +182 -76
  53. data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +23 -12
  54. data/source/bzs/db/protocol/tdap/client/stringConverter.h +8 -10
  55. data/source/bzs/db/protocol/tdap/client/table.cpp +172 -93
  56. data/source/bzs/db/protocol/tdap/client/table.h +112 -37
  57. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +17 -0
  58. data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +0 -1
  59. data/source/bzs/db/protocol/tdap/client/trdclcppautolink.h +0 -2
  60. data/source/bzs/db/protocol/tdap/client/trdormapi.h +1 -1
  61. data/source/bzs/db/protocol/tdap/fieldComp.h +698 -14
  62. data/source/bzs/db/protocol/tdap/myDateTime.cpp +723 -307
  63. data/source/bzs/db/protocol/tdap/myDateTime.h +294 -0
  64. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +164 -54
  65. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +6 -3
  66. data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +133 -550
  67. data/source/bzs/db/protocol/tdap/mysql/request.h +6 -5
  68. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +217 -82
  69. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +1 -1
  70. data/source/bzs/db/protocol/tdap/tdapRequest.h +4 -9
  71. data/source/bzs/db/protocol/tdap/tdapSchema.cpp +808 -17
  72. data/source/bzs/db/protocol/tdap/tdapSchema.h +656 -164
  73. data/source/bzs/db/protocol/tdap/tdapcapi.h +130 -28
  74. data/source/bzs/db/protocol/tdap/uri.h +40 -32
  75. data/source/bzs/db/transactd/connManager.cpp +1 -1
  76. data/source/bzs/db/transactd/transactd.cpp +7 -0
  77. data/source/bzs/env/compiler.h +107 -94
  78. data/source/bzs/env/crosscompile.cpp +24 -12
  79. data/source/bzs/env/crosscompile.h +75 -6
  80. data/source/bzs/env/mbcswchrLinux.cpp +2 -2
  81. data/source/bzs/env/tcharMinGW.h +4 -0
  82. data/source/bzs/example/changeSchema.cpp +22 -17
  83. data/source/bzs/example/queryData.cpp +4 -0
  84. data/source/bzs/netsvc/client/iconnection.h +3 -1
  85. data/source/bzs/netsvc/client/tcpClient.h +10 -3
  86. data/source/bzs/rtl/stringBuffers.cpp +7 -0
  87. data/source/bzs/test/tdclatl/bench_query_atl.js +6 -0
  88. data/source/bzs/test/tdclatl/bench_tdclatl.js +8 -1
  89. data/source/bzs/test/tdclatl/test_query_atl.js +22 -2
  90. data/source/bzs/test/tdclatl/test_v3.js +1017 -0
  91. data/source/bzs/test/tdclphp/transactd_Test.php +55 -21
  92. data/source/bzs/test/tdclphp/transactd_datetime_Test.php +0 -5
  93. data/source/bzs/test/tdclphp/transactd_pool_Test.php +2 -0
  94. data/source/bzs/test/tdclphp/transactd_v3_Test.php +743 -0
  95. data/source/bzs/test/tdclrb/transactd_datetime_spec.rb +0 -5
  96. data/source/bzs/test/tdclrb/transactd_pool_spec.rb +2 -0
  97. data/source/bzs/test/tdclrb/transactd_spec.rb +39 -16
  98. data/source/bzs/test/tdclrb/transactd_v3_spec.rb +748 -0
  99. data/source/bzs/test/transactdBench/transactdBench.cpp +55 -58
  100. data/source/bzs/test/transactdBench/transactdBench2.cpp +1 -3
  101. data/source/bzs/test/trdclengn/testField.h +3305 -0
  102. data/source/bzs/test/trdclengn/test_tdclcpp_v3.cpp +1050 -0
  103. data/source/bzs/test/trdclengn/test_trdclengn.cpp +112 -190
  104. data/source/bzs/test/trdclengn/testbase.h +137 -0
  105. data/source/global/ormsrcgen/srcgen.cpp +23 -12
  106. data/source/global/ormsrcgen/template/ormDataClass_template.h +2 -0
  107. data/source/global/querystmts/querystmts.cpp +2 -3
  108. data/source/global/tdclatl/Bitset.cpp +38 -0
  109. data/source/global/tdclatl/Bitset.h +63 -0
  110. data/source/global/tdclatl/Database.cpp +59 -18
  111. data/source/global/tdclatl/Database.h +7 -4
  112. data/source/global/tdclatl/DbDef.cpp +6 -6
  113. data/source/global/tdclatl/DbDef.h +2 -1
  114. data/source/global/tdclatl/Field.cpp +112 -0
  115. data/source/global/tdclatl/Field.h +19 -5
  116. data/source/global/tdclatl/FieldDef.cpp +137 -16
  117. data/source/global/tdclatl/FieldDef.h +18 -2
  118. data/source/global/tdclatl/FieldDefs.cpp +54 -1
  119. data/source/global/tdclatl/FieldDefs.h +3 -0
  120. data/source/global/tdclatl/GroupQuery.cpp +8 -8
  121. data/source/global/tdclatl/QueryBase.cpp +65 -0
  122. data/source/global/tdclatl/QueryBase.h +10 -0
  123. data/source/global/tdclatl/Record.cpp +33 -2
  124. data/source/global/tdclatl/Record.h +3 -1
  125. data/source/global/tdclatl/RecordsetQuery.cpp +42 -0
  126. data/source/global/tdclatl/RecordsetQuery.h +8 -0
  127. data/source/global/tdclatl/Table.cpp +127 -3
  128. data/source/global/tdclatl/Table.h +10 -1
  129. data/source/global/tdclatl/TableDef.cpp +41 -8
  130. data/source/global/tdclatl/TableDef.h +7 -2
  131. data/source/global/tdclatl/activeTable.cpp +40 -71
  132. data/source/global/tdclatl/resource.h +0 -0
  133. data/source/global/tdclatl/tdclatl.idl +222 -28
  134. data/source/linux/tchar.h +100 -96
  135. data/transactd.gemspec +2 -2
  136. metadata +13 -11
  137. data/BUILD_UNIX-JA.md +0 -161
  138. data/BUILD_WIN-JA.md +0 -326
  139. data/README_ORMSRCGEN-JA.md +0 -115
  140. data/README_ORMSRCGEN.md +0 -118
  141. data/RELEASE_NOTE-JA.md +0 -356
  142. data/RELEASE_NOTE.md +0 -360
  143. data/bin/common/tdclc_32_2_4.dll +0 -0
  144. data/bin/common/tdclc_64_2_4.dll +0 -0
  145. data/source/bzs/test/trdclengn/test_blob.cpp +0 -375
@@ -25,7 +25,7 @@
25
25
  #include "bulkInsert.h"
26
26
  #include <bzs/db/protocol/tdap/tdapRequest.h>
27
27
  #include <bzs/rtl/strtrim.h>
28
- #include <bzs/db/protocol/tdap/myDateTime.cpp>
28
+ #include <bzs/db/protocol/tdap/myDateTime.h>
29
29
  #include <bzs/rtl/stringBuffers.h>
30
30
  #include "stringConverter.h"
31
31
  #include <boost/timer.hpp>
@@ -80,16 +80,19 @@ struct tbimpl
80
80
 
81
81
  struct
82
82
  {
83
- unsigned char exBookMarking : 1;
83
+ unsigned char exBookMarking : 1;
84
84
  unsigned char smartUpDateFlag : 1;
85
- unsigned char dataPacked : 1;
85
+ unsigned char dataPacked : 1;
86
+ unsigned char useIncrimented : 1;
87
+ unsigned char getSchemaOpen : 1;
86
88
  };
87
89
 
88
90
  tbimpl(table& tb)
89
91
  : bookMarks(NULL), fields(tb), rc(NULL), mraPtr(NULL),
90
92
  dataBak(NULL), smartUpDate(NULL), bfAtcPtr(NULL), optionalData(NULL),
91
93
  dataBufferLen(0), bookMarksMemSize(0), maxBookMarkedCount(0),
92
- onRecordCountFunc(NULL), smartUpDateFlag(false), dataPacked(false)
94
+ onRecordCountFunc(NULL), smartUpDateFlag(false), dataPacked(false), useIncrimented(false),
95
+ getSchemaOpen(false)
93
96
  {
94
97
  memset(&keyNumIndex[0], 0, 128);
95
98
  }
@@ -119,15 +122,6 @@ struct tbimpl
119
122
  return NULL;
120
123
  }
121
124
 
122
- /*inline bookmark_td* bookmarksPtr(unsigned int index)
123
- {
124
- boost::mutex::scoped_lock lck(bookmarkMutex);
125
- unsigned int pos = index * 6 + 2;
126
- if ((index < maxBookMarkedCount) && bookMarks)
127
- return (bookmark_td*)((char*)bookMarks + pos);
128
- return NULL;
129
- }*/
130
-
131
125
  inline short insertBookmarks(unsigned int start, void* data, ushort_td len,
132
126
  ushort_td count)
133
127
  {
@@ -295,34 +289,43 @@ public:
295
289
  if (!mra) return;
296
290
  if (m_rowCount)
297
291
  {
298
-
299
292
  unsigned char* bd = NULL; //blob data
300
- if (m_filter->hasManyJoin())
293
+ if (m_filter->hasManyJoin() &&
294
+ ((mra->joinType() & mra_innerjoin) || mra->joinType() & mra_outerjoin))
301
295
  hasManyJoinMra(m_rowCount, data);
302
296
  size_t recordLen = m_filter->fieldSelected()
303
297
  ? m_filter->totalFieldLen()
304
- : m_tb->tableDef()->maxRecordLen;
298
+ : m_tb->tableDef()->recordlen();
305
299
  mra->init(m_rowCount, recordLen, m_memblockType, m_tb);
306
300
  if (hd)
307
- bd = mra->allocBlobBlock(hd->dataSize);
301
+ bd = mra->allocBlobBlock(hd->dataSize);
308
302
 
309
303
  // copy each row data
310
304
  int bookmarkSize = m_filter->bookmarkSize();
311
305
  const tabledef* td = m_tb->tableDef();
312
306
  ushort_td fieldCount = m_filter->fieldCount();
313
307
  m_tmpPtr = mra->ptr(m_row, mra_current_block);
314
-
308
+ int selNullbytes = m_filter->selectedNullbytes();
315
309
  while (m_row < m_rowCount)
316
310
  {
317
311
  if ((m_len == 0) && m_filter->isSeeksMode() && fieldCount)
318
- mra->setInvalidRecord(m_row, true);
312
+ mra->setInvalidMemblock(m_row, true);
319
313
  else
320
314
  {
321
315
  if (m_filter->fieldSelected())
322
316
  {
323
- uchar_td* fieldPtr = m_ptr;
324
317
  int resultOffset = 0;
325
318
  int blobFieldNum = 0;
319
+ uchar_td* fieldPtr = m_ptr;
320
+
321
+ //Copy null bytes
322
+ if (selNullbytes)
323
+ {
324
+ memcpy(m_tmpPtr, fieldPtr, selNullbytes);
325
+ fieldPtr += selNullbytes;
326
+ resultOffset += selNullbytes;
327
+ }
328
+
326
329
  for (int i = 0; i < fieldCount; i++)
327
330
  {
328
331
  const fielddef& fd =
@@ -341,7 +344,7 @@ public:
341
344
  {
342
345
  if (m_tb->valiableFormatType())
343
346
  {
344
- memset(m_tmpPtr, 0, td->maxRecordLen);
347
+ memset(m_tmpPtr, 0, td->recordlen());
345
348
  memcpy(m_tmpPtr, m_ptr, m_len);
346
349
  m_unpackLen = td->unPack((char*)m_tmpPtr, m_len);
347
350
  }
@@ -399,7 +402,7 @@ public:
399
402
  {
400
403
 
401
404
  m_seekMultiStat = STATUS_NOT_FOUND_TI;
402
- memset(m_tmpPtr, 0, td->maxRecordLen);
405
+ memset(m_tmpPtr, 0, td->recordlen());
403
406
  return m_tmpPtr;
404
407
  }
405
408
  else
@@ -407,20 +410,34 @@ public:
407
410
  m_seekMultiStat = 0;
408
411
  if (m_filter->fieldSelected())
409
412
  {
410
- int resultOffset = 0;
411
- uchar_td* fieldPtr = m_ptr;
412
- memset(m_tmpPtr, 0, td->maxRecordLen);
413
+ int selNullbytes = m_filter->selectedNullbytes();
414
+ uchar_td* fieldPtr = m_ptr + selNullbytes;
415
+ memset(m_tmpPtr, 0, td->recordlen());
416
+ int nullfields = 0;
413
417
  for (int i = 0; i < fieldCount; i++)
414
418
  {
415
419
  const fielddef& fd =
416
420
  td->fieldDefs[m_filter->selectFieldIndexes()[i]];
417
- resultOffset = fd.pos;
418
- fieldPtr += fd.unPackCopy(m_tmpPtr + resultOffset, fieldPtr);
421
+ fieldPtr += fd.unPackCopy(m_tmpPtr + fd.pos + td->nullbytes(), fieldPtr);
422
+
423
+ //Copy null results
424
+ if (selNullbytes && fd.isNullable() && fd.nullbytes())
425
+ {
426
+ uchar_td* p = m_ptr + (nullfields + 7) / 8;
427
+ bool nullResult = (*p & (1L << (nullfields % 8))) != 0;
428
+ p = m_tmpPtr + (fd.nullbit() / 8);
429
+ int bit = fd.nullbit() % 8 ;
430
+ if (nullResult)
431
+ (*p) |= (unsigned char)(1L << bit);
432
+ else
433
+ (*p) &= (unsigned char)~(1L << bit);
434
+ ++nullfields;
435
+ }
419
436
  }
420
437
  }
421
438
  else if (m_tb->valiableFormatType())
422
439
  {
423
- memset(m_tmpPtr, 0, td->maxRecordLen);
440
+ memset(m_tmpPtr, 0, td->recordlen());
424
441
  memcpy(m_tmpPtr, m_ptr, m_len);
425
442
  m_unpackLen = td->unPack((char*)m_tmpPtr, m_len);
426
443
  }
@@ -481,6 +498,11 @@ table::table(nsdatabase* pbe) : nstable(pbe)
481
498
 
482
499
  table::~table()
483
500
  {
501
+ if (m_impl->useIncrimented)
502
+ {
503
+ if (((database*)nsdb())->dbDef())
504
+ --((*m_tableDef)->m_inUse);
505
+ }
484
506
  delete m_impl->rc;
485
507
  m_fddefs->release();
486
508
  delete m_impl;
@@ -494,7 +516,7 @@ void* __STDCALL table::DDBA(client::table* tb, uint_td size)
494
516
  void* table::doDdba(uint_td size)
495
517
  {
496
518
  if (m_impl->filterPtr)
497
- size += tableDef()->maxRecordLen;;
519
+ size += tableDef()->recordlen();
498
520
  return reallocDataBuffer(size);
499
521
  }
500
522
 
@@ -765,7 +787,7 @@ void table::btrvGetExtend(ushort_td op)
765
787
  if (m_impl->rc->rowCount() && (!m_impl->exBookMarking))
766
788
  {
767
789
  m_pdata = (void*)m_impl->rc->setRow(0);
768
- m_datalen = tableDef()->maxRecordLen;
790
+ m_datalen = tableDef()->recordlen();
769
791
 
770
792
  m_stat = m_impl->rc->seekMultiStat();
771
793
  }else if (!filter->isStatContinue())
@@ -862,7 +884,7 @@ bool table::doSeekMultiAfter(int row)
862
884
  else if (!checkStatus(m_stat))
863
885
  return false;
864
886
  if (m_stat)
865
- m_impl->mraPtr->setInvalidRecord(row, true);
887
+ m_impl->mraPtr->setInvalidMemblock(row, true);
866
888
  else
867
889
  {
868
890
  uchar_td* dst = m_impl->mraPtr->ptr(row, mra_current_block);
@@ -893,7 +915,7 @@ void table::btrvSeekMulti()
893
915
  m_impl->rc->reset();
894
916
  size_t recordLen = m_impl->filterPtr->fieldSelected()
895
917
  ? m_impl->filterPtr->totalSelectFieldLen()
896
- : tableDef()->maxRecordLen;
918
+ : tableDef()->recordlen();
897
919
  if (!hasManyJoin)
898
920
  m_impl->mraPtr->init(seeks.size(), recordLen, mra_first, this);
899
921
 
@@ -932,7 +954,7 @@ void table::btrvSeekMulti()
932
954
  }
933
955
  }
934
956
  else
935
- m_impl->mraPtr->setInvalidRecord(0, true);
957
+ m_impl->mraPtr->setInvalidMemblock(0, true);
936
958
  }
937
959
  else
938
960
  {
@@ -984,7 +1006,7 @@ void table::doFind(ushort_td op, bool notIncCurrent)
984
1006
  setSeekValueField(row);
985
1007
 
986
1008
  // m_datalen = m_impl->rc->len();
987
- m_datalen = tableDef()->maxRecordLen;
1009
+ m_datalen = tableDef()->recordlen();
988
1010
  }
989
1011
  else if (m_impl->rc->isEndOfRow(row))
990
1012
  {
@@ -1218,11 +1240,19 @@ void table::setFilter(const _TCHAR* str, ushort_td RejectCount,
1218
1240
  }
1219
1241
  }
1220
1242
 
1221
- void table::clearBuffer()
1243
+ void table::clearBuffer(eNullReset resetType)
1222
1244
  {
1223
1245
  m_impl->rc->reset();
1224
1246
  m_pdata = m_impl->dataBak;
1225
- memset(m_pdata, 0x00, m_buflen);
1247
+ tabledef* td = (*m_tableDef);
1248
+ if (td->isMysqlNullMode() && td->defaultImage)
1249
+ {
1250
+ memcpy(m_pdata, td->defaultImage, m_buflen);
1251
+ if (resetType == clearNull)
1252
+ memset(m_pdata, 0x00, td->nullbytes());
1253
+ }
1254
+ else
1255
+ memset(m_pdata, 0x00, m_buflen);
1226
1256
  if ((bulkIns() == NULL) && blobFieldUsed())
1227
1257
  resetSendBlob();
1228
1258
  }
@@ -1266,7 +1296,7 @@ void table::doCreateIndex(bool SpecifyKeyNum)
1266
1296
  {
1267
1297
  uint_td len = m_datalen;
1268
1298
  m_pdata = (*m_tableDef);
1269
- m_datalen = (*m_tableDef)->varSize + 4;
1299
+ m_datalen = (*m_tableDef)->size();
1270
1300
  // tdclc check datalen, m_pdata is tabledef if bigger than sizeof(keySpec) * 8
1271
1301
  if (m_datalen <= sizeof(keySpec) * 8)
1272
1302
  m_datalen = sizeof(keySpec) * 8 + 10;
@@ -1291,10 +1321,10 @@ void table::doCreateIndex(bool SpecifyKeyNum)
1291
1321
  void table::smartUpdate()
1292
1322
  {
1293
1323
  if (!m_impl->smartUpDate)
1294
- m_impl->smartUpDate = malloc((*m_tableDef)->maxRecordLen);
1324
+ m_impl->smartUpDate = malloc((*m_tableDef)->recordlen());
1295
1325
  if (m_impl->smartUpDate)
1296
1326
  {
1297
- memcpy(m_impl->smartUpDate, data(), (*m_tableDef)->maxRecordLen);
1327
+ memcpy(m_impl->smartUpDate, data(), (*m_tableDef)->recordlen());
1298
1328
  m_impl->smartUpDateFlag = true;
1299
1329
  }
1300
1330
  else
@@ -1338,7 +1368,7 @@ bool table::onUpdateCheck(eUpdateType type)
1338
1368
  else if (m_impl->smartUpDateFlag)
1339
1369
  {
1340
1370
  m_stat = 0;
1341
- if (memcmp(m_impl->smartUpDate, data(), (*m_tableDef)->maxRecordLen) == 0)
1371
+ if (memcmp(m_impl->smartUpDate, data(), (*m_tableDef)->recordlen()) == 0)
1342
1372
  {
1343
1373
  m_impl->smartUpDateFlag = false;
1344
1374
  return false;
@@ -1401,7 +1431,7 @@ void* table::attachBuffer(void* NewPtr, bool unpack, size_t size)
1401
1431
  m_impl->bfAtcPtr = m_pdata;
1402
1432
  oldptr = m_pdata;
1403
1433
  m_pdata = NewPtr;
1404
- ushort_td len = (*m_tableDef)->maxRecordLen;
1434
+ ushort_td len = (*m_tableDef)->recordlen();
1405
1435
  if (unpack)
1406
1436
  len = (*m_tableDef)->unPack((char*)m_pdata, size);
1407
1437
  m_datalen = len;
@@ -1415,18 +1445,32 @@ void table::dettachBuffer()
1415
1445
  m_impl->bfAtcPtr = NULL;
1416
1446
  }
1417
1447
 
1418
- void table::init(tabledef** Def, short fnum, bool regularDir)
1448
+ inline void table::incTabledefRefCount(tabledef* td, bool mysqlMullmode)
1419
1449
  {
1420
- doInit(Def, fnum, regularDir);
1450
+ if (m_impl->useIncrimented == false)
1451
+ {
1452
+ td->m_mysqlNullMode = mysqlMullmode;
1453
+ if (td->m_inUse == 0)
1454
+ td->calcReclordlen();
1455
+ ++td->m_inUse;
1456
+ m_impl->useIncrimented = true;
1457
+ }
1421
1458
  }
1422
1459
 
1423
- void table::doInit(tabledef** Def, short fnum, bool /*regularDir*/)
1460
+ void table::init(tabledef** Def, short fnum, bool regularDir, bool mysqlnull)
1461
+ {
1462
+ doInit(Def, fnum, regularDir, mysqlnull);
1463
+ }
1464
+
1465
+ void table::doInit(tabledef** Def, short fnum, bool /*regularDir*/, bool mysqlnull)
1424
1466
  {
1425
1467
  m_tableDef = Def;
1426
1468
  tabledef* td = *m_tableDef;
1469
+
1470
+ incTabledefRefCount(td, mysqlnull);
1427
1471
  m_fddefs->addAllFileds(td);
1428
1472
  m_fddefs->cv()->setCodePage(mysql::codePage(td->charsetIndex));
1429
- ushort_td len = td->maxRecordLen;
1473
+ ushort_td len = td->recordlen();
1430
1474
  if (len == 0)
1431
1475
  {
1432
1476
  m_stat = STATUS_INVALID_RECLEN;
@@ -1455,13 +1499,16 @@ keylen_td table::writeKeyDataTo(uchar_td* to, int keySize)
1455
1499
  uchar_td* start = to;
1456
1500
  if (keySize == 0)
1457
1501
  keySize = keydef.segmentCount;
1458
-
1502
+ bool transactd = isUseTransactd();
1459
1503
  for (int j = 0; j < keySize; j++)
1460
1504
  {
1461
1505
  int fdnum = keydef.segments[j].fieldNum;
1506
+ FLAGS f = keydef.segments[j].flags;
1507
+ bool isNull = getFVNull(fdnum);
1508
+ if ((f.bit9 | f.bit3) && (transactd == true))
1509
+ isNull = false;
1462
1510
  fielddef& fd = (*m_tableDef)->fieldDefs[fdnum];
1463
- uchar_td* from = (uchar_td*)m_pdata + fd.pos;
1464
- to = fd.keyCopy(to, from);
1511
+ to = fd.keyCopy(to, (uchar_td*)fieldPtr(fdnum), 0xff, isNull);
1465
1512
  }
1466
1513
  return (keylen_td)(to - start);
1467
1514
  }
@@ -1473,7 +1520,6 @@ keylen_td table::writeKeyData()
1473
1520
  return writeKeyDataTo((uchar_td*)m_impl->keybuf, 0);
1474
1521
  }
1475
1522
 
1476
-
1477
1523
  uint_td table::unPack(char* ptr, size_t size)
1478
1524
  {
1479
1525
  m_impl->dataPacked = false;
@@ -1491,7 +1537,7 @@ uint_td table::doGetWriteImageLen()
1491
1537
  tabledef* td = (*m_tableDef);
1492
1538
  if (!blobFieldUsed() && !valiableFormatType() &&
1493
1539
  (td->flags.bit0 == false))
1494
- return td->maxRecordLen;
1540
+ return td->recordlen();
1495
1541
  // Make blob pointer list
1496
1542
  if (blobFieldUsed())
1497
1543
  {
@@ -1512,7 +1558,7 @@ uint_td table::doGetWriteImageLen()
1512
1558
  addSendBlob(NULL);
1513
1559
 
1514
1560
  if (valiableFormatType())
1515
- return pack((char*)m_pdata, td->maxRecordLen);
1561
+ return pack((char*)m_pdata, td->recordlen());
1516
1562
  else
1517
1563
  {
1518
1564
  fielddef* fd = &td->fieldDefs[td->fieldCount - 1];
@@ -1633,11 +1679,11 @@ void table::onReadAfter()
1633
1679
  const blobHeader* hd = getBlobHeader();
1634
1680
  setBlobFieldPointer((char*)m_pdata, hd);
1635
1681
  }
1636
- if ((*m_tableDef)->maxRecordLen - m_datalen > 0)
1637
- memset((char*)m_pdata + m_datalen, 0, (*m_tableDef)->maxRecordLen - m_datalen);
1682
+ if ((*m_tableDef)->recordlen() - m_datalen > 0)
1683
+ memset((char*)m_pdata + m_datalen, 0, (*m_tableDef)->recordlen() - m_datalen);
1638
1684
  }
1639
1685
 
1640
- short table::fieldNumByName(const _TCHAR* name)
1686
+ short table::fieldNumByName(const _TCHAR* name) const
1641
1687
  {
1642
1688
  return m_fddefs->indexByName(name);
1643
1689
  }
@@ -1646,14 +1692,14 @@ void* table::fieldPtr(short index) const
1646
1692
  {
1647
1693
  if (!checkIndex(index))
1648
1694
  return NULL;
1649
- return m_impl->fields[index].ptr();
1695
+ return m_impl->fields.getFieldNoCheck(index).ptr();
1650
1696
  }
1651
1697
 
1652
1698
  void table::setFVA(short index, const char* data)
1653
1699
  {
1654
1700
  if (!checkIndex(index))
1655
1701
  return;
1656
- m_impl->fields[index].setFVA(data);
1702
+ m_impl->fields.getFieldNoCheck(index).setFVA(data);
1657
1703
  }
1658
1704
 
1659
1705
  #ifdef _WIN32
@@ -1662,7 +1708,7 @@ void table::setFVW(short index, const wchar_t* data)
1662
1708
  {
1663
1709
  if (!checkIndex(index))
1664
1710
  return;
1665
- m_impl->fields[index].setFVW(data);
1711
+ m_impl->fields.getFieldNoCheck(index).setFVW(data);
1666
1712
  }
1667
1713
 
1668
1714
  void table::setFVW(const _TCHAR* FieldName, const wchar_t* data)
@@ -1670,7 +1716,7 @@ void table::setFVW(const _TCHAR* FieldName, const wchar_t* data)
1670
1716
  short index = fieldNumByName(FieldName);
1671
1717
  if (!checkIndex(index))
1672
1718
  return;
1673
- m_impl->fields[index].setFVW(data);
1719
+ m_impl->fields.getFieldNoCheck(index).setFVW(data);
1674
1720
  }
1675
1721
 
1676
1722
  #endif //_WIN32
@@ -1687,14 +1733,14 @@ void table::setFV(short index, int data)
1687
1733
  {
1688
1734
  if (!checkIndex(index))
1689
1735
  return;
1690
- m_impl->fields[index].setFV(data);
1736
+ m_impl->fields.getFieldNoCheck(index).setFV(data);
1691
1737
  }
1692
1738
 
1693
1739
  void table::setFV(short index, double data)
1694
1740
  {
1695
1741
  if (!checkIndex(index))
1696
1742
  return;
1697
- m_impl->fields[index].setFV(data);
1743
+ m_impl->fields.getFieldNoCheck(index).setFV(data);
1698
1744
  }
1699
1745
 
1700
1746
  void table::setFV(short index, short data)
@@ -1713,100 +1759,100 @@ void table::setFV(short index, float data)
1713
1759
  setFV(index, value);
1714
1760
  }
1715
1761
 
1716
- short table::getFVsht(short index)
1762
+ short table::getFVsht(short index) const
1717
1763
  {
1718
1764
  return (short)getFVlng(index);
1719
1765
  }
1720
1766
 
1721
- int table::getFVlng(short index)
1767
+ int table::getFVlng(short index) const
1722
1768
  {
1723
1769
  if (!checkIndex(index))
1724
1770
  return 0;
1725
- return m_impl->fields[index].getFVlng();
1771
+ return m_impl->fields.getFieldNoCheck(index).getFVlng();
1726
1772
  }
1727
1773
 
1728
- float table::getFVflt(short index)
1774
+ float table::getFVflt(short index) const
1729
1775
  {
1730
1776
  return (float)getFVdbl(index);
1731
1777
  }
1732
1778
 
1733
- double table::getFVdbl(short index)
1779
+ double table::getFVdbl(short index) const
1734
1780
  {
1735
1781
  if (!checkIndex(index))
1736
1782
  return 0;
1737
- return m_impl->fields[index].getFVdbl();
1783
+ return m_impl->fields.getFieldNoCheck(index).getFVdbl();
1738
1784
  }
1739
1785
 
1740
- unsigned char table::getFVbyt(short index)
1786
+ unsigned char table::getFVbyt(short index) const
1741
1787
  {
1742
1788
  return (unsigned char)getFVlng(index);
1743
1789
  }
1744
1790
 
1745
1791
  #ifdef _WIN32
1746
1792
 
1747
- const wchar_t* table::getFVWstr(short index)
1793
+ const wchar_t* table::getFVWstr(short index) const
1748
1794
  {
1749
1795
  if (!checkIndex(index))
1750
1796
  return NULL;
1751
- return m_impl->fields[index].getFVWstr();
1797
+ return m_impl->fields.getFieldNoCheck(index).getFVWstr();
1752
1798
  }
1753
1799
 
1754
- const wchar_t* table::getFVWstr(const _TCHAR* FieldName)
1800
+ const wchar_t* table::getFVWstr(const _TCHAR* FieldName) const
1755
1801
  {
1756
1802
  short index = fieldNumByName(FieldName);
1757
1803
  return getFVWstr(index);
1758
1804
  }
1759
1805
  #endif //_WIN32
1760
1806
 
1761
- const char* table::getFVAstr(short index)
1807
+ const char* table::getFVAstr(short index) const
1762
1808
  {
1763
1809
  if (index == -1)
1764
1810
  return NULL;
1765
- return m_impl->fields[index].getFVAstr();
1811
+ return m_impl->fields.getFieldNoCheck(index).getFVAstr();
1766
1812
  }
1767
1813
 
1768
- int table::getFVint(short index)
1814
+ int table::getFVint(short index) const
1769
1815
  {
1770
1816
  return (int)getFVlng(index);
1771
1817
  }
1772
1818
 
1773
- int table::getFVint(const _TCHAR* FieldName)
1819
+ int table::getFVint(const _TCHAR* FieldName) const
1774
1820
  {
1775
1821
  short index = fieldNumByName(FieldName);
1776
1822
  return (int)getFVlng(index);
1777
1823
  }
1778
1824
 
1779
- int table::getFVlng(const _TCHAR* FieldName)
1825
+ int table::getFVlng(const _TCHAR* FieldName) const
1780
1826
  {
1781
1827
  short index = fieldNumByName(FieldName);
1782
1828
  return getFVlng(index);
1783
1829
  }
1784
1830
 
1785
- const char* table::getFVAstr(const _TCHAR* FieldName)
1831
+ const char* table::getFVAstr(const _TCHAR* FieldName) const
1786
1832
  {
1787
1833
  short index = fieldNumByName(FieldName);
1788
1834
  return getFVAstr(index);
1789
1835
  }
1790
1836
 
1791
- double table::getFVdbl(const _TCHAR* FieldName)
1837
+ double table::getFVdbl(const _TCHAR* FieldName) const
1792
1838
  {
1793
1839
  short index = fieldNumByName(FieldName);
1794
1840
  return getFVdbl(index);
1795
1841
  }
1796
1842
 
1797
- unsigned char table::getFVbyt(const _TCHAR* FieldName)
1843
+ unsigned char table::getFVbyt(const _TCHAR* FieldName) const
1798
1844
  {
1799
1845
  short index = fieldNumByName(FieldName);
1800
1846
  return getFVbyt(index);
1801
1847
  }
1802
1848
 
1803
- short table::getFVsht(const _TCHAR* FieldName)
1849
+ short table::getFVsht(const _TCHAR* FieldName) const
1804
1850
  {
1805
1851
  short index = fieldNumByName(FieldName);
1806
1852
  return getFVsht(index);
1807
1853
  }
1808
1854
 
1809
- float table::getFVflt(const _TCHAR* FieldName)
1855
+ float table::getFVflt(const _TCHAR* FieldName) const
1810
1856
  {
1811
1857
  short index = fieldNumByName(FieldName);
1812
1858
  return getFVflt(index);
@@ -1848,7 +1894,7 @@ void table::setFV(const _TCHAR* FieldName, short data)
1848
1894
  setFV(index, data);
1849
1895
  }
1850
1896
 
1851
- __int64 table::getFV64(const _TCHAR* FieldName)
1897
+ __int64 table::getFV64(const _TCHAR* FieldName) const
1852
1898
  {
1853
1899
  short index = fieldNumByName(FieldName);
1854
1900
  return getFV64(index);
@@ -1860,18 +1906,18 @@ void table::setFV(const _TCHAR* FieldName, __int64 data)
1860
1906
  setFV(index, data);
1861
1907
  }
1862
1908
 
1863
- __int64 table::getFV64(short index)
1909
+ __int64 table::getFV64(short index) const
1864
1910
  {
1865
1911
  if (!checkIndex(index))
1866
1912
  return 0;
1867
- return m_impl->fields[index].getFV64();
1913
+ return m_impl->fields.getFieldNoCheck(index).getFV64();
1868
1914
  }
1869
1915
 
1870
1916
  void table::setFV(short index, __int64 data)
1871
1917
  {
1872
1918
  if (!checkIndex(index))
1873
1919
  return;
1874
- m_impl->fields[index].setFV(data);
1920
+ m_impl->fields.getFieldNoCheck(index).setFV(data);
1875
1921
  }
1876
1922
 
1877
1923
  void table::setFV(const _TCHAR* FieldName, const void* data, uint_td size)
@@ -1880,6 +1926,32 @@ void table::setFV(const _TCHAR* FieldName, const void* data, uint_td size)
1880
1926
  setFV(index, data, size);
1881
1927
  }
1882
1928
 
1929
+ bool table::getFVNull(short index) const
1930
+ {
1931
+ if (!checkIndex(index))
1932
+ return false;
1933
+ return m_impl->fields.getFieldNoCheck(index).isNull();
1934
+ }
1935
+
1936
+ bool table::getFVNull(const _TCHAR* FieldName) const
1937
+ {
1938
+ short index = fieldNumByName(FieldName);
1939
+ return getFVNull(index);
1940
+ }
1941
+
1942
+ void table::setFVNull(short index, bool v)
1943
+ {
1944
+ if (!checkIndex(index))
1945
+ return;
1946
+ m_impl->fields.getFieldNoCheck(index).setNull(v);
1947
+ }
1948
+
1949
+ void table::setFVNull(const _TCHAR* FieldName, bool v)
1950
+ {
1951
+ short index = fieldNumByName(FieldName);
1952
+ setFVNull(index, v);
1953
+ }
1954
+
1883
1955
  /* if blob and text ,set binary data that is only set pointer. it is not copied.
1884
1956
  * Caller must hold data until it sends to the server.
1885
1957
  */
@@ -1887,10 +1959,10 @@ void table::setFV(short index, const void* data, uint_td size)
1887
1959
  {
1888
1960
  if (!checkIndex(index))
1889
1961
  return;
1890
- m_impl->fields[index].setFV(data, size);
1962
+ m_impl->fields.getFieldNoCheck(index).setFV(data, size);
1891
1963
  }
1892
1964
 
1893
- void* table::getFVbin(const _TCHAR* FieldName, uint_td& size)
1965
+ void* table::getFVbin(const _TCHAR* FieldName, uint_td& size) const
1894
1966
  {
1895
1967
  short index = fieldNumByName(FieldName);
1896
1968
  return getFVbin(index, size);
@@ -1899,11 +1971,11 @@ void* table::getFVbin(const _TCHAR* FieldName, uint_td& size)
1899
1971
  /* offset is writen at data that is first address of data
1900
1972
  * text is not converted to unicode form stored charset.
1901
1973
  */
1902
- void* table::getFVbin(short index, uint_td& size)
1974
+ void* table::getFVbin(short index, uint_td& size) const
1903
1975
  {
1904
1976
  if (!checkIndex(index))
1905
1977
  return NULL;
1906
- return m_impl->fields[index].getFVbin(size);
1978
+ return m_impl->fields.getFieldNoCheck(index).getFVbin(size);
1907
1979
  }
1908
1980
 
1909
1981
  bool table::checkIndex(short index) const
@@ -1952,11 +2024,6 @@ bookmark_td table::bookmarks(unsigned int index) const
1952
2024
  return bm;
1953
2025
  }
1954
2026
 
1955
- /*bookmark_td* table::bookmarksPtr(unsigned int index) const
1956
- {
1957
- return m_impl->bookmarksPtr(index);
1958
- }*/
1959
-
1960
2027
  short_td table::doBtrvErr(HWND hWnd, _TCHAR* retbuf)
1961
2028
  {
1962
2029
  return nstable::tdapErr(hWnd, m_stat, (*m_tableDef)->tableName(), retbuf);
@@ -2566,6 +2633,12 @@ int makeSupplyValues(const _TCHAR* values[], int size,
2566
2633
  {
2567
2634
  if (size == 0) return 0;
2568
2635
  memset(values, sizeof(_TCHAR*), size);
2636
+ if (value == NULL)
2637
+ {
2638
+ THROW_BZS_ERROR_WITH_CODEMSG(STATUS_FILTERSTRING_ERROR,
2639
+ _T("Invalid the value, The value is NULL."));
2640
+ //return 0;
2641
+ }
2569
2642
  values[0] = value;
2570
2643
  if (size < 2 || !value1) return 1;
2571
2644
  values[1] = value1;
@@ -2597,6 +2670,12 @@ bool supplyValues(pq_handle& filter, const _TCHAR* values[], int size)
2597
2670
 
2598
2671
  bool supplyValue(pq_handle& filter, int index, const _TCHAR* v)
2599
2672
  {
2673
+ if (v == NULL)
2674
+ {
2675
+ THROW_BZS_ERROR_WITH_CODEMSG(STATUS_FILTERSTRING_ERROR,
2676
+ _T("Invalid the supplyValue, The supplyValue is NULL."));
2677
+ //return 0;
2678
+ }
2600
2679
  return filter->supplyValue(index, v);
2601
2680
  }
2602
2681