transactd 3.4.1 → 3.5.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 (91) hide show
  1. checksums.yaml +4 -4
  2. data/CMakeLists.txt +2 -2
  3. data/bin/common/tdclc_32_3_5.dll +0 -0
  4. data/bin/common/tdclc_64_3_5.dll +0 -0
  5. data/build/common/options.cmake +12 -0
  6. data/build/common/transactd_cl_common.cmake +1 -0
  7. data/build/common/transactd_required.cmake +5 -0
  8. data/build/swig/ruby/tdclrb_wrap.cpp +1029 -130
  9. data/build/swig/tdcl.i +60 -5
  10. data/build/tdclc/CMakeLists.txt +30 -32
  11. data/build/tdclc/libtdclcm.map +1 -1
  12. data/build/tdclc/tdclc.cbproj +1 -1
  13. data/build/tdclc/tdclc.rc +4 -4
  14. data/build/tdclcpp/CMakeLists.txt +39 -48
  15. data/build/tdclcpp/tdclcpp.rc +4 -4
  16. data/build/tdclcpp/tdclcpp_bc.cbproj +4 -1
  17. data/build/tdclrb/CMakeLists.txt +5 -4
  18. data/build/tdclrb/tdclrb.rc +4 -4
  19. data/source/bzs/db/engine/mysql/database.cpp +45 -35
  20. data/source/bzs/db/engine/mysql/database.h +6 -8
  21. data/source/bzs/db/engine/mysql/dbManager.cpp +11 -0
  22. data/source/bzs/db/engine/mysql/dbManager.h +1 -0
  23. data/source/bzs/db/engine/mysql/ha.cpp +174 -0
  24. data/source/bzs/db/engine/mysql/ha.h +50 -0
  25. data/source/bzs/db/engine/mysql/mysqlInternal.h +18 -1
  26. data/source/bzs/db/engine/mysql/mysqlProtocol.cpp +222 -9
  27. data/source/bzs/db/engine/mysql/mysqlProtocol.h +5 -0
  28. data/source/bzs/db/protocol/tdap/client/client.cpp +23 -9
  29. data/source/bzs/db/protocol/tdap/client/client.h +125 -94
  30. data/source/bzs/db/protocol/tdap/client/connMgr.cpp +139 -30
  31. data/source/bzs/db/protocol/tdap/client/connMgr.h +40 -8
  32. data/source/bzs/db/protocol/tdap/client/database.cpp +17 -17
  33. data/source/bzs/db/protocol/tdap/client/database.h +15 -0
  34. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +10 -4
  35. data/source/bzs/db/protocol/tdap/client/haNameResolver.cpp +486 -0
  36. data/source/bzs/db/protocol/tdap/client/haNameResolver.h +74 -0
  37. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +102 -71
  38. data/source/bzs/db/protocol/tdap/client/nsDatabase.h +15 -3
  39. data/source/bzs/db/protocol/tdap/client/nsTable.cpp +2 -5
  40. data/source/bzs/db/protocol/tdap/client/nsTable.h +2 -1
  41. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +2 -2
  42. data/source/bzs/db/protocol/tdap/client/table.cpp +1 -2
  43. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +13 -0
  44. data/source/bzs/db/protocol/tdap/client/trnsctcl.def +1 -0
  45. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +9 -7
  46. data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +2 -2
  47. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +328 -117
  48. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +7 -8
  49. data/source/bzs/db/protocol/tdap/tdapcapi.h +81 -41
  50. data/source/bzs/db/transactd/connManager.cpp +118 -93
  51. data/source/bzs/db/transactd/connManager.h +6 -1
  52. data/source/bzs/db/transactd/connectionRecord.h +27 -7
  53. data/source/bzs/db/transactd/transactd.cpp +24 -13
  54. data/source/bzs/env/crosscompile.h +2 -0
  55. data/source/bzs/netsvc/client/iconnection.h +2 -0
  56. data/source/bzs/netsvc/client/tcpClient.cpp +45 -14
  57. data/source/bzs/netsvc/client/tcpClient.h +21 -4
  58. data/source/bzs/netsvc/server/IAppModule.h +1 -0
  59. data/source/bzs/netsvc/server/serverCpt.cpp +1 -1
  60. data/source/bzs/netsvc/server/serverPipe.cpp +2 -0
  61. data/source/bzs/netsvc/server/serverTpool.cpp +3 -5
  62. data/source/bzs/test/tdclatl/test_v3.js +91 -3
  63. data/source/bzs/test/tdclphp/transactd_v3_Test.php +89 -3
  64. data/source/bzs/test/tdclrb/transactd_v3_spec.rb +69 -2
  65. data/source/bzs/test/trdclengn/testField.h +19 -1
  66. data/source/bzs/test/trdclengn/test_tdclcpp_ha.cpp +388 -0
  67. data/source/bzs/test/trdclengn/test_tdclcpp_v3.cpp +6 -1
  68. data/source/bzs/test/trdclengn/test_trdclengn.cpp +1 -0
  69. data/source/bzs/test/trdclengn/testbase.h +7 -1
  70. data/source/global/replication/haCommand.cpp +843 -0
  71. data/source/global/replication/haCommand.h +78 -0
  72. data/source/global/replication/haMgr.cpp +321 -0
  73. data/source/global/replication/replCommand.cpp +696 -0
  74. data/source/global/replication/replCommand.h +161 -0
  75. data/source/global/tdclatl/BinlogPos.cpp +10 -0
  76. data/source/global/tdclatl/BinlogPos.h +1 -0
  77. data/source/global/tdclatl/ConnMgr.cpp +89 -2
  78. data/source/global/tdclatl/ConnMgr.h +13 -1
  79. data/source/global/tdclatl/ConnRecord.cpp +8 -2
  80. data/source/global/tdclatl/ConnRecord.h +4 -3
  81. data/source/global/tdclatl/Database.cpp +13 -0
  82. data/source/global/tdclatl/Database.h +2 -0
  83. data/source/global/tdclatl/HaNameREsolver.cpp +54 -0
  84. data/source/global/tdclatl/HaNameREsolver.h +68 -0
  85. data/source/global/tdclatl/resource.h +0 -0
  86. data/source/global/tdclatl/tdclatl.idl +76 -5
  87. metadata +16 -6
  88. data/bin/common/tdclc_32_3_4.dll +0 -0
  89. data/bin/common/tdclc_64_3_4.dll +0 -0
  90. data/source/bzs/db/protocol/tdap/mysql/debuglog.cpp +0 -423
  91. data/source/bzs/db/protocol/tdap/mysql/debuglog.h +0 -116
@@ -0,0 +1,50 @@
1
+ #ifndef BZS_DB_ENGINE_MYSQL_HA_H
2
+ #define BZS_DB_ENGINE_MYSQL_HA_H
3
+ /*=================================================================
4
+ Copyright (C) 2016 BizStation Corp All rights reserved.
5
+
6
+ This program is free software; you can redistribute it and/or
7
+ modify it under the terms of the GNU General Public License
8
+ as published by the Free Software Foundation; either version 2
9
+ of the License, or (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program; if not, write to the Free Software
18
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19
+ 02111-1307, USA.
20
+ =================================================================*/
21
+
22
+ const static bool trx_block = false;
23
+ const static bool trx_noblock = true;
24
+ extern bool trx_blocking;
25
+
26
+ namespace bzs
27
+ {
28
+ namespace db
29
+ {
30
+ namespace engine
31
+ {
32
+ namespace mysql
33
+ {
34
+
35
+ int initHa();
36
+ bool haLock();
37
+ bool haUnlock();
38
+ bool setRole(int isMaster);
39
+ int getRole();
40
+ bool setEnableFailover(bool enable);
41
+ bool getEnableFailover();
42
+ bool setTrxBlock(bool v);
43
+ inline bool isTrxBlocking() { return trx_blocking == trx_block;}
44
+
45
+ } // namespace mysql
46
+ } // namespace engine
47
+ } // namespace db
48
+ } // namespace bzs
49
+
50
+ #endif // BZS_DB_ENGINE_MYSQL_HA_H
@@ -75,6 +75,10 @@
75
75
  #include "my_global.h"
76
76
  #include <math.h>
77
77
  #if defined(MYSQL_5_7)
78
+ #ifndef HAVE_REPLICATION
79
+ #define HAVE_REPLICATION
80
+ #endif
81
+
78
82
  // Not use malloc service
79
83
  #define MYSQL_SERVICE_MYSQL_ALLOC_INCLUDED
80
84
  typedef unsigned int PSI_memory_key;
@@ -229,11 +233,21 @@ inline void cp_restore_globals(THD* thd)
229
233
  my_pthread_setspecific_ptr(THR_THD, 0);
230
234
  my_pthread_setspecific_ptr(THR_MALLOC, 0);
231
235
  }
232
-
236
+ #if (MYSQL_VERSION_ID < 50600)
233
237
  inline void cp_thd_set_read_only(THD* thd, bool v) {}
234
238
 
235
239
  inline bool cp_thd_get_global_read_only(THD* thd) { return false; }
240
+ #else
241
+ inline void cp_thd_set_read_only(THD* thd, bool v)
242
+ {
243
+ thd->tx_read_only = (v || thd->variables.tx_read_only);
244
+ }
236
245
 
246
+ inline bool cp_thd_get_global_read_only(THD* thd)
247
+ {
248
+ return (thd->variables.tx_read_only != 0);
249
+ }
250
+ #endif
237
251
  inline bool cp_open_table(THD* thd, TABLE_LIST* tables,
238
252
  Open_table_context* ot_act)
239
253
  {
@@ -477,7 +491,9 @@ inline int cp_store_create_info(THD *thd, TABLE_LIST *table_list, String *packet
477
491
  }
478
492
 
479
493
  #define cp_get_executed_gtids get_executed_gtids
494
+ extern MYSQL_PLUGIN_IMPORT my_bool opt_show_slave_auth_info;
480
495
 
496
+ #define STATUS_VAR_SCOPE ,SHOW_SCOPE_GLOBAL
481
497
  #else //Not MySQL 5.7
482
498
 
483
499
  #define OPEN_TABLE_FLAG_TYPE MYSQL_OPEN_GET_NEW_TABLE
@@ -619,6 +635,7 @@ inline int cp_store_create_info(THD *thd, TABLE_LIST *table_list, String *packet
619
635
 
620
636
  #endif // Not MARIADB_10_1 || MARIADB_10_0
621
637
 
638
+ #define STATUS_VAR_SCOPE
622
639
  #endif // Not MySQL 5.7
623
640
 
624
641
 
@@ -17,11 +17,15 @@
17
17
  02111-1307, USA.
18
18
  ================================================================= */
19
19
  /* MySQL 5.5 and Mariadb are no-rtti */
20
+ #include <my_config.h>
21
+ # include <string>
22
+
20
23
  #ifdef __GNUC__
21
24
  # pragma implementation "mysqlInternal.h"
22
25
  #endif
23
26
 
24
27
  #include "mysqlProtocol.h"
28
+
25
29
  #include <bzs/env/crosscompile.h>
26
30
  #include <bzs/db/protocol/tdap/tdapcapi.h>
27
31
  #include <bzs/db/IBlobBuffer.h>
@@ -214,12 +218,13 @@ safe_commit_lock::~safe_commit_lock()
214
218
 
215
219
 
216
220
  #ifdef NOTUSE_BINLOG_VAR //Only MySQL 5.6 Windows
217
- inline short getBinlogPosInternal(THD* currentThd, binlogPos* bpos, THD* tmpThd, bzs::db::IblobBuffer* bb)
221
+ inline short getBinlogPosInternal(THD* currentThd, binlogPos* bpos, THD* tmpThd, bzs::db::IblobBuffer* bb)
218
222
  {
219
223
  short result = 0;
220
224
  {
221
225
  attachThd(tmpThd);
222
- copyGrant(tmpThd, currentThd, NULL);
226
+ if (tmpThd != currentThd)
227
+ copyGrant(tmpThd, currentThd, NULL);
223
228
  masterStatus p(tmpThd, bpos, bb);
224
229
  cp_query_command(tmpThd, "show master status");
225
230
  if (tmpThd->is_error())
@@ -232,7 +237,7 @@ safe_commit_lock::~safe_commit_lock()
232
237
  #endif
233
238
 
234
239
  #ifdef USE_BINLOG_GTID //MariaDB 10-
235
- inline short getBinlogPosInternal(THD* currentThd, binlogPos* bpos, THD* /*tmpThd*/, bzs::db::IblobBuffer* /*bb*/)
240
+ inline short getBinlogPosInternal(THD* currentThd, binlogPos* bpos, THD* /*tmpThd*/, bzs::db::IblobBuffer* /*bb*/)
236
241
  {
237
242
  if (mysql_bin_log.is_open())
238
243
  {
@@ -266,7 +271,7 @@ safe_commit_lock::~safe_commit_lock()
266
271
  if (size > 1024) buf = new char[size];
267
272
  gtid_set->to_string(buf);
268
273
  bpos->type = REPL_POSTYPE_GTID;
269
- bb->addBlob((unsigned int)size, 0, (const unsigned char *)buf);
274
+ bb->addBlob((unsigned int)size, TD_EXTENDED_VAR_BINLOG_GTID, (const unsigned char *)buf);
270
275
  bb->setFieldCount(1);
271
276
  if (p != buf) delete[] buf;
272
277
  }
@@ -275,7 +280,7 @@ safe_commit_lock::~safe_commit_lock()
275
280
  }
276
281
 
277
282
  // Linux MySQL can access to the mysql_bin_log variable
278
- inline short getBinlogPosInternal(THD*, binlogPos* bpos, THD* /*tmpThd*/, bzs::db::IblobBuffer* bb)
283
+ inline short getBinlogPosInternal(THD*, binlogPos* bpos, THD* /*tmpThd*/, bzs::db::IblobBuffer* bb)
279
284
  {
280
285
  if (mysql_bin_log.is_open())
281
286
  {
@@ -315,13 +320,17 @@ int execSql(THD* thd, const char* sql)
315
320
  using namespace bzs::db::transactd;
316
321
  class slaveStatus : public dummyProtocol
317
322
  {
323
+ protected:
318
324
  connection::records& m_records;
319
325
  bzs::db::IblobBuffer* m_bb;
320
326
  int m_blobfields;
321
327
  connection::record& getRec()
322
328
  {
323
329
  m_records.push_back(connection::record());
324
- return m_records[m_records.size() - 1];
330
+ size_t id = m_records.size() - 1;
331
+ connection::record& rec = m_records[id];
332
+ rec.id = (unsigned int)id;
333
+ return rec;
325
334
  }
326
335
  public:
327
336
  inline slaveStatus(THD *thd_arg, connection::records& recs, bzs::db::IblobBuffer* bb) :
@@ -329,7 +338,7 @@ public:
329
338
  {
330
339
  m_records.clear();
331
340
  }
332
- ~slaveStatus()
341
+ virtual ~slaveStatus()
333
342
  {
334
343
  m_bb->setFieldCount(m_blobfields);
335
344
  }
@@ -378,10 +387,214 @@ public:
378
387
  #endif
379
388
  };
380
389
 
381
- int getSlaveStatus(THD* thd, connection::records& recs, bzs::db::IblobBuffer* bb)
390
+ //----------------------------------------------------------------------
391
+ // slaveHosts
392
+ //----------------------------------------------------------------------
393
+ // rec.id = server_id
394
+ // rec.readCount = port
395
+ // rec.name = host
396
+ // opt_show_slave_auth_info
397
+ class slaveInfo
398
+ {
399
+ public:
400
+ std::string host;
401
+ std::string user;
402
+ std::string passwd;
403
+ std::string uuid;
404
+ void reset()
405
+ {
406
+ host = "";
407
+ user = "";
408
+ passwd = "";
409
+ uuid = "";
410
+
411
+ }
412
+ std::string tabSeparateValue()
413
+ {
414
+ return host + "\t" + user + "\t" + passwd + "\t" + uuid;
415
+ }
416
+ };
417
+
418
+
419
+ class slaveHosts : public slaveStatus
420
+ {
421
+ connection::record m_rec;
422
+ slaveInfo m_sinfo;
423
+ int m_strCount;
424
+ public:
425
+ inline slaveHosts(THD *thd_arg, connection::records& recs, bzs::db::IblobBuffer* bb) :
426
+ slaveStatus(thd_arg, recs, bb), m_strCount(0){}
427
+
428
+ bool store_longlong(longlong from, bool unsigned_flag)
429
+ {
430
+ if (m_rec.id == 0)
431
+ m_rec.id = (unsigned int)from;
432
+ else if (m_rec.readCount == 0)
433
+ m_rec.readCount = (unsigned int)from;
434
+ return false;
435
+ }
436
+ bool store_null()
437
+ {
438
+ return false;
439
+ }
440
+ bool str_store(const char *from, size_t length)
441
+ {
442
+ if (m_strCount == 0)
443
+ m_sinfo.host = from;
444
+ #if (defined(MYSQL_5_7))
445
+ else if (opt_show_slave_auth_info)
446
+ {
447
+ if (m_strCount == 1)
448
+ m_sinfo.user = from;
449
+ else if (m_strCount == 2)
450
+ m_sinfo.passwd = from;
451
+ else if (m_strCount == 3)
452
+ m_sinfo.uuid = from;
453
+ }
454
+ #endif
455
+ else if (m_strCount == 1)
456
+ m_sinfo.uuid = from;
457
+
458
+ ++m_strCount;
459
+ return false;
460
+ }
461
+
462
+ void addHostInfo()
463
+ {
464
+ std::string s = m_sinfo.tabSeparateValue();
465
+ m_rec.type = 1;
466
+ if (s.size() >= CON_REC_VALUE_SIZE)
467
+ {
468
+ ++m_blobfields;
469
+ m_rec.type = 2;
470
+ m_bb->addBlob((unsigned int)s.size() + 1, (unsigned short)m_records.size(),
471
+ (const unsigned char*)s.c_str());
472
+ }
473
+ else
474
+ strncpy(m_rec.name, s.c_str(), CON_REC_VALUE_SIZE);
475
+ }
476
+
477
+ #if (MYSQL_VERSION_ID < 50600 || defined(MARIADB_BASE_VERSION)) // MySQL 5.5
478
+ bool store(const char *from, size_t length, CHARSET_INFO *cs)
479
+ {
480
+ return str_store(from, length);
481
+ }
482
+ bool write()
483
+ {
484
+ addHostInfo();
485
+ m_records.push_back(m_rec);
486
+ m_rec.reset();
487
+ m_sinfo.reset();
488
+ m_strCount = 0;
489
+ return false;
490
+ }
491
+ #else
492
+ bool store(const char *from, size_t length, const CHARSET_INFO *cs)
493
+ {
494
+ return str_store(from, length);
495
+ }
496
+ bool end_row()
497
+ {
498
+ if (m_rec.id)
499
+ {
500
+ addHostInfo();
501
+ m_records.push_back(m_rec);
502
+ }
503
+ m_rec.reset();
504
+ m_sinfo.reset();
505
+ m_strCount = 0;
506
+ return false;
507
+ }
508
+ #endif
509
+ };
510
+
511
+
512
+ //----------------------------------------------------------------------
513
+ // channel
514
+ //----------------------------------------------------------------------
515
+ #pragma warning(disable : 4800)
516
+ #pragma warning(disable : 4271)
517
+ #pragma warning(disable : 4267)
518
+ #pragma warning(disable : 4244)
519
+ #if (defined(MARIADB_10_0) || defined(MARIADB_10_1))
520
+ #include "sql/slave.h"
521
+ #include "sql/rpl_mi.h"
522
+
523
+
524
+ int getChannels(THD* /*thd*/, connection::records& recs)
525
+ {
526
+ mysql_mutex_assert_owner(&LOCK_active_mi);
527
+ if (master_info_index)
528
+ {
529
+ uint_td size = master_info_index->master_info_hash.records;
530
+ for (uint_td i = 0;i < size; ++i)
531
+ {
532
+ Master_info* mi = (Master_info*)my_hash_element(&master_info_index->master_info_hash, i);
533
+ if (mi->host[0])
534
+ {
535
+ connection::record rec;
536
+ rec.type = 1;
537
+ strcpy_s(rec.name, CON_REC_VALUE_SIZE, mi->connection_name.str);
538
+ recs.push_back(rec);
539
+ }
540
+ }
541
+ }
542
+ return 0;
543
+ }
544
+ #elif defined(MYSQL_5_7)
545
+ #include "sql/rpl_msr.h" //channel_map
546
+ int getChannels(THD* thd, connection::records& recs)
547
+ {
548
+ channel_map.rdlock();
549
+ uint_td size = channel_map.get_num_instances();
550
+ if (size)
551
+ {
552
+ for (mi_map::iterator it = channel_map.begin(); it != channel_map.end(); it++)
553
+ {
554
+ Master_info* mi = it->second;
555
+ if (mi && mi->host[0])
556
+ {
557
+ connection::record rec;
558
+ rec.type = 1;
559
+ strcpy_s(rec.name, CON_REC_VALUE_SIZE, mi->get_channel());
560
+ recs.push_back(rec);
561
+ }
562
+ }
563
+ }
564
+ channel_map.unlock();
565
+ return 0;
566
+ }
567
+
568
+ #else
569
+ int getChannels(THD* thd, connection::records& recs)
570
+ {
571
+ return 0;
572
+ }
573
+ #endif
574
+ #pragma warning(default : 4800)
575
+ #pragma warning(default : 4271)
576
+ #pragma warning(default : 4267)
577
+ #pragma warning(default : 4244)
578
+ //------------------------------------------------------------------------------
579
+
580
+ int getSlaveStatus(THD* thd, const char* channel, connection::records& recs, bzs::db::IblobBuffer* bb)
382
581
  {
383
582
  slaveStatus ss(thd, recs, bb);
384
- return execSql(thd, "show slave status");
583
+ char tmp[128];
584
+ #if (defined(MYSQL_5_7))
585
+ sprintf_s(tmp, 128, "show slave status for channel '%s'", channel);
586
+ #elif (defined(MARIADB_10_1) || defined(MARIADB_10_0))
587
+ sprintf_s(tmp, 128, "show slave '%s' status", channel);
588
+ #else
589
+ sprintf_s(tmp, 128, "show slave status");
590
+ #endif
591
+ return execSql(thd, tmp);
592
+ }
593
+
594
+ int getSlaveHosts(THD* thd, connection::records& recs, bzs::db::IblobBuffer* bb)
595
+ {
596
+ slaveHosts ss(thd, recs, bb);
597
+ return execSql(thd, "show slave hosts");
385
598
  }
386
599
 
387
600
  #pragma GCC diagnostic warning "-Woverloaded-virtual"
@@ -48,6 +48,11 @@ struct binlogPos
48
48
  char type;
49
49
  char filename[BINLOGNAME_SIZE];
50
50
  char gtid[GTID_SIZE];
51
+ binlogPos()
52
+ {
53
+ filename[0] = 0x00;
54
+ gtid[0] = 0x00;
55
+ }
51
56
  };
52
57
  pragma_pop
53
58
 
@@ -19,10 +19,11 @@
19
19
  #include "client.h"
20
20
  #include "sqlBuilder.h"
21
21
  #include "stringConverter.h"
22
-
22
+ #include <errno.h>
23
23
  using namespace bzs::db::protocol::tdap::client;
24
24
 
25
- bzs::netsvc::client::connections* m_cons = NULL;
25
+ bnet::connections* m_cons = NULL;
26
+ extern void writeErrorLog(int err, const char* msg);
26
27
 
27
28
  namespace bzs
28
29
  {
@@ -51,6 +52,9 @@ short errorCode(const boost::system::error_code& e)
51
52
  {
52
53
  case 11004:
53
54
  case 11001:
55
+ case 109: // destination address required
56
+ case 2: //No such file or directory
57
+ case 1: //operation not permitted
54
58
  ret = ERROR_TD_HOSTNAME_NOT_FOUND;
55
59
  break;
56
60
  case 10060:
@@ -64,20 +68,21 @@ short errorCode(const boost::system::error_code& e)
64
68
  case 111: //connect: Connection refused
65
69
  case 10061:
66
70
  case 10053:
71
+ case 995: //Win32 WSA_OPERATION_ABORTED
67
72
  ret = ERROR_TD_CONNECTION_FAILURE;
68
73
  break;
69
74
  case 104: //write: Connection reset by peer
70
75
  case 10054:
71
- ret = ERROR_TD_NET_REMOTE_DISCONNECT;
72
- break;
73
76
  case 232:
74
- case 109:
75
- case 2:
76
- case 1:
77
- ret = ERROR_TD_INVALID_CLINETHOST;
77
+ ret = ERROR_TD_NET_REMOTE_DISCONNECT;
78
78
  break;
79
79
  default:
80
+ {
80
81
  ret = ERROR_TD_NET_OTHER;
82
+ char tmp[512];
83
+ sprintf_s(tmp, 512, "native socket error code %d", e.value());
84
+ writeErrorLog(ret, tmp);
85
+ }
81
86
  }
82
87
  return ret;
83
88
  }
@@ -87,9 +92,14 @@ short errorCode(const boost::system::error_code& e)
87
92
 
88
93
  int client::getServerCharsetIndex()
89
94
  {
90
- bzs::netsvc::client::connection* c = con();
95
+ assert(m_preResult == 0);
96
+ m_preResult = 0;
97
+ bnet::connection* c = con();
91
98
  if (!c)
99
+ {
100
+ m_preResult = ERROR_TD_NOT_CONNECTED;
92
101
  return -1;
102
+ }
93
103
  int v = c->charsetServer();
94
104
  if (v != -1)
95
105
  return v;
@@ -117,11 +127,15 @@ int client::getServerCharsetIndex()
117
127
  if (req.result == 0 && req.resultLen)
118
128
  {
119
129
  if (!checkVersion(ver))
130
+ {
131
+ m_preResult = SERVER_CLIENT_NOT_COMPATIBLE;
120
132
  return -1;
133
+ }
121
134
  c->setCharsetServer(mysql::charsetIndex(vers.cherserServer));
122
135
  return c->charsetServer();
123
136
  }
124
137
  }
138
+ m_preResult = errorCode(con()->error());
125
139
  return -1;
126
140
  }
127
141