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
@@ -38,7 +38,7 @@ protected:
38
38
  /** @cond INTERNAL */
39
39
  struct fieldNamesImple* m_impl;
40
40
  /** @endcond */
41
-
41
+ void doAddValue(const _TCHAR* v, bool isNull);
42
42
  public:
43
43
  fieldNames();
44
44
  fieldNames(const fieldNames& r);
@@ -63,6 +63,16 @@ public:
63
63
  void release();
64
64
  };
65
65
 
66
+ class DLLLIB fieldValues : public fieldNames
67
+ {
68
+ public:
69
+ fieldValues();
70
+ fieldValues(const fieldValues& r);
71
+ fieldValues& operator=(const fieldValues& r);
72
+ void addValue(const _TCHAR* v, bool isNull);
73
+ bool isNull(int index) const;
74
+ };
75
+
66
76
  struct sortField
67
77
  {
68
78
  std::_tstring name;
@@ -99,7 +109,6 @@ class DLLLIB recordsetQuery : protected query
99
109
 
100
110
  struct recordsetQueryImple* m_imple;
101
111
  void init(const fielddefs* fdinfo);
102
- bool isMatch(int ret, unsigned char compType) const;
103
112
  bool match(const row_ptr row) const;
104
113
 
105
114
  public:
@@ -139,6 +148,42 @@ public:
139
148
  return *this;
140
149
  }
141
150
 
151
+ inline recordsetQuery& whenIsNull(const _TCHAR* name)
152
+ {
153
+ query::whereIsNull(name);
154
+ return *this;
155
+ }
156
+
157
+ inline recordsetQuery& whenIsNotNull(const _TCHAR* name)
158
+ {
159
+ query::whereIsNotNull(name);
160
+ return *this;
161
+ }
162
+
163
+ inline recordsetQuery& andIsNull(const _TCHAR* name)
164
+ {
165
+ query::andIsNull(name);
166
+ return *this;
167
+ }
168
+
169
+ inline recordsetQuery& andIsNotNull(const _TCHAR* name)
170
+ {
171
+ query::andIsNotNull(name);
172
+ return *this;
173
+ }
174
+
175
+ inline recordsetQuery& orIsNull(const _TCHAR* name)
176
+ {
177
+ query::orIsNull(name);
178
+ return *this;
179
+ }
180
+
181
+ inline recordsetQuery& orIsNotNull(const _TCHAR* name)
182
+ {
183
+ query::orIsNotNull(name);
184
+ return *this;
185
+ }
186
+
142
187
  inline const _TCHAR* toString() const { return queryBase::toString(); }
143
188
 
144
189
  inline query* internalQuery() { return this; }
@@ -157,17 +202,19 @@ protected:
157
202
  class groupFuncBaseImple* m_imple;
158
203
 
159
204
  void init(const fielddefs* fdinfo);
160
- unsigned char* stringResult(int groupIndex) const;
205
+ unsigned char* stringResult(int index) const;
161
206
  uchar_td resultType() const;
162
207
  ushort_td resultLen() const;
163
208
  void operator()(const row_ptr& row, int index, bool insert);
164
209
 
165
210
  virtual void initResultVariable(int index);
166
- virtual void doCalc(const row_ptr& row, int groupIndex);
211
+ virtual void doCalcEachkey(const field& fd, int index);
212
+ virtual void doCalc(const row_ptr& row, int index);
167
213
  virtual void doReset();
168
214
  virtual void doInit(const fielddefs* fdinfo);
169
- virtual numeric_type numericResult(int groupIndex) const;
170
-
215
+ virtual numeric_type numericResult(int index) const;
216
+ bool insertFlag() const ;
217
+ void clearInsertFlag();
171
218
 
172
219
  public:
173
220
  groupFuncBase();
@@ -182,7 +229,10 @@ public:
182
229
  void setResultName(const _TCHAR* v);
183
230
  int resultKey() const;
184
231
  void reset();
232
+ bool isNull(int index) const;
233
+ uchar_td decimals() const;
185
234
  virtual groupFuncBase* clone() = 0;
235
+
186
236
  };
187
237
 
188
238
  class recordsetImple;
@@ -217,10 +267,10 @@ public:
217
267
  class DLLLIB sum : public groupFuncBase
218
268
  {
219
269
  protected:
220
- void doCalc(const row_ptr& row, int index);
270
+ virtual void doCalcEachkey(const field& fd, int index);
221
271
  groupFuncBase* clone();
222
272
  public:
223
- sum() {}
273
+ sum() : groupFuncBase() {}
224
274
  sum(const fieldNames& targetNames, const _TCHAR* resultName = NULL);
225
275
  static sum* create(const fieldNames& targetNames,
226
276
  const _TCHAR* resultName = NULL);
@@ -230,54 +280,56 @@ class DLLLIB count : public groupFuncBase
230
280
  {
231
281
  protected:
232
282
  groupFuncBase* clone();
283
+ void doCalcEachkey(const field& fd, int index);
233
284
  void doCalc(const row_ptr& row, int index);
234
-
285
+ void initResultVariable(int index);
235
286
  public:
236
- count() {}
287
+ count(): groupFuncBase(){}
237
288
  count(const _TCHAR* resultName);
289
+ count(const fieldNames& targetNames, const _TCHAR* resultName = NULL);
238
290
  static count* create(const _TCHAR* resultName);
291
+ static count* create(const fieldNames& targetNames,
292
+ const _TCHAR* resultName = NULL);
239
293
  };
240
294
 
241
- class DLLLIB avg : public sum
295
+ class DLLLIB avg : public groupFuncBase
242
296
  {
243
297
  void initResultVariable(int index);
244
- void doCalc(const row_ptr& row, int index);
298
+ void doCalcEachkey(const field& fd, int index);
245
299
  numeric_type numericResult(int index) const;
246
300
  groupFuncBase* clone();
247
-
248
301
  public:
249
- avg() {}
302
+ avg();
250
303
  avg(const fieldNames& targetNames, const _TCHAR* resultName = NULL);
251
304
  static avg* create(const fieldNames& targetNames,
252
305
  const _TCHAR* resultName = NULL);
306
+
253
307
  };
254
308
 
255
309
  #undef min
256
- class DLLLIB min : public sum
310
+ class DLLLIB min : public groupFuncBase
257
311
  {
258
312
  protected:
259
- bool m_flag;
260
- void doCalc(const row_ptr& row, int index);
313
+ void doCalcEachkey(const field& fd, int index);
261
314
  groupFuncBase* clone();
262
315
  min& operator=(const min& r);
263
316
 
264
317
  public:
265
- min() {}
318
+ min() : groupFuncBase() {}
266
319
  min(const fieldNames& targetNames, const _TCHAR* resultName = NULL);
267
320
  static min* create(const fieldNames& targetNames,
268
321
  const _TCHAR* resultName = NULL);
269
322
  };
270
323
 
271
324
  #undef max
272
- class DLLLIB max : public sum
325
+ class DLLLIB max : public groupFuncBase
273
326
  {
274
- bool m_flag;
275
- void doCalc(const row_ptr& row, int index);
327
+ void doCalcEachkey(const field& fd, int index);
276
328
  groupFuncBase* clone();
277
329
  max& operator=(const max& r);
278
330
 
279
331
  public:
280
- max() {}
332
+ max() : groupFuncBase(){}
281
333
  max(const fieldNames& targetNames, const _TCHAR* resultName = NULL);
282
334
  static max* create(const fieldNames& targetNames,
283
335
  const _TCHAR* resultName = NULL);
@@ -290,8 +342,9 @@ protected:
290
342
  void doCalc(const row_ptr& row, int index);
291
343
  void doInit(const fielddefs* fdinfo);
292
344
  groupFuncBase* clone();
345
+ void storeValue(const row_ptr& row, int index);
293
346
  public:
294
- last() {}
347
+ last() : groupFuncBase(){}
295
348
  last(const fieldNames& targetNames, const _TCHAR* resultName = NULL);
296
349
  static last* create(const fieldNames& targetNames,
297
350
  const _TCHAR* resultName = NULL);
@@ -300,14 +353,13 @@ public:
300
353
 
301
354
  class DLLLIB first : public last
302
355
  {
303
- bool m_readed;
304
356
  protected:
305
357
  void doCalc(const row_ptr& row, int index);
306
358
  void doReset();
307
359
  groupFuncBase* clone();
308
360
  first& operator=(const first& r);
309
361
  public:
310
- first() {}
362
+ first() : last() {}
311
363
  first(const fieldNames& targetNames, const _TCHAR* resultName = NULL);
312
364
  static first* create(const fieldNames& targetNames,
313
365
  const _TCHAR* resultName = NULL);
@@ -54,7 +54,7 @@ void autoMemory::setParams(unsigned char* p, size_t s, short* endIndex, bool own
54
54
  endFieldIndex = endIndex;
55
55
  if (owner)
56
56
  {
57
- ptr = new unsigned char[s];
57
+ ptr = new unsigned char[s+1];
58
58
  if (p)
59
59
  memcpy(ptr, p, size);
60
60
  else
@@ -122,7 +122,7 @@ autoMemory* autoMemory::create()
122
122
  //---------------------------------------------------------------------------
123
123
  // class memoryRecord
124
124
  //---------------------------------------------------------------------------
125
- inline memoryRecord::memoryRecord() : fieldsBase(NULL)
125
+ inline memoryRecord::memoryRecord() : fieldsBase(NULL), m_blockIndexCache(0)
126
126
  {
127
127
  #ifdef JOIN_UNLIMIT
128
128
  m_memblock.reserve(ROW_MEM_BLOCK_RESERVE);
@@ -131,7 +131,8 @@ inline memoryRecord::memoryRecord() : fieldsBase(NULL)
131
131
  #endif
132
132
  }
133
133
 
134
- inline memoryRecord::memoryRecord(fielddefs& fdinfo) : fieldsBase(&fdinfo)
134
+ inline memoryRecord::memoryRecord(fielddefs& fdinfo) : fieldsBase(&fdinfo),
135
+ m_blockIndexCache(0)
135
136
  {
136
137
  #ifdef JOIN_UNLIMIT
137
138
  m_memblock.reserve(ROW_MEM_BLOCK_RESERVE);
@@ -141,7 +142,7 @@ inline memoryRecord::memoryRecord(fielddefs& fdinfo) : fieldsBase(&fdinfo)
141
142
  }
142
143
 
143
144
  memoryRecord::memoryRecord(const memoryRecord& r)
144
- : fieldsBase(r.m_fns)
145
+ : fieldsBase(r.m_fns),m_blockIndexCache(r.m_blockIndexCache)
145
146
  {
146
147
  #ifdef JOIN_UNLIMIT
147
148
  m_memblock = r.m_memblock;
@@ -166,6 +167,7 @@ memoryRecord& memoryRecord::operator=(const memoryRecord& r)
166
167
  if (this != &r)
167
168
  {
168
169
  m_fns = r.m_fns;
170
+ m_blockIndexCache = r.m_blockIndexCache;
169
171
  #ifdef JOIN_UNLIMIT
170
172
  m_memblock = r.m_memblock;
171
173
  #endif
@@ -204,20 +206,30 @@ void memoryRecord::setRecordData(autoMemory* am, unsigned char* ptr,
204
206
  m_memblock[m_memblockSize] = am;
205
207
  ++m_memblockSize;
206
208
  #endif
209
+ m_InvalidFlags &= ~1L;
207
210
  }
208
211
 
209
212
  void memoryRecord::copyToBuffer(table* tb, bool updateOnly) const
210
213
  {
211
- if (!updateOnly)
212
- memcpy(tb->fieldPtr(0), ptr(0), m_fns->totalFieldLen());
213
- else
214
+ if (m_fns->size())
214
215
  {
215
- for (int i = 0; i < (int)m_fns->size(); ++i)
216
+ short index = 0;
217
+ if (!updateOnly)
218
+ memcpy(tb->fields()[index].nullPtr(), nullPtr(index),
219
+ m_fns->totalFieldLen());
220
+ else
216
221
  {
217
- const fielddef& fd = (*m_fns)[i];
218
- // ptr() return memory block first address
219
- if (fd.enableFlags.bitE)
220
- memcpy(tb->fieldPtr(i), ptr(i) + fd.pos, fd.len);
222
+ for (int i = 0; i < (int)m_fns->size(); ++i)
223
+ {
224
+ const fielddef& fd = (*m_fns)[i];
225
+ // ptr() return memory block first address
226
+ if (fd.enableFlags.bitE)
227
+ {
228
+ memcpy(tb->fieldPtr(i), ptr(i) + fd.pos, fd.len);
229
+ //copy null bits
230
+ tb->setFVNull(i, operator[](i).isNull());
231
+ }
232
+ }
221
233
  }
222
234
  }
223
235
  }
@@ -294,7 +306,7 @@ writableRecord::writableRecord(table* tb, const aliasMap_type* alias)
294
306
  m_tb->clearBuffer();
295
307
  m_fddefs->clear();
296
308
  m_fddefs->setAliases(alias);
297
- m_fddefs->copyFrom(m_tb);
309
+ m_fddefs->addSelectedFields(m_tb);
298
310
  setRecordData(autoMemory::create(), 0, 0, &m_endIndex, true);
299
311
  }
300
312
 
@@ -376,6 +388,12 @@ void writableRecord::save()
376
388
  }
377
389
  }
378
390
 
391
+ void writableRecord::clear()
392
+ {
393
+ m_tb->clearBuffer(table::defaultNull);
394
+ copyFromBuffer(m_tb);
395
+ }
396
+
379
397
  writableRecord* writableRecord::create(table* tb, const aliasMap_type* alias)
380
398
  {
381
399
  writableRecord* p = new writableRecord(tb, alias);
@@ -77,37 +77,38 @@ class DLLLIB memoryRecord : public fieldsBase
77
77
  autoMemory* m_memblock[JOINLIMIT_PER_RECORD];
78
78
  int m_memblockSize;
79
79
  #endif
80
-
80
+ mutable int m_blockIndexCache;
81
81
  static memoryRecord* create(fielddefs& fdinfo, int n);
82
82
  static memoryRecord* create(const memoryRecord& m, int n);
83
83
 
84
- protected:
85
- /** @cond INTERNAL */
86
84
 
87
- inline memoryRecord();
88
- inline memoryRecord(fielddefs& fdinfo);
89
- memoryRecord(const memoryRecord& r);
90
- ~memoryRecord();
91
- memoryRecord& operator=(const memoryRecord& r);
92
- void copyToBuffer(table* tb, bool updateOnly = false) const;
85
+ /** @cond INTERNAL */
93
86
 
94
87
  /* return memory block first address which not field ptr address */
95
88
  inline unsigned char* ptr(int index) const
96
89
  {
90
+ return nullPtr(index) + (*m_fns)[index].nullbytes();
91
+ }
92
+
93
+ inline unsigned char* nullPtr(int index) const
94
+ {
95
+ return m_memblock[memoryBlockIndex(index)]->ptr;
96
+ }
97
+
98
+ inline int memoryBlockIndex(int index) const
99
+ {
97
100
  for (int i = 0; i < memBlockSize(); ++i)
98
101
  if (*(m_memblock[i]->endFieldIndex) > index)
99
- return m_memblock[i]->ptr;
102
+ return m_blockIndexCache = i;
100
103
  assert(0);
101
- return NULL;
104
+ return 0;
102
105
  }
103
106
 
107
+ int memoryBlockIndexCache() const { return m_blockIndexCache;}
108
+
104
109
  inline const autoMemory& memBlockByField(int index) const
105
110
  {
106
- for (int i = 0; i < memBlockSize(); ++i)
107
- if (*(m_memblock[i]->endFieldIndex) > index)
108
- return *m_memblock[i];
109
- assert(0);
110
- return *((autoMemory*)0);
111
+ return *m_memblock[memoryBlockIndex(index)];
111
112
  }
112
113
 
113
114
  inline const autoMemory& memBlock(int index) const
@@ -119,10 +120,6 @@ protected:
119
120
  #else
120
121
  inline int memBlockSize() const { return m_memblockSize; }
121
122
  #endif
122
- inline void copyFromBuffer(const table* tb)
123
- {
124
- memcpy(ptr(0), tb->fieldPtr(0), m_fns->totalFieldLen());
125
- }
126
123
 
127
124
  void removeLastMemBlock()
128
125
  {
@@ -137,9 +134,21 @@ protected:
137
134
  }
138
135
  }
139
136
 
137
+ void releaseMemory();
138
+
139
+ protected:
140
+ inline memoryRecord();
141
+ inline memoryRecord(fielddefs& fdinfo);
142
+ memoryRecord(const memoryRecord& r);
143
+ ~memoryRecord();
144
+ memoryRecord& operator=(const memoryRecord& r);
145
+ void copyToBuffer(table* tb, bool updateOnly = false) const;
146
+ inline void copyFromBuffer(const table* tb)
147
+ {
148
+ memcpy(nullPtr(0), tb->data(), m_fns->totalFieldLen());
149
+ }
140
150
  void setRecordData(autoMemory* am, unsigned char* ptr, size_t size,
141
151
  short* endFieldIndex, bool owner = false);
142
- void releaseMemory();
143
152
 
144
153
  /** @endcond */
145
154
  public:
@@ -176,6 +185,7 @@ public:
176
185
  void del(bool KeysetAlrady = false, bool noSeek = false);
177
186
  void update(bool KeysetAlrady = false, bool noSeek = false);
178
187
  void save();
188
+ void clear();// orverride
179
189
 
180
190
  };
181
191
 
@@ -934,7 +934,7 @@ const char* nsdatabase::toServerUri(char* buf, int buflen, const _TCHAR* src,
934
934
  if (trd)
935
935
  {
936
936
  stringConverter cv(CP_UTF8, GetACP());
937
- cv.convert(buf, buflen, src, strlen_t(src));
937
+ cv.convert(buf, buflen, src, strlen_t(src)+1);// convert include null.
938
938
  return buf;
939
939
  }
940
940
  #endif
@@ -55,7 +55,10 @@ DLLLIB BTRCALLID_PTR getTrnsctdEntryPoint();
55
55
  class DLLLIB nsdatabase
56
56
  {
57
57
  friend class nstable;
58
+ friend class dbdef;
59
+ /** @cond INTERNAL */
58
60
  friend bool reconnectSharedConnection(const void* ptr);
61
+ /** @endcond */
59
62
  struct nsdbimpl* m_nsimpl;
60
63
  nsdatabase(const nsdatabase&);
61
64
  static unsigned int m_execCodepage;
@@ -79,7 +82,7 @@ protected:
79
82
  void internalRelease() { nsdatabase::release(); }
80
83
  void doReconnect(nstable* tb);
81
84
  virtual bool doReopenDatabaseSchema(){ return true; }
82
-
85
+ virtual void* getExtendBufferForOpen(uint_td& size){ return NULL; };
83
86
  public:
84
87
  nsdatabase();
85
88
  virtual void release();
@@ -30,10 +30,11 @@
30
30
  #pragma package(smart_init)
31
31
 
32
32
  /* TODO: To be support internal started transction with original flag.*/
33
- #ifdef __x86_64__
34
- #define MEM_FREED_MAGIC_NUMBER (nstimpl*)0x0FEEEFEEEFEEEFEEE
35
- #else
33
+
34
+ #if (defined(__x86_32__) || defined(__APPLE_32__))
36
35
  #define MEM_FREED_MAGIC_NUMBER (nstimpl*)0x0FEEEFEEE
36
+ #else
37
+ #define MEM_FREED_MAGIC_NUMBER (nstimpl*)0x0FEEEFEEEFEEEFEEE
37
38
  #endif
38
39
  namespace bzs
39
40
  {
@@ -49,14 +50,15 @@ namespace client
49
50
  struct nstimpl
50
51
  {
51
52
  nstimpl()
52
- : refCount(1), bulkIns(NULL), percentage(0),bookmarkLen(0),mode(0),
53
+ : bulkIns(NULL), refCount(1), percentage(0), bookmarkLen(0), tableid(0), mode(0),
53
54
  shared(false), isOpen(false)
54
55
  {
55
56
  memset(posblk, 0 ,POS_BLOCK_SIZE);
57
+ uri[0] = 0x00;
56
58
  }
57
- int refCount;
58
59
  bulkInsert* bulkIns;
59
60
  nsdatabase* nsdb;
61
+ int refCount;
60
62
  percentage_td percentage;
61
63
  ushort_td bookmarkLen;
62
64
  bookmark_td bookmark;
@@ -211,7 +213,6 @@ void nstable::addref(void)
211
213
 
212
214
  void nstable::release()
213
215
  {
214
-
215
216
  /* If before called database::drop() database::close() etc then
216
217
  nstable::destory called.
217
218
  Client cache nstable pointer that is invalid.
@@ -227,6 +228,7 @@ void nstable::release()
227
228
  }
228
229
  catch (...)
229
230
  {
231
+
230
232
  }
231
233
  }
232
234
 
@@ -240,7 +242,8 @@ void nstable::doClose()
240
242
  {
241
243
  if (test(this) && m_impl && (m_impl->isOpen))
242
244
  {
243
- tdap(TD_CLOSETABLE);
245
+ if (m_impl->nsdb->btrvFunc())
246
+ tdap(TD_CLOSETABLE);
244
247
  if (m_stat == STATUS_SUCCESS)
245
248
  m_impl->isOpen = false;
246
249
  }
@@ -366,7 +369,7 @@ void nstable::doOpen(const _TCHAR* name, char_td mode, const _TCHAR* ownerName)
366
369
  else
367
370
  #endif
368
371
  {
369
- if (m_impl->uri != name)
372
+ if (_tcscmp(m_impl->uri, name))
370
373
  _tcscpy_s(m_impl->uri, MAX_PATH, name);
371
374
  }
372
375
  // for trnasctd
@@ -396,27 +399,35 @@ void nstable::doOpen(const _TCHAR* name, char_td mode, const _TCHAR* ownerName)
396
399
  else
397
400
  m_keynum = mode;
398
401
 
399
- char ownerNameBuf[OWNERNAME_SIZE] = { 0x00 };
400
-
402
+ char ownerNameBuf[OWNERNAME_SIZE];// = { 0x00 };
403
+ uint_td size = 0;
404
+ char* buf = (char*)nsdb()->getExtendBufferForOpen(size);
405
+ if (!buf)
406
+ buf = ownerNameBuf;
407
+
408
+ m_pdata = (void*)buf;
401
409
  if (NULL != ownerName && 0x00 != ownerName[0])
402
410
  {
403
- const char* p2 = toChar(ownerNameBuf, ownerName, OWNERNAME_SIZE);
404
- m_pdata = (void*)p2;
405
- m_datalen = (uint_td)strlen(p2) + 1;
411
+ toCharCpy(buf, ownerName, OWNERNAME_SIZE);
412
+ m_datalen = (uint_td)strlen(buf) + 1;
413
+
406
414
  if (m_datalen > 11)
407
415
  {
408
416
  m_stat = STATUS_TOO_LONG_OWNERNAME;
409
417
  goto clean;
410
418
  }
411
- if (m_datalen < sizeof(unsigned int))
412
- m_datalen = sizeof(unsigned int);/* for bookmarklen*/
419
+ if (m_datalen < sizeof(ushort_td))
420
+ m_datalen = sizeof(ushort_td);/* for bookmarklen*/
413
421
  }
414
422
  else
415
423
  {
416
424
  m_impl->bookmarkLen = 0;
417
- m_pdata = &m_impl->bookmarkLen;
425
+ memcpy(buf, &m_impl->bookmarkLen, sizeof(ushort_td));
426
+ //m_pdata = &m_impl->bookmarkLen;
418
427
  m_datalen = sizeof(ushort_td);/* for bookmarklen*/
419
428
  }
429
+ if (size)
430
+ m_datalen = size;
420
431
  tdap(TD_OPENTABLE);
421
432
  if (m_stat == STATUS_SUCCESS)
422
433
  {
@@ -424,10 +435,15 @@ void nstable::doOpen(const _TCHAR* name, char_td mode, const _TCHAR* ownerName)
424
435
  m_impl->mode = mode;
425
436
  if (!isUseTransactd())
426
437
  m_impl->bookmarkLen = BTRV_BOOKMARK_SIZE;
427
- else if (m_impl->bookmarkLen == 0)
428
- m_impl->bookmarkLen = BTRV_BOOKMARK_SIZE;
429
- else if (m_impl->bookmarkLen == 0xFFFF) //No primary
430
- m_impl->bookmarkLen = 0;
438
+ else
439
+ {
440
+ ushort_td* p = (ushort_td*)m_pdata;
441
+ m_impl->bookmarkLen = *p;
442
+ if (m_impl->bookmarkLen == 0)
443
+ m_impl->bookmarkLen = BTRV_BOOKMARK_SIZE;
444
+ else if (m_impl->bookmarkLen == 0xFFFF) //No primary
445
+ m_impl->bookmarkLen = 0;
446
+ }
431
447
  }
432
448
  clean:
433
449
  m_keybuf = svm_keybuf;
@@ -896,7 +912,7 @@ short_td nstable::tdapErr(HWND hWnd, short_td status, const _TCHAR* TableName,
896
912
  }
897
913
  #pragma warning(default : 4996)
898
914
 
899
- if ((int)hWnd <= 0)
915
+ if (hWnd == 0)
900
916
  return errorCode;
901
917
 
902
918
  #ifdef _WIN32
@@ -937,9 +953,11 @@ _TCHAR* nstable::getDirURI(const _TCHAR* path, _TCHAR* buf)
937
953
  _tfullpath(buf, path, MAX_PATH);
938
954
  else
939
955
  #endif
940
- stripAuth(path, buf, MAX_PATH);
941
- _TUCHAR* p = (_TUCHAR*)_tcsmrchr((const _TUCHAR*)buf, PSEPARATOR_C);
942
- _TUCHAR* p2 = (_TUCHAR*)_tcsmrchr((const _TUCHAR*)buf, '=');
956
+ stripAuth(path, buf, MAX_PATH);
957
+ _TUCHAR* p = _tcsmrchr((_TUCHAR*)buf, PSEPARATOR_C);
958
+ _TUCHAR* p1 = _tcsmrchr((_TUCHAR*)buf, '?');
959
+ if (p1 && (p1 > p)) p = p1;
960
+ _TUCHAR* p2 = _tcsmrchr((_TUCHAR*)buf, '=');
943
961
  if (p && p2)
944
962
  {
945
963
  if (p2 > p)
@@ -951,6 +969,14 @@ _TCHAR* nstable::getDirURI(const _TCHAR* path, _TCHAR* buf)
951
969
  *p = 0x00;
952
970
  if (p2)
953
971
  *(p2 + 1) = 0x00;
972
+ if (uri && !_tcsstr(buf, _T("dbfile=")))
973
+ {
974
+ p = _tcsmrchr((_TUCHAR*)buf, '?');
975
+ if (!p)
976
+ _tcscat(buf, _T("?dbfile="));
977
+ else
978
+ _tcscat(buf, _T("dbfile="));
979
+ }
954
980
  return buf;
955
981
  }
956
982
 
@@ -1006,6 +1032,25 @@ bool nstable::test(nstable* p)
1006
1032
  return false;
1007
1033
  }
1008
1034
 
1035
+ void nstable::test_store(const char* values)
1036
+ {
1037
+ void* svm_pdata = m_pdata;
1038
+ m_stat = STATUS_SUCCESS;
1039
+ m_keylen = m_keybuflen;
1040
+ m_datalen = (uint_td)strlen(values) + 1;
1041
+ m_pdata = (void*)values;
1042
+ tdap(TD_STORE_TEST);
1043
+ m_pdata = svm_pdata;
1044
+ }
1045
+
1046
+ void nstable::setTimestampMode(int mode)
1047
+ {
1048
+ char_td keynum = m_keynum;
1049
+ m_keynum = (char_td)mode;
1050
+ tdap(TD_SET_TIMESTAMP_MODE);
1051
+ m_keynum = keynum;
1052
+ }
1053
+
1009
1054
  } // namespace client
1010
1055
  } // namespace tdap
1011
1056
  } // namespace protocol
@@ -72,9 +72,9 @@ private:
72
72
 
73
73
  protected:
74
74
  void* m_pdata;
75
+ void* m_keybuf;
75
76
  uint_td m_buflen;
76
77
  uint_td m_datalen;
77
- void* m_keybuf;
78
78
  ushort_td m_op;
79
79
  keylen_td m_keybuflen;
80
80
  keylen_td m_keylen;
@@ -225,6 +225,7 @@ public:
225
225
  void unlock(bookmark_td& bm);
226
226
  void unlock();
227
227
  char_td mode() const;
228
+ void setTimestampMode(int mode);
228
229
  static _TCHAR* getFileName(const _TCHAR* uri, _TCHAR* retbuf);
229
230
  static short_td tdapErr(HWND hWnd, short_td status,
230
231
  const _TCHAR* tableName = NULL,
@@ -235,6 +236,7 @@ public:
235
236
  static bool existsFile(const _TCHAR* filename);
236
237
  /** @cond INTERNAL */
237
238
  static bool test(nstable* p);
239
+ void test_store(const char* values);
238
240
  /** @endcond*/
239
241
  };
240
242
 
@@ -91,6 +91,7 @@ const fielddefs* recordset::fieldDefs() const
91
91
  row& recordset::operator[](size_t index) const
92
92
  {
93
93
  m_imple->checkIndex(index);
94
+ m_imple->clearStringBuffer();
94
95
  return (*m_imple)[index];
95
96
  }
96
97