transactd 3.1.0 → 3.2.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 (90) hide show
  1. checksums.yaml +4 -4
  2. data/bin/common/tdclc_32_3_2.dll +0 -0
  3. data/bin/common/{tdclc_64_3_1.dll → tdclc_64_3_2.dll} +0 -0
  4. data/build/swig/ruby/ruby.swg +3 -0
  5. data/build/swig/ruby/tdclrb_wrap.cpp +2413 -126
  6. data/build/swig/tdcl.i +120 -9
  7. data/build/tdclc/tdclc.cbproj +4 -1
  8. data/build/tdclc/tdclc.rc +4 -4
  9. data/build/tdclcpp/tdclcpp.rc +4 -4
  10. data/build/tdclcpp/tdclcpp_bc.cbproj +8 -1
  11. data/build/tdclrb/tdclrb.rc +4 -4
  12. data/source/bzs/db/engine/mysql/database.cpp +138 -130
  13. data/source/bzs/db/engine/mysql/database.h +43 -48
  14. data/source/bzs/db/engine/mysql/dbManager.cpp +81 -96
  15. data/source/bzs/db/engine/mysql/dbManager.h +13 -22
  16. data/source/bzs/db/engine/mysql/mysqlInternal.h +157 -291
  17. data/source/bzs/db/engine/mysql/mysqlProtocol.cpp +425 -0
  18. data/source/bzs/db/engine/mysql/mysqlProtocol.h +72 -0
  19. data/source/bzs/db/engine/mysql/mysqlThd.cpp +8 -6
  20. data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +7 -3
  21. data/source/bzs/db/protocol/hs/hsCommandExecuter.h +1 -0
  22. data/source/bzs/db/protocol/tdap/client/client.h +22 -8
  23. data/source/bzs/db/protocol/tdap/client/connMgr.cpp +225 -21
  24. data/source/bzs/db/protocol/tdap/client/connMgr.h +42 -16
  25. data/source/bzs/db/protocol/tdap/client/database.cpp +58 -15
  26. data/source/bzs/db/protocol/tdap/client/database.h +3 -3
  27. data/source/bzs/db/protocol/tdap/client/dbDef.cpp +93 -85
  28. data/source/bzs/db/protocol/tdap/client/dbDef.h +1 -2
  29. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +9 -5
  30. data/source/bzs/db/protocol/tdap/client/filter.h +2 -2
  31. data/source/bzs/db/protocol/tdap/client/groupComp.h +2 -2
  32. data/source/bzs/db/protocol/tdap/client/memRecord.cpp +1 -1
  33. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +71 -12
  34. data/source/bzs/db/protocol/tdap/client/nsDatabase.h +7 -1
  35. data/source/bzs/db/protocol/tdap/client/nsTable.cpp +35 -2
  36. data/source/bzs/db/protocol/tdap/client/nsTable.h +1 -0
  37. data/source/bzs/db/protocol/tdap/client/recordset.cpp +5 -1
  38. data/source/bzs/db/protocol/tdap/client/recordset.h +15 -0
  39. data/source/bzs/db/protocol/tdap/client/recordsetImple.h +21 -16
  40. data/source/bzs/db/protocol/tdap/client/serializer.cpp +32 -11
  41. data/source/bzs/db/protocol/tdap/client/serializer.h +4 -1
  42. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +3 -2
  43. data/source/bzs/db/protocol/tdap/client/sqlBuilder.h +3 -0
  44. data/source/bzs/db/protocol/tdap/client/table.cpp +18 -14
  45. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +8 -3
  46. data/source/bzs/db/protocol/tdap/mysql/characterset.cpp +1 -0
  47. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +83 -43
  48. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.h +3 -1
  49. data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +7 -7
  50. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +247 -137
  51. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +9 -9
  52. data/source/bzs/db/protocol/tdap/tdapSchema.cpp +1 -4
  53. data/source/bzs/db/protocol/tdap/tdapSchema.h +3 -7
  54. data/source/bzs/db/protocol/tdap/tdapcapi.h +23 -3
  55. data/source/bzs/db/protocol/tdap/uri.h +40 -0
  56. data/source/bzs/db/transactd/appModule.cpp +14 -5
  57. data/source/bzs/db/transactd/appModule.h +10 -1
  58. data/source/bzs/db/transactd/connManager.cpp +93 -48
  59. data/source/bzs/db/transactd/connManager.h +10 -7
  60. data/source/bzs/db/transactd/connectionRecord.h +114 -19
  61. data/source/bzs/env/tstring.h +2 -0
  62. data/source/bzs/example/changeSchema.cpp +1 -1
  63. data/source/bzs/example/changeSchema_c.cpp +1 -1
  64. data/source/bzs/example/insertRecords.cpp +2 -1
  65. data/source/bzs/example/insertRecords_c.cpp +2 -1
  66. data/source/bzs/example/queryData.cpp +5 -2
  67. data/source/bzs/netsvc/server/IAppModule.h +6 -0
  68. data/source/bzs/test/tdclatl/test_v3.js +75 -0
  69. data/source/bzs/test/tdclphp/transactd_v3_Test.php +104 -7
  70. data/source/bzs/test/tdclrb/transactd_v3_spec.rb +84 -0
  71. data/source/bzs/test/trdclengn/testField.h +66 -6
  72. data/source/bzs/test/trdclengn/test_tdclcpp_v3.cpp +10 -1
  73. data/source/bzs/test/trdclengn/test_trdclengn.cpp +85 -0
  74. data/source/bzs/test/trdclengn/testbase.h +1 -1
  75. data/source/global/tdclatl/BinlogPos.cpp +64 -0
  76. data/source/global/tdclatl/BinlogPos.h +84 -0
  77. data/source/global/tdclatl/ConnMgr.cpp +285 -0
  78. data/source/global/tdclatl/ConnMgr.h +83 -0
  79. data/source/global/tdclatl/ConnRecord.cpp +123 -0
  80. data/source/global/tdclatl/ConnRecord.h +69 -0
  81. data/source/global/tdclatl/ConnRecords.cpp +57 -0
  82. data/source/global/tdclatl/ConnRecords.h +55 -0
  83. data/source/global/tdclatl/Database.cpp +36 -0
  84. data/source/global/tdclatl/Database.h +4 -0
  85. data/source/global/tdclatl/Table.cpp +14 -1
  86. data/source/global/tdclatl/Table.h +1 -0
  87. data/source/global/tdclatl/resource.h +0 -0
  88. data/source/global/tdclatl/tdclatl.idl +148 -4
  89. metadata +14 -4
  90. data/bin/common/tdclc_32_3_1.dll +0 -0
@@ -20,6 +20,7 @@
20
20
  ================================================================= */
21
21
  #include "testbase.h"
22
22
  #include <bzs/db/protocol/tdap/btrDate.h>
23
+ #include <bzs/db/protocol/tdap/client/connMgr.h>
23
24
  #include <limits.h>
24
25
  #include <stdlib.h>
25
26
 
@@ -45,7 +46,7 @@ const char* test_records = "INSERT INTO `setenumbit` (`id`, `set5`, `set64`, `en
45
46
  "(3, '', '', '0', '0', b'0', b'00000000', b'00000000', b'00000000'),"
46
47
  "(4, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);";
47
48
 
48
-
49
+ const char* test_view = "create view idlessthan5 as select * from scores where id < 5";
49
50
 
50
51
  short createFieldStoreDataBase(database* db)
51
52
  {
@@ -55,6 +56,7 @@ short createFieldStoreDataBase(database* db)
55
56
  db->open(makeUri(PROTOCOL, HOSTNAME, DBNAMEV3, BDFNAME));
56
57
  if (db->stat()) return db->stat();
57
58
  db->drop();
59
+ if (db->stat()) return db->stat();
58
60
  db->create(makeUri(PROTOCOL, HOSTNAME, DBNAMEV3, BDFNAME));
59
61
  }
60
62
  if (db->stat()) return db->stat();
@@ -527,9 +529,9 @@ short createTestScores(database* db)
527
529
  td->primaryKeyNum = 0;
528
530
 
529
531
  short fieldnum = 0;
530
- fielddef* fd = insertField(def, tableid, fieldnum, _T("id"), ft_autoinc, 4);
531
- fd = insertField(def, tableid, ++fieldnum, _T("subject"), ft_integer, 4);
532
- fd = insertField(def, tableid, ++fieldnum, _T("score"), ft_integer, 4);
532
+ insertField(def, tableid, fieldnum, _T("id"), ft_autoinc, 4);
533
+ insertField(def, tableid, ++fieldnum, _T("subject"), ft_integer, 4);
534
+ fielddef* fd = insertField(def, tableid, ++fieldnum, _T("score"), ft_integer, 4);
533
535
  fd->setNullable(true);
534
536
 
535
537
  keydef* kd = insertKey(def, tableid, 0);
@@ -2310,13 +2312,13 @@ void testSetEnumBit()
2310
2312
 
2311
2313
  BOOST_CHECK(rs[1][_T("id")] == 2);
2312
2314
  BOOST_CHECK(rs[1][_T("set5")].i64() == 31);
2313
- BOOST_CHECK(rs[1][_T("set64")].i64() == 0x8000000000000001);
2315
+ BOOST_CHECK(rs[1][_T("set64")].i64() == (__int64)0x8000000000000001);
2314
2316
  BOOST_CHECK(rs[1][_T("enum2")].i64() == 1);
2315
2317
  BOOST_CHECK(rs[1][_T("enum260")].i64() == 260);
2316
2318
  BOOST_CHECK(rs[1][_T("bit1")].i64() == 1);
2317
2319
  BOOST_CHECK(rs[1][_T("bit8")].i64() == 0xFF);
2318
2320
  BOOST_CHECK(rs[1][_T("bit32")].i64() == 0xFFFFFFFF);
2319
- BOOST_CHECK(rs[1][_T("bit64")].i64() == 0xFFFFFFFFFFFFFFFF);
2321
+ BOOST_CHECK(rs[1][_T("bit64")].i64() == (__int64)0xFFFFFFFFFFFFFFFF);
2320
2322
 
2321
2323
  BOOST_CHECK(rs[2][_T("id")] == 3);
2322
2324
  BOOST_CHECK(rs[2][_T("set5")].i64() == 0);
@@ -3332,6 +3334,64 @@ void testSnapshotWithbinlog()
3332
3334
  BOOST_CHECK(tb->stat() == STATUS_ALREADY_INSNAPSHOT);
3333
3335
 
3334
3336
  db->endSnapshot();
3337
+ db->createTable(test_view);// create view for next test
3338
+ BOOST_CHECK(db->stat() == 0);
3339
+ }
3340
+
3341
+
3342
+ void testTableList()
3343
+ {
3344
+ nsdatabase::setCheckTablePtr(true);
3345
+ database_ptr db = createDatabaseObject();
3346
+ connMgr_ptr mgr(createConnMgr(db.get()));
3347
+ mgr->connect(makeUri(PROTOCOL, HOSTNAME, _T("")));
3348
+ BOOST_CHECK(mgr->stat() == 0);
3349
+ {
3350
+ const connMgr::records& recs = mgr->tables(DBNAMEV3);
3351
+ BOOST_CHECK(mgr->stat() == 0);
3352
+ BOOST_CHECK(recs.size() == 10); //8 + setenumbit + test.bdf
3353
+ }
3354
+ {
3355
+ const connMgr::records& recs = mgr->views(DBNAMEV3);
3356
+ BOOST_CHECK(mgr->stat() == 0);
3357
+ BOOST_CHECK(recs.size() == 1);
3358
+ BOOST_CHECK(recs[0].name == std::string("idlessthan5"));
3359
+ }
3360
+ {
3361
+ const connMgr::records& recs = mgr->schemaTables(DBNAMEV3);
3362
+ BOOST_CHECK(mgr->stat() == 0);
3363
+ BOOST_CHECK(recs.size() == 1);
3364
+ BOOST_CHECK(recs[0].name == std::string("test"));
3365
+ }
3366
+ {
3367
+ mgr->slaveStatus();
3368
+ BOOST_CHECK(mgr->stat() == 0);
3369
+ }
3370
+ mgr->disconnect();
3371
+
3372
+ }
3373
+
3374
+ void testCreateInfo()
3375
+ {
3376
+ nsdatabase::setCheckTablePtr(true);
3377
+ database_ptr db = createDatabaseObject();
3378
+ openDatabase(db, makeUri(PROTOCOL, HOSTNAME, DBNAMEV3, BDFNAME), TYPE_SCHEMA_BDF,TD_OPEN_READONLY);
3379
+ BOOST_CHECK(db->stat() == 0);
3380
+
3381
+ char buf[2048];
3382
+ uint_td size = 2048;
3383
+ db->getCreateViewSql(_T("idlessthan5"), buf, &size);
3384
+ BOOST_CHECK(db->stat() == 0);
3385
+ BOOST_CHECK(size > 20);
3386
+
3387
+ table* tb = db->openTable(1, TD_OPEN_READONLY);
3388
+ BOOST_CHECK(db->stat() == 0);
3389
+ size = 2048;
3390
+ tb->getCreateSql(buf, &size);
3391
+ BOOST_CHECK(db->stat() == 0);
3392
+ BOOST_CHECK(size > 1000);
3393
+ db->close();
3394
+ BOOST_CHECK(db->stat() == 0);
3335
3395
  }
3336
3396
 
3337
3397
  #pragma warning(default : 4996)
@@ -1053,5 +1053,14 @@ BOOST_AUTO_TEST_CASE(snapshot_binlog)
1053
1053
  }
1054
1054
  BOOST_AUTO_TEST_SUITE_END()
1055
1055
 
1056
-
1056
+ BOOST_AUTO_TEST_SUITE(tablelist)
1057
+ BOOST_AUTO_TEST_CASE(tablelist)
1058
+ {
1059
+ testTableList();
1060
+ }
1061
+ BOOST_AUTO_TEST_CASE(createInfo)
1062
+ {
1063
+ testCreateInfo();
1064
+ }
1065
+ BOOST_AUTO_TEST_SUITE_END()
1057
1066
  // ------------------------------------------------------------------------
@@ -3073,6 +3073,8 @@ void stringFileterCreateTable(database* db, int id, const _TCHAR* name,
3073
3073
  }
3074
3074
 
3075
3075
  fd->keylen = fd->len;
3076
+ if (use_nullfield)
3077
+ fd->setNullable(true, true);
3076
3078
  def->updateTableDef(id);
3077
3079
  BOOST_CHECK_MESSAGE(0 == def->stat(),
3078
3080
  "updateTableDef 2 stat = " << def->stat());
@@ -3091,6 +3093,8 @@ void stringFileterCreateTable(database* db, int id, const _TCHAR* name,
3091
3093
  fd->len = 12; // 8+4
3092
3094
  }
3093
3095
  fd->keylen = fd->len;
3096
+ if (use_nullfield)
3097
+ fd->setNullable(true, true);
3094
3098
  def->updateTableDef(id);
3095
3099
  BOOST_CHECK_MESSAGE(0 == def->stat(), "updateTableDef 3");
3096
3100
 
@@ -3294,6 +3298,86 @@ void doTestSF(table* tb)
3294
3298
  "doTestReadSF2 field value");
3295
3299
  }
3296
3300
 
3301
+ void doTestSF_Select(table* tb)
3302
+ {
3303
+ tb->setKeyNum(0);
3304
+ tb->clearBuffer();
3305
+
3306
+ tb->setFilter(_T("select id,name,namew name = 'あい*'"), 0, 10);
3307
+
3308
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
3309
+
3310
+ tb->seekFirst();
3311
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
3312
+
3313
+ tb->findNext(false);
3314
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
3315
+ BOOST_CHECK_MESSAGE(_tstring(_T("あいうえおかきくこ")) ==
3316
+ _tstring(tb->getFVstr(1)),
3317
+ "doTestReadSF2");
3318
+ BOOST_CHECK_MESSAGE(2 == (int)tb->recordCount(), "doTestReadSF2");
3319
+
3320
+ tb->setFilter(_T("select id,name,namew name <> 'あい*'"), 0, 10);
3321
+ BOOST_CHECK_MESSAGE(3 == (int)tb->recordCount(), "doTestReadSF2");
3322
+ tb->clearBuffer();
3323
+ tb->setFilter(_T("select id,name,namew name <> 'あい*'"), 0, 10);
3324
+ tb->seekFirst();
3325
+ tb->findNext(false);
3326
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1 stat = " << tb->stat());
3327
+ BOOST_CHECK_MESSAGE(_tstring(_T("A123456")) == _tstring(tb->getFVstr(2)),
3328
+ "doTestReadSF1");
3329
+
3330
+ tb->findNext();
3331
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
3332
+ BOOST_CHECK_MESSAGE(_tstring(_T("おはようございます")) ==
3333
+ _tstring(tb->getFVstr(2)),
3334
+ "doTestReadSF1");
3335
+
3336
+ tb->findNext();
3337
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
3338
+ BOOST_CHECK_MESSAGE(_tstring(_T("おめでとうございます。")) ==
3339
+ _tstring(tb->getFVstr(2)),
3340
+ "doTestReadSF1");
3341
+ tb->findNext();
3342
+ BOOST_CHECK_MESSAGE(9 == tb->stat(), "doTestReadSF1");
3343
+
3344
+ tb->clearBuffer();
3345
+ tb->seekLast();
3346
+ tb->findPrev(false);
3347
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
3348
+ BOOST_CHECK_MESSAGE(_tstring(_T("おめでとうございます。")) ==
3349
+ _tstring(tb->getFVstr(2)),
3350
+ "doTestReadSF1");
3351
+
3352
+ tb->findPrev();
3353
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
3354
+ BOOST_CHECK_MESSAGE(_tstring(_T("おはようございます")) ==
3355
+ _tstring(tb->getFVstr(2)),
3356
+ "doTestReadSF1");
3357
+
3358
+ tb->findPrev(false);
3359
+ BOOST_CHECK_MESSAGE(0 == tb->stat(), "doTestReadSF1");
3360
+ BOOST_CHECK_MESSAGE(_tstring(_T("A123456")) == _tstring(tb->getFVstr(2)),
3361
+ "doTestReadSF1");
3362
+
3363
+ tb->findPrev();
3364
+ BOOST_CHECK_MESSAGE(9 == tb->stat(), "doTestReadSF1");
3365
+
3366
+ tb->setFilter(_T("select id,name,namew name = 'あい'"), 0, 10);
3367
+ BOOST_CHECK_MESSAGE(0 == (int)tb->recordCount(), "doTestReadSF2");
3368
+
3369
+ tb->setFilter(_T("select id,name,namew name <> ''"), 0, 10);
3370
+ BOOST_CHECK_MESSAGE(5 == (int)tb->recordCount(), "doTestReadSF2");
3371
+
3372
+ // test setFilter don't change field value
3373
+ tb->clearBuffer();
3374
+ tb->setFV(_T("name"), _T("ABCDE"));
3375
+ tb->setFilter(_T("select id,name,namew name = 'あい'"), 0, 10);
3376
+ BOOST_CHECK_MESSAGE(_tstring(_T("ABCDE")) == _tstring(tb->getFVstr(1)),
3377
+ "doTestReadSF2 field value");
3378
+ }
3379
+
3380
+
3297
3381
  void doTestUpdateSF(table* tb)
3298
3382
  {
3299
3383
 
@@ -3344,6 +3428,7 @@ void doTestStringFileter(database* db, int id, const _TCHAR* name,
3344
3428
  doInsertStringFileter(tb);
3345
3429
  doTestReadSF(tb);
3346
3430
  doTestSF(tb);
3431
+ doTestSF_Select(tb);
3347
3432
  doTestUpdateSF(tb);
3348
3433
  tb->release();
3349
3434
  }
@@ -72,7 +72,7 @@ const _TCHAR* makeUri(const _TCHAR* protocol, const _TCHAR* host,
72
72
  return g_uri;
73
73
  }
74
74
 
75
- static bool use_nullfield = false;
75
+ static bool use_nullfield = true;
76
76
  static bool use_mysqlNullMode = true;
77
77
 
78
78
  boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]);
@@ -0,0 +1,64 @@
1
+ /*=================================================================
2
+ Copyright (C) 2016 BizStation Corp All rights reserved.
3
+
4
+ This program is free software; you can redistribute it and/or
5
+ modify it under the terms of the GNU General Public License
6
+ as published by the Free Software Foundation; either version 2
7
+ of the License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17
+ 02111-1307, USA.
18
+ =================================================================*/
19
+ // BinlogPos.cpp : CBinlogPos �̎���
20
+
21
+ #include "stdafx.h"
22
+ #include "BinlogPos.h"
23
+
24
+
25
+ // CBinlogPos
26
+ #ifdef _WIN64
27
+ STDMETHODIMP CBinlogPos::get_Pos(__int64* retVal)
28
+ {
29
+ *retVal = (__int64)m_pos.pos;
30
+ return S_OK;
31
+ }
32
+ #else
33
+ STDMETHODIMP CBinlogPos::get_Pos(int* retVal)
34
+ {
35
+ *retVal = (int)m_pos.pos;
36
+ return S_OK;
37
+ }
38
+ #endif
39
+
40
+ STDMETHODIMP CBinlogPos::get_Type(short* retVal)
41
+ {
42
+ *retVal = (short)m_pos.type;
43
+ return S_OK;
44
+ }
45
+
46
+ STDMETHODIMP CBinlogPos::get_Filename(BSTR* retVal)
47
+ {
48
+ CComBSTR ret;
49
+ ret = m_pos.filename;
50
+ *retVal = ret.Copy();
51
+ return S_OK;
52
+ }
53
+
54
+ STDMETHODIMP CBinlogPos::get_Gtid(BSTR* retVal)
55
+ {
56
+ CComBSTR ret;
57
+ ret = m_pos.gtid;
58
+ *retVal = ret.Copy();
59
+ return S_OK;
60
+ }
61
+
62
+
63
+
64
+
@@ -0,0 +1,84 @@
1
+ /*=================================================================
2
+ Copyright (C) 2016 BizStation Corp All rights reserved.
3
+
4
+ This program is free software; you can redistribute it and/or
5
+ modify it under the terms of the GNU General Public License
6
+ as published by the Free Software Foundation; either version 2
7
+ of the License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17
+ 02111-1307, USA.
18
+ =================================================================*/
19
+ // BinlogPos.h : CBinlogPos �̐錾
20
+
21
+ #pragma once
22
+ #include "resource.h" // ���C�� �V���{��
23
+
24
+
25
+
26
+ #include "tdclatl_i.h"
27
+ #include <bzs/db/protocol/tdap/client/nsdatabase.h>
28
+
29
+
30
+ #if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
31
+ #error "DCOM �̊��S�T�|�[�g���܂�ł��Ȃ� Windows Mobile �v���b�g�t�H�[���̂悤�� Windows CE �v���b�g�t�H�[���ł́A�P��X���b�h COM �I�u�W�F�N�g�͐������T�|�[�g����Ă��܂���BATL ���P��X���b�h COM �I�u�W�F�N�g�̍쐬���T�|�[�g���邱�ƁA����т��̒P��X���b�h COM �I�u�W�F�N�g�̎����̎g�p�����‚��邱�Ƃ���������ɂ́A_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA ���`���Ă��������B���g�p�� rgs �t�@�C���̃X���b�h ���f���� 'Free' �ɐݒ肳��Ă���ADCOM Windows CE �ȊO�̃v���b�g�t�H�[���ŃT�|�[�g�����B��̃X���b�h ���f���Ɛݒ肳��Ă��܂����B"
32
+ #endif
33
+
34
+ using namespace ATL;
35
+
36
+
37
+ // CBitset
38
+
39
+ class ATL_NO_VTABLE CBinlogPos :
40
+ public CComObjectRootEx<CComSingleThreadModel>,
41
+ public CComCoClass<CBinlogPos, &CLSID_BinlogPos>,
42
+ public IDispatchImpl<IBinlogPos, &IID_IBinlogPos, &LIBID_transactd, /*wMajor =*/ 1, /*wMinor =*/ 0>
43
+ {
44
+
45
+ public:
46
+ bzs::db::protocol::tdap::client::binlogPos m_pos;
47
+
48
+ CBinlogPos()
49
+ {
50
+ }
51
+
52
+ DECLARE_REGISTRY_RESOURCEID(IDR_BITSET)
53
+
54
+
55
+ BEGIN_COM_MAP(CBinlogPos)
56
+ COM_INTERFACE_ENTRY(IBinlogPos)
57
+ COM_INTERFACE_ENTRY(IDispatch)
58
+ END_COM_MAP()
59
+
60
+
61
+
62
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
63
+
64
+ HRESULT FinalConstruct()
65
+ {
66
+ return S_OK;
67
+ }
68
+
69
+ void FinalRelease()
70
+ {
71
+ }
72
+
73
+ public:
74
+ #ifdef _WIN64
75
+ STDMETHOD(get_Pos)(__int64* retVal);
76
+ #else
77
+ STDMETHOD(get_Pos)(int* retVal);
78
+ #endif
79
+ STDMETHOD(get_Type)(short* retVal);
80
+ STDMETHOD(get_Filename)(BSTR* retVal);
81
+ STDMETHOD(get_Gtid)(BSTR* retVal);
82
+ };
83
+
84
+ //OBJECT_ENTRY_AUTO(__uuidof(Bitset), CBitset)
@@ -0,0 +1,285 @@
1
+ /*=================================================================
2
+ Copyright (C) 2016 BizStation Corp All rights reserved.
3
+
4
+ This program is free software; you can redistribute it and/or
5
+ modify it under the terms of the GNU General Public License
6
+ as published by the Free Software Foundation; either version 2
7
+ of the License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17
+ 02111-1307, USA.
18
+ =================================================================*/
19
+ #include "stdafx.h"
20
+ #include "ConnMgr.h"
21
+ #include "ConnRecords.h"
22
+ #include "Database.h"
23
+
24
+ using namespace bzs::db::protocol::tdap::client;
25
+
26
+ STDMETHODIMP CConnMgr::InterfaceSupportsErrorInfo(REFIID riid)
27
+ {
28
+ static const IID* const arr[] =
29
+ {
30
+ &IID_IConnMgr
31
+ };
32
+
33
+ for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
34
+ {
35
+ if (InlineIsEqualGUID(*arr[i],riid))
36
+ return S_OK;
37
+ }
38
+ return S_FALSE;
39
+ }
40
+
41
+ STDMETHODIMP CConnMgr::SetDatabase(VARIANT Value)
42
+ {
43
+ try
44
+ {
45
+ if (Value.vt != VT_DISPATCH)
46
+ {
47
+ _TCHAR tmp[256];
48
+ wsprintf(tmp, _T("SetDatabase Type error type = %d"), Value.vt);
49
+ return Error(tmp, IID_IConnMgr);
50
+ }
51
+
52
+ CDatabase* p = dynamic_cast<CDatabase*>(Value.pdispVal);
53
+ if (p)
54
+ {
55
+ m_mgr = connMgr::create(p->database());
56
+ return S_OK;
57
+ }
58
+ return Error(_T("SetDatabase Type error"), IID_IConnMgr);
59
+ }
60
+ catch (bzs::rtl::exception& e)
61
+ {
62
+ return Error((*bzs::rtl::getMsg(e)).c_str(), IID_IConnMgr);
63
+ }
64
+ }
65
+
66
+
67
+ STDMETHODIMP CConnMgr::Connect(BSTR uri, VARIANT_BOOL* retVal)
68
+ {
69
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
70
+ m_mgr->connect(uri);
71
+ return S_OK;
72
+ }
73
+
74
+ STDMETHODIMP CConnMgr::Disconnect()
75
+ {
76
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
77
+ m_mgr->disconnect();
78
+ return S_OK;
79
+ }
80
+
81
+ void setResult(CComObject<CConnRecords>* obj, IConnRecords** retVal)
82
+ {
83
+ IConnRecords* recs;
84
+ obj->QueryInterface(IID_IConnRecords, (void**)&recs);
85
+ _ASSERTE(recs);
86
+ *retVal = recs;
87
+
88
+ }
89
+
90
+ STDMETHODIMP CConnMgr::Databases(IConnRecords** retVal)
91
+ {
92
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
93
+ CComObject<CConnRecords>* obj;
94
+ CComObject<CConnRecords>::CreateInstance(&obj);
95
+ if (!obj)
96
+ return Error("CreateInstance ConnRecords", IID_IConnMgr);
97
+ obj->m_recs = m_mgr->databases();
98
+ setResult(obj, retVal);
99
+ return S_OK;
100
+ }
101
+
102
+ STDMETHODIMP CConnMgr::Tables(BSTR dbname, IConnRecords** retVal)
103
+ {
104
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
105
+ CComObject<CConnRecords>* obj;
106
+ CComObject<CConnRecords>::CreateInstance(&obj);
107
+ if (!obj)
108
+ return Error("CreateInstance ConnRecords", IID_IConnMgr);
109
+ obj->m_recs = m_mgr->tables(dbname);
110
+ setResult(obj, retVal);
111
+ return S_OK;
112
+ }
113
+
114
+ STDMETHODIMP CConnMgr::Views(BSTR dbname, IConnRecords** retVal)
115
+ {
116
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
117
+ CComObject<CConnRecords>* obj;
118
+ CComObject<CConnRecords>::CreateInstance(&obj);
119
+ if (!obj)
120
+ return Error("CreateInstance ConnRecords", IID_IConnMgr);
121
+ obj->m_recs = m_mgr->views(dbname);
122
+ setResult(obj, retVal);
123
+ return S_OK;
124
+ }
125
+
126
+ STDMETHODIMP CConnMgr::SchemaTables(BSTR dbname, IConnRecords** retVal)
127
+ {
128
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
129
+ CComObject<CConnRecords>* obj;
130
+ CComObject<CConnRecords>::CreateInstance(&obj);
131
+ if (!obj)
132
+ return Error("CreateInstance ConnRecords", IID_IConnMgr);
133
+ obj->m_recs = m_mgr->schemaTables(dbname);
134
+ setResult(obj, retVal);
135
+ return S_OK;
136
+ }
137
+
138
+ STDMETHODIMP CConnMgr::Sysvars(IConnRecords** retVal)
139
+ {
140
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
141
+ CComObject<CConnRecords>* obj;
142
+ CComObject<CConnRecords>::CreateInstance(&obj);
143
+ if (!obj)
144
+ return Error("CreateInstance ConnRecords", IID_IConnMgr);
145
+ obj->m_recs = m_mgr->sysvars();
146
+ setResult(obj, retVal);
147
+ return S_OK;
148
+ }
149
+
150
+ STDMETHODIMP CConnMgr::SlaveStatus(IConnRecords** retVal)
151
+ {
152
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
153
+ CComObject<CConnRecords>* obj;
154
+ CComObject<CConnRecords>::CreateInstance(&obj);
155
+ if (!obj)
156
+ return Error("CreateInstance ConnRecords", IID_IConnMgr);
157
+ obj->m_recs = m_mgr->slaveStatus();
158
+ setResult(obj, retVal);
159
+ return S_OK;
160
+ }
161
+
162
+ STDMETHODIMP CConnMgr::Connections(IConnRecords** retVal)
163
+ {
164
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
165
+ CComObject<CConnRecords>* obj;
166
+ CComObject<CConnRecords>::CreateInstance(&obj);
167
+ if (!obj)
168
+ return Error("CreateInstance ConnRecords", IID_IConnMgr);
169
+ obj->m_recs = m_mgr->connections();
170
+ setResult(obj, retVal);
171
+ return S_OK;
172
+ }
173
+
174
+ #ifdef _WIN64
175
+ STDMETHODIMP CConnMgr::InUseDatabases(__int64 connid, IConnRecords** retVal)
176
+ {
177
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
178
+ CComObject<CConnRecords>* obj;
179
+ CComObject<CConnRecords>::CreateInstance(&obj);
180
+ if (!obj)
181
+ return Error("CreateInstance ConnRecords", IID_IConnMgr);
182
+ obj->m_recs = m_mgr->inUseDatabases(connid);
183
+ setResult(obj, retVal);
184
+ return S_OK;
185
+ }
186
+
187
+ STDMETHODIMP CConnMgr::InUseTables(__int64 connid, int db, IConnRecords** retVal)
188
+ {
189
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
190
+ CComObject<CConnRecords>* obj;
191
+ CComObject<CConnRecords>::CreateInstance(&obj);
192
+ if (!obj)
193
+ return Error("CreateInstance ConnRecords", IID_IConnMgr);
194
+ obj->m_recs = m_mgr->inUseTables(connid, db);
195
+ setResult(obj, retVal);
196
+ return S_OK;
197
+ }
198
+
199
+ STDMETHODIMP CConnMgr::PostDisconnectOne(__int64 connid)
200
+ {
201
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
202
+ m_mgr->postDisconnectOne(connid);
203
+ return S_OK;
204
+ }
205
+
206
+ #else
207
+
208
+ STDMETHODIMP CConnMgr::InUseDatabases(BSTR connid, IConnRecords** retVal)
209
+ {
210
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
211
+ CComObject<CConnRecords>* obj;
212
+ CComObject<CConnRecords>::CreateInstance(&obj);
213
+ if (!obj)
214
+ return Error("CreateInstance ConnRecords", IID_IConnMgr);
215
+ obj->m_recs = m_mgr->inUseDatabases(_wtoi64(connid));
216
+ setResult(obj, retVal);
217
+ return S_OK;
218
+ }
219
+
220
+ STDMETHODIMP CConnMgr::InUseTables(BSTR connid, int db, IConnRecords** retVal)
221
+ {
222
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
223
+ CComObject<CConnRecords>* obj;
224
+ CComObject<CConnRecords>::CreateInstance(&obj);
225
+ if (!obj)
226
+ return Error("CreateInstance ConnRecords", IID_IConnMgr);
227
+ obj->m_recs = m_mgr->inUseTables(_wtoi64(connid), db);
228
+ setResult(obj, retVal);
229
+ return S_OK;
230
+ }
231
+
232
+ STDMETHODIMP CConnMgr::PostDisconnectOne(BSTR connid)
233
+ {
234
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
235
+ m_mgr->postDisconnectOne(_wtoi64(connid));
236
+ return S_OK;
237
+ }
238
+
239
+ #endif
240
+
241
+ STDMETHODIMP CConnMgr::PostDisconnectAll()
242
+ {
243
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
244
+ m_mgr->postDisconnectAll();
245
+ return S_OK;
246
+ }
247
+
248
+ STDMETHODIMP CConnMgr::get_Stat(short* retVal)
249
+ {
250
+ if (m_mgr == NULL) Error(_T("No database error"), IID_IConnMgr);
251
+ *retVal = m_mgr->stat();
252
+ return S_OK;
253
+ }
254
+
255
+ STDMETHODIMP CConnMgr::TdapErr(OLE_HANDLE hWnd, BSTR* retVal)
256
+ {
257
+ return S_OK;
258
+ }
259
+
260
+ STDMETHODIMP CConnMgr::RemoveSystemDb(IConnRecords** retVal)
261
+ {
262
+ CConnRecords* p = dynamic_cast<CConnRecords*>(*retVal);
263
+ if (p)
264
+ {
265
+ connMgr::removeSystemDb(p->m_recs);
266
+ return S_OK;
267
+ }
268
+ return Error(_T("Invalid object"), IID_IConnMgr);
269
+ }
270
+
271
+ STDMETHODIMP CConnMgr::SlaveStatusName(int index, BSTR* retVal)
272
+ {
273
+ CComBSTR ret= connMgr::slaveStatusName(index);
274
+ *retVal = ret.Copy();
275
+ return S_OK;
276
+ }
277
+
278
+ STDMETHODIMP CConnMgr::SysvarName(int index, BSTR* retVal)
279
+ {
280
+ CComBSTR ret= connMgr::sysvarName(index);
281
+ *retVal = ret.Copy();
282
+ return S_OK;
283
+ }
284
+
285
+