transactd 3.0.0 → 3.1.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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/bin/common/tdclc_32_3_1.dll +0 -0
  3. data/bin/common/tdclc_64_3_1.dll +0 -0
  4. data/build/common/transactd.rc.in +1 -1
  5. data/build/swig/ruby/tdclrb_wrap.cpp +219 -15
  6. data/build/swig/tdcl.i +26 -0
  7. data/build/tdclc/tdclc.cbproj +1 -1
  8. data/build/tdclc/tdclc.rc +5 -5
  9. data/build/tdclcpp/tdclcpp.rc +5 -5
  10. data/build/tdclcpp/tdclcpp_bc.cbproj +1 -1
  11. data/build/tdclrb/tdclrb.rc +5 -5
  12. data/source/bzs/db/engine/mysql/database.cpp +131 -29
  13. data/source/bzs/db/engine/mysql/database.h +8 -6
  14. data/source/bzs/db/engine/mysql/dbManager.cpp +30 -12
  15. data/source/bzs/db/engine/mysql/dbManager.h +1 -1
  16. data/source/bzs/db/engine/mysql/mysqlInternal.h +251 -24
  17. data/source/bzs/db/engine/mysql/mysqlThd.cpp +2 -3
  18. data/source/bzs/db/protocol/tdap/client/bulkInsert.h +2 -2
  19. data/source/bzs/db/protocol/tdap/client/client.h +4 -3
  20. data/source/bzs/db/protocol/tdap/client/connMgr.h +1 -1
  21. data/source/bzs/db/protocol/tdap/client/database.cpp +195 -91
  22. data/source/bzs/db/protocol/tdap/client/database.h +6 -6
  23. data/source/bzs/db/protocol/tdap/client/databaseManager.h +9 -3
  24. data/source/bzs/db/protocol/tdap/client/dbDef.cpp +31 -25
  25. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +4 -2
  26. data/source/bzs/db/protocol/tdap/client/field.cpp +6 -16
  27. data/source/bzs/db/protocol/tdap/client/filter.h +28 -9
  28. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +14 -4
  29. data/source/bzs/db/protocol/tdap/client/nsDatabase.h +20 -2
  30. data/source/bzs/db/protocol/tdap/client/pooledDatabaseManager.h +5 -2
  31. data/source/bzs/db/protocol/tdap/client/recordsetImple.h +2 -1
  32. data/source/bzs/db/protocol/tdap/client/sqlBuilder.cpp +19 -16
  33. data/source/bzs/db/protocol/tdap/client/table.cpp +2 -1
  34. data/source/bzs/db/protocol/tdap/client/table.h +1 -1
  35. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +13 -9
  36. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +68 -21
  37. data/source/bzs/db/protocol/tdap/tdapSchema.cpp +3 -7
  38. data/source/bzs/db/protocol/tdap/tdapSchema.h +9 -1
  39. data/source/bzs/db/protocol/tdap/tdapcapi.h +11 -3
  40. data/source/bzs/db/protocol/tdap/uri.h +3 -1
  41. data/source/bzs/env/crosscompile.h +17 -3
  42. data/source/bzs/test/tdclatl/test_v3.js +60 -2
  43. data/source/bzs/test/tdclphp/transactd_Test.php +8 -0
  44. data/source/bzs/test/tdclphp/transactd_blob_Test.php +11 -3
  45. data/source/bzs/test/tdclphp/transactd_v3_Test.php +32 -8
  46. data/source/bzs/test/tdclrb/bench_tdclcpp.rb +7 -7
  47. data/source/bzs/test/tdclrb/transactd_spec.rb +22 -1
  48. data/source/bzs/test/tdclrb/transactd_v3_spec.rb +29 -3
  49. data/source/bzs/test/trdclengn/testField.h +34 -0
  50. data/source/bzs/test/trdclengn/test_tdclcpp_v3.cpp +7 -0
  51. data/source/bzs/test/trdclengn/test_trdclengn.cpp +7 -8
  52. data/source/global/tdclatl/Database.cpp +34 -10
  53. data/source/global/tdclatl/Database.h +5 -5
  54. data/source/global/tdclatl/PooledDbManager.cpp +20 -3
  55. data/source/global/tdclatl/PooledDbManager.h +2 -2
  56. data/source/global/tdclatl/_IDatabaseEvents_CP.h +5 -4
  57. data/source/global/tdclatl/tdclatl.idl +157 -119
  58. metadata +4 -4
  59. data/bin/common/tdclc_32_3_0.dll +0 -0
  60. data/bin/common/tdclc_64_3_0.dll +0 -0
@@ -199,22 +199,27 @@ void database::setAutoSchemaUseNullkey(bool v)
199
199
 
200
200
  void database::create(const _TCHAR* uri, short type)
201
201
  {
202
+ bool dbdefCreated = false;
203
+ short stat = 0;
202
204
  if (!m_impl->dbDef)
205
+ {
203
206
  m_impl->dbDef = new dbdef(this, type); // Create TabelDef here.
204
-
207
+ dbdefCreated = true;
208
+ }
209
+ bool isTransactd = isTransactdUri(uri);
205
210
  _TCHAR buf[MAX_PATH];
206
211
  schemaTable(uri, buf, MAX_PATH);
207
- if (buf[0])
212
+ if (buf[0] || !isTransactd)
208
213
  {
209
214
  m_impl->dbDef->create(uri);
210
- m_stat = m_impl->dbDef->stat();
215
+ stat = m_impl->dbDef->stat();
211
216
  }
212
217
  else
213
218
  {
214
- if (isTransactdUri(uri))
219
+ if (isTransactd)
215
220
  {
216
221
  if (setUseTransactd() == false)
217
- m_stat = ERROR_LOAD_CLIBRARY;
222
+ stat = ERROR_LOAD_CLIBRARY;
218
223
  else
219
224
  {
220
225
  _TCHAR uri_tmp[MAX_PATH];
@@ -232,35 +237,58 @@ void database::create(const _TCHAR* uri, short type)
232
237
  _TCHAR posblk[128] = { 0x00 };
233
238
  const char* p = toServerUri((char*)buf, MAX_PATH, uri_tmp, true);
234
239
  uint_td len = 0;
235
- m_stat = m_btrcallid(TD_CREATETABLE, posblk, NULL, &len,
240
+ stat = m_btrcallid(TD_CREATETABLE, posblk, NULL, &len,
236
241
  (void*)p, (uchar_td)strlen(p), CR_SUBOP_CREATE_DBONLY , clientID());
237
242
  }
238
243
  }
239
244
  else
240
- m_stat = STATUS_NOSUPPORT_OP;
245
+ stat = STATUS_NOSUPPORT_OP;
241
246
  }
247
+ if (dbdefCreated)
248
+ doClose();
249
+ m_stat = stat;
242
250
  }
243
251
 
244
- void database::drop()
252
+ void database::drop(const _TCHAR* uri)
245
253
  {
246
- if (m_impl->dbDef == NULL)
254
+ _TCHAR path[MAX_PATH];
255
+ _TCHAR* fileNames[255] = {NULL};
256
+
257
+ if (((uri == NULL) || (uri[0] == 0x00)) && checkOpened())
247
258
  {
248
259
  m_stat = STATUS_DB_YET_OPEN;
249
260
  return;
250
261
  }
251
- _TCHAR FullPath[MAX_PATH];
252
- _TCHAR* fileNames[255] = {NULL};
262
+
263
+ if (uri && uri[0])
264
+ {
265
+ _TCHAR pwd[MAX_PATH];
266
+ passwd(uri, pwd, MAX_PATH);
267
+ stripParam(uri, path, MAX_PATH);
268
+ _tcscat(path, _T("?dbfile="));
269
+ _tcscat(path, TRANSACTD_SCHEMANAME);
270
+ if (pwd[0])
271
+ {
272
+ _tcscat(path, _T("&pwd="));
273
+ _tcscat(path, pwd);
274
+ }
275
+ nsdatabase::dropTable(path);
276
+ if (m_stat) return;
277
+ nsdatabase::reset();
278
+ return;
279
+ }
280
+
253
281
  int count = 0;
254
- for (int i = 0; i <= m_impl->dbDef->tableCount(); i++)
282
+ for (int i = 1; i <= m_impl->dbDef->tableCount(); i++)
255
283
  {
256
284
  tabledef* td = m_impl->dbDef->tableDefs(i);
257
285
  if (td)
258
286
  {
259
- _stprintf_s(FullPath, MAX_PATH, _T("%s") PSEPARATOR _T("%s"),
287
+ _stprintf_s(path, MAX_PATH, _T("%s") PSEPARATOR _T("%s"),
260
288
  rootDir(), td->fileName());
261
- size_t len = _tcslen(FullPath);
289
+ size_t len = _tcslen(path);
262
290
  _TCHAR* s(new _TCHAR[len + 1]);
263
- _tcscpy(s, FullPath);
291
+ _tcscpy(s, path);
264
292
  fileNames[count++] = s;
265
293
  }
266
294
  }
@@ -298,11 +326,8 @@ void database::drop()
298
326
 
299
327
  void database::dropTable(const _TCHAR* TableName)
300
328
  {
301
- if (m_impl->dbDef == NULL)
302
- {
303
- m_stat = STATUS_DB_YET_OPEN;
304
- return;
305
- }
329
+ if (checkOpened()) return;
330
+
306
331
  _TCHAR FullPath[MAX_PATH];
307
332
  _tcscpy(FullPath, rootDir());
308
333
  _tcscat(FullPath, PSEPARATOR);
@@ -371,7 +396,7 @@ void database::onCopyDataInternal(table* tb, int recordCount, int count,
371
396
  bool& cancel)
372
397
  {
373
398
  if (m_impl->m_copyDataFn)
374
- m_impl->m_copyDataFn(this, recordCount, count, cancel);
399
+ m_impl->m_copyDataFn(this, tb, recordCount, count, cancel);
375
400
  }
376
401
 
377
402
  void database::setTableReadOnly(bool value)
@@ -549,6 +574,7 @@ short database::continuous(char_td IsEnd, bool inclideRepfile)
549
574
  void database::doClose()
550
575
  {
551
576
  m_stat = STATUS_SUCCESS;
577
+ resetSnapshot();
552
578
  if (m_impl->dbDef)
553
579
  {
554
580
  dbdef* def = m_impl->dbDef;
@@ -566,7 +592,18 @@ void database::close(bool withDropDefaultSchema)
566
592
  {
567
593
  bool flag = (m_impl->dbDef != NULL);
568
594
  if (m_impl && m_impl->dbDef)
595
+ {
569
596
  m_impl->dbDef->setKeyNum(withDropDefaultSchema ? CR_SUBOP_DROP : 0);
597
+ if (!isUseTransactd() && withDropDefaultSchema)
598
+ {
599
+ _TCHAR uri[MAX_PATH];
600
+ _tcscpy(uri, m_impl->dbDef->uri());
601
+ doClose();
602
+ nsdatabase::dropTable(uri);
603
+ nsdatabase::release();
604
+ return;
605
+ }
606
+ }
570
607
  doClose();
571
608
  if (flag)
572
609
  nsdatabase::release();
@@ -651,7 +688,7 @@ bool database::defaultImageCopy(const void* data, short& tableIndex)
651
688
  return ret;
652
689
  }
653
690
 
654
- short database::testOpenTable()
691
+ short database::checkOpened()
655
692
  {
656
693
  if ((!m_impl->dbDef) || (!m_impl->isOpened))
657
694
  return STATUS_DB_YET_OPEN;
@@ -835,7 +872,7 @@ table* database::doOpenTable(openTablePrams* pm, const _TCHAR* ownerName)
835
872
  table* database::openTable(const _TCHAR* tableName, short mode, bool autoCreate,
836
873
  const _TCHAR* ownerName, const _TCHAR* path)
837
874
  {
838
- m_stat = testOpenTable();
875
+ m_stat = checkOpened();
839
876
  if (m_stat) return NULL;
840
877
 
841
878
  openTablePrams pm(autoCreate);
@@ -859,7 +896,7 @@ table* database::openTable(const _TCHAR* tableName, short mode, bool autoCreate,
859
896
  table* database::openTable(short tableIndex, short mode, bool autoCreate,
860
897
  const _TCHAR* ownerName, const _TCHAR* path)
861
898
  {
862
- m_stat = testOpenTable();
899
+ m_stat = checkOpened();
863
900
  if (m_stat) return NULL;
864
901
 
865
902
  openTablePrams pm(autoCreate);
@@ -880,6 +917,8 @@ table* database::openTable(short tableIndex, short mode, bool autoCreate,
880
917
  char* database::getSqlStringForCreateTable(const _TCHAR* tableName, char* retbuf, uint_td* size)
881
918
  {
882
919
  retbuf[0] = 0x00;
920
+ if (checkOpened()) return retbuf;
921
+
883
922
  short tableIndex = m_impl->dbDef->tableNumByName(tableName);
884
923
  tabledef* td = NULL;
885
924
  if (tableIndex != -1)
@@ -930,7 +969,7 @@ char* database::getSqlStringForCreateTable(const _TCHAR* tableName, char* retbuf
930
969
 
931
970
  bool database::createTable(const char* utf8Sql)
932
971
  {
933
- if (testOpenTable()) return false;
972
+ if (checkOpened()) return false;
934
973
  if (isUseTransactd())
935
974
  {
936
975
  if (setUseTransactd() == false)
@@ -983,6 +1022,7 @@ bool database::createTable(short fileNum, const _TCHAR* uri)
983
1022
  m_stat = STATUS_CANT_ALLOC_MEMORY;
984
1023
  return false;
985
1024
  }
1025
+ memset(fs, 0, 1024);
986
1026
  m_impl->dbDef->getFileSpec(fs, fileNum);
987
1027
  if (uri)
988
1028
  buf = uri;
@@ -994,7 +1034,7 @@ bool database::createTable(short fileNum, const _TCHAR* uri)
994
1034
  return (m_stat == 0);
995
1035
  }
996
1036
 
997
- short database::assignSchemaData(dbdef* src)
1037
+ short database::assignSchemaData(const dbdef* src)
998
1038
  {
999
1039
  beginTrn();
1000
1040
  int Count = 1;
@@ -1004,7 +1044,7 @@ short database::assignSchemaData(dbdef* src)
1004
1044
 
1005
1045
  for (int i = 0; i <= src->tableCount(); i++)
1006
1046
  {
1007
- tabledef* td = src->tableDefs(i);
1047
+ const tabledef* td = const_cast<dbdef*>(src)->tableDefs(i);
1008
1048
  if (td)
1009
1049
  {
1010
1050
  tabledef tdtmp = *td;
@@ -1047,17 +1087,20 @@ short database::assignSchemaData(dbdef* src)
1047
1087
  return defDest->stat();
1048
1088
  }
1049
1089
 
1050
- struct filedChnageInfo
1090
+ struct fieldChnageInfo
1051
1091
  {
1052
- filedChnageInfo() : fieldnum(-1), changed(0) {}
1092
+ fieldChnageInfo() : fieldnum(-1), changed(0) {}
1053
1093
 
1054
1094
  short fieldnum;
1055
1095
  bool changed;
1056
1096
  };
1057
1097
 
1098
+
1099
+
1058
1100
  void makeChangeInfo(const tabledef* ddef, const tabledef* sdef,
1059
- filedChnageInfo* fci)
1101
+ fieldChnageInfo* fci, bool& hasBlob)
1060
1102
  {
1103
+ hasBlob = false;
1061
1104
  for (short i = 0; i < sdef->fieldCount; i++)
1062
1105
  {
1063
1106
  fielddef& fds = sdef->fieldDefs[i];
@@ -1067,10 +1110,16 @@ void makeChangeInfo(const tabledef* ddef, const tabledef* sdef,
1067
1110
  if (strcmp(fdd.nameA(), fds.nameA()) == 0)
1068
1111
  {
1069
1112
  fci[i].fieldnum = j;
1070
- if (fds.type != fdd.type)
1071
- fci[i].changed = true; // diffrent type
1072
- else if (fds.len != fdd.len)
1073
- fci[i].changed = true; // different size
1113
+ if (!hasBlob && fdd.isBlob()) hasBlob = true;
1114
+ // mydatetime and mytimestmp mytime is no same binary format as different
1115
+ // mysql versions
1116
+ if ((fds.type != fdd.type) ||
1117
+ (fds.len != fdd.len) ||
1118
+ (fds.isBlob() || fdd.isBlob()) ||
1119
+ (fds.type== ft_mytime || fdd.type== ft_mytime) ||
1120
+ (fds.type== ft_mytimestamp || fdd.type== ft_mytimestamp)||
1121
+ (fds.type== ft_mydatetime || fdd.type== ft_mydatetime))
1122
+ fci[i].changed = true;
1074
1123
  break;
1075
1124
  }
1076
1125
  else
@@ -1079,7 +1128,7 @@ void makeChangeInfo(const tabledef* ddef, const tabledef* sdef,
1079
1128
  }
1080
1129
  }
1081
1130
 
1082
- inline void database::copyEachFieldData(table* dest, table* src, filedChnageInfo* fci)
1131
+ inline void database::copyEachFieldData(table* dest, table* src, fieldChnageInfo* fci)
1083
1132
  {
1084
1133
  const tabledef* ddef = dest->tableDef();
1085
1134
  const tabledef* sdef = src->tableDef();
@@ -1093,7 +1142,7 @@ inline void database::copyEachFieldData(table* dest, table* src, filedChnageInfo
1093
1142
  if (dindex != -1)
1094
1143
  {
1095
1144
  dest->setFVNull(dindex, src->getFVNull(i));
1096
- // src valiable len and last field;
1145
+ // src variable len and last field;
1097
1146
  if ((fci[i].changed == false) || (fdd.type == ft_myfixedbinary))
1098
1147
  {
1099
1148
  int len = fds.len;
@@ -1131,7 +1180,7 @@ inline int moveVaileRecord(table* src)
1131
1180
  {
1132
1181
  bm = src->bookmark();
1133
1182
  if (src->stat() != STATUS_SUCCESS)
1134
- break;
1183
+ break;
1135
1184
  ++count;
1136
1185
  src->stepPrev();
1137
1186
  }
@@ -1145,8 +1194,11 @@ inline int moveVaileRecord(table* src)
1145
1194
 
1146
1195
  inline void moveNextRecord(table* src, short keyNum)
1147
1196
  {
1197
+
1148
1198
  if (keyNum == -1)
1149
1199
  src->stepNext();
1200
+ else if (keyNum == -2)
1201
+ src->findNext();
1150
1202
  else
1151
1203
  src->seekNext();
1152
1204
  }
@@ -1155,19 +1207,57 @@ inline void moveFirstRecord(table* src, short keyNum)
1155
1207
  {
1156
1208
  if (keyNum == -1)
1157
1209
  src->stepFirst();
1210
+ else if (keyNum == -2)
1211
+ {
1212
+ src->setKeyNum(0);
1213
+ query q;
1214
+ q.all().bookmarkAlso(false).reject(0)
1215
+ .limit(src->isUseTransactd() ? 100 : 20);
1216
+ src->setQuery(&q);
1217
+ src->findFirst();
1218
+ }
1158
1219
  else
1159
1220
  src->seekFirst();
1160
1221
  }
1161
1222
 
1162
1223
  /* Copy from src to dest table.
1163
- * Copy as same field name.
1164
- * If turbo then copy use memcpy and offset dest of first address.
1224
+ * Copy as same field name.
1225
+ * If turbo then copy use memcpy and offset dest of first address.
1165
1226
  * if a src field is variable size binary, that dest field needs to be variable
1166
- *size binary.
1227
+ * size binary.
1167
1228
  * if src and dest fields are different type ,then a text copy is used.
1229
+ * Bulkinsert use default, But not use it when dest table has blob(s).
1168
1230
  */
1169
1231
  #pragma warn -8004
1170
1232
 
1233
+ struct smartBulkInsert
1234
+ {
1235
+ smartBulkInsert(table* tb, bool hasBlob) : m_tb(tb), m_hasBlob(hasBlob)
1236
+ {
1237
+ if (m_tb->isUseTransactd() && !m_hasBlob)
1238
+ m_tb->beginBulkInsert(BULKBUFSIZE*10);
1239
+ }
1240
+
1241
+ short commit()
1242
+ {
1243
+ short ret = 0;
1244
+ if (m_tb->isUseTransactd() && !m_hasBlob)
1245
+ ret = m_tb->commitBulkInsert(false);
1246
+ m_tb = NULL;
1247
+ return ret;
1248
+ }
1249
+
1250
+ ~smartBulkInsert()
1251
+ {
1252
+ if (m_tb && m_tb->isUseTransactd() && !m_hasBlob)
1253
+ m_tb->abortBulkInsert();
1254
+ }
1255
+ private:
1256
+ table* m_tb;
1257
+ bool m_hasBlob;
1258
+
1259
+ };
1260
+
1171
1261
  short database::copyTableData(table* dest, table* src, bool turbo,
1172
1262
  short keyNum, int maxSkip)
1173
1263
  {
@@ -1177,75 +1267,89 @@ short database::copyTableData(table* dest, table* src, bool turbo,
1177
1267
  const tabledef* sdef = src->tableDef();
1178
1268
  ushort_td ins_rows = 0;
1179
1269
  bool repData = (_tcsstr(ddef->fileName(), _T("rep.dat"))) ? true : false;
1180
- int skipCount = 0, count = 1;
1270
+ int skipCount = 0, count = 0;
1181
1271
  int recordCount = src->recordCount();
1182
- filedChnageInfo fci[256];
1183
-
1184
- makeChangeInfo(ddef, sdef, fci);
1272
+ fieldChnageInfo fci[256];
1273
+ bool hasBlob = false;
1274
+ makeChangeInfo(ddef, sdef, fci, hasBlob);
1185
1275
  moveFirstRecord(src, keyNum);
1186
1276
 
1187
- while (1)
1188
- {
1189
- if (src->stat())
1277
+ {// smartBulkInsert commit scope
1278
+ smartBulkInsert smi(dest, hasBlob);
1279
+ while (1)
1190
1280
  {
1191
- while (src->stat() != STATUS_EOF)
1281
+ if (src->stat())
1192
1282
  {
1193
- if (maxSkip != -1)
1194
- break;
1195
- if (recordCount < skipCount + count)
1283
+ while (src->stat() != STATUS_EOF)
1196
1284
  {
1197
- if (src->stat() == STATUS_IO_ERROR)
1285
+ if (maxSkip != -1)
1286
+ break;
1287
+ if (recordCount < skipCount + count)
1198
1288
  {
1199
- int n = moveVaileRecord(src);
1200
- if (n)
1201
- skipCount = recordCount - n - count;
1289
+ if (src->stat() == STATUS_IO_ERROR)
1290
+ {
1291
+ int n = moveVaileRecord(src);
1292
+ if (n)
1293
+ skipCount = recordCount - n - count;
1294
+ else
1295
+ break;
1296
+ }
1202
1297
  else
1203
1298
  break;
1204
1299
  }
1205
- else
1300
+ moveNextRecord(src, keyNum);
1301
+
1302
+ skipCount++;
1303
+ if (src->stat() == STATUS_SUCCESS)
1206
1304
  break;
1207
1305
  }
1208
- moveNextRecord(src, keyNum);
1209
-
1210
- skipCount++;
1211
- if (src->stat() == STATUS_SUCCESS)
1306
+ if (src->stat())
1212
1307
  break;
1213
1308
  }
1214
- if (src->stat())
1215
- break;
1216
- }
1217
- dest->clearBuffer();
1218
- if (turbo)
1219
- {
1220
- if (dest->m_buflen < src->datalen())
1221
- return STATUS_CANT_ALLOC_MEMORY;
1309
+ dest->clearBuffer();
1310
+ if (turbo)
1311
+ {
1312
+ if (dest->m_buflen < src->datalen())
1313
+ return STATUS_CANT_ALLOC_MEMORY;
1222
1314
 
1223
- memcpy((char*)dest->m_pdata, src->data(), src->datalen());
1224
- }
1225
- else
1226
- copyEachFieldData(dest, src, fci);
1315
+ memcpy((char*)dest->m_pdata, src->data(), src->datalen());
1316
+ }
1317
+ else
1318
+ copyEachFieldData(dest, src, fci);
1227
1319
 
1228
- if (repData)
1229
- {
1230
- dest->m_datalen = src->m_datalen;
1231
- dest->tdap(TD_REC_INSERT);
1320
+ if (repData)
1321
+ {
1322
+ dest->m_datalen = src->m_datalen;
1323
+ dest->tdap(TD_REC_INSERT);
1324
+ }
1325
+ else
1326
+ ins_rows += dest->insert(true);
1327
+
1328
+ if (dest->stat() != STATUS_SUCCESS)
1329
+ {
1330
+ if (skipCount != maxSkip)
1331
+ {
1332
+ if (dest->stat() == STATUS_INVALID_VALLEN)
1333
+ skipCount++;
1334
+ else if (dest->stat() == STATUS_DUPPLICATE_KEYVALUE)
1335
+ skipCount++;
1336
+ else
1337
+ return dest->stat();
1338
+ }else
1339
+ return dest->stat();
1340
+ }
1341
+ else
1342
+ count++;
1343
+ bool cancel = false;
1344
+ onCopyDataInternal(dest, recordCount, count, cancel);
1345
+ if (cancel)
1346
+ return -1;
1347
+
1348
+ moveNextRecord(src, keyNum);
1232
1349
  }
1233
- else
1234
- ins_rows += dest->insert(true);
1235
- if (dest->stat() == STATUS_INVALID_VALLEN)
1236
- skipCount++;
1237
- else if (dest->stat() == STATUS_DUPPLICATE_KEYVALUE)
1238
- skipCount++;
1239
- else if (dest->stat() != STATUS_SUCCESS)
1350
+ if (dest->stat() == 0) smi.commit();
1351
+ if (dest->stat() != STATUS_SUCCESS)
1240
1352
  return dest->stat();
1241
- else
1242
- count++;
1243
- bool cancel = false;
1244
- onCopyDataInternal(dest, recordCount, count, cancel);
1245
- if (cancel)
1246
- return -1;
1247
-
1248
- moveNextRecord(src, keyNum);
1249
1353
  }
1250
1354
  if ((skipCount) && (maxSkip == -1))
1251
1355
  {
@@ -38,7 +38,7 @@ class dbdef;
38
38
  #if (defined(__BORLANDC__) && !defined(__APPLE__) && !defined(__clang__))
39
39
  typedef bool __stdcall (*deleteRecordFn)(database* db, table* tb, bool inkey);
40
40
  typedef short __stdcall (*schemaMgrFn)(database* db);
41
- typedef void __stdcall (*copyDataFn)(database* db, int recordCount, int count,
41
+ typedef void __stdcall (*copyDataFn)(database* db, table* tb, int recordCount, int count,
42
42
  bool& cancel);
43
43
  #else
44
44
  /** @cond INTERNAL */
@@ -52,7 +52,7 @@ typedef bool(__STDCALL* deleteRecordFn)(database* db, table* tb, bool inkey);
52
52
  typedef short(__STDCALL* schemaMgrFn)(database* db);
53
53
 
54
54
  /** Callback function on a record was copied by convert table operation. */
55
- typedef void(__STDCALL* copyDataFn)(database* db, int recordCount, int count,
55
+ typedef void(__STDCALL* copyDataFn)(database* db, table* tb, int recordCount, int count,
56
56
  bool& cancel);
57
57
  #endif
58
58
 
@@ -64,12 +64,12 @@ class DLLLIB database : public nsdatabase
64
64
  void setDir(const _TCHAR* directory);
65
65
  virtual table* createTableObject();
66
66
  bool defaultImageCopy(const void* data, short& tableIndex);
67
- short testOpenTable();
67
+ short checkOpened();
68
68
  table* doOpenTable(struct openTablePrams* pm, const _TCHAR* ownerName);
69
69
  void* getExtendBufferForOpen(uint_td& size); // orverload
70
70
  _TCHAR* getTableUri(_TCHAR* buf, short fileNum);
71
71
  _TCHAR* getTableUri(_TCHAR* buf, const _TCHAR* filename);
72
- inline void copyEachFieldData(table* dest, table* src, struct filedChnageInfo* fci);
72
+ inline void copyEachFieldData(table* dest, table* src, struct fieldChnageInfo* fci);
73
73
 
74
74
 
75
75
  protected:
@@ -118,12 +118,12 @@ public:
118
118
  bool createTable(short fileNum, const _TCHAR* uri = NULL);
119
119
  char* getSqlStringForCreateTable(const _TCHAR* tableName, char* retbuf, uint_td* size);
120
120
  void create(const _TCHAR* uri, short type = TYPE_SCHEMA_BDF);
121
- void drop();
121
+ void drop(const _TCHAR* uri=NULL);
122
122
  void dropTable(const _TCHAR* tableName);
123
123
  void close(bool withDropDefaultSchema = false);
124
124
  short aclReload();
125
125
  short continuous(char_td op = TD_BACKUP_START, bool inclideRepfile = false);
126
- short assignSchemaData(dbdef* src);
126
+ short assignSchemaData(const dbdef* src);
127
127
  short copyTableData(table* dest, table* src, bool turbo,
128
128
  short keyNum = -1, int maxSkip = -1);
129
129
  void convertTable(short tableIndex, bool turbo,
@@ -1,7 +1,7 @@
1
1
  #ifndef BZS_DB_PROTOCOL_TDAP_CLIENT_DATABASEMANAGER_H
2
2
  #define BZS_DB_PROTOCOL_TDAP_CLIENT_DATABASEMANAGER_H
3
3
  /*=================================================================
4
- Copyright (C) 2014 BizStation Corp All rights reserved.
4
+ Copyright (C) 2014 2016 BizStation Corp All rights reserved.
5
5
 
6
6
  This program is free software; you can redistribute it and/or
7
7
  modify it under the terms of the GNU General Public License
@@ -101,7 +101,10 @@ public:
101
101
 
102
102
  inline int enableTrn() { return m_db->enableTrn(); }
103
103
 
104
- inline void beginSnapshot(short bias = CONSISTENT_READ) { m_db->beginSnapshot(bias); }
104
+ inline void beginSnapshot(short bias = CONSISTENT_READ, binlogPos* bpos=NULL)
105
+ {
106
+ m_db->beginSnapshot(bias, bpos);
107
+ }
105
108
 
106
109
  inline void endSnapshot() { m_db->endSnapshot(); }
107
110
 
@@ -253,7 +256,10 @@ public:
253
256
 
254
257
  inline int enableTrn() { return m_db->enableTrn(); }
255
258
 
256
- inline void beginSnapshot(short bias = CONSISTENT_READ) { m_db->beginSnapshot(bias); }
259
+ inline void beginSnapshot(short bias = CONSISTENT_READ, binlogPos* bpos=NULL)
260
+ {
261
+ m_db->beginSnapshot(bias, bpos);
262
+ }
257
263
 
258
264
  inline void endSnapshot() { m_db->endSnapshot(); }
259
265
 
@@ -382,6 +382,9 @@ void dbdef::updateTableDef(short TableIndex, bool forPsqlDdf)
382
382
  m_pdata = td;
383
383
  m_buflen = td->size();
384
384
  td->formatVersion = FORMAT_VERSON_CURRENT;
385
+ if(isUseTransactd())
386
+ td->varSize = td->size() - 4;
387
+
385
388
  update();
386
389
  m_pdata = m_dimpl->bdf;
387
390
  m_buflen = m_dimpl->bdfLen;
@@ -745,10 +748,16 @@ tabledef* dbdef::initReadAfter(short tableIndex, const tabledef* data, uint_td d
745
748
  td->autoIncExSpace = ((database*)nsdb())->defaultAutoIncSpace();
746
749
  //Fix:Bug of maxRecordLen is mistake value saved, recalculate maxRecordLen.
747
750
  td->calcReclordlen();
748
- if (td->fieldDefs[td->fieldCount -1].type == ft_myfixedbinary)
749
- td->optionFlags.bitC = true;
751
+ td->optionFlags.bitC = (td->fieldDefs[td->fieldCount -1].type == ft_myfixedbinary);
750
752
  td->id = tableIndex;
751
753
  td->defaultImage = NULL;
754
+
755
+ //Check a page size
756
+ if (!isUseTransactd())
757
+ {
758
+ if (td->pageSize < 512 || td->pageSize > 4096 || td->pageSize % 512)
759
+ td->pageSize = 2048;
760
+ }
752
761
  return td;
753
762
  }
754
763
 
@@ -894,45 +903,42 @@ void dbdef::drop()
894
903
  m_stat = nsdb()->stat();
895
904
  }
896
905
 
897
- void dbdef::getFileSpec(fileSpec* fs, short TableIndex)
906
+ void dbdef::getFileSpec(fileSpec* fs, short tableIndex)
898
907
  {
899
- keySpec* ks;
900
- keydef* KeyDef;
901
908
  short i, j, k = 0;
902
- short FieldNum;
903
- tabledef* TableDef = tableDefs(TableIndex);
904
- fs->recLen = TableDef->fixedRecordLen;
905
- fs->pageSize = TableDef->pageSize;
906
- fs->indexCount = TableDef->keyCount;
909
+ tabledef* td = tableDefs(tableIndex);
910
+ fs->recLen = td->fixedRecordLen;
911
+ fs->pageSize = td->pageSize;
912
+ fs->indexCount = td->keyCount;
907
913
  fs->recCount = 0;
908
- fs->fileFlag.all = TableDef->flags.all;
914
+ fs->fileFlag.all = td->flags.all;
909
915
  fs->reserve1[0] = 0;
910
916
  fs->reserve1[1] = 0;
911
- fs->preAlloc = TableDef->preAlloc;
917
+ fs->preAlloc = td->preAlloc;
912
918
 
913
- for (i = 0; i < TableDef->keyCount; i++)
919
+ for (i = 0; i < td->keyCount; i++)
914
920
  {
915
- KeyDef = &(TableDef->keyDefs[i]);
916
- for (j = 0; j < KeyDef->segmentCount; j++)
921
+ keydef* kd = &(td->keyDefs[i]);
922
+ for (j = 0; j < kd->segmentCount; j++)
917
923
  {
918
- FieldNum = KeyDef->segments[j].fieldNum;
919
- ks = &(fs->keySpecs[k]);
920
- ks->keyPos = TableDef->fieldDefs[FieldNum].pos;
921
- ks->keyLen = TableDef->fieldDefs[FieldNum].len;
922
- ks->keyFlag.all = KeyDef->segments[j].flags.all;
924
+ short fnum = kd->segments[j].fieldNum;
925
+ keySpec* ks = &(fs->keySpecs[k]);
926
+ ks->keyPos = td->fieldDefs[fnum].pos + 1;
927
+ ks->keyLen = td->fieldDefs[fnum].len;
928
+ ks->keyFlag.all = kd->segments[j].flags.all;
923
929
  ks->keyCount = 0;
924
- ks->keyType = TableDef->fieldDefs[FieldNum].type;
930
+ ks->keyType = td->fieldDefs[fnum].type;
925
931
 
926
- if ((ks->keyType == ft_autoinc) && (KeyDef->segmentCount > 1))
932
+ if ((ks->keyType == ft_autoinc) && (kd->segmentCount > 1))
927
933
  ks->keyType = 1;
928
934
  if (ks->keyFlag.bit3 == true)
929
- ks->nullValue = TableDef->fieldDefs[FieldNum].nullValue;
935
+ ks->nullValue = td->fieldDefs[fnum].nullValue;
930
936
  else
931
937
  ks->nullValue = 0;
932
938
  ks->reserve2[0] = 0;
933
939
  ks->reserve2[1] = 0;
934
940
  if (fs->fileFlag.bitA == true)
935
- ks->keyNo = KeyDef->keyNumber;
941
+ ks->keyNo = kd->keyNumber;
936
942
  else
937
943
  ks->keyNo = 0;
938
944
  ;
@@ -1086,7 +1092,7 @@ uint_td dbdef::fieldValidLength(eFieldQuery query, uchar_td FieldType)
1086
1092
  defaultlen = 3;
1087
1093
  break;
1088
1094
  case ft_myfixedbinary:
1089
- minlen = 256;
1095
+ minlen = 3;
1090
1096
  maxlen = 60000;
1091
1097
  defaultlen = 1024;
1092
1098
  break;