transactd 2.4.5 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -23,12 +23,13 @@
23
23
  #include <string.h>
24
24
  #include <algorithm>
25
25
  #include <wchar.h>
26
+ #include <stdio.h>
26
27
  #include <bzs/env/compiler.h>
27
28
  #include <bzs/env/crosscompile.h>
28
29
  #include <bzs/db/protocol/tdap/mysql/characterset.h>
29
30
  #include <bzs/db/blobStructs.h>
30
31
  #include <assert.h>
31
-
32
+ #include <bzs/db/protocol/tdap/myDateTime.h>
32
33
  namespace bzs
33
34
  {
34
35
  namespace db
@@ -37,10 +38,28 @@ namespace protocol
37
38
  {
38
39
  namespace tdap
39
40
  {
40
-
41
+
42
+ namespace mysql
43
+ {
44
+ class schemaBuilder;
45
+ }
41
46
  namespace client
42
47
  {
43
48
  class dbdef;
49
+ class fielddefs;
50
+ class table;
51
+ class database;
52
+ struct openTablePrams;
53
+ struct dbdimple;
54
+ class filter;
55
+ class recordCache;
56
+ class fielddefs;
57
+ class fields;
58
+ class field;
59
+ class memoryRecord;
60
+ struct logic;
61
+ class recordsetQuery;
62
+ class sqlBuilder;
44
63
  }
45
64
 
46
65
  #pragma pack(push, 1)
@@ -140,15 +159,52 @@ struct keySegment
140
159
  FLAGS flags; // key flags. 11 to 15bit is not use.
141
160
  };
142
161
 
162
+ /** keySegment::flags
163
+ */
164
+ #define kf_duplicatable bit0
165
+ #define kf_changeatable bit1
166
+ #define kf_allseg_nullkey bit3
167
+ #define kf_order_desc bit6
168
+ #define kf_extend bit8
169
+ #define kf_seg_nullkey bit9
170
+ #define kf_incase bitA
171
+
172
+
173
+
143
174
  /* brief A key infomation
144
175
  */
145
176
  #define MAX_KEY_SEGMENT 8
146
-
177
+ #define COMP_KEY_FLAGS(l, r, NAME) (l.NAME == r.NAME)
147
178
  struct keydef
148
179
  {
149
- uchar_td segmentCount; // Number of segment
150
- keySegment segments[MAX_KEY_SEGMENT]; // key segments . max 8 segments
151
- uchar_td keyNumber; // key number
180
+ uchar_td segmentCount;
181
+ keySegment segments[MAX_KEY_SEGMENT];
182
+ uchar_td keyNumber;
183
+
184
+ bool operator==(const keydef& r) const
185
+ {
186
+ if (this == &r) return true;
187
+ bool ret = (segmentCount == r.segmentCount) && (keyNumber == r.keyNumber);
188
+ if (!ret) return false;
189
+ for (int i = 0;i < segmentCount; ++i)
190
+ {
191
+ FLAGS f = segments[i].flags;
192
+ FLAGS rf = r.segments[i].flags;
193
+ ret = COMP_KEY_FLAGS(f, rf, kf_duplicatable) &&
194
+ COMP_KEY_FLAGS(f, rf, kf_changeatable) &&
195
+ COMP_KEY_FLAGS(f, rf, kf_allseg_nullkey) &&
196
+ COMP_KEY_FLAGS(f, rf, kf_order_desc) &&
197
+ COMP_KEY_FLAGS(f, rf, kf_seg_nullkey) &&
198
+ COMP_KEY_FLAGS(f, rf, kf_incase);
199
+ if (!ret) return false;
200
+ }
201
+ return true;
202
+ }
203
+
204
+ private:
205
+ short synchronize(const keydef* kd);
206
+ friend struct tabledef;
207
+ friend class client::dbdef;
152
208
  };
153
209
 
154
210
  static const int MYSQL_FDNAME_SIZE = 64;
@@ -157,12 +213,14 @@ static const int PERVASIVE_FDNAME_SIZE = 20;
157
213
  static const int FIELD_NAME_SIZE = MYSQL_FDNAME_SIZE;
158
214
  static const int TABLE_NAME_SIZE = 32;
159
215
  static const int FILE_NAME_SIZE = 266;
160
-
161
- #if (defined(__x86_32__) || __APPLE_32__)
162
- static const int TABLEDEF_FILLER_SIZE = 21; // 25-4;
216
+
217
+ /** @cond INTERNAL */
218
+ #if (defined(__x86_32__) || defined(__APPLE_32__))
219
+ static const int TABLEDEF_FILLER_SIZE = 17; // 25-4-4;
163
220
  #else
164
- static const int TABLEDEF_FILLER_SIZE = 9; // 17-8;
165
- #endif
221
+ static const int TABLEDEF_FILLER_SIZE = 1; // 17-8 -8;
222
+ #endif
223
+ /** @endcond */
166
224
 
167
225
  #ifndef MYSQL_DYNAMIC_PLUGIN
168
226
 
@@ -205,6 +263,8 @@ inline bool isStringType(uchar_td type)
205
263
  {
206
264
  switch (type)
207
265
  {
266
+ case ft_mygeometry:
267
+ case ft_myjson:
208
268
  case ft_myblob:
209
269
  case ft_mytext:
210
270
  case ft_lstring:
@@ -218,8 +278,56 @@ inline bool isStringType(uchar_td type)
218
278
  #define PAD_CHAR_OPTION_SAVED 1
219
279
  #define USE_PAD_CHAR 2
220
280
  #define TRIM_PAD_CHAR 4
281
+
282
+ #define FIELD_OPTION_NULLABLE 1
283
+ #define FIELD_OPTION_MARIADB 2
284
+ #define FIELD_OPTION_REGACY_TIME 4
285
+
286
+ #define DEFAULT_VALUE_SIZE 8
287
+
288
+ //For decimals
289
+ #define DIGITS_INT32 9
290
+ static const int decimalBytesBySurplus[DIGITS_INT32 + 1] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 4};
291
+
221
292
  /** @endcond */
222
293
 
294
+ class bitset
295
+ {
296
+ unsigned __int64 m_i64;
297
+
298
+ public:
299
+ bitset() : m_i64(0) { }
300
+
301
+ bitset(__int64 v) : m_i64(v) { }
302
+
303
+ inline void set(int index, bool value)
304
+ {
305
+ unsigned __int64 bits = 1ULL << index;
306
+ m_i64 = value ? m_i64 | bits : m_i64 & ~bits;
307
+ }
308
+
309
+ inline bool get(int index) const
310
+ {
311
+ unsigned __int64 bits = 1ULL << index;
312
+ return (m_i64 & bits) != 0;
313
+ }
314
+
315
+ inline __int64 internalValue() const { return (__int64)m_i64; }
316
+
317
+ inline bool operator[](int index) const {return get(index); };
318
+
319
+ inline bool operator==(const bitset& r) const
320
+ {
321
+ return (m_i64 == r.m_i64);
322
+ }
323
+
324
+ inline bool contains(const bitset& r, bool all=true) const
325
+ {
326
+ return all ? ((m_i64 & r.m_i64) == r.m_i64) : ((m_i64 & r.m_i64) != 0);
327
+ }
328
+
329
+ };
330
+
223
331
  /* Mark of ** that BizStation Corp internal use only.
224
332
  */
225
333
  template <int N> struct fielddef_t
@@ -235,21 +343,27 @@ public:
235
343
  ushort_td viewWidth; // ** view width pix
236
344
  double max; // ** max value
237
345
  double min; // ** min value
238
- double defValue; // ** default value
346
+ protected:
347
+ char m_defValue[DEFAULT_VALUE_SIZE];
348
+ public:
239
349
  uchar_td lookTable; // ** reference table number
240
350
  uchar_td lookField; // ** field number of reference table
241
351
  uchar_td lookFields[3]; // ** View fields of reference bit567
242
352
  ushort_td pos; // Field offset position from record image
243
- ushort_td defViewWidth; // ** default view wifth
244
-
245
353
  protected:
354
+ uchar_td m_nullbit; // bit number for null indicator
355
+ uchar_td m_nullbytes; // byte of null indicator which head of record memory block.
246
356
  char m_chainChar[2];
247
357
 
248
358
  public:
249
- ushort_td ddfid; // ddf field id
359
+ union
360
+ {
361
+ ushort_td ddfid; // ddf field id
362
+ ushort_td digits; // for ft_myDecimal
363
+ };
250
364
  ushort_td filterId; // ** filter id for reference
251
365
  uchar_td filterKeynum; // ** key number for reference
252
- uchar_td nullValue; // null value
366
+ uchar_td nullValue; // null value for P.SQL
253
367
  ushort_td userOption; // ** option
254
368
  uchar_td lookDBNum; // ** database number of reference bitD
255
369
 
@@ -262,13 +376,17 @@ public:
262
376
  protected:
263
377
  uchar_td m_charsetIndex; // charctor set index of this field data
264
378
  ushort_td m_schemaCodePage;
265
- ushort_td m_padCharOptions;
379
+ uchar_td m_padCharOptions;
380
+ uchar_td m_options;
381
+
266
382
  public:
267
383
  FLAGS enableFlags; // ** enable flags. see below
268
384
 
269
385
  private:
270
386
  inline void setSchemaCodePage(uint_td v) { m_schemaCodePage = (ushort_td)v; };
271
387
  friend class client::dbdef;
388
+ friend class client::fielddefs;
389
+ friend struct tabledef;
272
390
  };
273
391
 
274
392
  /* This is only for BizStation Corp internal.
@@ -276,7 +394,7 @@ private:
276
394
  bit0 show list view
277
395
  bit1 enable max value
278
396
  bit2 enable min value
279
- bit3 enable default value
397
+ bit3 reserved. not use
280
398
  bit4 enable lookTable
281
399
  bit5 enable lookFields[0]
282
400
  bit6 enable lookFields[1]
@@ -288,6 +406,7 @@ private:
288
406
  bitC not show list view but add select field list
289
407
  bitD enable lookDBNum
290
408
  bitE field value is changed
409
+ bitF defaultNull
291
410
  */
292
411
 
293
412
  typedef fielddef_t<MYSQL_FDNAME_SIZE> fielddef_t_my;
@@ -299,34 +418,103 @@ typedef fielddef_t<PERVASIVE_FDNAME_SIZE> fielddef_t_pv;
299
418
 
300
419
  struct PACKAGE fielddef : public fielddef_t_my
301
420
  {
421
+
302
422
  #ifdef _UNICODE
303
423
  const wchar_t* name() const; // Return a field name.
304
424
  const wchar_t* name(wchar_t* buf) const; // Return a field name to bufffer .
305
425
  const wchar_t* chainChar() const; // ** internal use only.
426
+ const wchar_t* defaultValue_str() const;
306
427
  void setName(const wchar_t* s);
307
428
  void setChainChar(const wchar_t* s); // ** internal use only.
429
+ void setDefaultValue(const wchar_t* s);
308
430
  #else // NOT _UNICODE
309
431
 
310
432
  #ifdef MYSQL_DYNAMIC_PLUGIN
311
433
 
312
- inline const char* name() const { return m_name; };
434
+ //inline const char* name() const { return m_name; };
313
435
 
314
- inline const char* chainChar() const { return m_chainChar; };
436
+ //inline const char* chainChar() const { return m_chainChar; };
437
+
438
+ //inline const char* defaultValue_str() const{return m_defValue; }
315
439
 
316
440
  inline void setName(const char* s)
317
441
  {
318
442
  strncpy_s(m_name, FIELD_NAME_SIZE, s, sizeof(m_name) - 1);
319
- };
443
+ }
320
444
 
321
445
  inline void setChainChar(const char* s)
322
446
  {
323
447
  strncpy_s(m_chainChar, 2, s, sizeof(m_chainChar) - 1);
324
- };
448
+ }
449
+
450
+ inline void setDefaultValue(const char* s)
451
+ {
452
+ if (isBlob())
453
+ {
454
+ memset(m_defValue, 0, DEFAULT_VALUE_SIZE);
455
+ return;
456
+ }
457
+
458
+ enableFlags.bitF = false;
459
+ __int64 i64 = 0;
460
+ switch(type)
461
+ {
462
+ case ft_time:
463
+ case ft_mytime:
464
+ {
465
+ myDateTime dt(7, true);
466
+ dt.setTime(s);
467
+ i64 = dt.getValue();
468
+ memcpy(m_defValue, &i64, 7);
469
+ return;
470
+ }
471
+ case ft_date:
472
+ case ft_mydate:
473
+ case ft_datetime:
474
+ case ft_mytimestamp:
475
+ case ft_mydatetime:
476
+ i64 = str_to_64<myDateTime, char>(7, true, s);
477
+ memcpy(m_defValue, &i64, 7);
478
+ return;
479
+ case ft_integer:
480
+ case ft_autoinc:
481
+ *((__int64*)m_defValue) = _atoi64(s);
482
+ return;
483
+ case ft_uinteger:
484
+ case ft_logical:
485
+ case ft_set:
486
+ case ft_bit:
487
+ case ft_enum:
488
+ case ft_autoIncUnsigned:
489
+ case ft_myyear:
490
+ *((unsigned __int64*)m_defValue) = strtoull(s, NULL, 10);
491
+ return;
492
+ }
493
+
494
+ if (isNumericType())
495
+ {
496
+ *((double*)m_defValue) = atof(s);
497
+ return;
498
+ }
499
+ strncpy_s(m_defValue, 8, s, sizeof(m_defValue) - 1);
500
+ }
501
+
502
+ inline void setDefaultValue(double v)
503
+ {
504
+ *((double*)m_defValue) = v;
505
+ }
506
+
507
+ inline void setDefaultValue(__int64 v)
508
+ {
509
+ *((__int64*)m_defValue) = v;
510
+ }
511
+
325
512
 
326
513
  #else // NOT MYSQL_DYNAMIC_PLUGIN
327
514
  const char* name() const;
328
515
  const char* name(char* buf) const;
329
516
  const char* chainChar() const;
517
+ const char* defaultValue_str() const;
330
518
  void setName(const char* s);
331
519
  void setChainChar(const char* s);
332
520
  #endif // NOT MYSQL_DYNAMIC_PLUGIN
@@ -337,8 +525,23 @@ struct PACKAGE fielddef : public fielddef_t_my
337
525
  inline void setNameA(const char* s)
338
526
  {
339
527
  strncpy_s(m_name, FIELD_NAME_SIZE, s, sizeof(m_name) - 1);
340
- };
528
+ }
529
+
341
530
  #ifndef MYSQL_DYNAMIC_PLUGIN
531
+ void setDefaultValue(const char* s);
532
+
533
+ void setDefaultValue(__int64 v);
534
+
535
+ void setDefaultValue(double v);
536
+
537
+ void setDefaultValue(const bitset& v)
538
+ {
539
+ setDefaultValue(v.internalValue());
540
+ }
541
+
542
+ double defaultValue() const;
543
+
544
+ __int64 defaultValue64() const;
342
545
 
343
546
  inline const _TCHAR* typeName() const { return getTypeName(type); };
344
547
 
@@ -349,22 +552,9 @@ struct PACKAGE fielddef : public fielddef_t_my
349
552
  len = lenByCharnum(type, m_charsetIndex, charnum);
350
553
  }
351
554
 
555
+ void setDecimalDigits(int dig, int dec);
352
556
  #endif // MYSQL_DYNAMIC_PLUGIN
353
557
 
354
- private:
355
- /* Is variable key type
356
- */
357
- inline bool isKeyVarType() const
358
- {
359
- return (((type >= ft_myvarchar) && (type <= ft_mywvarbinary)) ||
360
- (type == ft_myblob) || (type == ft_mytext));
361
- }
362
-
363
- /* max key segment length. not include sizeBytes.
364
- */
365
- inline ushort_td maxKeylen() const { return keylen ? keylen : len; };
366
-
367
- public:
368
558
  inline unsigned int codePage() const
369
559
  {
370
560
  return mysql::codePage((unsigned short)m_charsetIndex);
@@ -372,22 +562,46 @@ public:
372
562
 
373
563
  /* Is string type or not.
374
564
  */
375
- bool isStringType() const;
565
+ inline bool isStringType() const {return tdap::isStringType(type);}
566
+
567
+ inline bool isPadCharType() const
568
+ {
569
+ return ((type == ft_mychar) || (type == ft_mywchar) ||
570
+ (type == ft_string) || (type == ft_wstring));
571
+ }
572
+
573
+ inline bool isIntegerType() const
574
+ {
575
+ return ((type == ft_integer) || (type == ft_logical) || (type == ft_uinteger) ||
576
+ (type == ft_autoinc) || (type == ft_set) || (type == ft_bit) ||
577
+ (type == ft_enum) || (type == ft_autoIncUnsigned) || (type == ft_myyear));
578
+ }
376
579
 
377
580
  inline bool isNumericType() const
378
581
  {
379
582
  return ((type == ft_integer) || (type == ft_decimal) ||
380
- (type == ft_money) || (type == ft_logical) ||
381
- (type == ft_numeric) || (type == ft_bfloat) ||
382
- (type == ft_uinteger) || (type == ft_autoinc) ||
383
- (type == ft_bit) || (type == ft_numericsts) ||
384
- (type == ft_numericsa) || (type == ft_autoIncUnsigned));
583
+ (type == ft_money) || (type == ft_logical) || (type == ft_currency) ||
584
+ (type == ft_numeric) || (type == ft_bfloat) || (type == ft_float) ||
585
+ (type == ft_uinteger) || (type == ft_autoinc) || (type == ft_set) ||
586
+ (type == ft_bit) || (type == ft_enum) || (type == ft_numericsts) ||
587
+ (type == ft_numericsa) || (type == ft_autoIncUnsigned) ||
588
+ (type == ft_myyear) || (type == ft_mydecimal));
589
+ }
590
+
591
+ inline bool isDateTimeType() const
592
+ {
593
+ return ((type == ft_date) || (type == ft_mydate) ||
594
+ (type == ft_time) || (type == ft_mytime) ||
595
+ (type == ft_datetime) || (type == ft_timestamp) ||
596
+ (type == ft_mydatetime) || (type == ft_mytimestamp));
385
597
  }
386
598
 
387
599
  /* Charctor numbers from charset.
388
600
  */
389
601
  unsigned int charNum() const;
390
602
 
603
+ bool isValidCharNum() const;
604
+
391
605
  inline void setCharsetIndex(uchar_td index)
392
606
  {
393
607
  m_charsetIndex = index;
@@ -399,9 +613,86 @@ public:
399
613
 
400
614
  inline uchar_td charsetIndex() const { return m_charsetIndex; };
401
615
 
616
+ inline bool isBlob() const
617
+ {
618
+ return (type == ft_myblob) || (type == ft_mytext) || (type == ft_mygeometry) || (type == ft_myjson);
619
+ }
620
+
621
+ inline void setPadCharSettings(bool set, bool trim)
622
+ {
623
+ m_padCharOptions = 0;
624
+ m_padCharOptions |= PAD_CHAR_OPTION_SAVED;
625
+ if ((type == ft_mychar) || (type == ft_mywchar))
626
+ {
627
+ m_padCharOptions |= USE_PAD_CHAR;
628
+ if (trim)
629
+ m_padCharOptions |= TRIM_PAD_CHAR;
630
+ } // For compatibility with conventional.
631
+ else if ((type == ft_string) || (type == ft_wstring))
632
+ {
633
+ if (set)
634
+ m_padCharOptions |= USE_PAD_CHAR;
635
+ if (trim)
636
+ m_padCharOptions |= TRIM_PAD_CHAR;
637
+ }
638
+ }
639
+
640
+ /* When ft_string or ft_wstring, fill by pad char at write. */
641
+ inline bool isUsePadChar() const {return (m_padCharOptions & USE_PAD_CHAR) == USE_PAD_CHAR;}
642
+
643
+ /* When ft_string or ft_wstring or ft_mychar or ft_mywchar,
644
+ remove pad char at read.*/
645
+ inline bool isTrimPadChar() const {return (m_padCharOptions & TRIM_PAD_CHAR) == TRIM_PAD_CHAR;}
646
+
647
+ inline bool isNullable() const {return (m_options & FIELD_OPTION_NULLABLE) == FIELD_OPTION_NULLABLE;}
648
+
649
+ void setNullable(bool v, bool defaultNull = true)
650
+ {
651
+ if (v)
652
+ {
653
+ m_options |= FIELD_OPTION_NULLABLE;
654
+ enableFlags.bitF = defaultNull;
655
+ }
656
+ else
657
+ {
658
+ m_options &= ~FIELD_OPTION_NULLABLE;
659
+ enableFlags.bitF = false;
660
+ }
661
+ }
662
+
663
+ void setTimeStampOnUpdate(bool v)
664
+ {
665
+ if (type == ft_mytimestamp || type == ft_mydatetime)
666
+ m_defValue[7] = v ? 1: 0;
667
+ }
668
+
669
+ bool isTimeStampOnUpdate() const
670
+ {
671
+ if (type == ft_mytimestamp || type == ft_mydatetime)
672
+ return (m_defValue[7] == 1);
673
+ return false;
674
+ }
675
+
676
+ inline bool isDefaultNull() const
677
+ {
678
+ return enableFlags.bitF;
679
+ }
680
+
681
+ inline bool isLegacyTimeFormat() const
682
+ {
683
+ return (m_options & FIELD_OPTION_REGACY_TIME) != 0;
684
+ }
685
+
686
+ inline uint_td blobLenBytes() const
687
+ {
688
+ if (isBlob())
689
+ return len - 8;
690
+ return 0;
691
+ }
692
+
402
693
  /* length bytes of var field
403
694
  */
404
- inline int varLenBytes() const
695
+ inline uint_td varLenBytes() const
405
696
  {
406
697
  if (((type >= ft_myvarchar) && (type <= ft_mywvarbinary)) ||
407
698
  type == ft_lstring)
@@ -411,16 +702,30 @@ public:
411
702
  return 0;
412
703
  }
413
704
 
414
- inline uint_td blobLenBytes() const
705
+ bool operator==(const fielddef& r) const;
706
+
707
+ private:
708
+ const char* defaultValue_strA(char* p, size_t size) const;
709
+ /* data length
710
+ */
711
+ inline uint_td dataLen(const uchar_td* ptr) const
415
712
  {
416
- if ((type == ft_myblob) || (type == ft_mytext))
417
- return len - 8;
418
- return 0;
713
+ int blen = varLenBytes();
714
+ if (blen == 0)
715
+ return len;
716
+ else if (blen == 1)
717
+ return *((unsigned char*)ptr);
718
+ return *((unsigned short*)ptr);
419
719
  }
420
720
 
421
- inline bool isBlob() const
721
+ inline uint_td blobDataLen(const uchar_td* ptr) const
422
722
  {
423
- return (type == ft_myblob) || (type == ft_mytext);
723
+ int blen = blobLenBytes();
724
+ if (blen == 0)
725
+ return len;
726
+ uint_td v = 0;
727
+ memcpy(&v, ptr, blen);
728
+ return v;
424
729
  }
425
730
 
426
731
  inline int maxVarDatalen() const
@@ -430,7 +735,7 @@ public:
430
735
  return (len < 256) ? len - 1 : len - 2;
431
736
  else if (type == ft_lvar)
432
737
  return len - 4;
433
- else if ((type == ft_myblob) || (type == ft_mytext))
738
+ else if (isBlob())
434
739
  {
435
740
  switch (len - 8)
436
741
  {
@@ -448,34 +753,12 @@ public:
448
753
  return 0;
449
754
  }
450
755
 
451
- /* data length
452
- */
453
- inline uint_td dataLen(const uchar_td* ptr) const
454
- {
455
- int blen = varLenBytes();
456
- if (blen == 0)
457
- return len;
458
- else if (blen == 1)
459
- return *((unsigned char*)ptr);
460
- return *((unsigned short*)ptr);
461
- }
462
-
463
- inline uint_td blobDataLen(const uchar_td* ptr) const
464
- {
465
- int blen = blobLenBytes();
466
- if (blen == 0)
467
- return len;
468
- uint_td v = 0;
469
- memcpy(&v, ptr, blen);
470
- return v;
471
- }
472
-
473
756
  /* data image for key
474
757
  * param ptr address of record buffer
475
758
  */
476
759
  inline const uchar_td* keyData(const uchar_td* ptr) const
477
760
  {
478
- if ((type == ft_myblob) || (type == ft_mytext))
761
+ if (isBlob())
479
762
  return blobDataPtr(ptr);
480
763
  int sizeByte = varLenBytes();
481
764
  return ptr + sizeByte;
@@ -483,68 +766,63 @@ public:
483
766
 
484
767
  inline uint_td keyDataLen(const uchar_td* ptr) const
485
768
  {
486
- if ((type == ft_myblob) || (type == ft_mytext))
769
+ if (isBlob())
487
770
  return blobDataLen(ptr);
488
771
  return dataLen(ptr);
489
772
  }
490
773
 
491
- inline void setPadCharSettings(bool set, bool trim)
774
+ /* Is variable key type
775
+ */
776
+ inline bool isKeyVarType() const
492
777
  {
493
- m_padCharOptions = 0;
494
- m_padCharOptions |= PAD_CHAR_OPTION_SAVED;
495
- if ((type == ft_mychar) || (type == ft_mywchar))
496
- {
497
- m_padCharOptions |= USE_PAD_CHAR;
498
- if (trim)
499
- m_padCharOptions |= TRIM_PAD_CHAR;
500
- } // For compatibility with conventional.
501
- else if ((type == ft_string) || (type == ft_wstring))
502
- {
503
- if (set)
504
- m_padCharOptions |= USE_PAD_CHAR;
505
- if (trim)
506
- m_padCharOptions |= TRIM_PAD_CHAR;
507
- }
778
+ return (((type >= ft_myvarchar) && (type <= ft_mywvarbinary)) || isBlob());
508
779
  }
509
-
510
- /* When ft_string or ft_wstring, fill by pad char at write. */
511
- bool usePadChar() const {return (m_padCharOptions & USE_PAD_CHAR) == USE_PAD_CHAR;}
512
-
513
- /* When ft_string or ft_wstring or ft_mychar or ft_mywchar,
514
- remove pad char at read.*/
515
- bool trimPadChar() const {return (m_padCharOptions & TRIM_PAD_CHAR) == TRIM_PAD_CHAR;}
516
780
 
781
+ /* max key segment length. not include sizeBytes.
782
+ */
783
+ inline ushort_td maxKeylen() const { return keylen ? keylen : len; };
517
784
 
518
- /** @cond INTERNAL */
519
- /* copy key data for send to mysql
785
+ /* copy key data for send to mysql and btrv
520
786
  * return next copy address.
521
787
  * If datalen==0xff then From is field formated (string) type.
522
788
  * If datalen!=0xff then From is none field formated (string) type.
523
789
  */
524
- inline uchar_td* keyCopy(uchar_td* to, const uchar_td* from, ushort_td datalen=0xff)
790
+ inline uchar_td* keyCopy(uchar_td* to, const uchar_td* from, ushort_td datalen,
791
+ bool isNull)
525
792
  {
793
+ ushort_td keylen = maxKeylen(); // size of max key segmnet for mysql
794
+ ushort_td keyVarlen = varLenByteForKey(); // size of var sizeByte for record.
795
+ ushort_td copylen = std::min<ushort_td>(keylen, datalen);
526
796
 
527
- ushort_td kl = maxKeylen(); // size of max key segmnet for mysql
528
- memset(to, 0x00, kl);
529
- ushort_td keyVarlen =
530
- varLenByteForKey(); // size of var sizeByte for record.
531
- ushort_td copylen = std::min<ushort_td>(kl, datalen);
532
- if (keyVarlen)
797
+ memset(to, 0x00, keylen + 1); //clear plus null byte
798
+ if (isNullable())
533
799
  {
534
- if (datalen==0xff)
535
- copylen = (ushort_td)std::min<uint_td>((uint_td)copylen,
536
- keyDataLen(from));
537
- // Var size is allways 2byte for key.
538
- memcpy(to, &copylen, 2);
539
- to += 2;
540
- if (datalen==0xff)
541
- from = keyData(from);
800
+ // mysql only
801
+ if (isNull)
802
+ {
803
+ *to = 1;
804
+ return to + 1 + keylen - keyVarlen;
805
+ }else
806
+ ++to;
542
807
  }
543
- memcpy(to, from, copylen);
544
- return to + kl - keyVarlen;// incremnt 2 + (store_len - varlen)
808
+ if(!isNull)
809
+ {
810
+ if (keyVarlen)
811
+ {
812
+ if (datalen==0xff)
813
+ copylen = (ushort_td)std::min<uint_td>((uint_td)copylen,
814
+ keyDataLen(from));
815
+ // Var size is allways 2byte for key.
816
+ memcpy(to, &copylen, 2);
817
+ to += 2;
818
+ if (datalen==0xff)
819
+ from = keyData(from);
820
+ }
821
+ memcpy(to, from, copylen);
822
+ }
823
+ return to + keylen - keyVarlen;// incremnt 2 + (store_len - varlen)
545
824
  }
546
825
 
547
-
548
826
  inline const uchar_td* blobDataPtr(const uchar_td* ptr) const
549
827
  {
550
828
  int blen = blobLenBytes();
@@ -572,7 +850,7 @@ public:
572
850
  if (((type >= ft_myvarchar) && (type <= ft_mywvarbinary)) ||
573
851
  (type == ft_lstring))
574
852
  return len < 256 ? 1 : 2;
575
- else if ((type == ft_myblob) || (type == ft_mytext))
853
+ else if (isBlob())
576
854
  return len - 8;
577
855
  return 0;
578
856
  }
@@ -626,7 +904,7 @@ public:
626
904
 
627
905
  inline void setPadCharDefaultSettings()
628
906
  {
629
- if (!padCharOptionSaved())
907
+ if (!isPadCharOptionSaved())
630
908
  {
631
909
  // For compatibility with conventional.
632
910
  if ((type == ft_string) || (type == ft_wstring) ||
@@ -640,37 +918,153 @@ public:
640
918
  m_padCharOptions |= USE_PAD_CHAR;
641
919
  }
642
920
 
643
- /* PadChar options are saved at schema.
921
+
644
922
  /* PadChar options are saved at schema.
645
923
  This is for compatibility with conventional.*/
646
- bool padCharOptionSaved() const
924
+ bool isPadCharOptionSaved() const
647
925
  {
648
926
  return (m_padCharOptions & PAD_CHAR_OPTION_SAVED) == PAD_CHAR_OPTION_SAVED;
649
927
  }
928
+ #ifdef SP_SCOPE_FIELD_TEST
929
+ public:
930
+ #endif
931
+ inline uchar_td nullbit() const {return m_nullbit;} // bit number for null indicator
932
+ inline uchar_td nullbytes() const {return m_nullbytes;} // byte of null indicator which head of record memory block.
933
+ inline void setOptions(uchar_td v) {m_options = v;}
934
+ private:
650
935
 
651
- /** @endcond */
652
- };
936
+ /** Length of compare
937
+ * if part of string or zstring then return strlen * sizeof(char or wchar).
938
+ */
939
+ inline uint_td compDataLen(const uchar_td* ptr, bool part) const
940
+ {
941
+ uint_td length = keyDataLen(ptr);
942
+ if (part)
943
+ {
944
+ if ((type == ft_string) || (type == ft_zstring) ||
945
+ (type == ft_note) || (type == ft_mychar))
946
+ length = (uint_td)strlen((const char*)ptr);
947
+ else if ((type == ft_wstring) || (type == ft_wzstring) ||
948
+ (type == ft_mywchar))
949
+ length = (uint_td)strlen16((char16_t*)ptr)*sizeof(char16_t);
950
+ }
951
+ return length;
952
+ }
953
+
954
+ short synchronize(const fielddef* td);
955
+
956
+ void fixCharnum_bug();
957
+
958
+ friend class client::database;
959
+ friend class client::dbdef;
960
+ friend class client::field;
961
+ friend class client::fields;
962
+ friend class client::recordCache;
963
+ friend class client::fielddefs;
964
+ friend class client::memoryRecord;
965
+ friend class client::filter;
966
+ friend class client::table;
967
+ friend struct client::logic;
968
+ friend class client::recordsetQuery;
969
+ friend class client::sqlBuilder;
970
+ friend class mysql::schemaBuilder;
971
+ friend struct tabledef;
653
972
 
654
- namespace client
973
+ /** @cond INTERNAL */
974
+ friend uint_td dataLen(const fielddef& fd, const uchar_td* ptr);
975
+ friend uint_td blobDataLen(const fielddef& fd, const uchar_td* ptr);
976
+ friend uint_td blobLenBytes(const fielddef& fd);
977
+ /** @endcond */
978
+ };
979
+
980
+ /** @cond INTERNAL */
981
+ inline void updateTimeStampStr(const fielddef* fd, char* p, size_t size)
655
982
  {
656
- class dbdef;
657
- }
983
+ if (fd->isLegacyTimeFormat())
984
+ sprintf_s(p, 64, " ON UPDATE CURRENT_TIMESTAMP");
985
+ else
986
+ sprintf_s(p, 64, " ON UPDATE CURRENT_TIMESTAMP(%d)", fd->decimals);
987
+ }
988
+
989
+ #ifdef _WIN32
990
+ inline void updateTimeStampStr(const fielddef* fd, wchar_t* p, size_t size)
991
+ {
992
+ if (fd->isLegacyTimeFormat())
993
+ swprintf_s(p, 64, L" ON UPDATE CURRENT_TIMESTAMP");
994
+ else
995
+ {
996
+ int dec = (fd->type == ft_mytimestamp) ? (fd->len - 4) * 2 : (fd->len - 5) * 2;
997
+ swprintf_s(p, 64, L" ON UPDATE CURRENT_TIMESTAMP(%d)",dec);
998
+ }
999
+ }
1000
+ #endif
1001
+
1002
+ inline uint_td dataLen(const fielddef& fd, const uchar_td* ptr)
1003
+ {
1004
+ return fd.dataLen(ptr);
1005
+ }
1006
+
1007
+ inline uint_td blobDataLen(const fielddef& fd, const uchar_td* ptr)
1008
+ {
1009
+ return fd.blobDataLen(ptr);
1010
+ }
1011
+
1012
+ inline uint_td blobLenBytes(const fielddef& fd)
1013
+ {
1014
+ return fd.blobLenBytes();
1015
+ }
1016
+
1017
+ inline _TCHAR* timeStampDefaultStr(const fielddef& fd, _TCHAR* buf, size_t bufsize)
1018
+ {
1019
+ if (fd.type == ft_mytimestamp || fd.type == ft_mydatetime)
1020
+ {
1021
+ buf[0] = 0x00;
1022
+ if (fd.isLegacyTimeFormat())
1023
+ _stprintf_s(buf, bufsize, _T("CURRENT_TIMESTAMP"));
1024
+ else
1025
+ _stprintf_s(buf, bufsize, _T("CURRENT_TIMESTAMP(%d)"), fd.decimals);
1026
+ }
1027
+ return buf;
1028
+ }
1029
+
1030
+
1031
+ /** @endcond */
1032
+
1033
+ #define FORMAT_VERSON_BTRV_DEF 0
1034
+ #define FORMAT_VERSON_CURRENT 1
1035
+
658
1036
 
659
1037
  /* Mark of ** that BizStation Corp internal use only.
660
1038
  */
661
1039
  struct PACKAGE tabledef
662
1040
  {
663
1041
  friend class client::dbdef; // for formatVersion
664
-
665
- tabledef() { cleanup(); }
666
-
1042
+ friend class client::table; // for inUse
1043
+ friend class client::database; // for m_mysqlNullMode
1044
+ friend struct client::openTablePrams;
1045
+ friend struct client::dbdimple;
1046
+ friend class client::filter;
1047
+ friend class client::recordCache;
1048
+ friend class client::fielddefs;
1049
+ friend class client::sqlBuilder;
1050
+ friend class mysql::schemaBuilder;
1051
+
1052
+
1053
+ tabledef()
1054
+ {
1055
+ cleanup();
1056
+ }
667
1057
  void cleanup()
668
1058
  {
669
1059
  memset(this, 0, sizeof(tabledef));
670
- formatVersion = 1;
1060
+ formatVersion = FORMAT_VERSON_CURRENT;
671
1061
  primaryKeyNum = -1;
672
1062
  parentKeyNum = -1;
673
1063
  replicaKeyNum = -1;
674
1064
  pageSize = 2048;
1065
+ schemaCodePage = 65001;//CP_UTF8
1066
+
1067
+ // set temp server version
1068
+ m_useInMariadb = true;
675
1069
  }
676
1070
 
677
1071
  #ifdef _UNICODE
@@ -678,8 +1072,8 @@ struct PACKAGE tabledef
678
1072
  const wchar_t* tableName() const; // table name
679
1073
  void setFileName(const wchar_t* s);
680
1074
  void setTableName(const wchar_t* s);
681
- const char* toChar(char* buf, const wchar_t* s, int size);
682
-
1075
+ private:
1076
+ const char* toChar(char* buf, const wchar_t* s, int size) const;
683
1077
  #else
684
1078
  #ifdef MYSQL_DYNAMIC_PLUGIN
685
1079
 
@@ -690,8 +1084,8 @@ struct PACKAGE tabledef
690
1084
  inline void setFileName(const char* s) { setFileNameA(s); };
691
1085
 
692
1086
  inline void setTableName(const char* s) { setTableNameA(s); };
693
-
694
- inline const char* toChar(char* buf, const char* s, int size)
1087
+ private:
1088
+ inline const char* toChar(char* buf, const char* s, int size) const
695
1089
  {
696
1090
  strncpy_s(buf, size, s, size - 1);
697
1091
  return buf;
@@ -701,10 +1095,11 @@ struct PACKAGE tabledef
701
1095
  const char* tableName() const;
702
1096
  void setFileName(const char* s);
703
1097
  void setTableName(const char* s);
704
- const char* toChar(char* buf, const char* s, int size);
1098
+ private:
1099
+ const char* toChar(char* buf, const char* s, int size) const;
705
1100
  #endif // MYSQL_DYNAMIC_PLUGIN
706
1101
  #endif
707
-
1102
+ public:
708
1103
  const char* fileNameA() const { return m_fileName; };
709
1104
 
710
1105
  const char* tableNameA() const { return m_tableName; };
@@ -719,9 +1114,77 @@ struct PACKAGE tabledef
719
1114
  strncpy_s(m_tableName, TABLE_NAME_SIZE, s, sizeof(m_tableName) - 1);
720
1115
  }
721
1116
 
1117
+ inline uchar_td nullfields() const { return m_nullfields;}
1118
+
1119
+ inline uchar_td nullbytes() const { return m_nullbytes; }
1120
+
1121
+ inline uchar_td inUse() const { return m_inUse; }
1122
+
1123
+ int size() const;
1124
+ short fieldNumByName(const _TCHAR* name) const;
1125
+
1126
+ inline ushort_td recordlen() const { return m_maxRecordLen; }
1127
+
722
1128
  uint_td unPack(char* ptr, size_t size) const;
1129
+
1130
+ inline void setValidationTarget(bool isMariadb, uchar_td srvMinorVersion)
1131
+ {
1132
+ m_useInMariadb = isMariadb;
1133
+ m_srvMinorVer = srvMinorVersion;
1134
+ }
1135
+
1136
+ inline bool isMysqlNullMode() const { return m_mysqlNullMode; }
1137
+
1138
+ inline bool isLegacyTimeFormat(const fielddef& fd) const
1139
+ {
1140
+ if (fd.type == ft_mytime || fd.type == ft_mydatetime ||
1141
+ fd.type == ft_mytimestamp)
1142
+ {
1143
+ if (m_useInMariadb)
1144
+ {
1145
+ if (fd.decimals == 0 && (m_srvMinorVer == 5 || m_srvMinorVer == 0)) return true;
1146
+ }
1147
+ else
1148
+ {
1149
+ if (m_srvMinorVer < 6) return true;
1150
+ }
1151
+ }
1152
+ return false;
1153
+ }
1154
+ bool operator==(const tabledef& r) const;
1155
+
1156
+ private:
1157
+ short synchronize(const tabledef* td);
1158
+ bool isNullKey(const keydef& key) const;
723
1159
  uint_td pack(char* ptr, size_t size) const;
1160
+ short findKeynumByFieldNum(short fieldNum) const;
1161
+ inline ushort_td recordlenServer() const
1162
+ {
1163
+ if (optionFlags.bitC) return m_maxRecordLen + 2;
1164
+ return m_maxRecordLen;
1165
+ }
1166
+ bool isNeedNis(const keydef& key) const;
1167
+ bool isNULLFieldFirstKeySegField(const keydef& key) const;
1168
+ bool isNullValueZeroAll(const keydef& key) const;
1169
+ void setMysqlNullMode(bool v);
1170
+ void calcReclordlen(bool force= false);
1171
+ inline keydef* setKeydefsPtr()
1172
+ {
1173
+ return keyDefs = (keydef*)((char*)this + sizeof(tabledef) +
1174
+ (fieldCount * sizeof(fielddef)));
1175
+ }
724
1176
 
1177
+ inline fielddef* setFielddefsPtr()
1178
+ {
1179
+ return fieldDefs = (fielddef*)((char*)this + sizeof(tabledef));
1180
+ }
1181
+
1182
+ inline bool isMariaTimeFormat() const
1183
+ {
1184
+ return (m_useInMariadb && (m_srvMajorVer == 5 || m_srvMinorVer == 0));
1185
+ }
1186
+
1187
+ public:
725
1188
  ushort_td id; // table id
726
1189
 
727
1190
  #ifdef SWIG
@@ -748,16 +1211,27 @@ private:
748
1211
  char m_tableName[TABLE_NAME_SIZE];
749
1212
 
750
1213
  public:
751
- short version; // table version
752
- uchar_td charsetIndex; // SCHARSET_INFO vector index;
753
- uchar_td filler0[17]; // reserved
1214
+ short version; // table version
1215
+ uchar_td charsetIndex; // SCHARSET_INFO vector index;
1216
+ private:
1217
+ uchar_td m_nullfields; // number of nullable field
1218
+ uchar_td m_nullbytes; // number of null indicator byte
1219
+ uchar_td m_inUse;
1220
+ bool m_mysqlNullMode ; // use in mysqlnull mode
1221
+ bool m_useInMariadb ; // use in mariadb
1222
+ uchar_td m_srvMajorVer; // server major version;
1223
+ uchar_td m_srvMinorVer; // server minor version;
1224
+ uchar_td m_filler0[10]; // reserved
1225
+ public:
754
1226
  FLAGS flags; // file flags
755
1227
  uchar_td primaryKeyNum; // Primary key number. -1 is no primary.
756
1228
  uchar_td parentKeyNum; // ** Key number for listview. -1 is no use.
757
1229
  uchar_td replicaKeyNum; // ** Key number for repdata. -1 is no use.
758
1230
  FLAGS optionFlags; // ** optional flags
759
1231
  ushort_td convertFileNum; // ** not use
760
- ushort_td maxRecordLen; // max record length of var size table.
1232
+ private:
1233
+ ushort_td m_maxRecordLen; // max record length of var size table.
1234
+ public:
761
1235
  uchar_td treeIndex; // ** View index for listview.
762
1236
  uchar_td iconIndex; // ** Icon index for listview.
763
1237
  ushort_td ddfid;
@@ -769,15 +1243,18 @@ public:
769
1243
 
770
1244
  private:
771
1245
  char formatVersion;
772
-
773
- public:
774
1246
  client::dbdef* parent;
1247
+ void* defaultImage;
775
1248
  uchar_td reserved[TABLEDEF_FILLER_SIZE]; // reserved
776
-
1249
+ public:
777
1250
  fielddef* fieldDefs; // Pointer cahche of first field.
778
1251
  keydef* keyDefs; // Pointer cahche of first key.
779
1252
  };
780
1253
 
1254
+ // sizeof(fielddef) * 255 + sizeof(keydef) * 64 + sizeof(tabledef)
1255
+ // (124 * 255) + (26 * 64) + 388 = 31620 + 1664 + 388 = 33672
1256
+ #define MAX_SCHEMASIZE 33672
1257
+
781
1258
  /* optionFlags BizStation internal use only.
782
1259
  Bit0 send windows messege.
783
1260
  Bit1 show tree view.
@@ -791,6 +1268,7 @@ public:
791
1268
  Bit9 Can export this table.
792
1269
  BitA is this table include valiable fields (varchar or varbinary is used)
793
1270
  BitB is this table include blob field (Blob is used)
1271
+ BitC is this table include fixedbinary
794
1272
  */
795
1273
 
796
1274
  struct PACKAGE btrVersion
@@ -801,6 +1279,33 @@ struct PACKAGE btrVersion
801
1279
 
802
1280
  const _TCHAR* moduleVersionShortString(_TCHAR* buf);
803
1281
  const _TCHAR* moduleTypeString();
1282
+
1283
+ inline bool isSupportDateTimeTimeStamp() const
1284
+ {
1285
+ if (majorVersion >= 10) return true;
1286
+ if ((majorVersion == 5) && (minorVersion > 5)) return true;
1287
+ return false;
1288
+ }
1289
+
1290
+ inline bool isSupportMultiTimeStamp() const
1291
+ {
1292
+ return isSupportDateTimeTimeStamp();
1293
+ }
1294
+
1295
+ inline bool isMariaDB() const { return type == MYSQL_TYPE_MARIA; }
1296
+
1297
+ inline bool isMysql56TimeFormat() const
1298
+ {
1299
+ if ((majorVersion == 10) && (minorVersion >= 1)) return true;
1300
+ if ((majorVersion == 5) && (minorVersion >= 6)) return true;
1301
+ return false;
1302
+ }
1303
+
1304
+ inline bool isFullLegacyTimeFormat() const
1305
+ {
1306
+ return !isMariaDB() && (minorVersion < 6);
1307
+ }
1308
+
804
1309
  };
805
1310
 
806
1311
  struct btrVersions
@@ -808,29 +1313,16 @@ struct btrVersions
808
1313
  btrVersion versions[4];
809
1314
  };
810
1315
 
1316
+ #define VER_IDX_CLINET 0
1317
+ #define VER_IDX_DB_SERVER 1
1318
+ #define VER_IDX_PLUGIN 2
1319
+
1320
+
1321
+
1322
+
811
1323
  #pragma pack(pop)
812
1324
  pragma_pop;
813
1325
 
814
- /* filter cobine type */
815
- enum combineType
816
- {
817
- eCend,
818
- eCand,
819
- eCor
820
- };
821
-
822
- /* compair types */
823
- enum eCompType
824
- {
825
- eEqual = 1,
826
- eGreater = 2,
827
- eLess = 3,
828
- eNotEq = 4,
829
- eGreaterEq = 5,
830
- eLessEq = 6,
831
- eBitAnd = 8,
832
- eNotBitAnd = 9
833
- };
834
1326
 
835
1327
  PACKAGE uchar_td getFilterLogicTypeCode(const _TCHAR* cmpstr);
836
1328