transactd 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -23,6 +23,7 @@
23
23
  #include <sys/stat.h>
24
24
  #include <stdio.h>
25
25
  #include <boost/thread/mutex.hpp>
26
+ #include <bzs/db/protocol/tdap/uri.h>
26
27
 
27
28
  #ifdef LINUX
28
29
  #include <dlfcn.h>
@@ -146,27 +147,31 @@ struct nsdbimpl
146
147
  short snapShotCount;
147
148
  nstable* tables[nsdatabase::maxtables];
148
149
  uchar_td cidPtr[16];
149
- uchar_td* cid() { return cidPtr; }
150
150
  _TCHAR bdfPath[MAX_PATH];
151
151
  short tableCount;
152
152
  short lockWaitCount;
153
153
  short lockWaitTime;
154
- bool uriMode;
155
- bool uselongFilename;
156
- bool localSharing;
157
- bool ignoreTestPtr;
158
- bool reconnected;
154
+ short enginIndex;
155
+ struct
156
+ {
157
+ bool uriMode : 1;
158
+ bool uselongFilename : 1;
159
+ bool localSharing : 1;
160
+ bool ignoreTestPtr : 1;
161
+ bool reconnected : 1;
162
+ bool associateMode : 1;
163
+ };
159
164
  nsdbimpl()
160
165
  : refCount(1), tranCount(0), id(0), snapShotCount(0), tableCount(0),
161
- lockWaitCount(10), lockWaitTime(100), uriMode(false),
166
+ lockWaitCount(10), lockWaitTime(100), enginIndex(0), uriMode(false),
162
167
  uselongFilename(false), localSharing(false), ignoreTestPtr(false),
163
- reconnected(false)
168
+ reconnected(false), associateMode(false)
164
169
  {
165
170
  }
166
171
 
167
172
  void setId(unsigned short id_)
168
173
  {
169
- id = id_;
174
+ id = enginIndex = id_;
170
175
 
171
176
  // make client id
172
177
  memset(cidPtr, 0, 12);
@@ -184,6 +189,7 @@ struct nsdbimpl
184
189
  lockWaitTime = rt.lockWaitCount;
185
190
  uselongFilename = rt.uselongFilename;
186
191
  uriMode = rt.uriMode;
192
+ associateMode = rt.associateMode;
187
193
  }
188
194
  return *this;
189
195
  }
@@ -241,6 +247,11 @@ nsdatabase::nsdatabase() : m_stat(0)
241
247
  m_nsimpl->setId((unsigned short)index + 1);
242
248
  }
243
249
 
250
+ void nsdatabase::setAssociate()
251
+ {
252
+ m_nsimpl->associateMode = true;
253
+ }
254
+
244
255
  int nsdatabase::refCount() const
245
256
  {
246
257
  return m_nsimpl->refCount;
@@ -262,8 +273,8 @@ nsdatabase::~nsdatabase()
262
273
  reset();
263
274
 
264
275
  boost::mutex::scoped_lock lck(g_mutex);
265
- if (m_nsimpl->id != 0)
266
- engins()[m_nsimpl->id - 1] = NULL;
276
+ if (m_nsimpl->enginIndex != 0)
277
+ engins()[m_nsimpl->enginIndex - 1] = NULL;
267
278
  delete m_nsimpl;
268
279
  m_nsimpl = 0x00;
269
280
  #ifdef _WIN32
@@ -593,6 +604,21 @@ void nsdatabase::reset()
593
604
  m_btrcallid = getBtrvEntryPoint();
594
605
  }
595
606
 
607
+ bool nsdatabase::checkAssociate()
608
+ {
609
+ if (m_nsimpl->associateMode)
610
+ {
611
+ m_stat = STATUS_NOSUPPORT_OP;
612
+ return false;
613
+ }
614
+ return true;
615
+ }
616
+
617
+ bool nsdatabase::isAssociate() const
618
+ {
619
+ return m_nsimpl->associateMode;
620
+ }
621
+
596
622
  void nsdatabase::resetSnapshot()
597
623
  {
598
624
  if (m_nsimpl->snapShotCount)
@@ -604,6 +630,8 @@ void nsdatabase::resetSnapshot()
604
630
 
605
631
  void nsdatabase::beginSnapshot(short bias, binlogPos* bpos)
606
632
  {
633
+ if (!checkAssociate()) return;
634
+
607
635
  if (m_nsimpl->snapShotCount == 0)
608
636
  {
609
637
  uint_td datalen = (bias == CONSISTENT_READ_WITH_BINLOG_POS) ? sizeof(binlogPos) : 0;
@@ -637,6 +665,7 @@ void nsdatabase::endSnapshot()
637
665
 
638
666
  void nsdatabase::beginTrn(short BIAS)
639
667
  {
668
+ if (!checkAssociate()) return;
640
669
  if (m_nsimpl->tranCount == 0)
641
670
  {
642
671
  m_stat = m_btrcallid((ushort_td)(BIAS + TD_BEGIN_TRANSACTION), NULL,
@@ -737,6 +766,28 @@ void nsdatabase::getBtrVersion(btrVersions* Vers, uchar_td* posblk)
737
766
  }
738
767
  }
739
768
 
769
+ char* nsdatabase::getCreateViewSql(const _TCHAR* name , char* retbuf, uint_td* size)
770
+ {
771
+ if (isUseTransactd() == false)
772
+ {
773
+ m_stat = STATUS_NOSUPPORT_OP;
774
+ return retbuf;
775
+ }
776
+ _TCHAR tmp[MAX_PATH];
777
+ stripParam(uri(), tmp, MAX_PATH);
778
+ _tcscat(tmp, _T("?dbfile="));
779
+ _tcscat(tmp, name);
780
+
781
+ char Uri[MAX_PATH] = { 0x00 };
782
+ const char* p = nsdatabase::toServerUri(Uri, MAX_PATH, tmp, true);
783
+ keylen_td keylen = (keylen_td)strlen(p) + 1;
784
+ m_stat = m_btrcallid(TD_GET_SCHEMA, NULL, retbuf, size, (void*)p, keylen,
785
+ SC_SUBOP_VIEW_BY_SQL, m_nsimpl->cidPtr);
786
+ if (m_stat != STATUS_SUCCESS)
787
+ retbuf[0] = 0x00;
788
+ return retbuf;
789
+ }
790
+
740
791
  bool nsdatabase::useLongFilename()
741
792
  {
742
793
  return m_nsimpl->uselongFilename;
@@ -782,6 +833,13 @@ void nsdatabase::readDatabaseDirectory(_TCHAR* retbuf, uchar_td buflen)
782
833
 
783
834
  bool nsdatabase::connect(const _TCHAR* URI, bool newConnection)
784
835
  {
836
+ if (!checkAssociate()) return false;
837
+ if (isOpened())
838
+ {
839
+ m_stat = STATUS_DB_YET_OPEN;
840
+ return false;
841
+ }
842
+
785
843
  if (isTransactdUri(URI))
786
844
  {
787
845
  if (!setUseTransactd())
@@ -806,6 +864,8 @@ bool nsdatabase::connect(const _TCHAR* URI, bool newConnection)
806
864
 
807
865
  bool nsdatabase::disconnect(const _TCHAR* URI)
808
866
  {
867
+ if (!checkAssociate()) return false;
868
+
809
869
  if (!URI || (URI[0] == 0x00) || isTransactdUri(URI))
810
870
  if (!setUseTransactd())
811
871
  return false;
@@ -820,7 +880,6 @@ bool nsdatabase::disconnect(const _TCHAR* URI)
820
880
  return true;
821
881
  }
822
882
 
823
-
824
883
  bool nsdatabase::disconnectForReconnectTest()
825
884
  {
826
885
  //Transactd only
@@ -99,6 +99,8 @@ protected:
99
99
  void addref();
100
100
  void internalRelease() { nsdatabase::release(); }
101
101
  void doReconnect(nstable* tb);
102
+ void setAssociate();
103
+ bool checkAssociate();
102
104
  virtual bool doReopenDatabaseSchema(){ return true; }
103
105
  virtual void* getExtendBufferForOpen(uint_td& size){ return NULL; };
104
106
  public:
@@ -152,8 +154,11 @@ public:
152
154
  bool disconnectForReconnectTest(); //for connection brokn emulate
153
155
  bool reconnect();
154
156
  bool isReconnected() const;
157
+ bool isAssociate() const;
158
+ virtual bool isOpened() const { return false;}
159
+ char* getCreateViewSql(const _TCHAR* name, char* retbuf, uint_td* size);
155
160
 
156
- static const int maxtables = 50;
161
+ static const int maxtables = 150;
157
162
  static bool trnsactionFlushWaitStatus();
158
163
  static void setExecCodePage(unsigned int codepage);
159
164
  static unsigned int execCodePage();
@@ -163,6 +168,7 @@ public:
163
168
  static WIN_TPOOL_SHUTDOWN_PTR getWinTPoolShutdownFunc();
164
169
  static bool testTablePtr(nstable* ptr);
165
170
  static void setCheckTablePtr(bool v);
171
+
166
172
  /** @endcond */
167
173
  };
168
174
 
@@ -762,6 +762,40 @@ void nstable::clearOwnerName()
762
762
  tdap(TD_CLEAR_OWNERNAME);
763
763
  }
764
764
 
765
+ char* nstable::getCreateSql(char* retbuf, uint_td* size /* in out */)
766
+ {
767
+ if (isUseTransactd() == false)
768
+ {
769
+ m_stat = STATUS_NOSUPPORT_OP;
770
+ return retbuf;
771
+ }
772
+
773
+ void* tmp = m_keybuf;
774
+ char_td keynum = m_keynum;
775
+ void* pdata = m_pdata;
776
+
777
+ char tmpName[MAX_PATH] = { 0x00 };
778
+ const char* p = nsdatabase::toServerUri(tmpName, MAX_PATH, uri(), true);
779
+ m_keybuf = (void*)p;
780
+ m_keylen = (keylen_td)strlen(p) + 1;
781
+ m_pdata = retbuf;
782
+ m_datalen = *size;
783
+ m_keynum = SC_SUBOP_BY_SQL;
784
+
785
+ tdap((ushort_td)TD_GET_SCHEMA);
786
+ if (m_stat != STATUS_SUCCESS)
787
+ {
788
+ retbuf[0] = 0x00;
789
+ *size = 0;
790
+ }else
791
+ *size = m_datalen;
792
+
793
+ m_keybuf = tmp;
794
+ m_keynum = keynum;
795
+ m_pdata = pdata;
796
+ return retbuf;
797
+ }
798
+
765
799
  void nstable::stats(void* dataBuf, uint_td len, bool estimate)
766
800
  {
767
801
  void* svm_pdata = m_pdata;
@@ -811,7 +845,6 @@ ushort_td nstable::recordLength()
811
845
 
812
846
  void nstable::doCreateIndex(bool specifyKeyNum)
813
847
  {
814
-
815
848
  if (specifyKeyNum)
816
849
  m_keynum += ((uchar_td)0x80);
817
850
  tdap(TD_BUILD_INDEX);
@@ -965,7 +998,7 @@ _TCHAR* nstable::getDirURI(const _TCHAR* path, _TCHAR* buf)
965
998
  else
966
999
  p2 = NULL;
967
1000
  }
968
- if (p)
1001
+ if (p && (uri == false))
969
1002
  *p = 0x00;
970
1003
  if (p2)
971
1004
  *(p2 + 1) = 0x00;
@@ -222,6 +222,7 @@ public:
222
222
  void clearOwnerName();
223
223
  ushort_td recordLength();
224
224
  void stats(void* databuffer, uint_td buflen, bool estimate = true);
225
+ char* getCreateSql(char* retbuf, uint_td* size);
225
226
  void unlock(bookmark_td& bm);
226
227
  void unlock();
227
228
  char_td mode() const;
@@ -1,5 +1,5 @@
1
1
  /*=================================================================
2
- Copyright (C) 2014 BizStation Corp All rights reserved.
2
+ Copyright (C) 2014-2016 BizStation Corp All rights reserved.
3
3
 
4
4
  This program is free software; you can redistribute it and/or
5
5
  modify it under the terms of the GNU General Public License
@@ -208,6 +208,10 @@ void recordset::dump()
208
208
  {
209
209
  m_imple->dump();
210
210
  }
211
+ void recordset::dump(std::tostream& os)
212
+ {
213
+ m_imple->dump(os);
214
+ }
211
215
  #endif
212
216
 
213
217
  } // namespace client
@@ -19,6 +19,10 @@
19
19
  02111-1307, USA.
20
20
  =================================================================*/
21
21
  #include "groupQuery.h"
22
+ #ifdef _DEBUG
23
+ #include <iostream>
24
+ #include <bzs/env/tstring.h>
25
+ #endif
22
26
 
23
27
  namespace bzs
24
28
  {
@@ -74,6 +78,17 @@ public:
74
78
 
75
79
  #ifdef _DEBUG
76
80
  void dump();
81
+ void dump(std::tostream& os);
82
+
83
+ /*
84
+ Output to file.
85
+
86
+ #include <fstream>
87
+ std::locale::global(std::locale("japanese"));
88
+ std::wofstream ost("temp.txt");
89
+ rs.dump(ost);
90
+ */
91
+
77
92
  #endif
78
93
  };
79
94
 
@@ -81,14 +81,14 @@ class dumpRecordset
81
81
  return s;
82
82
  }
83
83
 
84
- void printValue(size_t width, std::ios::fmtflags f, const _TCHAR* value)
84
+ void printValue(std::tostream& os, size_t width, std::ios::fmtflags f, const _TCHAR* value)
85
85
  {
86
- std::tcout.setf(f, std::ios::adjustfield);
87
- std::tcout << _T(" ") << std::setw(width) << value << _T(" |");
86
+ os.setf(f, std::ios::adjustfield);
87
+ os << _T(" ") << std::setw(width) << value << _T(" |");
88
88
  }
89
89
 
90
90
  const _TCHAR* value(const fielddef& fd) {return fd.name();}
91
- const _TCHAR* value(const field& fd)
91
+ const _TCHAR* value(const field& fd)
92
92
  {
93
93
  if (fd.isNull())
94
94
  return _T("NULL");
@@ -96,31 +96,31 @@ class dumpRecordset
96
96
  }
97
97
 
98
98
  template <class T>
99
- void printRecord(const T& coll)
99
+ void printRecord(std::tostream& os, const T& coll)
100
100
  {
101
- std::tcout << _T("|");
101
+ os << _T("|");
102
102
  for (size_t col = 0; col < m_widths.size(); ++col)
103
- printValue(m_widths[col], m_ailgns[col], value(coll[(short)col]));
104
- std::tcout << std::endl;
103
+ printValue(os, m_widths[col], m_ailgns[col], value(coll[(short)col]));
104
+ os << std::endl;
105
105
  }
106
106
  public:
107
- void operator()(RS& rs)
107
+ void operator()(std::tostream& os, RS& rs)
108
108
  {
109
109
  if (rs.size())
110
110
  {
111
111
  cacheWidthAndAlign(rs);
112
112
  std::_tstring line = makeLine();
113
113
  //header
114
- std::tcout << line;
115
- printRecord(*rs.fieldDefs());
116
- std::tcout << line;
114
+ os << line;
115
+ printRecord(os, *rs.fieldDefs());
116
+ os << line;
117
117
 
118
118
  //field value
119
119
  for(size_t i = 0; i < rs.size(); ++i)
120
- printRecord(rs[i]);
121
- std::tcout << line;
120
+ printRecord(os, rs[i]);
121
+ os << line;
122
122
  }else
123
- std::tcout << _T("Empty set ") << std::endl;
123
+ os << _T("Empty set ") << std::endl;
124
124
  }
125
125
  };
126
126
  #endif
@@ -697,7 +697,12 @@ public:
697
697
  void dump()
698
698
  {
699
699
  dumpRecordset<recordsetImple> dumpRs;
700
- dumpRs(*this);
700
+ dumpRs(std::tcout, *this);
701
+ }
702
+ void dump(std::tostream& os)
703
+ {
704
+ dumpRecordset<recordsetImple> dumpRs;
705
+ dumpRs(os, *this);
701
706
  }
702
707
  #endif
703
708
  };
@@ -66,8 +66,14 @@ BOOST_CLASS_EXPORT_GUID(bzs::db::protocol::tdap::client::reverseOrderStatement,
66
66
 
67
67
  BOOST_CLASS_VERSION(bzs::db::protocol::tdap::client::groupFuncBase, 1)
68
68
  BOOST_CLASS_VERSION(bzs::db::protocol::tdap::client::queryBase, 1)
69
- BOOST_CLASS_VERSION(bzs::db::protocol::tdap::client::readStatement, 1)
70
69
  BOOST_CLASS_VERSION(bzs::db::protocol::tdap::client::readHasMany, 1)
70
+ BOOST_CLASS_VERSION(bzs::db::protocol::tdap::client::executable, 2)
71
+ BOOST_CLASS_VERSION(bzs::db::protocol::tdap::client::readStatement, 2)
72
+ BOOST_CLASS_VERSION(bzs::db::protocol::tdap::client::groupByStatement, 2)
73
+ BOOST_CLASS_VERSION(bzs::db::protocol::tdap::client::matchByStatement, 2)
74
+ BOOST_CLASS_VERSION(bzs::db::protocol::tdap::client::orderByStatement, 2)
75
+ BOOST_CLASS_VERSION(bzs::db::protocol::tdap::client::reverseOrderStatement, 2)
76
+
71
77
  namespace bzs
72
78
  {
73
79
  namespace db
@@ -117,8 +123,15 @@ void serialize_string(Archive& ar, const char* name, std::_tstring& v)
117
123
  }
118
124
 
119
125
  template <class Archive>
120
- void serialize(Archive&, executable&, const unsigned int)
126
+ void serializeExecutable(Archive& ar, executable& exec, const unsigned int version)
121
127
  {
128
+ if (version >= 2)
129
+ {
130
+ int v = (int)exec.isEnabled();
131
+ ar& make_nvp("enabled", v);
132
+ if (Archive::is_loading::value)
133
+ exec.setEnabled(v);
134
+ }
122
135
  }
123
136
 
124
137
  template <class Archive>
@@ -148,40 +161,45 @@ void serialize(Archive& ar, sortFields& q, const unsigned int)
148
161
  }
149
162
 
150
163
  template <class Archive>
151
- void serialize(Archive& ar, groupByStatement& q, const unsigned int /*version*/)
164
+ void serialize(Archive& ar, groupByStatement& q, const unsigned int version)
152
165
  {
153
166
  boost::serialization::base_object<executable>(q);
167
+ serializeExecutable(ar, q, version);
154
168
  ar& boost::serialization::make_nvp(
155
169
  "keyFields", boost::serialization::base_object<fieldNames>(q));
156
170
  ar& boost::serialization::make_nvp("functions", *q.m_statements);
157
171
  }
158
172
 
159
173
  template <class Archive>
160
- void serialize(Archive& ar, matchByStatement& q, const unsigned int /*version*/)
174
+ void serialize(Archive& ar, matchByStatement& q, const unsigned int version)
161
175
  {
162
176
  boost::serialization::base_object<executable>(q);
177
+ serializeExecutable(ar, q, version);
163
178
  ar& make_nvp("matchByStatement",
164
179
  boost::serialization::base_object<recordsetQuery>(q));
165
180
  }
166
181
 
167
182
  template <class Archive>
168
- void serialize(Archive& ar, orderByStatement& q, const unsigned int /*version*/)
183
+ void serialize(Archive& ar, orderByStatement& q, const unsigned int version)
169
184
  {
170
185
  boost::serialization::base_object<executable>(q);
186
+ serializeExecutable(ar, q, version);
171
187
  ar& boost::serialization::make_nvp("sortFields", *q.m_sortFields);
172
188
  }
173
189
 
174
190
  template <class Archive>
175
- void serialize(Archive& /*ar*/, reverseOrderStatement& q,
176
- const unsigned int /*version*/)
191
+ void serialize(Archive& ar, reverseOrderStatement& q,
192
+ const unsigned int version)
177
193
  {
178
194
  boost::serialization::base_object<executable>(q);
195
+ serializeExecutable(ar, q, version);
179
196
  }
180
197
 
181
198
  template <class Archive>
182
199
  void serialize(Archive& ar, readStatement& q, const unsigned int version)
183
200
  {
184
201
  boost::serialization::base_object<executable>(q);
202
+ serializeExecutable(ar, q, version);
185
203
  if (version < 1)
186
204
  ar& boost::serialization::make_nvp(
187
205
  "keyFields", boost::serialization::base_object<fieldNames>(q));
@@ -440,7 +458,7 @@ void serialize(Archive& ar, alias_type& q, const unsigned int /*version*/)
440
458
  void executable::release()
441
459
  {
442
460
  delete this;
443
- };
461
+ }
444
462
 
445
463
  //---------------------------------------------------------------------------
446
464
  // class groupByStatement
@@ -673,9 +691,12 @@ struct queryStatementsImple
673
691
  {
674
692
  for (size_t i = 0; i < statements.size(); ++i)
675
693
  {
676
- statements[i]->execute(rs);
677
- if (listner)
678
- listner->onExecuted(statements[i], rs);
694
+ if (statements[i]->isEnabled())
695
+ {
696
+ statements[i]->execute(rs);
697
+ if (listner)
698
+ listner->onExecuted(statements[i], rs);
699
+ }
679
700
  }
680
701
  }
681
702
 
@@ -60,11 +60,14 @@ namespace client
60
60
  class DLLLIBSTMT executable
61
61
  {
62
62
  friend struct queryStatementsImple;
63
-
63
+ bool m_enabled;
64
64
  public:
65
+ executable() : m_enabled(true){}
65
66
  virtual ~executable(){};
66
67
  virtual void execute(recordset& rs) = 0;
67
68
  void release();
69
+ void setEnabled(bool v) { m_enabled = v; }
70
+ bool isEnabled() const { return m_enabled; }
68
71
  virtual const int typeID() const = 0;
69
72
  };
70
73
 
@@ -281,7 +281,8 @@ std::string sqlBuilder::getFieldList(const tabledef* table, std::vector<std::str
281
281
  s += fdl[i];
282
282
  s += "` ";
283
283
  len = fd.len - fd.varLenBytes();
284
-
284
+ if (fd.type == ft_myfixedbinary)
285
+ len -= 2;
285
286
  /*
286
287
  Although len is a number of bytes in BDF, it becomes the number of
287
288
  characters in MySQL.
@@ -489,7 +490,7 @@ std::string sqlBuilder::getKeyList(const tabledef* table, std::vector<std::strin
489
490
  return s;
490
491
  }
491
492
 
492
- std::string convertString(unsigned int toPage, unsigned int fromPage,
493
+ std::string sqlBuilder::convertString(unsigned int toPage, unsigned int fromPage,
493
494
  const char* p)
494
495
  {
495
496
  std::string s;
@@ -54,6 +54,9 @@ public:
54
54
 
55
55
  static std::string sqlCreateIndex(const tabledef* table, int keyNum,
56
56
  bool specifyKeyNum, uchar_td charsetIndexServer, const clsrv_ver* ver);
57
+
58
+ static std::string convertString(unsigned int toPage, unsigned int fromPage,
59
+ const char* p);
57
60
  };
58
61
 
59
62
  } // namespace client
@@ -351,7 +351,7 @@ public:
351
351
  else
352
352
  memcpy(m_tmpPtr, m_ptr, m_len);
353
353
  if (bd)
354
- bd = m_tb->setBlobFieldPointer((char*)m_tmpPtr, m_hd, bd);
354
+ bd = m_tb->setBlobFieldPointer(((char*)m_tmpPtr) + td->nullbytes(), m_hd, bd);
355
355
  }
356
356
  }
357
357
  ++m_row;
@@ -444,7 +444,7 @@ public:
444
444
  else
445
445
  m_tmpPtr = m_ptr;
446
446
 
447
- m_tb->setBlobFieldPointer((char*)m_tmpPtr, m_hd);
447
+ m_tb->setBlobFieldPointer((char*)m_tmpPtr + td->nullbytes(), m_hd);
448
448
  return m_tmpPtr;
449
449
  }
450
450
  }
@@ -1509,7 +1509,7 @@ keylen_td table::writeKeyDataTo(uchar_td* to, int keySize)
1509
1509
  if ((f.bit9 | f.bit3) && (transactd == true))
1510
1510
  isNull = false;
1511
1511
  fielddef& fd = (*m_tableDef)->fieldDefs[fdnum];
1512
- to = fd.keyCopy(to, (uchar_td*)fieldPtr(fdnum), 0xff, isNull);
1512
+ to = fd.keyCopy(to, (uchar_td*)fieldPtr(fdnum), 0xff, isNull, transactd);
1513
1513
  }
1514
1514
  return (keylen_td)(to - start);
1515
1515
  }
@@ -1548,7 +1548,7 @@ uint_td table::doGetWriteImageLen()
1548
1548
  uint_td bytes = fd.blobLenBytes();
1549
1549
  if (bytes)
1550
1550
  {
1551
- uchar_td* fdptr = (uchar_td*)m_pdata + fd.pos;
1551
+ uchar_td* fdptr = (uchar_td*)m_pdata + fd.pos + td->nullbytes();
1552
1552
  blob b(fd.blobDataLen(fdptr), i, fd.blobDataPtr(fdptr));
1553
1553
  addSendBlob(&b);
1554
1554
  }
@@ -1648,16 +1648,20 @@ unsigned char* table::setBlobFieldPointer(char* ptr, const blobHeader* hd, unsig
1648
1648
 
1649
1649
  //copy size byte
1650
1650
  memcpy(fdptr, &f->size, sizeByte);
1651
- const char* data = f->data();
1652
- //copy data
1653
- if (to)
1651
+ if (f->size)
1654
1652
  {
1655
- memcpy(to, data, f->size);
1656
- data = (char*)to;
1657
- to += f->size;
1658
- }
1659
- //copy address
1660
- memcpy(fdptr + sizeByte, &data, sizeof(char*));
1653
+ const char* data = f->data();
1654
+ //copy data
1655
+ if (to)
1656
+ {
1657
+ memcpy(to, data, f->size);
1658
+ data = (char*)to;
1659
+ to += f->size;
1660
+ }
1661
+ //copy address
1662
+ memcpy(fdptr + sizeByte, &data, sizeof(char*));
1663
+ }else
1664
+ memset(fdptr + sizeByte, 0, sizeof(char*));
1661
1665
  f = f->next();
1662
1666
  }
1663
1667
  ++hd->curRow;
@@ -1678,7 +1682,7 @@ void table::onReadAfter()
1678
1682
  if (blobFieldUsed())
1679
1683
  {
1680
1684
  const blobHeader* hd = getBlobHeader();
1681
- setBlobFieldPointer((char*)m_pdata, hd);
1685
+ setBlobFieldPointer((char*)m_pdata + (*m_tableDef)->nullbytes(), hd);
1682
1686
  }
1683
1687
  if ((*m_tableDef)->recordlen() - m_datalen > 0)
1684
1688
  memset((char*)m_pdata + m_datalen, 0, (*m_tableDef)->recordlen() - m_datalen);
@@ -807,6 +807,12 @@ inline database_ptr createDatabaseObject()
807
807
  return p;
808
808
  }
809
809
 
810
+ inline database_ptr createAssociateObject(database_ptr db)
811
+ {
812
+ database_ptr p(db->createAssociate(), releaseDatabase);
813
+ return p;
814
+ }
815
+
810
816
  template <class Database_Ptr>
811
817
  inline void disconnect(Database_Ptr db, const connectParams& connPrams)
812
818
  {
@@ -889,9 +895,8 @@ inline void connectOpen(Database_Ptr db, const connectParams& connPrams,
889
895
  template <class Database_Ptr> inline void dropDatabase(Database_Ptr db, const _TCHAR* uri=NULL)
890
896
  {
891
897
  db->drop(uri);
892
- if (db->stat())
893
- nstable::throwError(std::_tstring(_T("Drop database ")).c_str(),
894
- db->stat());
898
+ if (db->stat() && (db->stat() != ERROR_NO_DATABASE))
899
+ throwDbError(db, _T("Drop database : "), uri ? uri : _T(""));
895
900
  }
896
901
 
897
902
  template <class Database_Ptr>
@@ -158,6 +158,7 @@ unsigned int charsetIndex(const char* name)
158
158
 
159
159
  unsigned int charsetIndex(unsigned short codePage)
160
160
  {
161
+ if (codePage == 932) return CHARSET_CP932;
161
162
  for (int i = 1; i < MAX_CHAR_INFO; ++i)
162
163
  {
163
164
  if (charsetInfo[i].codePage == codePage)