transactd 1.2.0-x86-mswin32-100 → 2.0.0-x86-mswin32-100

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,7 +33,7 @@ ruby_exe_path = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_ins
33
33
  # use prebuilt binary
34
34
  #
35
35
  if has_binary(transactd_gem_root)
36
- make_makefile_prebuilt_win32(ruby_bin_path, transactd_gem_root) if RUBY_PLATFORM =~ /mswin/
36
+ make_makefile_prebuilt_win32(ruby_bin_path, transactd_gem_root) if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
37
37
  exit
38
38
  end
39
39
 
@@ -54,6 +54,8 @@ generator = arg_config('--generator', '').gsub(/"\n/, '')
54
54
  ruby_include_dirs = arg_config('--ruby_include_dirs', '').gsub(/"\n/, '')
55
55
  ruby_library_path = arg_config('--ruby_library_path', '').gsub(/"\n/, '')
56
56
  install_prefix = arg_config('--install_prefix', '').gsub(/"\n/, '')
57
+ build_type = arg_config('--build_type', '').gsub(/"\n/, '')
58
+ no_rb_tbr = arg_config('--without_rb_thread_blocking_region', '').gsub(/"\n/, '').downcase
57
59
 
58
60
  # boost
59
61
  if boost != '' && boost !=~ /^\-DBOOST_ROOT/
@@ -81,7 +83,9 @@ end
81
83
 
82
84
  # ruby_library_path
83
85
  if ruby_library_path != '' && ruby_library_path !=~ /^\-DRUBY_SWIG_LIBRARY_PATH/
84
- ruby_library_path = '-DTRANSACTD_RUBY_LIBRARY_PATH="' + to_slash_path(ruby_library_path) + '"'
86
+ lib_path = to_slash_path(ruby_library_path)
87
+ $LDFLAGS = $LDFLAGS + ' -libpath:' + File.dirname(lib_path)
88
+ ruby_library_path = '-DTRANSACTD_RUBY_LIBRARY_PATH="' + lib_path + '"'
85
89
  end
86
90
 
87
91
  # install_prefix
@@ -89,6 +93,15 @@ if install_prefix != '' && install_prefix !=~ /^\-DCMAKE_INSTALL_PREFIX/
89
93
  install_prefix = '-DTRANSACTD_CLIENTS_PREFIX="' + to_slash_path(install_prefix) + '"'
90
94
  end
91
95
 
96
+ # build_type
97
+ if build_type !=~ /^\-DCMAKE_BUILD_TYPE/
98
+ if build_type != ''
99
+ build_type = '-DCMAKE_BUILD_TYPE=' + build_type
100
+ else
101
+ build_type = '-DCMAKE_BUILD_TYPE=Release'
102
+ end
103
+ end
104
+
92
105
  # ruby executable path
93
106
  ruby_executable = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
94
107
  ruby_executable = '-DTRANSACTD_RUBY_EXECUTABLE_PATH="' + to_slash_path(ruby_executable) + '"'
@@ -96,10 +109,22 @@ ruby_executable = '-DTRANSACTD_RUBY_EXECUTABLE_PATH="' + to_slash_path(ruby_exec
96
109
  # output dir
97
110
  gem_root = '-DTRANSACTD_RUBY_GEM_ROOT_PATH="' + to_slash_path(transactd_gem_root) + '"'
98
111
 
112
+ # rb_thread_blocking_region or rb_thread_call_without_gvl
113
+ use_TCWOG = have_func('rb_thread_call_without_gvl', 'ruby/thread.h')
114
+ use_TBR = (! use_TCWOG) && have_func('rb_thread_blocking_region')
115
+ if no_rb_tbr != '' && no_rb_tbr != 'off'
116
+ use_TCWOG = false
117
+ use_TBR = false
118
+ end
119
+ rb_tbr = ' -DTRANSACTD_HAVE_RB_THREAD_CALL_WITHOUT_GVL=' +
120
+ (use_TCWOG ? 'ON' : 'OFF') +
121
+ ' -DTRANSACTD_HAVE_RB_THREAD_BLOCKING_REGION=' +
122
+ (use_TBR ? 'ON' : 'OFF')
123
+
99
124
  # cmake
100
125
  cmake_cmd = ['cmake', to_native_path(transactd_gem_root_relative), '-DTRANSACTD_RUBY_GEM=ON',
101
126
  generator, boost, ruby_executable, ruby_library_path, ruby_include_dirs,
102
- install_prefix, gem_root, '>> cmake_generate.log'].join(' ')
127
+ install_prefix, gem_root, build_type, rb_tbr, '>> cmake_generate.log'].join(' ')
103
128
  begin
104
129
  f = open('cmake_generate.log', 'w')
105
130
  f.puts cmake_cmd
@@ -53,7 +53,7 @@ def get_common_binary_files(transactd_gem_root)
53
53
  windows_bitness = get_windows_bitness()
54
54
  ruby_bitness = 32 if windows_bitness == 32
55
55
  bin_files = Dir.glob(File.join(transactd_gem_root, 'bin/common/tdclc_' + ruby_bitness.to_s + '_*.dll'))
56
- bin_files += Dir.glob(File.join(transactd_gem_root, 'bin/common/tdclcpp_*_' + ruby_bitness.to_s + 'm_*.dll'))
56
+ bin_files += Dir.glob(File.join(transactd_gem_root, 'bin/common/tdclcpp_*_' + ruby_bitness.to_s + 'mr_*.dll'))
57
57
  sysdir = get_windows_sysdir()
58
58
  bin_files = bin_files.map{ |i| '"' + to_native_path(i) + '" "' + sysdir + '"' }
59
59
  return bin_files
@@ -110,4 +110,14 @@ EOS
110
110
  mkfile.close
111
111
  mkfile_dummy.close
112
112
  end
113
+ if RUBY_PLATFORM =~ /mingw/
114
+ begin
115
+ mkfile = open('nmake.cmd', 'r')
116
+ mkfile2 = open('make.cmd', 'w')
117
+ mkfile2.puts mkfile.read
118
+ ensure
119
+ mkfile.close
120
+ mkfile2.close
121
+ end
122
+ end
113
123
  end
data/index_ja.html ADDED
@@ -0,0 +1,15 @@
1
+ <html>
2
+ <head>
3
+ <title>Redirect to Transactd SDK Document (JA)</title>
4
+ <meta http-equiv="REFRESH" content="0;url=http://www.bizstation.jp/ja/transactd/client/sdk/doc/index.html">
5
+ </head>
6
+ <body>
7
+
8
+ <p class="h1">
9
+ Redirect to Transactd SDK Document ...
10
+ </p>
11
+ <p>
12
+ Redirecting to <a href="http://www.bizstation.jp/ja/transactd/client/sdk/doc/index.html">Transactd SDK Document (JA)</a>
13
+ </p>
14
+ </body>
15
+ </html>
@@ -21,8 +21,6 @@
21
21
  require 'date'
22
22
  require 'transactd'
23
23
 
24
- TYPE_SCHEMA_BDF = 0
25
-
26
24
  USE_NORMAL = 0
27
25
  USE_TRANS = 1
28
26
  USE_BALKINS = 2
@@ -203,7 +201,7 @@ def createTestDataBase(db, uri)
203
201
  puts("createTestDataBase erorr:No.#{db.stat().to_s} #{uri}")
204
202
  return false
205
203
  end
206
- if (db.open(uri, TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL, '', ''))
204
+ if (db.open(uri, Transactd::TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL, '', ''))
207
205
  dbdef = db.dbDef()
208
206
  td = Transactd::Tabledef.new()
209
207
  td.setTableName('user')
@@ -286,8 +284,8 @@ def main(argv)
286
284
  exeType = Integer(argv[3]) # -1
287
285
  insertBeforeNoDelete = ((argv.length > 4) && (Integer(argv[4]) != 0))
288
286
 
289
- db = Transactd::Database.createObject()
290
- if (db.open(uri, TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL, '', '') == false)
287
+ db = Transactd::Database.new()
288
+ if (db.open(uri, Transactd::TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL, '', '') == false)
291
289
  if (!createTestDataBase(db, uri))
292
290
  db.close()
293
291
  return
@@ -296,7 +294,7 @@ def main(argv)
296
294
  end
297
295
  printHeader(uri, count)
298
296
 
299
- if (!db.open(uri, TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL, '', ''))
297
+ if (!db.open(uri, Transactd::TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL, '', ''))
300
298
  puts("open table erorr No:#{db.stat().to_s}")
301
299
  else
302
300
  tb = openTable(db, 'user', Transactd::TD_OPEN_NORMAL)
@@ -23,7 +23,6 @@ require 'transactd'
23
23
  FN_ID = 0
24
24
  FN_NAME = 1
25
25
 
26
- TYPE_SCHEMA_BDF = 0
27
26
  PARALLEL_TRN = 1000
28
27
  LOCK_SINGLE_NOWAIT = 200
29
28
  TRANS_BIAS = PARALLEL_TRN + LOCK_SINGLE_NOWAIT
@@ -31,31 +30,35 @@ TRANS_BIAS = PARALLEL_TRN + LOCK_SINGLE_NOWAIT
31
30
  def createTable(db)
32
31
  dbdef = db.dbDef()
33
32
  td = Transactd::Tabledef.new()
33
+ # Set table schema codepage to UTF-8
34
+ # - codepage for field NAME and tableNAME
35
+ td.schemaCodePage = Transactd::CP_UTF8
34
36
  td.setTableName('user')
35
37
  td.setFileName('user.dat')
38
+ # Set table default charaset index
39
+ # - default charset for field VALUE
40
+ td.charsetIndex = Transactd::charsetIndex(Transactd::CP_UTF8)
36
41
  td.id = 1
37
42
  td.pageSize = 2048
38
43
  dbdef.insertTable(td)
39
- td = dbdef.tableDefs(td.id)
40
-
41
- fd = dbdef.insertField(td.id, 0)
44
+ # id
45
+ fd = dbdef.insertField(td.id, FN_ID)
42
46
  fd.setName('id')
43
47
  fd.type = Transactd::Ft_integer
44
48
  fd.len = 4
45
49
  dbdef.updateTableDef(1)
46
-
47
- fd = dbdef.insertField(td.id, 1)
50
+ # name
51
+ fd = dbdef.insertField(td.id, FN_NAME)
48
52
  fd.setName('name')
49
53
  fd.type = Transactd::Ft_myvarchar
50
54
  fd.len = 100
51
55
  dbdef.updateTableDef(td.id)
52
-
56
+ # key
53
57
  kd = dbdef.insertKey(td.id, 0)
54
58
  kd.segment(0).fieldNum = 0
55
59
  kd.segment(0).flags.bit8 = 1 # extend key type
56
60
  kd.segment(0).flags.bit1 = 1 # changeable
57
61
  kd.segmentCount = 1
58
-
59
62
  td.primaryKeyNum = 0
60
63
  dbdef.updateTableDef(td.id)
61
64
  end
@@ -107,9 +110,9 @@ def main(argv)
107
110
  end
108
111
  end
109
112
 
110
- db = Transactd::Database.createObject()
113
+ db = Transactd::Database.new()
111
114
 
112
- if !db.open(uri, TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL, '', '')
115
+ if !db.open(uri, Transactd::TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL, '', '')
113
116
  db.create(uri)
114
117
  if db.stat() != 0
115
118
  puts("create database error No #{db.stat()}")
@@ -118,7 +121,7 @@ def main(argv)
118
121
  end
119
122
  end
120
123
 
121
- if !db.open(uri, TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL, '', '')
124
+ if !db.open(uri, Transactd::TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL, '', '')
122
125
  puts("open table erorr No #{db.stat().to_s}")
123
126
  db.close()
124
127
  return
@@ -158,8 +161,8 @@ def main(argv)
158
161
 
159
162
  if functionNumber == 2
160
163
  db.beginTrn(TRANS_BIAS)
161
- tb.clearBuffer()
162
164
  for i in rangeStart..rangeEnd do
165
+ tb.clearBuffer()
163
166
  tb.setFV(FN_ID, i)
164
167
  tb.seek()
165
168
  if (tb.stat() == 0)
@@ -38,8 +38,6 @@ FDI_USER_ID = 1
38
38
  FDI_BODY = 2
39
39
  FDI_IMAGE = 3
40
40
 
41
- TYPE_SCHEMA_BDF = 0
42
-
43
41
  def dropDatabase(db)
44
42
  db.open(URL)
45
43
  expect(db.stat()).to eq 0
@@ -57,7 +55,7 @@ def createDatabase(db)
57
55
  end
58
56
 
59
57
  def openDatabase(db)
60
- db.open(URL, TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL)
58
+ db.open(URL, Transactd::TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL)
61
59
  expect(db.stat()).to eq 0
62
60
  end
63
61
 
@@ -128,26 +126,20 @@ def getTestBinary()
128
126
  end
129
127
 
130
128
  describe Transactd, 'blob' do
131
- before :each do
132
- @db = Transactd::Database.createObject()
133
- end
134
- after :each do
135
- @db.close()
136
- @db = nil
137
- end
138
-
139
129
  it 'create' do
140
- createDatabase(@db)
141
- openDatabase(@db)
142
- createTable(@db)
143
- tb = openTable(@db)
144
- tb.close()
130
+ db = Transactd::Database.new()
131
+ createDatabase(db)
132
+ openDatabase(db)
133
+ createTable(db)
134
+ tb = openTable(db)
135
+ db.close()
145
136
  end
146
137
 
147
138
  it 'insert' do
139
+ db = Transactd::Database.new()
148
140
  image = getTestBinary()
149
- openDatabase(@db)
150
- tb = openTable(@db)
141
+ openDatabase(db)
142
+ tb = openTable(db)
151
143
  expect(tb).not_to be nil
152
144
  # 1
153
145
  tb.clearBuffer()
@@ -172,13 +164,14 @@ describe Transactd, 'blob' do
172
164
  tb.setFV(FDI_IMAGE, str, str.bytesize)
173
165
  tb.insert()
174
166
  expect(tb.stat()).to eq 0
175
- tb.close()
167
+ db.close()
176
168
  end
177
169
 
178
170
  it 'seek' do
171
+ db = Transactd::Database.new()
179
172
  image = getTestBinary()
180
- openDatabase(@db)
181
- tb = openTable(@db)
173
+ openDatabase(db)
174
+ tb = openTable(db)
182
175
  expect(tb).not_to be nil
183
176
  # 1
184
177
  tb.clearBuffer()
@@ -210,13 +203,14 @@ describe Transactd, 'blob' do
210
203
  expect(tb.getFVint(FDI_USER_ID)).to eq 1
211
204
  expect(tb.getFVstr(FDI_BODY)).to eq "2\ntest\nテスト\n\nあいうえおあいうえお"
212
205
  expect(tb.getFVbin(FDI_IMAGE).force_encoding('UTF-8')).to eq "2\ntest\nテスト\n\nあいうえおあいうえお"
213
- tb.close()
206
+ db.close()
214
207
  end
215
208
 
216
209
  it 'find' do
210
+ db = Transactd::Database.new()
217
211
  image = getTestBinary()
218
- openDatabase(@db)
219
- tb = openTable(@db)
212
+ openDatabase(db)
213
+ tb = openTable(db)
220
214
  expect(tb).not_to be nil
221
215
  # 1
222
216
  tb.setKeyNum(0)
@@ -243,13 +237,14 @@ describe Transactd, 'blob' do
243
237
  # 2... but changing seek-direction is not allowed
244
238
  tb.findPrev(true)
245
239
  expect(tb.stat()).to eq Transactd::STATUS_PROGRAM_ERROR
246
- tb.close()
240
+ db.close()
247
241
  end
248
242
 
249
243
  it 'update' do
244
+ db = Transactd::Database.new()
250
245
  image = getTestBinary()
251
- openDatabase(@db)
252
- tb = openTable(@db)
246
+ openDatabase(db)
247
+ tb = openTable(db)
253
248
  expect(tb).not_to be nil
254
249
  # select 1
255
250
  tb.clearBuffer()
@@ -289,13 +284,14 @@ describe Transactd, 'blob' do
289
284
  expect(tb.getFVint(FDI_USER_ID)).to eq 1
290
285
  expect(tb.getFVstr(FDI_BODY)).to eq "2\nテスト\ntest\n\nABCDEFG"
291
286
  expect(tb.getFVbin(FDI_IMAGE).force_encoding('UTF-8')).to eq "2\ntest\nテスト\n\nあいうえおあいうえお"
292
- tb.close()
287
+ db.close()
293
288
  end
294
289
 
295
290
  it 'delete' do
291
+ db = Transactd::Database.new()
296
292
  image = getTestBinary()
297
- openDatabase(@db)
298
- tb = openTable(@db)
293
+ openDatabase(db)
294
+ tb = openTable(db)
299
295
  expect(tb).not_to be nil
300
296
  # delete 2
301
297
  tb.clearBuffer()
@@ -323,10 +319,11 @@ describe Transactd, 'blob' do
323
319
  # eof
324
320
  tb.seekNext()
325
321
  expect(tb.stat()).to eq Transactd::STATUS_EOF
326
- tb.close()
322
+ db.close()
327
323
  end
328
324
 
329
325
  it 'drop' do
330
- dropDatabase(@db)
326
+ db = Transactd::Database.new()
327
+ dropDatabase(db)
331
328
  end
332
329
  end
@@ -32,14 +32,11 @@ describe Transactd, 'datetime' do
32
32
  nowdate.i = i_nowdate # get today as BtrDate
33
33
  s_nowdate = Transactd::btrdtoa(nowdate)
34
34
  s_nowdate2 = Transactd::btrdtoa(nowdate, true)
35
- cs_nowdate = Transactd::c_str(nowdate)
36
35
  #p nowdate
37
36
  #p s_nowdate + ' ' + s_nowdate.encoding.to_s
38
37
  #p s_nowdate2 + ' ' + s_nowdate2.encoding.to_s
39
- #p cs_nowdate + ' ' + cs_nowdate.encoding.to_s
40
38
  expect(s_i_nowdate).to eq s_nowdate
41
39
  expect(s_i_nowdate2).to eq s_nowdate2
42
- expect(cs_nowdate).to eq s_nowdate
43
40
  end
44
41
 
45
42
  it 'get BtrTime' do
@@ -53,14 +50,11 @@ describe Transactd, 'datetime' do
53
50
  nowtime.i = i_nowtime # get now time as BtrTime
54
51
  s_nowtime = Transactd::btrttoa(nowtime)
55
52
  s_nowtime2 = Transactd::btrttoa(nowtime, true)
56
- cs_nowtime = Transactd::c_str(nowtime)
57
53
  #p nowtime
58
54
  #p s_nowtime + ' ' + s_nowtime.encoding.to_s
59
55
  #p s_nowtime2 + ' ' + s_nowtime2.encoding.to_s
60
- #p cs_nowtime + ' ' + cs_nowtime.encoding.to_s
61
56
  expect(s_i_nowtime).to eq s_nowtime
62
57
  expect(s_i_nowtime2).to eq s_nowtime2
63
- expect(cs_nowtime).to eq s_nowtime
64
58
  end
65
59
 
66
60
  it 'get BtrDateTime' do
@@ -88,29 +82,6 @@ describe Transactd, 'datetime' do
88
82
  #p s_datetime_d + ' ' + s_datetime_t
89
83
  end
90
84
 
91
- it 'get Bdate' do
92
- date = Transactd::atobtrd('2012-08-22')
93
- bdate = Transactd::Bdate.new(date.i)
94
- bdate2 = Transactd::Bdate.new(Transactd::btrdtoa(date))
95
- #p bdate,bdate2
96
- btrdate = bdate.btr_date()
97
- btrdate2 = bdate2.btr_date()
98
- #p btrdate, btrdate2
99
- s_bdate = bdate.c_str()
100
- s_bdate2 = bdate2.c_str()
101
- expect(s_bdate).to eq s_bdate2
102
- #p s_bdate + ' ' + s_bdate.encoding.to_s
103
- #p s_bdate2 + ' ' + s_bdate2.encoding.to_s
104
- expect(bdate.year()).to eq 2012
105
- expect(bdate.month()).to eq 8
106
- expect(bdate.date()).to eq 22
107
- expect(bdate.year_str()).to eq '2012'
108
- expect(bdate.month_str()).to eq '8'
109
- expect(bdate.date_str()).to eq '22'
110
- #p bdate.year(), bdate.month(), bdate.date()
111
- #p bdate.year_str(), bdate.month_str(), bdate.date_str()
112
- end
113
-
114
85
  it 'get BtrTimeStamp from string' do
115
86
  date = Transactd::atobtrd('2012-08-22')
116
87
  time = Transactd::atobtrt('15:37:00')
@@ -41,8 +41,6 @@ FDI_NAME = 1
41
41
  FDN_NAME = '名前'.encode('UTF-8')
42
42
 
43
43
 
44
- TYPE_SCHEMA_BDF = 0
45
-
46
44
  def testDropDatabase(db, url)
47
45
  db.open(url)
48
46
  expect(db.stat()).to eq 0
@@ -50,17 +48,19 @@ def testDropDatabase(db, url)
50
48
  expect(db.stat()).to eq 0
51
49
  end
52
50
 
53
- def testCreateDatabase(db, url)
51
+ def testCreateDatabase(url)
52
+ db = Transactd::Database.new()
54
53
  db.create(url)
55
54
  if db.stat() == Transactd::STATUS_TABLE_EXISTS_ERROR
56
55
  testDropDatabase(db, url)
57
56
  db.create(url)
58
57
  end
59
58
  expect(db.stat()).to eq 0
59
+ db.close()
60
60
  end
61
61
 
62
62
  def testOpenDatabase(db, url)
63
- db.open(url, TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL)
63
+ db.open(url, Transactd::TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL)
64
64
  expect(db.stat()).to eq 0
65
65
  end
66
66
 
@@ -162,7 +162,8 @@ def testFind(db, tablename)
162
162
  tb.close()
163
163
  end
164
164
 
165
- def testWhole(db, tableid, tablename, url)
165
+ def testWhole(tableid, tablename, url)
166
+ db = Transactd::Database.new()
166
167
  tablename = tablename.encode('UTF-8') # table name must be UTF-8
167
168
  testOpenDatabase(db, url)
168
169
  testCreateTable(db, tableid, tablename)
@@ -170,39 +171,37 @@ def testWhole(db, tableid, tablename, url)
170
171
  testInsert(db, tablename)
171
172
  testGetEqual(db, tablename)
172
173
  testFind(db, tablename)
174
+ db.close()
173
175
  end
174
176
 
175
177
 
176
178
  describe Transactd do
177
- before :each do
178
- @db = Transactd::Database.createObject()
179
- end
180
- after :each do
181
- @db.close()
182
- @db = nil
183
- end
184
-
185
179
  it 'create database' do
186
- testCreateDatabase(@db, URL.encode('UTF-8'))
180
+ testCreateDatabase(URL.encode('UTF-8'))
187
181
  end
188
182
 
189
183
  it 'table which has kanji-named field' do
190
- testWhole(@db, 1, 'kanji-field', URL.encode('UTF-8'))
184
+ testWhole(1, 'kanji-field', URL.encode('UTF-8'))
191
185
  end
192
186
 
193
187
  it 'kanji-named table' do
194
- testWhole(@db, 2, '漢字テーブル', URL)
188
+ testWhole(2, '漢字テーブル', URL)
195
189
  end
196
190
 
197
191
  it 'create kanji-named database' do
198
- testCreateDatabase(@db, URL_KANJI.encode('UTF-8')) # URL must be UTF-8
192
+ testCreateDatabase(URL_KANJI.encode('UTF-8')) # URL must be UTF-8
199
193
  end
200
194
 
201
195
  it 'table which has kanji-named field' do
202
- testWhole(@db, 1, 'kanji-field', URL_KANJI.encode('UTF-8'))
196
+ testWhole(1, 'kanji-field', URL_KANJI.encode('UTF-8'))
203
197
  end
204
198
 
205
199
  it 'kanji-named table' do
206
- testWhole(@db, 2, '漢字テーブル', URL_KANJI.encode('UTF-8'))
200
+ testWhole(2, '漢字テーブル', URL_KANJI.encode('UTF-8'))
201
+ end
202
+
203
+ it 'drop database' do
204
+ db = Transactd::Database.new()
205
+ testDropDatabase(db, URL_KANJI.encode('UTF-8'))
207
206
  end
208
207
  end
@@ -0,0 +1,107 @@
1
+ # coding : utf-8
2
+ =begin ============================================================
3
+ Copyright (C) 2014 BizStation Corp All rights reserved.
4
+
5
+ This program is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU General Public License
7
+ as published by the Free Software Foundation; either version 2
8
+ of the License, or (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program; if not, write to the Free Software
17
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18
+ 02111-1307, USA.
19
+ ===================================================================
20
+ =end
21
+ require 'transactd'
22
+ require 'thwait'
23
+
24
+ def getHost()
25
+ hostname = '127.0.0.1/'
26
+ if (ENV['TRANSACTD_RSPEC_HOST'] != nil && ENV['TRANSACTD_RSPEC_HOST'] != '')
27
+ hostname = ENV['TRANSACTD_RSPEC_HOST']
28
+ end
29
+ hostname = hostname + '/' unless (hostname =~ /\/$/)
30
+ return hostname
31
+ end
32
+
33
+ PROTOCOL = 'tdap'
34
+ HOSTNAME = getHost().sub(/\/$/, '')
35
+ DBNAME = 'querytest'
36
+ SCHEMANAME = 'test'
37
+ BDFNAME = '?dbfile=' + SCHEMANAME + '.bdf'
38
+ URL = PROTOCOL + '://' + HOSTNAME + '/' + DBNAME + BDFNAME
39
+ TABLENAME = 'user'
40
+
41
+ describe Transactd, 'pool' do
42
+ it 'create ConnectParams' do
43
+ cp = Transactd::ConnectParams.new(URL)
44
+ expect(cp.uri()).to eq URL
45
+ cp = Transactd::ConnectParams.new(PROTOCOL, HOSTNAME, DBNAME, SCHEMANAME)
46
+ expect(cp.uri()).to eq URL
47
+ end
48
+
49
+ it 'use connections' do
50
+ Transactd::PooledDbManager::setMaxConnections(3)
51
+ cp = Transactd::ConnectParams.new(URL)
52
+ expect(cp.uri()).to eq URL
53
+ dbm1 = Transactd::PooledDbManager.new(cp)
54
+ dbm2 = Transactd::PooledDbManager.new(cp)
55
+ dbm3 = Transactd::PooledDbManager.new(cp)
56
+ dbm1.unUse()
57
+ dbm4 = Transactd::PooledDbManager.new(cp)
58
+ dbm3.unUse()
59
+ dbm5 = Transactd::PooledDbManager.new(cp)
60
+ Transactd::PooledDbManager::setMaxConnections(5)
61
+ dbm1 = Transactd::PooledDbManager.new(cp)
62
+ dbm3 = Transactd::PooledDbManager.new(cp)
63
+ dbm1.unUse()
64
+ dbm2.unUse()
65
+ dbm3.unUse()
66
+ dbm4.unUse()
67
+ dbm5.unUse()
68
+ end
69
+
70
+ it 'connect to table' do
71
+ Transactd::PooledDbManager::setMaxConnections(3)
72
+ cp = Transactd::ConnectParams.new(URL)
73
+ expect(cp.uri()).to eq URL
74
+ dbm = Transactd::PooledDbManager.new(cp)
75
+ atu = Transactd::ActiveTable.new(dbm, 'user')
76
+ q = Transactd::Query.new()
77
+ atu.alias('名前', 'name')
78
+ q.select('id', 'name', 'group').where('id', '<=', '15000')
79
+ rs = atu.index(0).keyValue(1).read(q)
80
+ expect(rs.size()).to eq 15000
81
+ expect(rs[0]['id']).to eq 1
82
+ expect(rs[0][0]).to eq 1
83
+ expect(rs[0]['name']).to eq '1 user'
84
+ expect(rs[0][1]).to eq '1 user'
85
+ expect(rs[0][2]).to eq 1
86
+ atu.release()
87
+ dbm.unUse()
88
+ end
89
+
90
+ it 'can be used in MultiThreads' do
91
+ Transactd::PooledDbManager::setMaxConnections(5)
92
+ threads = [];
93
+ for i in 1..12 do
94
+ threads.push(Thread.new(i) { |i|
95
+ #puts('... waiting to get dbm' + i.to_s + ' ...')
96
+ Thread.pass
97
+ dbm = Transactd::PooledDbManager.new(Transactd::ConnectParams.new(URL))
98
+ #puts('GOT dbm' + i.to_s + ' !')
99
+ sleep(rand(3) + 1)
100
+ #puts('end dbm' + i.to_s)
101
+ dbm.unUse()
102
+ })
103
+ end
104
+ tw = ThreadsWait.new(*threads)
105
+ tw.all_waits()
106
+ end
107
+ end