transactd 2.0.1 → 2.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 (146) hide show
  1. checksums.yaml +4 -4
  2. data/BUILD_UNIX-JA +6 -6
  3. data/README +16 -16
  4. data/README-JA +16 -16
  5. data/bin/common/tdclc_32_2_1.dll +0 -0
  6. data/bin/common/tdclc_64_2_1.dll +0 -0
  7. data/build/common/transactd_cl_common.cmake +0 -1
  8. data/build/common/transactd_common.cmake +28 -38
  9. data/build/swig/ruby/ruby.swg +36 -30
  10. data/build/swig/ruby/tdclrb_wrap.cpp +35016 -0
  11. data/build/swig/tdcl.i +217 -62
  12. data/build/tdclc/CMakeLists.txt +14 -26
  13. data/build/tdclc/libtdclcm.map +4 -0
  14. data/build/tdclc/tdclc.cbproj +1 -1
  15. data/build/tdclc/tdclc.rc +0 -0
  16. data/build/tdclcpp/CMakeLists.txt +7 -22
  17. data/build/tdclcpp/tdclcpp.rc +0 -0
  18. data/build/tdclcpp/tdclcpp_bc.cbproj +1 -1
  19. data/build/tdclrb/CMakeLists.txt +7 -49
  20. data/build/tdclrb/tdclrb.rc +62 -0
  21. data/source/bzs/db/blobBuffer.h +5 -0
  22. data/source/bzs/db/blobStructs.h +2 -0
  23. data/source/bzs/db/engine/mysql/IReadRecords.h +9 -0
  24. data/source/bzs/db/engine/mysql/database.cpp +391 -169
  25. data/source/bzs/db/engine/mysql/database.h +178 -40
  26. data/source/bzs/db/engine/mysql/dbManager.cpp +45 -3
  27. data/source/bzs/db/engine/mysql/dbManager.h +3 -39
  28. data/source/bzs/db/engine/mysql/errorMessage.cpp +11 -7
  29. data/source/bzs/db/engine/mysql/errorMessage.h +1 -1
  30. data/source/bzs/db/engine/mysql/mydebuglog.cpp +1 -2
  31. data/source/bzs/db/engine/mysql/mysqlInternal.h +8 -8
  32. data/source/bzs/db/engine/mysql/mysqlThd.cpp +11 -0
  33. data/source/bzs/db/protocol/hs/hsCommandExecuter.cpp +1 -1
  34. data/source/bzs/db/protocol/tdap/client/activeTable.cpp +41 -6
  35. data/source/bzs/db/protocol/tdap/client/activeTable.h +177 -8
  36. data/source/bzs/db/protocol/tdap/client/activeTableImple.h +141 -62
  37. data/source/bzs/db/protocol/tdap/client/client.cpp +39 -35
  38. data/source/bzs/db/protocol/tdap/client/client.h +52 -25
  39. data/source/bzs/db/protocol/tdap/client/connectionPool.cpp +17 -0
  40. data/source/bzs/db/protocol/tdap/client/connectionPool.h +1 -0
  41. data/source/bzs/db/protocol/tdap/client/database.cpp +5 -1
  42. data/source/bzs/db/protocol/tdap/client/database.h +1 -1
  43. data/source/bzs/db/protocol/tdap/client/databaseFactory.cpp +49 -12
  44. data/source/bzs/db/protocol/tdap/client/databaseManager.h +42 -5
  45. data/source/bzs/db/protocol/tdap/client/dbDef.cpp +4 -2
  46. data/source/bzs/db/protocol/tdap/client/dllmain.cpp +71 -41
  47. data/source/bzs/db/protocol/tdap/client/errorMessage_ja.cpp +49 -49
  48. data/source/bzs/db/protocol/tdap/client/field.cpp +22 -13
  49. data/source/bzs/db/protocol/tdap/client/field.h +7 -3
  50. data/source/bzs/db/protocol/tdap/client/fieldDDF.cpp +1 -1
  51. data/source/bzs/db/protocol/tdap/client/fieldNameAlias.cpp +0 -1
  52. data/source/bzs/db/protocol/tdap/client/fieldNameAlias.h +1 -0
  53. data/source/bzs/db/protocol/tdap/client/fields.h +111 -24
  54. data/source/bzs/db/protocol/tdap/client/fileDDF.cpp +1 -1
  55. data/source/bzs/db/protocol/tdap/client/filter.h +687 -310
  56. data/source/bzs/db/protocol/tdap/client/groupQuery.cpp +12 -4
  57. data/source/bzs/db/protocol/tdap/client/indexDDF.cpp +1 -1
  58. data/source/bzs/db/protocol/tdap/client/memRecord.cpp +190 -32
  59. data/source/bzs/db/protocol/tdap/client/memRecord.h +64 -22
  60. data/source/bzs/db/protocol/tdap/client/nsDatabase.cpp +4 -4
  61. data/source/bzs/db/protocol/tdap/client/nsDatabase.h +4 -2
  62. data/source/bzs/db/protocol/tdap/client/nsTable.cpp +6 -3
  63. data/source/bzs/db/protocol/tdap/client/nsTable.h +1 -1
  64. data/source/bzs/db/protocol/tdap/client/pooledDatabaseManager.h +19 -8
  65. data/source/bzs/db/protocol/tdap/client/recordsetImple.h +194 -87
  66. data/source/bzs/db/protocol/tdap/client/request.h +84 -26
  67. data/source/bzs/db/protocol/tdap/client/stringConverter.h +22 -12
  68. data/source/bzs/db/protocol/tdap/client/table.cpp +494 -286
  69. data/source/bzs/db/protocol/tdap/client/table.h +48 -5
  70. data/source/bzs/db/protocol/tdap/client/trdboostapi.h +133 -87
  71. data/source/bzs/db/protocol/tdap/client/trdboostapiInternal.h +22 -22
  72. data/source/bzs/db/protocol/tdap/client/trdormapi.h +43 -18
  73. data/source/bzs/db/protocol/tdap/client/trnsctcl.def +3 -3
  74. data/source/bzs/db/protocol/tdap/mysql/databaseSchema.cpp +1 -0
  75. data/source/bzs/db/protocol/tdap/mysql/recordsetReader.h +268 -74
  76. data/source/bzs/db/protocol/tdap/mysql/request.h +4 -4
  77. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.cpp +179 -43
  78. data/source/bzs/db/protocol/tdap/mysql/tdapCommandExecuter.h +4 -4
  79. data/source/bzs/db/protocol/tdap/tdapRequest.h +15 -14
  80. data/source/bzs/db/protocol/tdap/tdapSchema.h +125 -90
  81. data/source/bzs/db/protocol/tdap/tdapcapi.h +46 -5
  82. data/source/bzs/db/transactd/appModule.h +1 -1
  83. data/source/bzs/db/transactd/connManager.cpp +2 -0
  84. data/source/bzs/db/transactd/transactd.cpp +1 -0
  85. data/source/bzs/env/compiler.h +10 -0
  86. data/source/bzs/env/mbcswchrLinux.cpp +42 -6
  87. data/source/bzs/env/mbcswchrLinux.h +40 -12
  88. data/source/bzs/example/queryData.cpp +33 -4
  89. data/source/bzs/netsvc/client/iconnection.h +107 -0
  90. data/source/bzs/netsvc/client/tcpClient.cpp +15 -1
  91. data/source/bzs/netsvc/client/tcpClient.h +96 -87
  92. data/source/bzs/netsvc/server/serverCpt.cpp +5 -6
  93. data/source/bzs/rtl/benchmark.cpp +2 -2
  94. data/source/bzs/rtl/stringBuffers.cpp +3 -3
  95. data/source/bzs/rtl/stringBuffers.h +2 -2
  96. data/source/bzs/test/tdclatl/bench_query_atl.js +92 -99
  97. data/source/bzs/test/tdclatl/test_query_atl.js +224 -115
  98. data/source/bzs/test/tdclphp/bench.php +126 -101
  99. data/source/bzs/test/tdclphp/transactd_Test.php +1122 -158
  100. data/source/bzs/test/tdclrb/bench_tdclcpp.rb +12 -14
  101. data/source/bzs/test/tdclrb/transactd_spec.rb +1127 -142
  102. data/source/bzs/test/transactdBench/query_bench.cpp +32 -15
  103. data/source/bzs/test/transactdBench/scaling_bench.cpp +32 -7
  104. data/source/bzs/test/transactdBench/transactdBench.cpp +1 -1
  105. data/source/bzs/test/transactdBench/workerBase.h +46 -0
  106. data/source/bzs/test/transactdBench/workerMySQLImple.h +15 -7
  107. data/source/bzs/test/transactdBench/workerTransactdImple.h +10 -18
  108. data/source/bzs/test/trdclengn/test_trdclengn.cpp +1487 -174
  109. data/source/global/ormsrcgen/main.cpp +2 -0
  110. data/source/global/tdclatl/Database.cpp +2 -2
  111. data/source/global/tdclatl/Database.h +1 -1
  112. data/source/global/tdclatl/FieldDefs.cpp +0 -3
  113. data/source/global/tdclatl/PooledDbManager.cpp +2 -2
  114. data/source/global/tdclatl/PooledDbManager.h +1 -1
  115. data/source/global/tdclatl/PreparedQuery.cpp +53 -0
  116. data/source/global/tdclatl/PreparedQuery.h +61 -0
  117. data/source/global/tdclatl/QueryBase.cpp +2 -1
  118. data/source/global/tdclatl/QueryBase.h +1 -1
  119. data/source/global/tdclatl/Record.cpp +3 -15
  120. data/source/global/tdclatl/Recordset.cpp +15 -10
  121. data/source/global/tdclatl/Recordset.h +3 -0
  122. data/source/global/tdclatl/Table.cpp +42 -7
  123. data/source/global/tdclatl/Table.h +3 -1
  124. data/source/global/tdclatl/activeTable.cpp +264 -76
  125. data/source/global/tdclatl/activeTable.h +12 -3
  126. data/source/global/tdclatl/tdclatl.idl +92 -10
  127. data/source/linux/charsetConvert.h +7 -7
  128. data/transactd.gemspec +14 -27
  129. metadata +18 -27
  130. data/bin/common/tdclc_32_2_0.dll +0 -0
  131. data/bin/common/tdclc_64_2_0.dll +0 -0
  132. data/build/swig/php/generate.cmake.in +0 -56
  133. data/build/swig/php/generate.cmd.in +0 -47
  134. data/build/swig/php/php.swg +0 -197
  135. data/build/swig/php/transactd.no_yield.php +0 -4494
  136. data/build/swig/php/transactd.no_yield.php.git.patch +0 -685
  137. data/build/swig/php/transactd.no_yield.php.patch +0 -685
  138. data/build/swig/php/transactd.yield.php +0 -4461
  139. data/build/swig/php/transactd.yield.php.git.patch +0 -652
  140. data/build/swig/php/transactd.yield.php.patch +0 -652
  141. data/build/swig/ruby/generate.cmake.in +0 -35
  142. data/build/swig/ruby/generate.cmd.in +0 -19
  143. data/build/tdclc/BUILDNUMBER.txt +0 -1
  144. data/build/tdclcpp/BUILDNUMBER.txt +0 -1
  145. data/build/tdclrb/BUILDNUMBER.txt +0 -1
  146. data/build/tdclrb/GEM_RELEASE_VERSION +0 -1
@@ -135,12 +135,11 @@ class connection : public iconnection, private boost::noncopyable
135
135
  if (m_segmentWrite == false)
136
136
  {
137
137
  DEBUG_PROFILE_END(1, "write")
138
- async_read(
139
- m_socket, buffer(&m_buffer[0], 4),
140
- boost::asio::transfer_all(),
141
- boost::bind(&connection::handle_read, this,
142
- boost::asio::placeholders::error,
143
- boost::asio::placeholders::bytes_transferred));
138
+ async_read(m_socket, buffer(&m_buffer[0], m_buffer.size()),
139
+ boost::asio::transfer_at_least(4),
140
+ boost::bind(&connection::handle_read, this,
141
+ boost::asio::placeholders::error,
142
+ boost::asio::placeholders::bytes_transferred));
144
143
  }
145
144
  }
146
145
  }
@@ -76,7 +76,7 @@ int benchmark::stop()
76
76
  #ifdef BOOST_HIGH_RESOL_TIMER_ENABLE
77
77
  boost_timer::time_point p = boost_timer::now();
78
78
  boost::chrono::nanoseconds ns = p - m_start;
79
- return (int)(ns.count()/1000000;
79
+ return (int)(ns.count()/1000000);
80
80
  #else
81
81
  return (int)(t.elapsed() * 1000);
82
82
  #endif
@@ -145,7 +145,7 @@ int benchmarkMt::end()
145
145
  #ifdef BOOST_HIGH_RESOL_TIMER_ENABLE
146
146
  boost_timer::time_point p = boost_timer::now();
147
147
  boost::chrono::nanoseconds ns = p - m_start;
148
- return (int)(ns.count()/1000;
148
+ return (int)(ns.count()/1000);
149
149
  #else
150
150
  return (int)(t.elapsed() * 1000000);
151
151
  #endif
@@ -57,7 +57,7 @@ size_t stringBuffer::alloc(size_t size)
57
57
  return m_len;
58
58
  }
59
59
 
60
- size_t stringBuffer::realloc(size_t size)
60
+ size_t stringBuffer::re_alloc(size_t size)
61
61
  {
62
62
  size =
63
63
  ((size / MEMORY_UNIT) + ((size % MEMORY_UNIT) ? 1 : 0)) * MEMORY_UNIT;
@@ -72,7 +72,7 @@ char* stringBuffer::getPtrA(size_t size)
72
72
  char* p = NULL;
73
73
 
74
74
  if (m_pos + size > m_len)
75
- realloc(m_pos + size + 1);
75
+ re_alloc(m_pos + size + 1);
76
76
  if (m_pos + size <= m_len)
77
77
  {
78
78
  p = m_ptr + m_pos;
@@ -88,7 +88,7 @@ WCHAR* stringBuffer::getPtrW(size_t size /* charnum */)
88
88
  WCHAR* p = NULL;
89
89
  size_t sizetmp = size * sizeof(WCHAR);
90
90
  if (m_pos + sizetmp > m_len)
91
- realloc(m_pos + sizetmp + sizeof(WCHAR));
91
+ re_alloc(m_pos + sizetmp + sizeof(WCHAR));
92
92
  if (m_pos + sizetmp <= m_len)
93
93
  {
94
94
  p = (WCHAR*)(m_ptr + m_pos);
@@ -38,12 +38,12 @@ class stringBuffer
38
38
  size_t m_pos;
39
39
  size_t m_curSize;
40
40
 
41
+ size_t alloc(size_t size);
42
+ size_t re_alloc(size_t size);
41
43
  public:
42
44
  stringBuffer(size_t size);
43
45
  ~stringBuffer();
44
46
  void clear();
45
- size_t alloc(size_t size);
46
- size_t realloc(size_t size);
47
47
  char* getPtrA(size_t size);
48
48
  WCHAR* getPtrW(size_t size /* charnum */);
49
49
  size_t size() const { return m_curSize; }
@@ -78,7 +78,7 @@ var ft_autoIncUnsigned = 52;
78
78
 
79
79
  //file flag
80
80
  var table_varlen = 0;
81
-
81
+
82
82
  //key flag
83
83
  var key_duplicate = 0;
84
84
  var key_changeable = 1;
@@ -165,24 +165,24 @@ var joinWhereFields = 2;
165
165
 
166
166
  function createQuery()
167
167
  {
168
- return new ActiveXObject('transactd.query');
168
+ return new ActiveXObject('transactd.query');
169
169
  }
170
170
 
171
171
  function createDatabaseObject()
172
172
  {
173
- return new ActiveXObject("transactd.database");
173
+ return new ActiveXObject("transactd.database");
174
174
  }
175
175
 
176
176
  function createGroupQuery()
177
177
  {
178
- return new ActiveXObject("transactd.groupQuery");
178
+ return new ActiveXObject("transactd.groupQuery");
179
179
  }
180
180
 
181
181
  function createActiveTable(db, tableName)
182
182
  {
183
- var at = new ActiveXObject("transactd.activeTable");
184
- at.SetDatabase(db, tableName);
185
- return at;
183
+ var at = new ActiveXObject("transactd.activeTable");
184
+ at.SetDatabase(db, tableName);
185
+ return at;
186
186
  }
187
187
 
188
188
 
@@ -252,8 +252,8 @@ function createUserTable(db)
252
252
  dbdef.UpDateTableDef(tableid);
253
253
  if (dbdef.Stat!=0)
254
254
  {
255
- WScript.Echo("user UpDateTableDef erorr:No." + dbdef.Stat);
256
- return false;
255
+ WScript.Echo("user UpDateTableDef erorr:No." + dbdef.Stat);
256
+ return false;
257
257
  }
258
258
  dbdef = null;
259
259
  return true;
@@ -352,16 +352,16 @@ function createUserExtTable(db)
352
352
  /*--------------------------------------------------------------------------------*/
353
353
  function bench()
354
354
  {
355
- var tick=0;
355
+ var tick=0;
356
356
 
357
357
  this.report = function(func, p1, p2, p3, p4, p5, p6, p7, p8)
358
358
  {
359
359
  var now = new Date();
360
- ticks = now.getTime();
360
+ ticks = now.getTime();
361
361
  var ret = func(p1, p2, p3, p4, p5, p6, p7, p8);
362
- now = new Date();
362
+ now = new Date();
363
363
  ticks = (now.getTime() - ticks)/1000;
364
- return ret;
364
+ return ret;
365
365
  }
366
366
 
367
367
  this.time = function(){return tick;}
@@ -400,53 +400,51 @@ function showConsole(recordset)
400
400
  var s = "";
401
401
  for (var i=0;i<record.Size;++i)
402
402
  s += record.Field(i).Text + "\t";
403
-
404
- WScript.Echo(s);
403
+
404
+ WScript.Echo(s);
405
405
  }
406
406
  }
407
407
  else
408
- WScript.Echo("No data.");
408
+ WScript.Echo("No data.");
409
409
  WScript.Echo(sep);
410
410
  }
411
411
 
412
-
413
-
414
412
  function wirteRecord()
415
413
  {
416
414
  var rec = ate.Index(0).CreateWritableRecord();
417
415
 
418
-
419
- rec.Field("id").Vlng = 1200;
420
- rec.Field("���O").Text = "���";
421
- if (!rec.Read())
422
- rec.Insert();
423
-
424
- rec.Clear();
425
- rec.Field("id").Vlng = 1201;
426
- rec.Field("���O").Text = "����";
427
- if (!rec.Read())
428
- rec.Insert();
429
-
430
- //update changed filed only
431
- rec.Clear();
432
- rec.Field("id").Vlng = 1201;
433
- rec.Field("parent").Vlng = 1240;
434
- rec.Update();
435
-
436
- //rec.Del();
437
- rec.Field("id").Vlng = 1200;
438
- //rec.Del();
416
+
417
+ rec.Field("id").Vlng = 1200;
418
+ rec.Field("���O").Text = "���";
419
+ if (!rec.Read())
420
+ rec.Insert();
421
+
422
+ rec.Clear();
423
+ rec.Field("id").Vlng = 1201;
424
+ rec.Field("���O").Text = "����";
425
+ if (!rec.Read())
426
+ rec.Insert();
427
+
428
+ //update changed filed only
429
+ rec.Clear();
430
+ rec.Field("id").Vlng = 1201;
431
+ rec.Field("parent").Vlng = 1240;
432
+ rec.Update();
433
+
434
+ //rec.Del();
435
+ rec.Field("id").Vlng = 1200;
436
+ //rec.Del();
439
437
  }
440
438
 
441
439
  /*--------------------------------------------------------------------------------*/
442
440
  function createDatabase(db, uri)
443
441
  {
444
- db.Create(uri);
442
+ db.Create(uri);
445
443
  if (db.Stat!=0)
446
- {
447
- WScript.Echo("createDatabase erorr:No." + db.Stat + " " + uri);
448
- return false;
449
- }
444
+ {
445
+ WScript.Echo("createDatabase erorr:No." + db.Stat + " " + uri);
446
+ return false;
447
+ }
450
448
  if (db.Open(uri, TYPE_BDF, OPEN_NORMAL, "", ""))
451
449
  {
452
450
  if (!createUserTable(db))return false;
@@ -454,9 +452,9 @@ function createDatabase(db, uri)
454
452
  if (!createUserExtTable(db))return false;
455
453
 
456
454
  return true;
457
- }else
458
- WScript.Echo("open daatabse erorr:No" + db.stat);
459
- return false;
455
+ }else
456
+ WScript.Echo("open daatabse erorr:No" + db.stat);
457
+ return false;
460
458
  }
461
459
  /*--------------------------------------------------------------------------------*/
462
460
  function insertData(db)
@@ -509,19 +507,18 @@ function checkNotEqual(a, b, on)
509
507
  }
510
508
  }
511
509
 
512
-
513
510
  /*--------------------------------------------------------------------------------*/
514
511
  function test(atu, atg, ate)
515
512
  {
516
513
  initQuery();
517
514
  atu.Alias("���O", "name");
518
- q.Select("id", "name","group").Where("id", "<=", 15900);
519
- var rs = atu.Index(0).KeyValue(1).Read(q);
515
+ q.Select("id", "name","group").Where("id", "<=", 15900);
516
+ var rs = atu.Index(0).KeyValue(1).Read(q);
520
517
  checkEqual(rs.Count, 15900, "atu rs.Count = 15900 ");
521
518
 
522
519
  //Join extention::comment
523
520
 
524
- initQuery();
521
+ initQuery();
525
522
  //first reverse
526
523
  var last = ate.Index(0).Join(rs, q.Select("comment").Optimize(hasOneJoin), "id").Reverse().First();
527
524
  checkEqual(rs.Count, 15900, "ate rs.Count = 15900 ");
@@ -539,14 +536,14 @@ function test(atu, atg, ate)
539
536
  checkEqual(first.Field("id").Vlng, 1, "id = 1 ");
540
537
  checkEqual(first.Field("comment").Text, "1 comment", "comment = 1 comment");
541
538
  checkEqual(first.Field("group_name").Text, "1 group", "group_name = 1 group ");
542
- checkEqual(rs.Record(15900 - 9).Field("group_name").Text, "9 group", "group_name = 9 group ");
539
+ checkEqual(rs.Record(15900 - 9).Field("group_name").Text, "9 group", "group_name = 9 group ");
543
540
 
544
541
  rs.OrderBy("group_name");
545
- checkEqual(rs.Record(0).Field("group_name").Text, "1 group", "group_name = 1 group ");
546
- //var s;
542
+ checkEqual(rs.Record(0).Field("group_name").Text, "1 group", "group_name = 1 group ");
543
+
547
544
  var count = rs.Count;
548
- for (var j= 0;j<count;++j)
549
- var s = rs.Record(j);
545
+ for (var j= 0;j<count;++j)
546
+ var s = rs.Record(j);
550
547
 
551
548
  }
552
549
  function btest(atu, atg, ate, n)
@@ -557,9 +554,8 @@ function btest(atu, atg, ate, n)
557
554
  initQuery();
558
555
  atu.Alias("���O", "name");
559
556
  q.Select("id", "name","group").Where("id", "<=", i+15000);
560
-
561
557
  var rs = atu.Index(0).KeyValue(i+1).Read(q);
562
-
558
+
563
559
  //Join extention::comment
564
560
 
565
561
  initQuery();
@@ -585,63 +581,60 @@ var resultCode = 0;
585
581
  function main()
586
582
  {
587
583
 
588
- var isCreate = 0;
589
- var host = "localhost";
590
- var n = 100;
591
- if (WScript.arguments.length > 0)
592
- isCreate = parseInt(WScript.arguments(0), 10);
593
-
594
- if (WScript.arguments.length > 1)
595
- host = WScript.arguments(1);
596
- var URI = "tdap://" + host + "/querytest?dbfile=test.bdf";
597
-
598
- if (WScript.arguments.length > 2)
599
- n = parseInt(WScript.arguments(2), 10);
600
-
601
-
602
- WScript.Echo(URI);
584
+ var isCreate = 0;
585
+ var host = "localhost";
586
+ var n = 100;
587
+ if (WScript.arguments.length > 0)
588
+ isCreate = parseInt(WScript.arguments(0), 10);
589
+
590
+ if (WScript.arguments.length > 1)
591
+ host = WScript.arguments(1);
592
+ var URI = "tdap://" + host + "/querytest?dbfile=test.bdf";
593
+
594
+ if (WScript.arguments.length > 2)
595
+ n = parseInt(WScript.arguments(2), 10);
596
+
597
+
598
+ WScript.Echo(URI);
603
599
  var b = new bench();
604
- try
605
- {
606
- var database = createDatabaseObject();
607
- if (database == null)
608
- {
600
+ try
601
+ {
602
+ var database = createDatabaseObject();
603
+ if (database == null)
604
+ {
609
605
  WScript.Echo("transactd.database ActiveXObject erorr.");
610
606
  return 1;
611
- }
612
-
607
+ }
613
608
  if (isCreate > 0)
614
609
  {
615
- if (database.Open(URI, TYPE_BDF, OPEN_NORMAL, "", ""))
616
- database.Drop();
617
- if (createDatabase(database, URI))
610
+ if (database.Open(URI, TYPE_BDF, OPEN_NORMAL, "", ""))
611
+ database.Drop();
612
+ if (createDatabase(database, URI))
618
613
  insertData(database);
619
614
  }else
620
615
  database.Open(URI, TYPE_BDF, OPEN_NORMAL, "", "");
621
-
622
-
623
-
624
- if (database.stat !== 0)
625
- {
626
- WScript.Echo("open table erorr:No" + database.stat);
627
- return 2;
628
- }
629
- var atu = createActiveTable(database, "user");
630
- var atg = createActiveTable(database, "groups");
616
+
617
+
618
+ if (database.stat !== 0)
619
+ {
620
+ WScript.Echo("open table erorr:No" + database.stat);
621
+ return 2;
622
+ }
623
+ var atu = createActiveTable(database, "user");
624
+ var atg = createActiveTable(database, "groups");
631
625
  var ate = createActiveTable(database, "extention");
632
-
626
+
633
627
  q = createQuery();;
634
628
  gq = createGroupQuery();
635
629
 
636
- b.report(btest, atu, atg, ate, n);
637
- b.show();
630
+ b.report(btest, atu, atg, ate, n);
631
+ b.show();
638
632
  }
639
633
  catch(e)
640
634
  {
641
- WScript.Echo("line " + e.name + " " + e.description);
635
+ WScript.Echo("Error: " + e.name + " " + e.description);
642
636
  return 2;
643
637
  }
644
-
645
- return resultCode;
638
+ return resultCode;
646
639
  }
647
640
 
@@ -1,20 +1,20 @@
1
1
  /*=================================================================
2
- Copyright (C) 2014 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.
2
+ Copyright (C) 2014 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
18
  =================================================================*/
19
19
  var TYPE_DDF = 1;
20
20
  var TYPE_BDF = 0;
@@ -78,7 +78,7 @@ var ft_autoIncUnsigned = 52;
78
78
 
79
79
  //file flag
80
80
  var table_varlen = 0;
81
-
81
+
82
82
  //key flag
83
83
  var key_duplicate = 0;
84
84
  var key_changeable = 1;
@@ -181,50 +181,47 @@ var joinWhereFields = 2;
181
181
 
182
182
  function createRecordsetQuery()
183
183
  {
184
- return new ActiveXObject('transactd.recordsetQuery');
184
+ return new ActiveXObject('transactd.recordsetQuery');
185
185
  }
186
186
 
187
187
 
188
188
  function createQuery()
189
189
  {
190
- return new ActiveXObject('transactd.query');
190
+ return new ActiveXObject('transactd.query');
191
191
  }
192
192
 
193
193
  function createDatabaseObject()
194
194
  {
195
- return new ActiveXObject("transactd.database");
195
+ return new ActiveXObject("transactd.database");
196
196
  }
197
197
 
198
198
  function createGroupQuery()
199
199
  {
200
- return new ActiveXObject("transactd.groupQuery");
200
+ return new ActiveXObject("transactd.groupQuery");
201
201
  }
202
202
 
203
203
  function createActiveTable(db, tableName)
204
204
  {
205
- var at = new ActiveXObject("transactd.activeTable");
206
- at.SetDatabase(db, tableName);
207
- return at;
205
+ var at = new ActiveXObject("transactd.activeTable");
206
+ at.SetDatabase(db, tableName);
207
+ return at;
208
208
  }
209
209
 
210
210
  function createSortFields()
211
211
  {
212
- return new ActiveXObject("transactd.sortFields");
212
+ return new ActiveXObject("transactd.sortFields");
213
213
  }
214
214
 
215
215
  function createFieldNames()
216
216
  {
217
- return new ActiveXObject("transactd.fieldNames");
217
+ return new ActiveXObject("transactd.fieldNames");
218
218
  }
219
219
 
220
220
  var sep = "-------------------------------------------------------------------------------";
221
-
222
-
223
221
  var FMT_LEFT = 0;
224
222
  var FMT_CENTER = 1;
225
223
  var FMT_RIGHT = 2;
226
224
  var MAGNIFICATION = 100;
227
-
228
225
  var resultCode = 0;
229
226
  var q;
230
227
  var gq;
@@ -242,7 +239,7 @@ function createUserTable(db)
242
239
  tableDef.FileName = "user";
243
240
  tableDef.CharsetIndex = CHARSET_CP932;
244
241
  tableDef.SchemaCodePage = CP_UTF8;
245
-
242
+
246
243
  var filedIndex = 0;
247
244
  var fd = dbdef.InsertField(tableid, filedIndex);
248
245
  fd.Name = "id";
@@ -386,18 +383,18 @@ function createUserExtTable(db)
386
383
  /*--------------------------------------------------------------------------------*/
387
384
  function bench()
388
385
  {
389
- var tick=0;
390
-
386
+ var tick=0;
387
+
391
388
  this.report = function(func, p1, p2, p3, p4, p5, p6, p7, p8)
392
389
  {
393
390
  var now = new Date();
394
- ticks = now.getTime();
391
+ ticks = now.getTime();
395
392
  var ret = func(p1, p2, p3, p4, p5, p6, p7, p8);
396
- now = new Date();
393
+ now = new Date();
397
394
  ticks = (now.getTime() - ticks)/1000;
398
- return ret;
395
+ return ret;
399
396
  }
400
-
397
+
401
398
  this.time = function(){return tick;}
402
399
  this.show = function(){WScript.Echo("(exec time " + ticks + " sec)\n");}
403
400
  }
@@ -415,22 +412,21 @@ function initQuery()
415
412
  /*--------------------------------------------------------------------------------*/
416
413
  function createDatabase(db, uri)
417
414
  {
418
- db.Create(uri);
415
+ db.Create(uri);
419
416
  if (db.Stat!=0)
420
- {
421
- WScript.Echo("createDatabase erorr:No." + db.Stat + " " + uri);
422
- return false;
423
- }
417
+ {
418
+ WScript.Echo("createDatabase erorr:No." + db.Stat + " " + uri);
419
+ return false;
420
+ }
424
421
  if (db.Open(uri, TYPE_BDF, OPEN_NORMAL, "", ""))
425
422
  {
426
423
  if (!createUserTable(db))return false;
427
424
  if (!createGroupTable(db))return false;
428
425
  if (!createUserExtTable(db))return false;
429
-
430
426
  return true;
431
- }else
432
- WScript.Echo("open daatabse erorr:No" + db.stat);
433
- return false;
427
+ }else
428
+ WScript.Echo("open daatabse erorr:No" + db.stat);
429
+ return false;
434
430
  }
435
431
  /*--------------------------------------------------------------------------------*/
436
432
  function insertData(db)
@@ -442,7 +438,6 @@ function insertData(db)
442
438
  try
443
439
  {
444
440
  db.BeginTrn();
445
-
446
441
  tb.ClearBuffer();
447
442
  for (var i= 1;i<= 20000;++i)
448
443
  {
@@ -474,7 +469,6 @@ function insertData(db)
474
469
  db.AbortTrn();
475
470
  throw e;
476
471
  }
477
-
478
472
  }
479
473
  /*--------------------------------------------------------------------------------*/
480
474
  function checkEqual(a, b, on)
@@ -503,44 +497,43 @@ function wirteRecord(atg)
503
497
  atg.ResetAlias();
504
498
  var rec = atg.Index(0).GetWritableRecord();
505
499
 
506
-
507
- rec.Field("code").Vlng = 1200;
508
- rec.Field("name").Text = "���";
509
- if (!rec.Read())
510
- rec.Insert();
511
-
512
- rec.Clear();
513
- rec.Field("code").Vlng = 1201;
514
- rec.Field("name").Text = "����";
515
- if (!rec.Read())
516
- rec.Insert();
517
-
518
- //update changed filed only
519
- rec.Clear();
520
- rec.Field("code").Vlng = 1201;
521
- rec.Field("name").Vlng = 1240;
522
- rec.Update();
523
-
524
- rec.Del();
525
- rec.Field("code").Vlng = 1200;
526
- rec.Del();
500
+ rec.Field("code").Vlng = 1200;
501
+ rec.Field("name").Text = "���";
502
+ if (!rec.Read())
503
+ rec.Insert();
504
+
505
+ rec.Clear();
506
+ rec.Field("code").Vlng = 1201;
507
+ rec.Field("name").Text = "����";
508
+ if (!rec.Read())
509
+ rec.Insert();
510
+
511
+ //update changed filed only
512
+ rec.Clear();
513
+ rec.Field("code").Vlng = 1201;
514
+ rec.Field("name").Vlng = 1240;
515
+ rec.Update();
516
+
517
+ rec.Del();
518
+ rec.Field("code").Vlng = 1200;
519
+ rec.Del();
527
520
  }
528
521
 
529
522
 
530
523
  /*--------------------------------------------------------------------------------*/
531
- function test(atu, atg, ate)
524
+ function test(atu, atg, ate, db)
532
525
  {
533
526
  WScript.Echo(" -- Start Test -- ");
534
527
 
535
528
  initQuery();
536
529
  atu.Alias("���O", "name");
537
- q.Select("id", "name","group").Where("id", "<=", 15900);
538
- var rs = atu.Index(0).KeyValue(1).Read(q);
530
+ q.Select("id", "name","group").Where("id", "<=", 15900);
531
+ var rs = atu.Index(0).KeyValue(1).Read(q);
539
532
  checkEqual(rs.Count, 15900, "atu rs.Count = 15900 ");
540
533
 
541
534
  //Join extention::comment
542
535
 
543
- initQuery();
536
+ initQuery();
544
537
  //first reverse
545
538
  var last = ate.Index(0).Join(rs, q.Select("comment").Optimize(hasOneJoin), "id").Reverse().First();
546
539
  checkEqual(rs.Count, 15900, "ate rs.Count = 15900 ");
@@ -558,7 +551,7 @@ function test(atu, atg, ate)
558
551
  checkEqual(first.Field("id").Vlng, 1, "id = 1 ");
559
552
  checkEqual(first.Field("comment").Text, "1 comment", "comment = 1 comment");
560
553
  checkEqual(first.Field("group_name").Text, "1 group", "group_name = 1 group ");
561
- checkEqual(rs.Record(15900 - 9).Field("group_name").Text, "4 group", "group_name = 9 group ");
554
+ checkEqual(rs.Record(15900 - 9).Field("group_name").Text, "4 group", "group_name = 9 group ");
562
555
 
563
556
  rs.OrderBy("group_name");
564
557
  checkEqual(rs.Record(0).Field("group_name").Text, "1 group", "group_name = 1 group ");
@@ -586,41 +579,157 @@ function test(atu, atg, ate)
586
579
  checkEqual(row.Field("gropu1_count").Vlng, 0, "gropu1_count = 0 ");
587
580
 
588
581
  var count = rs.Count;
589
- for (var j= 0;j<count;++j)
590
- var s = rs.Record(j);
591
-
582
+ for (var j= 0;j<count;++j)
583
+ var s = rs.Record(j);
584
+
585
+ //Client preparedQuery test
586
+ initQuery();
587
+ q.Select("id", "name","group").Where("id", "<=", "?");
588
+ var pq = atu.Prepare(q);
589
+ initQuery();
590
+ q.Select("group_name");
591
+ var pq2 = atg.Prepare(q);
592
+ // use AddValye
593
+ pq.AddValue(15900);
594
+ rs = atu.Index(0).KeyValue(1).Read(pq);
595
+ checkEqual(rs.Count, 15900, "atu rs.Count = 15900 ");
596
+ // use SupplyValue
597
+ pq.ResetAddIndex();
598
+ pq.SupplyValue(0, 15900);
599
+ rs = atu.Index(0).KeyValue(1).Read(pq);
600
+ checkEqual(rs.Count, 15900, "atu rs.Count = 15900 ");
601
+
602
+ atg.Index(0).Join(rs, pq2, "group");
603
+ checkEqual(rs.Count, 15900, "rs.Count = 15900 ");
604
+ checkEqual(rs.FieldDefs.Size, 4, "rs.FieldDefs.Size = 4 ");
605
+
606
+ //Server preparedQuery test
607
+ initQuery();
608
+ q.Select("id", "name","group").Where("id", "<=", "?");
609
+ var pq = atu.Prepare(q, true);
610
+ initQuery();
611
+ q.Select("group_name");
612
+ var pq2 = atg.Prepare(q, true);
613
+ // use AddValye
614
+ pq.AddValue(15900);
615
+ rs = atu.Index(0).KeyValue(1).Read(pq);
616
+ checkEqual(rs.Count, 15900, "atu rs.Count = 15900 ");
617
+ // use SupplyValue
618
+ pq.ResetAddIndex();
619
+ pq.SupplyValue(0, 15900);
620
+ rs = atu.Index(0).KeyValue(1).Read(pq);
621
+ checkEqual(rs.Count, 15900, "atu rs.Count = 15900 ");
622
+
623
+ atg.Index(0).Join(rs, pq2, "group");
624
+ checkEqual(rs.Count, 15900, "rs.Count = 15900 ");
625
+ checkEqual(rs.FieldDefs.Size, 4, "rs.FieldDefs.Size = 4 ");
626
+ checkEqual(rs.FieldDefs.Size, 4, "rs.FieldDefs.Size = 4 ");
627
+
628
+ // test table::setPrapare
629
+ var tb = db.OpenTable("user", OPEN_NORMAL);
630
+ q.Reset().Select("id", "���O","group").Where("id", "<=", "?");
631
+ pq = tb.Prepare(q, true);
632
+ pq.AddValue(15900);
633
+ tb.SetPrepare(pq);
634
+ tb.ClearBuffer();
635
+ tb.V64("id") = 1;
636
+ tb.Find();
637
+ var num = 0;
638
+ while (tb.Stat == 0)
639
+ {
640
+ ++num;
641
+ tb.FindNext();
642
+ }
643
+ checkEqual(num, 15900, "num = 15900 ");
592
644
 
593
- wirteRecord(atg);
645
+ //test preparedQuery
646
+ testPrepare(atu, atg, ate)
594
647
 
648
+ // test wirteRecord
649
+ wirteRecord(atg);
650
+
595
651
  WScript.Echo(" -- End Test -- ");
596
652
 
597
653
  }
598
654
 
599
655
  /*--------------------------------------------------------------------------------*/
600
- function main()
656
+ function testPrepare(atu, atg, ate)
601
657
  {
602
658
 
603
- var isCreate = 0;
604
- var host = "localhost";
605
- if (WScript.arguments.length > 0)
606
- isCreate = parseInt(WScript.arguments(0), 10);
659
+ initQuery();
660
+ q.Select("id", "name","group").Where("id", "<=", '?');
661
+ var pq = atu.Prepare(q);
607
662
 
608
- if (WScript.arguments.length > 1)
609
- host = WScript.arguments(1);
610
- var URI = "tdap://" + host + "/querytest?dbfile=test.bdf";
663
+ //int value
664
+ var rs = atu.Index(0).KeyValue(1).Read(pq, 15900);
665
+ checkEqual(rs.Count, 15900, "atu rs.Count = 15900 ");
666
+
667
+ //float value
668
+ rs.Clear();
669
+ rs = atu.Index(0).KeyValue(1).Read(pq, 15900.000);
670
+ checkEqual(rs.Count, 15900, "atu rs.Count = 15900 ");
671
+
672
+ //String value
673
+ rs.Clear();
674
+ rs = atu.Index(0).KeyValue(1).Read(pq, "15900");
675
+ checkEqual(rs.Count, 15900, "atu rs.Count = 15900 ");
676
+
677
+ //Using supplyValue value
678
+ rs.Clear();
679
+ pq.SupplyValue(0, 15900);
680
+ rs = atu.Index(0).KeyValue(1).Read(pq);
681
+ checkEqual(rs.Count, 15900, "atu rs.Count = 15900 ");
611
682
 
612
-
613
- WScript.Echo(URI);
683
+ //Join extention::comment first reverse
684
+
685
+ initQuery();
686
+ q.Select("comment").Optimize(hasOneJoin);
687
+ pq = ate.Prepare(q);
688
+
689
+ var last = ate.Index(0).Join(rs, pq, "id").Reverse().First();
690
+ checkEqual(rs.Count, 15900, "ate rs.Count = 15900 ");
691
+ checkEqual(last.Field("id").Vlng, 15900, "last.id = 15900 ");
692
+ checkEqual(last.Field("comment").Text, "15900 comment", "last.comment = 15900 ");
693
+
694
+ //Join group::name
695
+ initQuery();
696
+ q.Select("group_name");
697
+ pq = atg.Prepare(q);
698
+ atg.Index(0).Join(rs, pq, "group");
699
+
700
+ //last
701
+ var first = rs.Last();
702
+ checkEqual(rs.Count, 15900, "rs.Count = 15900 ");
703
+ checkEqual(first.Field("id").Vlng, 1, "id = 1 ");
704
+ checkEqual(first.Field("comment").Text, "1 comment", "comment = 1 comment");
705
+ checkEqual(first.Field("group_name").Text, "1 group", "group_name = 1 group ");
706
+ checkEqual(rs.Record(15900 - 9).Field("group_name").Text, "4 group", "group_name = 9 group ");
707
+
708
+ }
709
+ /*--------------------------------------------------------------------------------*/
710
+ function main()
711
+ {
712
+ var isCreate = 0;
713
+ var host = "localhost";
714
+ if (WScript.arguments.length > 0)
715
+ isCreate = parseInt(WScript.arguments(0), 10);
716
+
717
+ if (WScript.arguments.length > 1)
718
+ host = WScript.arguments(1);
719
+ var URI = "tdap://" + host + "/querytest?dbfile=test.bdf";
720
+
721
+
722
+ WScript.Echo(URI);
614
723
  var b = new bench();
615
- try
616
- {
617
- var database = createDatabaseObject();
618
- if (database == null)
619
- {
724
+ try
725
+ {
726
+ var database = createDatabaseObject();
727
+ if (database == null)
728
+ {
620
729
  WScript.Echo("transactd.database ActiveXObject erorr.");
621
730
  return 1;
622
- }
623
- if (database.Open(URI, TYPE_BDF, OPEN_NORMAL, "", ""))
731
+ }
732
+ if (database.Open(URI, TYPE_BDF, OPEN_NORMAL, "", ""))
624
733
  {
625
734
 
626
735
  if (isCreate > 0)
@@ -634,36 +743,36 @@ function main()
634
743
  }
635
744
  isCreate = true;
636
745
  }
637
- if (isCreate > 0)
746
+ if (isCreate > 0)
638
747
  {
639
- WScript.Echo("Creating test data. Please wait ...");
640
- if (createDatabase(database, URI))
748
+ WScript.Echo("Creating test data. Please wait ...");
749
+ if (createDatabase(database, URI))
641
750
  insertData(database);
642
751
  }
643
-
644
- if (database.Stat !== 0)
645
- {
646
- WScript.Echo("open table erorr:No" + database.stat);
647
- return 2;
648
- }
649
- var atu = createActiveTable(database, "user");
650
- var atg = createActiveTable(database, "groups");
651
- var ate = createActiveTable(database, "extention");
652
-
752
+
753
+ if (database.Stat !== 0)
754
+ {
755
+ WScript.Echo("open table erorr:No" + database.stat);
756
+ return 2;
757
+ }
758
+ var atu = createActiveTable(database, "user");
759
+ var atg = createActiveTable(database, "groups");
760
+ var ate = createActiveTable(database, "extention");
761
+
653
762
  q = createQuery();;
654
763
  gq = createGroupQuery();
655
-
656
- b.report(test, atu, atg, ate);
657
- b.show();
658
- if (resultCode == 0)
659
- WScript.Echo("*** No errors detected.");
764
+
765
+ b.report(test, atu, atg, ate, database);
766
+ b.show();
767
+ if (resultCode == 0)
768
+ WScript.Echo("*** No errors detected.");
660
769
  }
661
770
  catch(e)
662
771
  {
663
- WScript.Echo("line " + e.name + " " + e.description);
772
+ WScript.Echo("Error:" + e.name + " " + e.description);
664
773
  return 2;
665
774
  }
666
-
667
- return resultCode;
775
+
776
+ return resultCode;
668
777
  }
669
778