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
@@ -39,31 +39,49 @@
39
39
  #undef ERROR
40
40
  #endif
41
41
 
42
- #ifdef NOMINMAX
43
- #undef NOMINMAX
44
- #endif
45
42
  #ifdef _MSC_VER
46
43
  #pragma warning(disable : 4800)
47
44
  #pragma warning(disable : 4267)
48
45
  #pragma warning(disable : 4996)
49
46
  #pragma warning(disable : 4805)
47
+ #pragma warning(disable : 4005)
48
+ #define NOMINMAX
50
49
  #endif
51
-
52
50
  #include <my_config.h>
53
51
  #include <mysql_version.h>
54
52
  #include <sql/sql_const.h>
55
53
  #include "my_global.h"
54
+ #include <math.h>
55
+ #if ((MYSQL_VERSION_ID > 50700) && !defined(MARIADB_BASE_VERSION))
56
+ // Not use malloc service
57
+ #define MYSQL_SERVICE_MYSQL_ALLOC_INCLUDED
58
+ typedef unsigned int PSI_memory_key;
59
+ typedef int myf_t;
60
+ extern "C" {
61
+ extern void * my_malloc(PSI_memory_key key, size_t size, myf_t flags);
62
+ extern void * my_realloc(PSI_memory_key key, void *ptr, size_t size, myf_t flags);
63
+ extern void my_free(void *ptr);
64
+ extern void * my_memdup(PSI_memory_key key, const void *from, size_t length, myf_t flags);
65
+ extern char * my_strdup(PSI_memory_key key, const char *from, myf_t flags);
66
+ extern char * my_strndup(PSI_memory_key key, const char *from, size_t length, myf_t flags);
67
+ }
68
+ #include "sql/log.h"
69
+ #endif //For MYSQL 5.7
70
+
56
71
  #include "sql/sql_class.h"
57
72
  #include <mysql/plugin.h>
58
73
  #include "sql/mysqld.h"
59
74
 
60
- #if ((MYSQL_VERSION_ID >= 50600) && !defined(MARIADB_BASE_VERSION))
75
+ #if ((MYSQL_VERSION_ID >= 50600) && (MYSQL_VERSION_ID < 50700) && !defined(MARIADB_BASE_VERSION))
61
76
  #include "sql/global_threads.h"
62
77
  #endif
63
78
 
64
79
  #include "sql/sql_plugin.h"
65
80
  #include "sql/sql_cache.h"
81
+ #if (MYSQL_VERSION_ID < 50700)
66
82
  #include "sql/structs.h"
83
+ #endif
84
+
67
85
  #include "sql/sql_priv.h"
68
86
  #include "sql/unireg.h"
69
87
  #include "sql/lock.h"
@@ -82,13 +100,7 @@
82
100
  #define MYSQL_USER_FIELD_PASSWORD 2
83
101
  #endif
84
102
 
85
-
86
- #if ((MYSQL_VERSION_ID > 50700) && !defined(MARIADB_BASE_VERSION))
87
- #include "sql/log.h"
88
- #endif
89
-
90
103
  #undef test
91
-
92
104
  #undef sleep
93
105
  #ifdef ERROR
94
106
  #define ERROR 0
@@ -99,6 +111,7 @@
99
111
  #pragma warning(default : 4267)
100
112
  #pragma warning(default : 4800)
101
113
  #pragma warning(default : 4805)
114
+ #pragma warning(default : 4005)
102
115
  #endif
103
116
 
104
117
  #undef min
@@ -152,12 +165,12 @@
152
165
 
153
166
  #if ((MYSQL_VERSION_NUM < 50600) || defined(MARIADB_BASE_VERSION))
154
167
 
155
- inline void cp_add_global_thread(THD* thd)
168
+ inline void add_global_thread(THD* thd)
156
169
  {
157
170
  ;
158
171
  }
159
172
 
160
- inline void cp_remove_global_thread(THD* thd)
173
+ inline void remove_global_thread(THD* thd)
161
174
  {
162
175
  ;
163
176
  }
@@ -173,12 +186,12 @@ inline void cp_restore_globals(THD* thd)
173
186
  my_pthread_setspecific_ptr(THR_MALLOC, 0);
174
187
  }
175
188
 
176
- inline void cp_thd_set_read_only(THD* thd)
189
+ inline void cp_thd_set_read_only(THD* thd, bool v)
177
190
  {
178
191
  ;
179
192
  }
180
193
 
181
- inline bool cp_thd_get_read_only(THD* thd)
194
+ inline bool cp_thd_get_global_read_only(THD* thd)
182
195
  {
183
196
  return false;
184
197
  }
@@ -191,15 +204,6 @@ inline bool cp_open_table(THD* thd, TABLE_LIST* tables,
191
204
  #define set_mysys_var(A)
192
205
  #else
193
206
 
194
- inline void cp_add_global_thread(THD* thd)
195
- {
196
- add_global_thread(thd);
197
- }
198
-
199
- inline void cp_remove_global_thread(THD* thd)
200
- {
201
- remove_global_thread(thd);
202
- }
203
207
 
204
208
  inline void cp_thd_release_resources(THD* thd)
205
209
  {
@@ -208,7 +212,11 @@ inline void cp_thd_release_resources(THD* thd)
208
212
 
209
213
  inline void cp_set_mysys_var(st_my_thread_var* var)
210
214
  {
215
+ #if(MYSQL_VERSION_NUM < 50700)
211
216
  set_mysys_var(var);
217
+ #else
218
+ set_mysys_thread_var(var);
219
+ #endif
212
220
  }
213
221
 
214
222
  inline void cp_restore_globals(THD* thd)
@@ -216,12 +224,12 @@ inline void cp_restore_globals(THD* thd)
216
224
  thd->restore_globals();
217
225
  }
218
226
 
219
- inline void cp_thd_set_read_only(THD* thd)
227
+ inline void cp_thd_set_read_only(THD* thd, bool v)
220
228
  {
221
- thd->tx_read_only = (thd->variables.tx_read_only != 0);
229
+ thd->tx_read_only = (v || thd->variables.tx_read_only);
222
230
  }
223
231
 
224
- inline bool cp_thd_get_read_only(THD* thd)
232
+ inline bool cp_thd_get_global_read_only(THD* thd)
225
233
  {
226
234
  return (thd->variables.tx_read_only != 0);
227
235
  }
@@ -237,32 +245,114 @@ inline bool cp_open_table(THD* thd, TABLE_LIST* tables,
237
245
  #define ha_index_read_map index_read_map
238
246
  #endif
239
247
 
240
- /* memory management */
241
- #if ((MYSQL_VERSION_NUM > 50700) && !defined(MARIADB_BASE_VERSION))
248
+
249
+ extern unsigned int g_openDatabases;
250
+ #if((MYSQL_VERSION_NUM > 50700) && !defined(MARIADB_BASE_VERSION))
251
+ #define OPEN_TABLE_FLAG_TYPE 0
252
+
242
253
  #define td_malloc(A, B) my_malloc(PSI_NOT_INSTRUMENTED, A, B)
243
254
  #define td_realloc(A, B, C) my_realloc(PSI_NOT_INSTRUMENTED, A, B, C)
244
255
  #define td_strdup(A, B) my_strdup(PSI_NOT_INSTRUMENTED, A, B)
245
256
  #define td_free(A) my_free(A)
246
257
 
247
258
  /* On Windows,
248
- "operator delete()" function is implemented in mysqld.
249
- But "operator new" operation implement in transactd.dll.
250
- Therefore, memory managers differ. */
259
+ "operator delete()" function is implemented in mysqld.
260
+ But "operator new" operation implement in transactd.dll.
261
+ Therefore, memory managers differ. */
251
262
  #ifdef _WIN32
252
263
 
253
264
  inline void releaseTHD(THD* thd)
254
265
  {
255
- thd->~THD();
256
- operator delete((void*)thd);
266
+ thd->~THD();
267
+ operator delete((void*)thd);
257
268
  }
258
269
  #else
259
270
 
260
271
  inline void releaseTHD(THD* thd)
261
272
  {
262
- delete thd;
273
+ delete thd;
263
274
  }
264
275
  #endif
265
- #else
276
+
277
+ #include <boost/thread/mutex.hpp>
278
+ extern boost::mutex g_db_count_mutex;
279
+ extern void global_thd_manager_add_thd(THD *thd);
280
+ extern void global_thd_manager_remove_thd(THD *thd);
281
+
282
+ inline void cp_set_new_thread_id(THD* thd)
283
+ {
284
+ thd->set_new_thread_id();
285
+ global_thd_manager_add_thd(thd);
286
+ boost::mutex::scoped_lock lck(g_db_count_mutex);
287
+ ++g_openDatabases;
288
+ }
289
+
290
+ inline void cp_dec_dbcount(THD* thd)
291
+ {
292
+ {
293
+ boost::mutex::scoped_lock lck(g_db_count_mutex);
294
+ --g_openDatabases;
295
+ }
296
+ global_thd_manager_remove_thd(thd);
297
+ }
298
+
299
+ inline Security_context* cp_security_ctx(THD* thd)
300
+ {
301
+ return thd->security_context();
302
+ }
303
+
304
+ inline int cp_record_count(handler* file, ha_rows* rows)
305
+ {
306
+ return file->ha_records(rows);
307
+ }
308
+
309
+ #define cp_strdup(A, B) my_strdup(PSI_INSTRUMENT_ME, (A), (B))
310
+ #define cp_set_mysys_var(A) set_mysys_thread_var(A)
311
+ inline void cp_set_db(THD* thd, char* p)
312
+ {
313
+ thd->set_db(to_lex_cstring(p));
314
+ }
315
+
316
+
317
+ inline THD* cp_thread_get_THR_THD()
318
+ {
319
+ return my_thread_get_THR_THD();
320
+ return NULL;
321
+ }
322
+
323
+ inline int cp_thread_set_THR_THD(THD* thd)
324
+ {
325
+ return my_thread_set_THR_THD(thd);
326
+ return 0;
327
+ }
328
+
329
+ inline void cp_set_transaction_duration_for_all_locks(THD* /*thd*/)
330
+ {
331
+ ;
332
+ }
333
+
334
+ inline void cp_set_mdl_request_types(TABLE_LIST& tables, short mode)
335
+ {
336
+ if (mode == -2 /* TD_OPEN_READONLY */)
337
+ tables.mdl_request.set_type(MDL_SHARED_READ);
338
+ else if (mode == -4 /* TD_OPEN_EXCLUSIVE */)
339
+ tables.mdl_request.set_type(MDL_SHARED_NO_READ_WRITE);
340
+ else if (mode == -6 /* TD_OPEN_READONLY_EXCLUSIVE */)
341
+ tables.mdl_request.set_type(MDL_SHARED_READ_ONLY);
342
+ else
343
+ tables.mdl_request.set_type(MDL_SHARED_WRITE);
344
+
345
+ tables.mdl_request.duration = MDL_TRANSACTION;
346
+ }
347
+
348
+ inline void cp_open_error_release(THD* /*thd*/, TABLE_LIST& /*tables*/)
349
+ {
350
+ ;
351
+ }
352
+
353
+ #else //Not MySQL 5.7
354
+ #define OPEN_TABLE_FLAG_TYPE MYSQL_OPEN_GET_NEW_TABLE
355
+
266
356
  #define td_malloc(A, B) my_malloc(A, B)
267
357
  #define td_realloc(A, B, C) my_realloc(A, B, C)
268
358
  #define td_strdup(A, B) my_strdup(A, B)
@@ -270,8 +360,70 @@ inline void releaseTHD(THD* thd)
270
360
 
271
361
  inline void releaseTHD(THD* thd)
272
362
  {
273
- delete thd;
363
+ delete thd;
364
+ }
365
+ inline void cp_set_new_thread_id(THD* thd)
366
+ {
367
+ mysql_mutex_lock(&LOCK_thread_count);
368
+ ++g_openDatabases;
369
+ thd->variables.pseudo_thread_id = thread_id++;
370
+ add_global_thread(thd);
371
+ mysql_mutex_unlock(&LOCK_thread_count);
372
+ thd->thread_id = thd->variables.pseudo_thread_id;
274
373
  }
374
+ inline void cp_dec_dbcount(THD* thd)
375
+ {
376
+ mysql_mutex_lock(&LOCK_thread_count);
377
+ --g_openDatabases;
378
+ mysql_mutex_unlock(&LOCK_thread_count);
379
+ remove_global_thread(thd);
380
+ }
381
+ inline Security_context* cp_security_ctx(THD* thd)
382
+ {
383
+ return thd->security_ctx;
384
+ }
385
+
386
+ inline int cp_record_count(handler* file, ha_rows* rows)
387
+ {
388
+ *rows = file->records();
389
+ return 0;
390
+ }
391
+ #define cp_strdup(A, B) my_strdup((A), (B))
392
+ #define cp_set_mysys_var(A) set_mysys_var(A)
393
+
394
+ inline void cp_set_db(THD* thd, char* p)
395
+ {
396
+ td_free(thd->db);
397
+ thd->db = p;
398
+ }
399
+
400
+ inline THD* cp_thread_get_THR_THD()
401
+ {
402
+ return (THD*)my_pthread_getspecific(THD*, THR_THD);
403
+ }
404
+
405
+ inline int cp_thread_set_THR_THD(THD* thd)
406
+ {
407
+ my_pthread_setspecific_ptr(THR_THD, thd);
408
+ return 0;
409
+ }
410
+
411
+ inline void cp_set_transaction_duration_for_all_locks(THD* thd)
412
+ {
413
+ thd->mdl_context.set_transaction_duration_for_all_locks();
414
+ }
415
+
416
+ inline void cp_set_mdl_request_types(TABLE_LIST& tables, short mode)
417
+ {
418
+ tables.mdl_request.set_type(MDL_SHARED_READ);
419
+ tables.mdl_request.duration = MDL_EXPLICIT;
420
+ }
421
+
422
+ inline void cp_open_error_release(THD* thd, TABLE_LIST& tables)
423
+ {
424
+ thd->mdl_context.release_lock(tables.mdl_request.ticket);
425
+ }
426
+
275
427
  #endif
276
428
 
277
429
  #endif // BZS_DB_ENGINE_MYSQL_MYSQLINTERNAL_H
@@ -25,7 +25,13 @@ unsigned int g_openDatabases = 0;
25
25
 
26
26
  extern unsigned int g_lock_wait_timeout;
27
27
  extern char* g_transaction_isolation;
28
- static unsigned int transaction_isolation_cache = -1;
28
+ static int transaction_isolation_cache = -1;
29
+
30
+ #if((MYSQL_VERSION_NUM > 50700) && !defined(MARIADB_BASE_VERSION))
31
+ boost::mutex g_db_count_mutex;
32
+ LEX_CSTRING NULL_CSTR = { NULL, 0 };
33
+ #endif
34
+
29
35
 
30
36
  #ifdef USETLS
31
37
  tls_key g_tlsiID;
@@ -101,7 +107,7 @@ void waitForServerStart()
101
107
  mysql_mutex_unlock(&LOCK_server_started);
102
108
  }
103
109
 
104
- unsigned int getTransactdIsolation()
110
+ int getTransactdIsolation()
105
111
  {
106
112
  if (transaction_isolation_cache != -1)
107
113
  return transaction_isolation_cache;
@@ -125,22 +131,19 @@ THD* buildTHD()
125
131
  waitForServerStart();
126
132
 
127
133
  THD* thd = new THD();
128
- mysql_mutex_lock(&LOCK_thread_count);
129
- thd->variables.pseudo_thread_id = thread_id++;
130
- ++g_openDatabases;
131
- cp_add_global_thread(thd);
132
- mysql_mutex_unlock(&LOCK_thread_count);
133
- thd->thread_id = thd->variables.pseudo_thread_id;
134
+
135
+ cp_set_new_thread_id(thd);
136
+
134
137
  thd->thread_stack = reinterpret_cast<char*>(&thd);
135
138
  thd->store_globals();
136
139
  assert(thd->mysys_var);
137
- set_mysys_var(thd->mysys_var);
140
+ cp_set_mysys_var(thd->mysys_var);
138
141
  thd->system_thread = NON_SYSTEM_THREAD;
139
142
  const NET v = { 0 };
140
143
  thd->net = v;
141
144
 
142
145
  thd->variables.option_bits |= OPTION_BIN_LOG;
143
- thd->variables.tx_isolation = getTransactdIsolation();
146
+ thd->variables.tx_isolation = (ulong)getTransactdIsolation();
144
147
 
145
148
  thd->clear_error();
146
149
  char tmp[256];
@@ -148,8 +151,8 @@ THD* buildTHD()
148
151
  g_lock_wait_timeout);
149
152
  dispatch_command(COM_QUERY, thd, tmp, (uint)strlen(tmp));
150
153
 
151
- td_free(thd->db);
152
- thd->db = td_strdup("bizstation", MYF(0));
154
+
155
+ cp_set_db(thd, td_strdup("bizstation", MYF(0)));
153
156
  if (thd->variables.sql_log_bin)
154
157
  thd->set_current_stmt_binlog_format_row();
155
158
  return thd;
@@ -157,10 +160,10 @@ THD* buildTHD()
157
160
 
158
161
  THD* attachThd(THD* thd)
159
162
  {
160
- THD* curThd = my_pthread_getspecific(THD*, THR_THD);
163
+ THD* curThd = cp_thread_get_THR_THD();
161
164
 
162
- if (!thd)
163
- my_pthread_setspecific_ptr(THR_THD, thd);
165
+ if (!thd)
166
+ cp_thread_set_THR_THD(thd);
164
167
  else
165
168
  {
166
169
  initThread(thd);
@@ -168,7 +171,7 @@ THD* attachThd(THD* thd)
168
171
  if (curThd != thd)
169
172
  {
170
173
  thd->store_globals();
171
- set_mysys_var(thd->mysys_var);
174
+ cp_set_mysys_var(thd->mysys_var);
172
175
  }
173
176
  }
174
177
  return curThd;
@@ -186,10 +189,7 @@ THD* createThdForThread()
186
189
  void deleteThdForThread(THD* thd)
187
190
  {
188
191
  cp_restore_globals(thd);
189
- mysql_mutex_lock(&LOCK_thread_count);
190
- --g_openDatabases;
191
- mysql_mutex_unlock(&LOCK_thread_count);
192
- cp_thd_release_resources(thd);
193
- cp_remove_global_thread(thd);
192
+ cp_thd_release_resources(thd);
193
+ cp_dec_dbcount(thd);
194
194
  releaseTHD(thd);
195
195
  }
@@ -147,26 +147,37 @@ pq_handle activeTable::prepare(queryBase& q, bool serverPrepare)
147
147
  return m_imple->prepare(q, serverPrepare);
148
148
  }
149
149
 
150
+ activeTable& activeTable::readMore(recordset& rs)
151
+ {
152
+ rs.clear();
153
+ m_imple->readMore(*rs.m_imple);
154
+ return *this;
155
+ }
156
+
150
157
  activeTable& activeTable::read(recordset& rs, queryBase& q)
151
158
  {
159
+ rs.clear();
152
160
  m_imple->read(*rs.m_imple, q);
153
161
  return *this;
154
162
  }
155
163
 
156
164
  activeTable& activeTable::read(recordset& rs, queryBase& q, validationFunc func)
157
165
  {
166
+ rs.clear();
158
167
  m_imple->read(*rs.m_imple, q, func);
159
168
  return *this;
160
169
  }
161
170
 
162
171
  activeTable& activeTable::read(recordset& rs, pq_handle& q)
163
172
  {
173
+ rs.clear();
164
174
  m_imple->read(*rs.m_imple, q);
165
175
  return *this;
166
176
  }
167
177
 
168
178
  activeTable& activeTable::read(recordset& rs, pq_handle& q, validationFunc func)
169
179
  {
180
+ rs.clear();
170
181
  m_imple->read(*rs.m_imple, q, func);
171
182
  return *this;
172
183
  }
@@ -139,7 +139,7 @@ public:
139
139
  activeTable& read(recordset& rs, queryBase& q, validationFunc func);
140
140
  activeTable& read(recordset& rs, pq_handle& q);
141
141
  activeTable& read(recordset& rs, pq_handle& q, validationFunc func);
142
-
142
+ activeTable& readMore(recordset& rs);
143
143
  /** @cond INTERNAL */
144
144
  template<class T0>
145
145
  activeTable& read(recordset& rs, pq_handle& q, const T0 v0)
@@ -94,9 +94,10 @@ public:
94
94
  typedef mdlsHandler<map_orm, recordsetImple> collection_orm_typename;
95
95
  };
96
96
 
97
+ #define FIXED_VALUE_BUF_SIZE 256
97
98
  struct joinInfo
98
99
  {
99
- std::_tstring fixedValue;
100
+ unsigned char fixedValue[FIXED_VALUE_BUF_SIZE];
100
101
  ushort_td len;
101
102
  ushort_td type;
102
103
  };
@@ -152,9 +153,15 @@ class activeTableImple : public activeObject<map_orm>
152
153
  if (s[0] == '[')
153
154
  {
154
155
  fieldIndexes[i] = -1;
156
+ const fielddef& f = td->fieldDefs[kd->segments[i].fieldNum];
157
+ if (f.len > FIXED_VALUE_BUF_SIZE)
158
+ THROW_BZS_ERROR_WITH_MSG(_T("Join fixed key field is too long")
159
+ _T(" field.\n This field can not use join."));
160
+ field fd(joinFields[i].fixedValue, f, fds);
161
+ fd = s.c_str() +1;
162
+ joinFields[i].len = f.len;
155
163
  joinFields[i].type = JOIN_KEYVALUE_TYPE_PTR;
156
- joinFields[i].len = (ushort_td)(s.size() - 2);
157
- joinFields[i].fixedValue = s.substr(1, s.size() - 2);
164
+
158
165
  }
159
166
  else
160
167
  {
@@ -212,7 +219,7 @@ class activeTableImple : public activeObject<map_orm>
212
219
  {
213
220
  if (fieldIndexes[i] == -1)
214
221
  {
215
- ptr[i] = (const uchar_td*)joinFields[i].fixedValue.c_str();
222
+ ptr[i] = joinFields[i].fixedValue;
216
223
  len[i] = joinFields[i].len;
217
224
  }
218
225
  else if (joinFields[i].type == JOIN_KEYVALUE_TYPE_PTR)
@@ -76,7 +76,7 @@ class client
76
76
 
77
77
  bool checkVersion(trdVersiton& ver)
78
78
  {
79
- if ((ver.srvMajor < 2) || ((ver.srvMajor == 2) && (ver.srvMinor < 1)))
79
+ if ((ver.srvMajor < 2) || ((ver.srvMajor == 2) && (ver.srvMinor < 3)))
80
80
  return false;
81
81
  return true;
82
82
  }
@@ -307,6 +307,30 @@ public:
307
307
  }
308
308
  }
309
309
 
310
+ inline void reconnect()
311
+ {
312
+ bzs::netsvc::client::connection* c = con();
313
+ if (!c)
314
+ {
315
+ m_preResult = ERROR_TD_NOT_CONNECTED;
316
+ return;
317
+ }
318
+ std::string host = getHostName((const char*)m_req.keybuf);
319
+ m_preResult = ERROR_TD_HOSTNAME_NOT_FOUND;
320
+ if (host == "") return;
321
+ if (!m_cons->reconnect(c, host, handshakeCallback, this))
322
+ return;
323
+ m_connecting = true;
324
+ if (getServerCharsetIndex() == -1)
325
+ m_preResult = SERVER_CLIENT_NOT_COMPATIBLE;
326
+ else
327
+ {
328
+ m_preResult = 0;
329
+ buildDualChasetKeybuf();
330
+ }
331
+ m_req.paramMask = P_MASK_KEYONLY;
332
+ }
333
+
310
334
  inline void cmdConnect()
311
335
  {
312
336
  if ((m_req.keyNum == LG_SUBOP_CONNECT) ||
@@ -338,7 +362,12 @@ public:
338
362
  m_logout = true;
339
363
  else if (m_op == TD_CONNECT)
340
364
  m_preResult = 1;
365
+ }else if (m_req.keyNum == LG_SUBOP_DISCONNECT_EX)
366
+ {
367
+ if (con())
368
+ con()->cleanup();
341
369
  }
370
+
342
371
  m_req.paramMask = P_MASK_KEYONLY;
343
372
  }
344
373
 
@@ -228,7 +228,7 @@ void dbdef::updateTableDef(short TableIndex, bool forPsqlDdf)
228
228
  uchar_td type;
229
229
 
230
230
  td->optionFlags.bitA = false; // reset valiable type
231
-
231
+ td->optionFlags.bitB = false;
232
232
  for (i = 0; i < td->fieldCount; ++i)
233
233
  {
234
234
  ret = fieldNumByName(TableIndex, td->fieldDefs[i].name());
@@ -593,6 +593,7 @@ fielddef* dbdef::insertField(short TableIndex, short InsertIndex)
593
593
  fielddef* fd = &(td->fieldDefs[InsertIndex]);
594
594
  fd->setCharsetIndex(td->charsetIndex);
595
595
  fd->setSchemaCodePage(td->schemaCodePage);
596
+ fd->setPadCharSettings(false, true);
596
597
  return fd;
597
598
  }
598
599
 
@@ -335,7 +335,17 @@ extern "C" PACKAGE_OSX short_td __STDCALL
335
335
  break;
336
336
  case TD_CONNECT:
337
337
  {
338
- client_t->cmdConnect();
338
+ if (client_t->req().keyNum == LG_SUBOP_RECONNECT)
339
+ client_t->reconnect();
340
+ else
341
+ client_t->cmdConnect();
342
+ if (client_t->req().keyNum == LG_SUBOP_DISCONNECT_EX)
343
+ return 0;
344
+ break;
345
+ }
346
+ case TD_RECONNECT:
347
+ {
348
+ client_t->req().paramMask = P_MASK_ALL;
339
349
  break;
340
350
  }
341
351
  case TD_STASTISTICS:
@@ -367,9 +377,22 @@ extern "C" PACKAGE_OSX short_td __STDCALL
367
377
  case 11001:
368
378
  ret = ERROR_TD_HOSTNAME_NOT_FOUND;
369
379
  break;
380
+ case 10060:
381
+ case 10057: //blocking fire wall
382
+ case 110: //connect: Connection timed out
383
+ case 121: //timeout sema
384
+ case 11: //EAGAIN
385
+ ret = ERROR_TD_NET_TIMEOUT;
386
+ break;
387
+ case 32: //write:brokn pipe
388
+ case 111: //connect: Connection refused
370
389
  case 10061:
371
390
  ret = ERROR_TD_CONNECTION_FAILURE;
372
391
  break;
392
+ case 104: //write: Connection reset by peer
393
+ case 10054:
394
+ ret = ERROR_TD_NET_REMOTE_DISCONNECT;
395
+ break;
373
396
  case 232:
374
397
  case 109:
375
398
  case 2:
@@ -377,10 +400,12 @@ extern "C" PACKAGE_OSX short_td __STDCALL
377
400
  ret = ERROR_TD_INVALID_CLINETHOST;
378
401
  break;
379
402
  default:
380
- ret = e.code().value() + 20000;
403
+ ret = ERROR_TD_NET_OTHER;
381
404
  }
382
405
  OutputDebugString(e.what());
383
- writeErrorLog(ret, e.what());
406
+ char tmp[512];
407
+ sprintf_s(tmp, 512, "%d %s", e.code().value(), e.what());
408
+ writeErrorLog(ret, tmp);
384
409
  }
385
410
  catch (bzs::netsvc::client::exception& e)
386
411
  {
@@ -390,9 +415,14 @@ extern "C" PACKAGE_OSX short_td __STDCALL
390
415
  }
391
416
  catch (std::exception& e)
392
417
  {
393
- ret = 1;
418
+ ret = ERROR_TD_C_CLIENT_UNKNOWN;
394
419
  OutputDebugString(e.what());
395
- writeErrorLog(30000, e.what());
420
+ writeErrorLog(ret, e.what());
421
+ }
422
+ catch (...)
423
+ {
424
+ ret = ERROR_TD_C_CLIENT_UNKNOWN;
425
+ writeErrorLog(ret, "Unknown error");
396
426
  }
397
427
  return ret;
398
428
  }