transactd 2.2.0 → 2.3.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 (114) hide show
  1. checksums.yaml +4 -4
  2. data/BUILD_UNIX-JA +6 -6
  3. data/README +20 -18
  4. data/README-JA +19 -17
  5. data/RELEASE_NOTE +144 -0
  6. data/RELEASE_NOTE-JA +153 -0
  7. data/bin/common/tdclc_32_2_3.dll +0 -0
  8. data/bin/common/tdclc_64_2_3.dll +0 -0
  9. data/build/common/get_ruby_path.cmake +1 -1
  10. data/build/swig/ruby/ruby.swg +10 -9
  11. data/build/swig/ruby/tdclrb_wrap.cpp +1416 -561
  12. data/build/swig/tdcl.i +30 -3
  13. data/build/tdclc/tdclc.cbproj +1 -1
  14. data/build/tdclc/tdclc.rc +4 -4
  15. data/build/tdclcpp/BUILDNUMBER.txt +1 -0
  16. data/build/tdclcpp/tdclcpp.rc +4 -4
  17. data/build/tdclcpp/tdclcpp_bc.cbproj +1 -1
  18. data/build/tdclrb/BUILDNUMBER.txt +1 -0
  19. data/build/tdclrb/tdclrb.rc +4 -4
  20. data/source/bzs/db/engine/mysql/database.cpp +85 -41
  21. data/source/bzs/db/engine/mysql/database.h +35 -5
  22. data/source/bzs/db/engine/mysql/mysqlInternal.h +189 -37
  23. data/source/bzs/db/engine/mysql/mysqlThd.cpp +21 -21
  24. data/source/bzs/db/protocol/tdap/client/activeTable.cpp +11 -0
  25. data/source/bzs/db/protocol/tdap/client/activeTable.h +1 -1
  26. data/source/bzs/db/protocol/tdap/client/activeTableImple.h +11 -4
  27. data/source/bzs/db/protocol/tdap/client/client.h +30 -1
  28. data/source/bzs/db/protocol/tdap/client/dbDef.cpp +2 -1
  29. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +35 -5
  30. data/source/bzs/db/protocol/tdap/client/field.cpp +100 -51
  31. data/source/bzs/db/protocol/tdap/client/field.h +7 -7
  32. data/source/bzs/db/protocol/tdap/client/filter.h +20 -6
  33. data/source/bzs/db/protocol/tdap/client/groupQuery.cpp +337 -58
  34. data/source/bzs/db/protocol/tdap/client/groupQuery.h +56 -13
  35. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +83 -5
  36. data/source/bzs/db/protocol/tdap/client/nsDatabase.h +4 -1
  37. data/source/bzs/db/protocol/tdap/client/nsTable.cpp +2 -2
  38. data/source/bzs/db/protocol/tdap/client/nsTable.h +2 -1
  39. data/source/bzs/db/protocol/tdap/client/pooledDatabaseManager.h +20 -6
  40. data/source/bzs/db/protocol/tdap/client/recordset.cpp +7 -0
  41. data/source/bzs/db/protocol/tdap/client/recordsetImple.h +8 -4
  42. data/source/bzs/db/protocol/tdap/client/request.h +11 -1
  43. data/source/bzs/db/protocol/tdap/client/serializer.cpp +40 -2
  44. data/source/bzs/db/protocol/tdap/client/serializer.h +4 -2
  45. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +1 -0
  46. data/source/bzs/db/protocol/tdap/client/stringConverter.h +4 -4
  47. data/source/bzs/db/protocol/tdap/client/table.cpp +124 -71
  48. data/source/bzs/db/protocol/tdap/client/table.h +8 -7
  49. data/source/bzs/db/protocol/tdap/client/trdormapi.h +33 -1
  50. data/source/bzs/db/protocol/tdap/fieldComp.h +1 -1
  51. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +3 -1
  52. data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +20 -4
  53. data/source/bzs/db/protocol/tdap/mysql/request.h +14 -0
  54. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +132 -69
  55. data/source/bzs/db/protocol/tdap/tdapRequest.h +18 -4
  56. data/source/bzs/db/protocol/tdap/tdapSchema.cpp +32 -22
  57. data/source/bzs/db/protocol/tdap/tdapSchema.h +69 -4
  58. data/source/bzs/db/protocol/tdap/tdapcapi.h +13 -5
  59. data/source/bzs/db/protocol/tdap/uri.h +4 -4
  60. data/source/bzs/db/transactd/transactd.cpp +6 -5
  61. data/source/bzs/env/crosscompile.cpp +17 -0
  62. data/source/bzs/env/crosscompile.h +4 -1
  63. data/source/bzs/env/mbcswchrLinux.cpp +3 -0
  64. data/source/bzs/example/deleteRecords.cpp +13 -0
  65. data/source/bzs/example/deleteRecords_c.cpp +8 -1
  66. data/source/bzs/example/insertRecords.cpp +14 -0
  67. data/source/bzs/example/insertRecords_c.cpp +8 -1
  68. data/source/bzs/example/ormap_c.cpp +8 -1
  69. data/source/bzs/example/queryData.cpp +92 -2
  70. data/source/bzs/example/queryData.h +3 -1
  71. data/source/bzs/example/readRecords.cpp +13 -0
  72. data/source/bzs/example/readRecords_c.cpp +8 -1
  73. data/source/bzs/example/updateRecords.cpp +13 -0
  74. data/source/bzs/example/updateRecords_c.cpp +8 -1
  75. data/source/bzs/example/update_with_transaction.cpp +13 -0
  76. data/source/bzs/example/update_with_transaction_c.cpp +8 -1
  77. data/source/bzs/example/useORMRecord.cpp +9 -3
  78. data/source/bzs/netsvc/client/iconnection.h +8 -0
  79. data/source/bzs/netsvc/client/tcpClient.cpp +61 -16
  80. data/source/bzs/netsvc/client/tcpClient.h +430 -214
  81. data/source/bzs/netsvc/server/serverPipe.cpp +2 -2
  82. data/source/bzs/test/tdclphp/transactd_Test.php +115 -19
  83. data/source/bzs/test/tdclphp/transactd_blob_Test.php +33 -5
  84. data/source/bzs/test/tdclphp/transactd_kanjischema_Test.php +21 -3
  85. data/source/bzs/test/tdclphp/transactd_pool_Test.php +17 -3
  86. data/source/bzs/test/tdclrb/transactd_blob_spec.rb +26 -8
  87. data/source/bzs/test/tdclrb/transactd_kanjischema_spec.rb +13 -6
  88. data/source/bzs/test/tdclrb/transactd_pool_spec.rb +14 -8
  89. data/source/bzs/test/tdclrb/transactd_spec.rb +117 -27
  90. data/source/bzs/test/transactdBench/scaling_bench.cpp +5 -5
  91. data/source/bzs/test/transactdBench/workerBase.h +2 -2
  92. data/source/bzs/test/trdclengn/test_trdclengn.cpp +898 -51
  93. data/source/global/tdclatl/Database.cpp +12 -0
  94. data/source/global/tdclatl/Database.h +4 -0
  95. data/source/global/tdclatl/FieldDef.cpp +19 -0
  96. data/source/global/tdclatl/FieldDef.h +4 -0
  97. data/source/global/tdclatl/FieldDefs.cpp +14 -16
  98. data/source/global/tdclatl/GroupQuery.cpp +21 -16
  99. data/source/global/tdclatl/GroupQuery.h +1 -1
  100. data/source/global/tdclatl/QueryBase.cpp +14 -0
  101. data/source/global/tdclatl/QueryBase.h +2 -0
  102. data/source/global/tdclatl/Record.cpp +41 -10
  103. data/source/global/tdclatl/Record.h +1 -1
  104. data/source/global/tdclatl/Recordset.cpp +117 -31
  105. data/source/global/tdclatl/Recordset.h +6 -5
  106. data/source/global/tdclatl/Table.cpp +24 -28
  107. data/source/global/tdclatl/Table.h +3 -4
  108. data/source/global/tdclatl/activeTable.cpp +149 -103
  109. data/source/global/tdclatl/activeTable.h +1 -1
  110. data/source/global/tdclatl/tdclatl.idl +38 -18
  111. data/transactd.gemspec +1 -1
  112. metadata +8 -4
  113. data/bin/common/tdclc_32_2_2.dll +0 -0
  114. data/bin/common/tdclc_64_2_2.dll +0 -0
@@ -66,7 +66,7 @@ inline const _TCHAR* hostName(const _TCHAR* uri, _TCHAR* buf, size_t size)
66
66
  if (st)
67
67
  {
68
68
  const _TCHAR* en = _tcsstr(st, _T("/"));
69
- if (en)
69
+ if (en && en > st)
70
70
  {
71
71
  _tcsncpy_s(buf, size, st, en - st);
72
72
  buf[en - st] = 0x00;
@@ -85,7 +85,7 @@ inline const _TCHAR* dbname(const _TCHAR* uri, _TCHAR* buf, size_t size)
85
85
  if (st)
86
86
  {
87
87
  const _TCHAR* en = _tcsstr(st + 1, _T("?"));
88
- if (en)
88
+ if (en && en > st)
89
89
  {
90
90
  _tcsncpy_s(buf, size, st + 1, en - (st + 1));
91
91
  buf[en - (st + 1)] = 0x00;
@@ -103,7 +103,7 @@ inline const _TCHAR* schemaTable(const _TCHAR* uri, _TCHAR* buf, size_t size)
103
103
  {
104
104
  st+= 7;
105
105
  const _TCHAR* en = _tcsrchr(uri, _T('.'));
106
- if (en)
106
+ if (en && en > st)
107
107
  {
108
108
  _tcsncpy_s(buf, size, st, en - st);
109
109
  buf[en - st] = 0x00;
@@ -122,7 +122,7 @@ inline const _TCHAR* userName(const _TCHAR* uri, _TCHAR* buf, size_t size)
122
122
  if (st)
123
123
  {
124
124
  const _TCHAR* en = _tcsstr(st, _T("@"));
125
- if (en)
125
+ if (en && en > st)
126
126
  {
127
127
  _tcsncpy_s(buf, size, st, en - st);
128
128
  buf[en - st] = 0x00;
@@ -35,8 +35,9 @@
35
35
 
36
36
  /** tcp server type
37
37
  */
38
- #define TCP_CPT_SERVER 1
39
- #define TCP_TPOOL_SERVER 2
38
+ #define TCP_CPT_SERVER 1
39
+ #define TCP_TPOOL_SERVER 2
40
+ #define PIPE_SHARE_MEM_SIZE 6292480 // 6Mbyte + 1024
40
41
 
41
42
  using namespace bzs::netsvc::server;
42
43
 
@@ -50,7 +51,7 @@ static unsigned int g_tcpServerType = TCP_CPT_SERVER;
50
51
 
51
52
  static unsigned int g_maxTcpConnections = 200;
52
53
  static unsigned int g_pool_threads = 20;
53
- unsigned int g_pipeCommSharememSize = 3145728;
54
+ unsigned int g_pipeCommSharememSize = PIPE_SHARE_MEM_SIZE;
54
55
  int g_tableNmaeLower = 1; // defined in btrvProtocol.h
55
56
  unsigned int g_lock_wait_timeout = 1;
56
57
  char* g_transaction_isolation = NULL;
@@ -257,8 +258,8 @@ static MYSQL_SYSVAR_STR(auth_type, g_auth_type,
257
258
  */
258
259
  #ifdef PIPE_SERVER
259
260
  static MYSQL_SYSVAR_UINT(pipe_comm_sharemem_size, g_pipeCommSharememSize,
260
- PLUGIN_VAR_READONLY, "66000..52428800", 0, 0, 3145728,
261
- 66000, 52428800, 0);
261
+ PLUGIN_VAR_READONLY, "66000..52428800 ", 0, 0, PIPE_SHARE_MEM_SIZE,
262
+ 66000, 52428800, 0);
262
263
  static MYSQL_SYSVAR_UINT(max_pipe_connections, g_maxPipeConnections,
263
264
  PLUGIN_VAR_READONLY, "1..100", 0, 0, 50, 1, 100, 0);
264
265
  static MYSQL_SYSVAR_INT(use_piped_local, g_usePipedLocal, PLUGIN_VAR_READONLY,
@@ -114,6 +114,23 @@ int wcsncmp16(const char16_t* sl, const char16_t* sr, size_t n)
114
114
  return 0 - *sr;
115
115
  }
116
116
 
117
+ int wmemcmp16(const char16_t* sl, const char16_t* sr, size_t n)
118
+ {
119
+ if (n == 0)
120
+ return 0;
121
+ while (1)
122
+ {
123
+ if (*sl != *sr)
124
+ return (int)(*sl - *sr);
125
+ if (--n == 0)
126
+ return 0;
127
+ ++sl;
128
+ ++sr;
129
+ }
130
+ return 0 - *sr;
131
+ }
132
+
133
+
117
134
  char16_t* wmemset16(char16_t* p, char16_t c, size_t n)
118
135
  {
119
136
  char16_t* end = p + n;
@@ -78,9 +78,11 @@ char16_t* _strlwr16(char16_t* s);
78
78
  size_t strlen16(const char16_t* src);
79
79
  int wcsnicmp16(const char16_t* sl, const char16_t* sr, size_t n);
80
80
  int wcsncmp16(const char16_t* sl, const char16_t* sr, size_t n);
81
+ int wmemcmp16(const char16_t* sl, const char16_t* sr, size_t n);
81
82
  char16_t* wmemset16(char16_t* p, char16_t c, size_t n);
82
83
  char16_t* wmemcpy(char16_t* dest, const char16_t* src, size_t count);
83
84
 
85
+
84
86
  /* operating system */
85
87
  #ifndef _TCHAR
86
88
  #define _TCHAR char
@@ -143,8 +145,9 @@ typedef unsigned __int32 char32_t; // 32bit
143
145
  #define wcsnicmp16(A, B, C) \
144
146
  _wcsnicmp((const wchar_t*)(A), (const wchar_t*)(B), C)
145
147
  #define wcsncmp16(A, B, C) wcsncmp((const wchar_t*)(A), (const wchar_t*)(B), C)
148
+ #define wmemcmp16(A, B, C) wmemcmp((const wchar_t*)(A), (const wchar_t*)(B), C)
146
149
  #define wmemset16 wmemset
147
- #define strlen16 wcslen
150
+ #define strlen16(A) wcslen((const wchar_t*)(A))
148
151
 
149
152
  /* operating system */
150
153
  #define PSEPARATOR _T("\\")
@@ -42,6 +42,7 @@ void initCvtProcess()
42
42
  {
43
43
  int ret = pthread_key_create(&g_tls1, cleanupTls);
44
44
  assert(ret == 0);
45
+ pthread_setspecific(g_tls1, NULL);
45
46
  }
46
47
 
47
48
  void deinitCvtProcess()
@@ -51,6 +52,8 @@ void deinitCvtProcess()
51
52
 
52
53
  cvt& getCvt(int index)
53
54
  {
55
+ if (g_tls1 == 0)
56
+ initCvtProcess();
54
57
  cvt* p = (cvt*)pthread_getspecific(g_tls1);
55
58
  if (p == NULL)
56
59
  {
@@ -48,6 +48,19 @@ bool deleteUser(table* tb)
48
48
  */
49
49
  bool openDatabase(database* db, const _TCHAR* uri)
50
50
  {
51
+ /******************************************************
52
+ !!! Important !!!
53
+ When using a multi-threaded,
54
+ please request a new connection for each database.
55
+ *******************************************************/
56
+ // When using a multi-threaded, set to true.
57
+ bool newConnection = false;
58
+ if (!db->connect(uri, newConnection))
59
+ {
60
+ showError(_T("connect daatabase"), NULL, db->stat());
61
+ return false;
62
+ }
63
+
51
64
  db->open(uri, TYPE_SCHEMA_BDF);
52
65
  if (db->stat() != 0)
53
66
  {
@@ -37,7 +37,14 @@ int _tmain(int argc, _TCHAR* argv[])
37
37
  {
38
38
  connectParams param(_T("tdap"), _T("localhost"), _T("test"),
39
39
  _T("test"));
40
- openDatabase(db, param);
40
+ /******************************************************
41
+ !!! Important !!!
42
+ When using a multi-threaded,
43
+ please request a new connection for each database.
44
+ *******************************************************/
45
+ // When using a multi-threaded, set to true.
46
+ bool newConnection = false;
47
+ connectOpen(db, param, newConnection);
41
48
 
42
49
  table_ptr tb = openTable(db, _T("user"));
43
50
  deleteUser(tb);
@@ -161,6 +161,20 @@ void readImage(const _TCHAR* path, std::vector<char>& s)
161
161
  */
162
162
  bool openDatabase(database* db, const _TCHAR* uri)
163
163
  {
164
+ /******************************************************
165
+ !!! Important !!!
166
+ When using a multi-threaded,
167
+ please request a new connection for each database.
168
+ *******************************************************/
169
+ // When using a multi-threaded, set to true.
170
+ bool newConnection = false;
171
+
172
+ if (!db->connect(uri, newConnection))
173
+ {
174
+ showError(_T("connect daatabase"), NULL, db->stat());
175
+ return false;
176
+ }
177
+
164
178
  db->open(uri, TYPE_SCHEMA_BDF);
165
179
  if (db->stat() != 0)
166
180
  {
@@ -121,7 +121,14 @@ int _tmain(int argc, _TCHAR* argv[])
121
121
  {
122
122
  connectParams param(_T("tdap"), _T("localhost"), _T("test"),
123
123
  _T("test"));
124
- openDatabase(db, param);
124
+ /******************************************************
125
+ !!! Important !!!
126
+ When using a multi-threaded,
127
+ please request a new connection for each database.
128
+ *******************************************************/
129
+ // When using a multi-threaded, set to true.
130
+ bool newConnection = false;
131
+ connectOpen(db, param, newConnection);
125
132
 
126
133
  table_ptr tb = openTable(db, _T("group1"));
127
134
  insertGroups(tb);
@@ -601,7 +601,14 @@ int _tmain(int argc, _TCHAR* argv[])
601
601
  {
602
602
  connectParams param(_T("tdap"), _T("localhost"), _T("test"),
603
603
  _T("test"));
604
- openDatabase(db, param);
604
+ /******************************************************
605
+ !!! Important !!!
606
+ When using a multi-threaded,
607
+ please request a new connection for each database.
608
+ *******************************************************/
609
+ // When using a multi-threaded, set to true.
610
+ bool newConnection = false;
611
+ connectOpen(db, param, newConnection);
605
612
 
606
613
  databaseManager mgr(db);
607
614
  std::vector<user_ptr> users;
@@ -214,6 +214,12 @@ bool createUserExtTable(dbdef* def)
214
214
  fd->type = BLOB_TYPE;
215
215
  #ifndef USE_PSQL_DATABASE
216
216
  fd->len = 10;
217
+ ++filedIndex;
218
+ fd = def->insertField(tableid, filedIndex);
219
+ fd->setName(_T("binary"));
220
+ fd->type = BLOB_TYPE;
221
+ fd->len = 10;
222
+
217
223
  #else
218
224
  fd->len = 16000;
219
225
  #endif
@@ -276,6 +282,69 @@ bool createCacheTable(dbdef* def)
276
282
  return true;
277
283
  }
278
284
 
285
+ bool createBlobOnlyTable(dbdef* def)
286
+ {
287
+ short tableid = 4;
288
+ tabledef t;
289
+ tabledef* td = &t;
290
+ td->charsetIndex = mysql::charsetIndex(GetACP());
291
+ td->schemaCodePage = CP_UTF8;
292
+ td->id = tableid;
293
+ td->setTableName(_T("blobonly"));
294
+ td->setFileName(_T("blobonly"));
295
+
296
+ def->insertTable(td);
297
+ if (def->stat() != 0)
298
+ return showDbdefError(def, _T("blobonly insertTable"));
299
+
300
+ short filedIndex = 0;
301
+ fielddef* fd = def->insertField(tableid, filedIndex);
302
+ fd->setName(_T("id"));
303
+ fd->type = ft_integer;
304
+ fd->len = 4;
305
+
306
+ ++filedIndex;
307
+ fd = def->insertField(tableid, filedIndex);
308
+ fd->setName(_T("binary"));
309
+ fd->type = BLOB_TYPE;
310
+ fd->len = 10;
311
+
312
+ char keyNum = 0;
313
+ keydef* kd = def->insertKey(tableid, keyNum);
314
+ keySegment* seg1 = &kd->segments[0];
315
+ seg1->fieldNum = 0;
316
+ seg1->flags.bit8 = true; // extended key type
317
+ seg1->flags.bit1 = true; // chanageable
318
+ kd->segmentCount = 1;
319
+ td = def->tableDefs(tableid);
320
+ td->primaryKeyNum = keyNum;
321
+ def->updateTableDef(tableid);
322
+ if (def->stat() != 0)
323
+ return showDbdefError(def, _T("blobonly updateTableDef"));
324
+ return true;
325
+ }
326
+
327
+ void fillBlobField(short fieldNum, int id, table* tb, unsigned char* buf)
328
+ {
329
+ for (int j = 0 ; j < 256 ; ++j)
330
+ buf[j] = (unsigned char)(j + id);
331
+ tb->setFV(fieldNum, buf, 256);
332
+ }
333
+
334
+ bool compBlobField(int id, field& fd)
335
+ {
336
+ uint_td size;
337
+ unsigned char* p = (unsigned char*)fd.getBin(size);
338
+ if (size != 256) return false;
339
+
340
+ for (int j = 0 ; j < 256 ; ++j)
341
+ {
342
+ if (p[j] != (unsigned char)(j + id))
343
+ return false;
344
+ }
345
+ return true;
346
+ }
347
+
279
348
  bool insertData(database_ptr db, int maxId)
280
349
  {
281
350
  _TCHAR tmp[256];
@@ -300,6 +369,13 @@ bool insertData(database_ptr db, int maxId)
300
369
  return false;
301
370
  }
302
371
 
372
+ table* tbb = db->openTable(_T("blobonly"), TD_OPEN_NORMAL);
373
+ if (db->stat())
374
+ {
375
+ showDbError(db.get(), _T("openTable blobonly"));
376
+ return false;
377
+ }
378
+
303
379
  dbTransaction trn(db);
304
380
  trn.begin();
305
381
 
@@ -326,6 +402,7 @@ bool insertData(database_ptr db, int maxId)
326
402
  return showTableError(tbg, _T("groups insert"));
327
403
  }
328
404
 
405
+ unsigned char bin[256];
329
406
  tbe->clearBuffer();
330
407
  for (int i = 1; i <= maxId; ++i)
331
408
  {
@@ -334,15 +411,27 @@ bool insertData(database_ptr db, int maxId)
334
411
  tbe->setFV(1, tmp);
335
412
  _stprintf_s(tmp, 256, _T("%d blob"), i);
336
413
  tbe->setFV(2, tmp);
414
+ fillBlobField(3, i, tbe, bin);
337
415
  tbe->insert();
338
416
  if (tbe->stat() != 0)
339
417
  return showTableError(tbe, _T("extention insert"));
340
418
  }
341
419
 
420
+ tbb->clearBuffer();
421
+ for (int i = 1; i <= 10; ++i)
422
+ {
423
+ tbb->setFV((short)0, i);
424
+ fillBlobField(1, i, tbb, bin);
425
+ tbb->insert();
426
+ if (tbb->stat() != 0)
427
+ return showTableError(tbb, _T("blobonly insert"));
428
+ }
429
+
342
430
  trn.end();
343
431
  tbg->release();
344
432
  tbu->release();
345
433
  tbe->release();
434
+ tbb->release();
346
435
  return true;
347
436
  }
348
437
 
@@ -354,7 +443,7 @@ bool checkVersion(database_ptr db)
354
443
  tabledef* td = def->tableDefs(3);
355
444
  if (td)
356
445
  {
357
- if (td->fieldCount == 3)
446
+ if (td->fieldCount == 4)
358
447
  {
359
448
  table_ptr tb = openTable(db, _T("extention"));
360
449
  return (tb->recordCount(false) == 20000);
@@ -386,7 +475,8 @@ int prebuiltData(database_ptr db, const connectParams& param, bool foceCreate,
386
475
  return 1;
387
476
  if (!createUserExtTable(db->dbDef()))
388
477
  return 1;
389
-
478
+ if (!createBlobOnlyTable(db->dbDef()))
479
+ return 1;
390
480
  if (!insertData(db, maxId))
391
481
  return 1;
392
482
  std::tcout << _T("done!") << std::endl;
@@ -10,7 +10,9 @@ int prebuiltData(bzs::db::protocol::tdap::client::database_ptr db,
10
10
  bool foceCreate = false, int maxId = 20000);
11
11
 
12
12
  bool createCacheTable(bzs::db::protocol::tdap::client::dbdef* def);
13
-
13
+ void fillBlobField(short fieldNum, int id, bzs::db::protocol::tdap::client::table* tb,
14
+ unsigned char* buf);
15
+ bool compBlobField(int id, bzs::db::protocol::tdap::client::field& fd);
14
16
  const _TCHAR* name_field_str(_TCHAR* buf);
15
17
 
16
18
  #endif // BZS_EXSAMPLE_QUERYDATA_H
@@ -98,6 +98,19 @@ bool readUsers(table* tb, std::vector<user*>& users)
98
98
  */
99
99
  bool openDatabase(database* db, const _TCHAR* uri)
100
100
  {
101
+ /******************************************************
102
+ !!! Important !!!
103
+ When using a multi-threaded,
104
+ please request a new connection for each database.
105
+ *******************************************************/
106
+ // When using a multi-threaded, set to true.
107
+ bool newConnection = false;
108
+ if (!db->connect(uri, newConnection))
109
+ {
110
+ showError(_T("connect daatabase"), NULL, db->stat());
111
+ return false;
112
+ }
113
+
101
114
  db->open(uri, TYPE_SCHEMA_BDF);
102
115
  if (db->stat() != 0)
103
116
  {
@@ -86,7 +86,14 @@ int _tmain(int argc, _TCHAR* argv[])
86
86
  {
87
87
  connectParams param(_T("tdap"), _T("localhost"), _T("test"),
88
88
  _T("test"));
89
- openDatabase(db, param);
89
+ /******************************************************
90
+ !!! Important !!!
91
+ When using a multi-threaded,
92
+ please request a new connection for each database.
93
+ *******************************************************/
94
+ // When using a multi-threaded, set to true.
95
+ bool newConnection = false;
96
+ connectOpen(db, param, newConnection);
90
97
 
91
98
  table_ptr tb = openTable(db, _T("user"));
92
99
  std::vector<user_ptr> users;
@@ -60,6 +60,19 @@ bool updateUsers(table* tb)
60
60
  */
61
61
  bool openDatabase(database* db, const _TCHAR* uri)
62
62
  {
63
+ /******************************************************
64
+ !!! Important !!!
65
+ When using a multi-threaded,
66
+ please request a new connection for each database.
67
+ *******************************************************/
68
+ // When using a multi-threaded, set to true.
69
+ bool newConnection = false;
70
+ if (!db->connect(uri, newConnection))
71
+ {
72
+ showError(_T("connect daatabase"), NULL, db->stat());
73
+ return false;
74
+ }
75
+
63
76
  db->open(uri, TYPE_SCHEMA_BDF);
64
77
  if (db->stat() != 0)
65
78
  {
@@ -51,7 +51,14 @@ int _tmain(int argc, _TCHAR* argv[])
51
51
  {
52
52
  connectParams param(_T("tdap"), _T("localhost"), _T("test"),
53
53
  _T("test"));
54
- openDatabase(db, param);
54
+ /******************************************************
55
+ !!! Important !!!
56
+ When using a multi-threaded,
57
+ please request a new connection for each database.
58
+ *******************************************************/
59
+ // When using a multi-threaded, set to true.
60
+ bool newConnection = false;
61
+ connectOpen(db, param, newConnection);
55
62
 
56
63
  table_ptr tb = openTable(db, _T("user"));
57
64
  updateUsers(tb);
@@ -61,6 +61,19 @@ bool updateUsers(table* tb)
61
61
  */
62
62
  bool openDatabase(database* db, const _TCHAR* uri)
63
63
  {
64
+ /******************************************************
65
+ !!! Important !!!
66
+ When using a multi-threaded,
67
+ please request a new connection for each database.
68
+ *******************************************************/
69
+ // When using a multi-threaded, set to true.
70
+ bool newConnection = false;
71
+ if (!db->connect(uri, newConnection))
72
+ {
73
+ showError(_T("connect daatabase"), NULL, db->stat());
74
+ return false;
75
+ }
76
+
64
77
  db->open(uri, TYPE_SCHEMA_BDF);
65
78
  if (db->stat() != 0)
66
79
  {
@@ -51,7 +51,14 @@ int _tmain(int argc, _TCHAR* argv[])
51
51
  {
52
52
  connectParams param(_T("tdap"), _T("localhost"), _T("test"),
53
53
  _T("test"));
54
- openDatabase(db, param);
54
+ /******************************************************
55
+ !!! Important !!!
56
+ When using a multi-threaded,
57
+ please request a new connection for each database.
58
+ *******************************************************/
59
+ // When using a multi-threaded, set to true.
60
+ bool newConnection = false;
61
+ connectOpen(db, param, newConnection);
55
62
 
56
63
  table_ptr tb = openTable(db, _T("user"));
57
64
  dbTransaction trn(db);
@@ -156,11 +156,17 @@ int _tmain(int argc, _TCHAR* argv[])
156
156
  {
157
157
  connectParams param(_T("tdap"), _T("localhost"), _T("mri"),
158
158
  _T("dj32.bdf"));
159
- openDatabase(db, param);
160
- databaseManager mgr(db);
159
+ /******************************************************
160
+ !!! Important !!!
161
+ When using a multi-threaded,
162
+ please request a new connection for each database.
163
+ *******************************************************/
164
+ // When using a multi-threaded, set to true.
165
+ bool newConnection = false;
166
+ connectOpen(db, param, newConnection);
161
167
 
168
+ databaseManager mgr(db);
162
169
  recordset rowset;
163
-
164
170
  bzs::rtl::benchmark bm;
165
171
  bm.report(boost::bind(readUsers, &mgr, &rowset), "exec time ");
166
172
  showConsole(rowset);
@@ -22,10 +22,16 @@
22
22
  #pragma warn -8012
23
23
  #endif
24
24
 
25
+ #include <boost/version.hpp>
26
+ #if (BOOST_VERSION > 104900)
27
+ #include <boost/asio.hpp>
28
+ #else
25
29
  #include <boost/asio/ip/tcp.hpp>
26
30
  #include <boost/asio/buffer.hpp>
31
+ #endif
27
32
  #include <vector>
28
33
 
34
+
29
35
  #ifdef __BCPLUSPLUS__
30
36
  #pragma warn +8012
31
37
  #endif
@@ -76,6 +82,8 @@ class connection
76
82
  public:
77
83
  virtual ~connection(){};
78
84
  virtual void connect() = 0;
85
+ virtual void reconnect(boost::asio::ip::tcp::endpoint& ep) = 0;
86
+ virtual void cleanup() = 0;
79
87
  virtual void addref() = 0;
80
88
  virtual void release() = 0;
81
89
  virtual int refCount() const = 0;