transactd 1.1.2-x86-mswin32-100 → 1.2.0-x86-mswin32-100

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6200bef5f8ef6f2835167bce4f85f9b2239dba7
4
- data.tar.gz: d803b4207ed504b72e99dc7d6b1df02754a8f6a7
3
+ metadata.gz: e1c19c4cfb8fb4184230e0da0626b44b0fce74b0
4
+ data.tar.gz: eb2c12e7fd617d322e21c6f3bb122bfd1224f143
5
5
  SHA512:
6
- metadata.gz: 9a9820b9008a14acc919ca7e328c631b92042eb8fa74c3d5be171cdd0e6b7643d1ff7ae02c1749b8dede28d5477db9b6771db741a33bab07ef1b8e51771e72d1
7
- data.tar.gz: a1dda537ce4070246166549f977b59ae4ba6016a698ea08caa45394f32d44ffe5340801dc5a1abd7c3fa90f2c5e54414442bef7494834a7705726e8920cb027f
6
+ metadata.gz: 08e1277d7d49c3aaa0d1704ed075076401eb55bef634c5b6f24c6c7faa7cc50e73e635b40b71b68e43f212a226320bd339bb3fe199101afa0fa45b50a7e8c88c
7
+ data.tar.gz: 28daaeda8fffb3e94c901dfc1852c2d539487d67d5c48a1dc6b24963f94202e8bc7e6c3861cc695ea9ddc377c63946feed75347c74a048ff3d9d6c20041410b2
data/CMakeLists.txt CHANGED
@@ -29,16 +29,28 @@ include(build/common/transactd_common.cmake)
29
29
  option(WITH_TRANSACTD_SERVER "Build Transactd server plugin" ON)
30
30
  option(WITH_TRANSACTD_CLIENTS "Build Transactd client libraries" ON)
31
31
  option(TRANSACTD_HANDLERSOCKET "Add HandlerSocket protocol to Transactd plugin" ON)
32
- option(TRANSACTD_RUBY_GEM "Build Transactd ruby gem" OFF)
33
32
  set(TRANSACTD_PREFIX "/usr/local/transactd" CACHE STRING "Prefix for transactd executables(test,benchmark)")
34
33
  set(TRANSACTD_CLIENTS_PREFIX "" CACHE STRING "Prefix for transactd client libraries")
34
+ # options for Ruby client
35
+ option(TRANSACTD_RUBY_GEM "Build Transactd ruby gem" OFF)
36
+ # options for PHP client
37
+ option(TRANSACTD_PHP "Build Transactd client PHP extension" OFF)
38
+ set(TRANSACTD_PHP_SOURCE_ROOT "" CACHE STRING "Path of php source directory")
39
+ set(TRANSACTD_PHP_LIBRARY_PATH "" CACHE STRING "Library path for php")
40
+ option(TRANSACTD_PHP_ZTS "Add ZTS flag for build Transactd client PHP extension" OFF)
35
41
 
36
42
  # The following options are set automatically if not specified.
37
43
  # Usually you do not have to set these values.
44
+ # options for Ruby client
38
45
  set(TRANSACTD_RUBY_GEM_ROOT_PATH "" CACHE STRING "Transactd gem root path")
39
46
  set(TRANSACTD_RUBY_EXECUTABLE_PATH "" CACHE STRING "Ruby executable path")
40
- set(TRANSACTD_RUBY_INCLUDE_PATH "" CACHE STRING "Include path for ruby-swig")
41
- set(TRANSACTD_RUBY_LIBRARY_PATH "" CACHE STRING "Include path for ruby")
47
+ set(TRANSACTD_RUBY_INCLUDE_PATH "" CACHE STRING "Include path for ruby")
48
+ set(TRANSACTD_RUBY_LIBRARY_PATH "" CACHE STRING "Library path for ruby")
49
+ # options for PHP client
50
+ set(TRANSACTD_PHP_INCLUDE_PATH "" CACHE STRING "Include path for PHP")
51
+ option(TRANSACTD_PHP_USE_32BIT_TIME_T
52
+ "Add _USE_32BIT_TIME_T option for building Transactd client PHP extension" ON)
53
+ set(TDCL_CPP_CHARSET "" CACHE STRING "Transactd clients charset m:Multibyte u:Unicode")
42
54
 
43
55
 
44
56
  # ==========================================================
@@ -50,6 +62,10 @@ if(TRANSACTD_RUBY_GEM)
50
62
  set(WITH_TRANSACTD_SERVER OFF)
51
63
  set(WITH_TRANSACTD_CLIENTS OFF)
52
64
  endif()
65
+ if(TRANSACTD_PHP)
66
+ set(WITH_TRANSACTD_SERVER OFF)
67
+ set(WITH_TRANSACTD_CLIENTS OFF)
68
+ endif()
53
69
 
54
70
 
55
71
  # ==========================================================
@@ -71,7 +87,9 @@ if(WITH_TRANSACTD_CLIENTS)
71
87
  endif()
72
88
  subdirs("build/tdclc")
73
89
  if(WIN32 AND NOT MINGW)
74
- set(TDCL_CPP_CHARSET u)
90
+ if((NOT ("${TDCL_CPP_CHARSET}" STREQUAL "m")) AND (NOT ("${TDCL_CPP_CHARSET}" STREQUAL "u")))
91
+ set(TDCL_CPP_CHARSET u)
92
+ endif()
75
93
  else()
76
94
  set(TDCL_CPP_CHARSET m)
77
95
  endif()
@@ -91,6 +109,21 @@ if(TRANSACTD_RUBY_GEM)
91
109
  if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
92
110
  project(tdcl)
93
111
  endif()
112
+ set(TDCL_CPP_CHARSET m)
94
113
  transactd_copy_subdir("${TRANSACTD_ROOT}" tdclcpp tdclcppm)
95
114
  subdirs("build/tdclrb")
96
115
  endif()
116
+
117
+
118
+ # ==========================================================
119
+ # build PHP extension
120
+ # ==========================================================
121
+ if(TRANSACTD_PHP)
122
+ message(STATUS "BUILD Transactd client PHP extension")
123
+ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
124
+ project(tdcl)
125
+ endif()
126
+ set(TDCL_CPP_CHARSET m)
127
+ transactd_copy_subdir("${TRANSACTD_ROOT}" tdclcpp tdclcppm)
128
+ subdirs("build/tdclphp")
129
+ endif()
data/bin/1.9/transactd.so CHANGED
Binary file
data/bin/2.0/transactd.so CHANGED
Binary file
Binary file
@@ -0,0 +1,332 @@
1
+ # coding : utf-8
2
+ =begin ============================================================
3
+ Copyright (C) 2013 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 'base64'
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
+ HOSTNAME = getHost()
34
+ URL = 'tdap://' + HOSTNAME + 'test_blob?dbfile=test.bdf'
35
+ TABLENAME = 'comments'
36
+ FDI_ID = 0
37
+ FDI_USER_ID = 1
38
+ FDI_BODY = 2
39
+ FDI_IMAGE = 3
40
+
41
+ TYPE_SCHEMA_BDF = 0
42
+
43
+ def dropDatabase(db)
44
+ db.open(URL)
45
+ expect(db.stat()).to eq 0
46
+ db.drop()
47
+ expect(db.stat()).to eq 0
48
+ end
49
+
50
+ def createDatabase(db)
51
+ db.create(URL)
52
+ if db.stat() == Transactd::STATUS_TABLE_EXISTS_ERROR
53
+ dropDatabase(db)
54
+ db.create(URL)
55
+ end
56
+ expect(db.stat()).to eq 0
57
+ end
58
+
59
+ def openDatabase(db)
60
+ db.open(URL, TYPE_SCHEMA_BDF, Transactd::TD_OPEN_NORMAL)
61
+ expect(db.stat()).to eq 0
62
+ end
63
+
64
+ def createTable(db)
65
+ openDatabase(db)
66
+ dbdef = db.dbDef()
67
+ expect(dbdef).not_to be nil
68
+ td = Transactd::Tabledef.new()
69
+ # Set table schema codepage to UTF-8
70
+ # - codepage for field NAME and tableNAME
71
+ td.schemaCodePage = Transactd::CP_UTF8
72
+ td.setTableName(TABLENAME)
73
+ td.setFileName(TABLENAME + '.dat')
74
+ # Set table default charaset index
75
+ # - default charset for field VALUE
76
+ td.charsetIndex = Transactd::charsetIndex(Transactd::CP_UTF8)
77
+ td.id = 1
78
+ td.pageSize = 2048
79
+ dbdef.insertTable(td)
80
+ expect(dbdef.stat()).to eq 0
81
+ # id
82
+ fd = dbdef.insertField(1, FDI_ID)
83
+ fd.setName('id')
84
+ fd.type = Transactd::Ft_autoinc
85
+ fd.len = 4
86
+ dbdef.updateTableDef(1)
87
+ expect(dbdef.stat()).to eq 0
88
+ # user_id
89
+ fd = dbdef.insertField(1, FDI_USER_ID)
90
+ fd.setName('user_id')
91
+ fd.type = Transactd::Ft_integer
92
+ fd.len = 4
93
+ dbdef.updateTableDef(1)
94
+ expect(dbdef.stat()).to eq 0
95
+ # body
96
+ fd = dbdef.insertField(1, FDI_BODY)
97
+ fd.setName('body')
98
+ fd.type = Transactd::Ft_mytext
99
+ fd.len = 10 # 9:TYNYTEXT 10:TEXT 11:MIDIUMTEXT 12:LONGTEXT
100
+ dbdef.updateTableDef(1)
101
+ expect(dbdef.stat()).to eq 0
102
+ # image
103
+ fd = dbdef.insertField(1, FDI_IMAGE)
104
+ fd.setName('image')
105
+ fd.type = Transactd::Ft_myblob
106
+ fd.len = 10 # 9:TYNYBLOB 10:BLOB 11:MIDIUMBLOB 12:LONGBLOB
107
+ dbdef.updateTableDef(1)
108
+ expect(dbdef.stat()).to eq 0
109
+ # key
110
+ kd = dbdef.insertKey(1,0)
111
+ kd.segment(0).fieldNum = 0
112
+ kd.segment(0).flags.bit8 = 1
113
+ kd.segment(0).flags.bit1 = 1
114
+ kd.segmentCount = 1
115
+ dbdef.updateTableDef(1)
116
+ expect(dbdef.stat()).to eq 0
117
+ end
118
+
119
+ def openTable(db)
120
+ tb = db.openTable(TABLENAME)
121
+ expect(db.stat()).to eq 0
122
+ return tb
123
+ end
124
+
125
+ def getTestBinary()
126
+ image_base64 = 'R0lGODdhEAAQAKEBAGZmZv#/5mZmczMzCwAAAAAEAAQAAACRowzIgA6BxebTMAgG60nW5NM1kAZikGFHAmgYvYgJpW12FfTyLpJjz+IVSSXR4IlQCoUgCCG8ds0D5xZT3TJYS8IZiMJKQAAOw=='
127
+ return Base64.decode64(image_base64)
128
+ end
129
+
130
+ 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
+ it 'create' do
140
+ createDatabase(@db)
141
+ openDatabase(@db)
142
+ createTable(@db)
143
+ tb = openTable(@db)
144
+ tb.close()
145
+ end
146
+
147
+ it 'insert' do
148
+ image = getTestBinary()
149
+ openDatabase(@db)
150
+ tb = openTable(@db)
151
+ expect(tb).not_to be nil
152
+ # 1
153
+ tb.clearBuffer()
154
+ tb.setFV(FDI_USER_ID, 1)
155
+ tb.setFV(FDI_BODY, "1\ntest\nテスト\n\nあいうえおあいうえお")
156
+ tb.setFV(FDI_IMAGE, image, image.bytesize)
157
+ tb.insert()
158
+ expect(tb.stat()).to eq 0
159
+ # 2
160
+ tb.clearBuffer()
161
+ tb.setFV('user_id', 1)
162
+ tb.setFV('body', "2\ntest\nテスト\n\nあいうえおあいうえお")
163
+ str = "2\ntest\nテスト\n\nあいうえおあいうえお"
164
+ tb.setFV('image', str, str.bytesize)
165
+ tb.insert()
166
+ expect(tb.stat()).to eq 0
167
+ # 3
168
+ tb.clearBuffer()
169
+ tb.setFV(FDI_USER_ID, 2)
170
+ tb.setFV(FDI_BODY, "3\ntest\nテスト\n\nあいうえおあいうえお")
171
+ str = "3\ntest\nテスト\n\nあいうえおあいうえお"
172
+ tb.setFV(FDI_IMAGE, str, str.bytesize)
173
+ tb.insert()
174
+ expect(tb.stat()).to eq 0
175
+ tb.close()
176
+ end
177
+
178
+ it 'seek' do
179
+ image = getTestBinary()
180
+ openDatabase(@db)
181
+ tb = openTable(@db)
182
+ expect(tb).not_to be nil
183
+ # 1
184
+ tb.clearBuffer()
185
+ tb.setFV(FDI_ID, 1)
186
+ tb.seek()
187
+ expect(tb.stat()).to eq 0
188
+ expect(tb.getFVint(FDI_ID)).to eq 1
189
+ expect(tb.getFVint(FDI_USER_ID)).to eq 1
190
+ expect(tb.getFVstr(FDI_BODY)).to eq "1\ntest\nテスト\n\nあいうえおあいうえお"
191
+ expect(tb.getFVbin(FDI_IMAGE)).to eq image
192
+ # 2
193
+ tb.seekNext()
194
+ expect(tb.stat()).to eq 0
195
+ expect(tb.getFVint(FDI_ID)).to eq 2
196
+ expect(tb.getFVint(FDI_USER_ID)).to eq 1
197
+ expect(tb.getFVstr(FDI_BODY)).to eq "2\ntest\nテスト\n\nあいうえおあいうえお"
198
+ expect(tb.getFVbin(FDI_IMAGE).force_encoding('UTF-8')).to eq "2\ntest\nテスト\n\nあいうえおあいうえお"
199
+ # 3
200
+ tb.seekNext()
201
+ expect(tb.stat()).to eq 0
202
+ expect(tb.getFVint(FDI_ID)).to eq 3
203
+ expect(tb.getFVint(FDI_USER_ID)).to eq 2
204
+ expect(tb.getFVstr(FDI_BODY)).to eq "3\ntest\nテスト\n\nあいうえおあいうえお"
205
+ expect(tb.getFVbin(FDI_IMAGE).force_encoding('UTF-8')).to eq "3\ntest\nテスト\n\nあいうえおあいうえお"
206
+ # 2
207
+ tb.seekPrev()
208
+ expect(tb.stat()).to eq 0
209
+ expect(tb.getFVint(FDI_ID)).to eq 2
210
+ expect(tb.getFVint(FDI_USER_ID)).to eq 1
211
+ expect(tb.getFVstr(FDI_BODY)).to eq "2\ntest\nテスト\n\nあいうえおあいうえお"
212
+ expect(tb.getFVbin(FDI_IMAGE).force_encoding('UTF-8')).to eq "2\ntest\nテスト\n\nあいうえおあいうえお"
213
+ tb.close()
214
+ end
215
+
216
+ it 'find' do
217
+ image = getTestBinary()
218
+ openDatabase(@db)
219
+ tb = openTable(@db)
220
+ expect(tb).not_to be nil
221
+ # 1
222
+ tb.setKeyNum(0)
223
+ tb.clearBuffer()
224
+ tb.setFilter('id >= 1 and id < 3', 1, 0)
225
+ expect(tb.stat()).to eq 0
226
+ tb.setFV(FDI_ID, 1)
227
+ tb.find(Transactd::Table::FindForword)
228
+ expect(tb.stat()).to eq 0
229
+ expect(tb.getFVint(FDI_ID)).to eq 1
230
+ expect(tb.getFVint(FDI_USER_ID)).to eq 1
231
+ expect(tb.getFVstr(FDI_BODY)).to eq "1\ntest\nテスト\n\nあいうえおあいうえお"
232
+ expect(tb.getFVbin(FDI_IMAGE)).to eq image
233
+ # 2
234
+ tb.findNext(true)
235
+ expect(tb.stat()).to eq 0
236
+ expect(tb.getFVint(FDI_ID)).to eq 2
237
+ expect(tb.getFVint(FDI_USER_ID)).to eq 1
238
+ expect(tb.getFVstr(FDI_BODY)).to eq "2\ntest\nテスト\n\nあいうえおあいうえお"
239
+ expect(tb.getFVbin(FDI_IMAGE).force_encoding('UTF-8')).to eq "2\ntest\nテスト\n\nあいうえおあいうえお"
240
+ # 3... but not found because filtered
241
+ tb.findNext(true)
242
+ expect(tb.stat()).to eq Transactd::STATUS_EOF
243
+ # 2... but changing seek-direction is not allowed
244
+ tb.findPrev(true)
245
+ expect(tb.stat()).to eq Transactd::STATUS_PROGRAM_ERROR
246
+ tb.close()
247
+ end
248
+
249
+ it 'update' do
250
+ image = getTestBinary()
251
+ openDatabase(@db)
252
+ tb = openTable(@db)
253
+ expect(tb).not_to be nil
254
+ # select 1
255
+ tb.clearBuffer()
256
+ tb.setFV(FDI_ID, 1)
257
+ tb.seek()
258
+ expect(tb.stat()).to eq 0
259
+ expect(tb.getFVint(FDI_ID)).to eq 1
260
+ expect(tb.getFVint(FDI_USER_ID)).to eq 1
261
+ expect(tb.getFVstr(FDI_BODY)).to eq "1\ntest\nテスト\n\nあいうえおあいうえお"
262
+ expect(tb.getFVbin(FDI_IMAGE)).to eq image
263
+ # update
264
+ tb.setFV(FDI_BODY, "1\nテスト\ntest\n\nABCDEFG")
265
+ tb.update()
266
+ expect(tb.stat()).to eq 0
267
+ # select 2
268
+ tb.seekNext()
269
+ expect(tb.stat()).to eq 0
270
+ expect(tb.getFVint(FDI_ID)).to eq 2
271
+ expect(tb.getFVint(FDI_USER_ID)).to eq 1
272
+ expect(tb.getFVstr(FDI_BODY)).to eq "2\ntest\nテスト\n\nあいうえおあいうえお"
273
+ expect(tb.getFVbin(FDI_IMAGE).force_encoding('UTF-8')).to eq "2\ntest\nテスト\n\nあいうえおあいうえお"
274
+ # update
275
+ tb.setFV(FDI_BODY, "2\nテスト\ntest\n\nABCDEFG")
276
+ tb.update()
277
+ expect(tb.stat()).to eq 0
278
+ # check 1
279
+ tb.seekPrev()
280
+ expect(tb.stat()).to eq 0
281
+ expect(tb.getFVint(FDI_ID)).to eq 1
282
+ expect(tb.getFVint(FDI_USER_ID)).to eq 1
283
+ expect(tb.getFVstr(FDI_BODY)).to eq "1\nテスト\ntest\n\nABCDEFG"
284
+ expect(tb.getFVbin(FDI_IMAGE)).to eq image
285
+ # check 2
286
+ tb.seekNext()
287
+ expect(tb.stat()).to eq 0
288
+ expect(tb.getFVint(FDI_ID)).to eq 2
289
+ expect(tb.getFVint(FDI_USER_ID)).to eq 1
290
+ expect(tb.getFVstr(FDI_BODY)).to eq "2\nテスト\ntest\n\nABCDEFG"
291
+ expect(tb.getFVbin(FDI_IMAGE).force_encoding('UTF-8')).to eq "2\ntest\nテスト\n\nあいうえおあいうえお"
292
+ tb.close()
293
+ end
294
+
295
+ it 'delete' do
296
+ image = getTestBinary()
297
+ openDatabase(@db)
298
+ tb = openTable(@db)
299
+ expect(tb).not_to be nil
300
+ # delete 2
301
+ tb.clearBuffer()
302
+ tb.setFV(FDI_ID, 2)
303
+ tb.seek()
304
+ expect(tb.stat()).to eq 0
305
+ tb.del()
306
+ expect(tb.stat()).to eq 0
307
+ # select 1
308
+ tb.clearBuffer()
309
+ tb.setFV(FDI_ID, 1)
310
+ tb.seek()
311
+ expect(tb.stat()).to eq 0
312
+ expect(tb.getFVint(FDI_ID)).to eq 1
313
+ expect(tb.getFVint(FDI_USER_ID)).to eq 1
314
+ expect(tb.getFVstr(FDI_BODY)).to eq "1\nテスト\ntest\n\nABCDEFG"
315
+ expect(tb.getFVbin(FDI_IMAGE)).to eq image
316
+ # next is 3
317
+ tb.seekNext()
318
+ expect(tb.stat()).to eq 0
319
+ expect(tb.getFVint(FDI_ID)).to eq 3
320
+ expect(tb.getFVint(FDI_USER_ID)).to eq 2
321
+ expect(tb.getFVstr(FDI_BODY)).to eq "3\ntest\nテスト\n\nあいうえおあいうえお"
322
+ expect(tb.getFVbin(FDI_IMAGE).force_encoding('UTF-8')).to eq "3\ntest\nテスト\n\nあいうえおあいうえお"
323
+ # eof
324
+ tb.seekNext()
325
+ expect(tb.stat()).to eq Transactd::STATUS_EOF
326
+ tb.close()
327
+ end
328
+
329
+ it 'drop' do
330
+ dropDatabase(@db)
331
+ end
332
+ end
@@ -100,6 +100,21 @@ def testCreateTable(db)
100
100
  fd.len = 33
101
101
  dbdef.updateTableDef(1)
102
102
  expect(dbdef.stat()).to eq 0
103
+
104
+ fd = dbdef.insertField(1, 2)
105
+ fd.setName('select')
106
+ fd.type = Transactd::Ft_integer
107
+ fd.len = 4
108
+ dbdef.updateTableDef(1)
109
+ expect(dbdef.stat()).to eq 0
110
+
111
+ fd = dbdef.insertField(1, 3)
112
+ fd.setName('in')
113
+ fd.type = Transactd::Ft_integer
114
+ fd.len = 4
115
+ dbdef.updateTableDef(1)
116
+ expect(dbdef.stat()).to eq 0
117
+
103
118
  kd = dbdef.insertKey(1,0)
104
119
  kd.segment(0).fieldNum = 0
105
120
  kd.segment(0).flags.bit8 = 1
@@ -191,6 +206,7 @@ def testFind(db)
191
206
  i = i - 1
192
207
  end
193
208
  # out of filter range (EOF)
209
+ tb.clearBuffer()
194
210
  v = TEST_COUNT
195
211
  tb.setFV(FDI_ID, v)
196
212
  tb.find(Transactd::Table::FindForword)
@@ -215,6 +231,79 @@ def testFindNext(db)
215
231
  tb.close()
216
232
  end
217
233
 
234
+ def testFindIn(db)
235
+ tb = testOpenTable(db)
236
+ tb.setKeyNum(0)
237
+ tb.clearBuffer()
238
+ q = Transactd::QueryBase.new()
239
+ q.addInValue('10', true)
240
+ q.addInValue('300000')
241
+ q.addInValue('50')
242
+ q.addInValue('-1')
243
+ q.addInValue('80')
244
+ q.addInValue('5000')
245
+
246
+ tb.setQuery(q)
247
+ expect(tb.stat()).to eq 0
248
+ tb.find()
249
+ expect(tb.stat()).to eq 0
250
+ expect(tb.getFVint(FDI_ID)).to eq 10
251
+ tb.findNext()
252
+ expect(tb.stat()).to eq Transactd::STATUS_NOT_FOUND_TI
253
+
254
+ msg = tb.keyValueDescription()
255
+ expect(msg).to eq "table:user\nstat:4\nid = 300000\n"
256
+
257
+ tb.findNext()
258
+ expect(tb.getFVint(FDI_ID)).to eq 50
259
+ tb.findNext()
260
+ expect(tb.stat()).to eq Transactd::STATUS_NOT_FOUND_TI
261
+
262
+ msg = tb.keyValueDescription()
263
+ expect(msg).to eq "table:user\nstat:4\nid = -1\n"
264
+
265
+ tb.findNext()
266
+ expect(tb.getFVint(FDI_ID)).to eq 80
267
+ tb.findNext()
268
+ expect(tb.getFVint(FDI_ID)).to eq 5000
269
+ tb.findNext()
270
+ expect(tb.stat()).to eq Transactd::STATUS_EOF
271
+
272
+ # Many params
273
+ q.addInValue('1', true)
274
+ 2.upto(10000) do |i|
275
+ q.addInValue(i.to_s)
276
+ end
277
+ tb.setQuery(q)
278
+ expect(tb.stat()).to eq 0
279
+
280
+ tb.find()
281
+ i = 0
282
+ while tb.stat() == 0 do
283
+ i = i + 1
284
+ expect(tb.getFVint(FDI_ID)).to eq i
285
+ tb.findNext(true)
286
+ end
287
+ expect(tb.stat()).to eq Transactd::STATUS_EOF
288
+ expect(i).to eq 10000
289
+
290
+ # LogicalCountLimit
291
+ q.select('id')
292
+ tb.setQuery(q)
293
+
294
+ tb.find()
295
+ i = 0
296
+ while tb.stat() == 0 do
297
+ i = i + 1
298
+ expect(tb.getFVint(FDI_ID)).to eq i
299
+ tb.findNext(true)
300
+ end
301
+ expect(tb.stat()).to eq Transactd::STATUS_EOF
302
+ expect(i).to eq 10000
303
+
304
+ tb.close()
305
+ end
306
+
218
307
  def testGetPercentage(db)
219
308
  tb = testOpenTable(db)
220
309
  tb.clearBuffer()
@@ -448,7 +537,7 @@ def testSnapShot(db)
448
537
  if ISOLATION_READ_COMMITTED
449
538
  expect(tb2.stat()).to eq 0
450
539
  elsif ISOLATION_REPEATABLE_READ
451
- expect(tb2.stat()).to eq STATUS_LOCK_ERROR
540
+ expect(tb2.stat()).to eq Transactd::STATUS_LOCK_ERROR
452
541
  end
453
542
  # ----------------------------------------------------
454
543
  tb.seekFirst()
@@ -1263,6 +1352,7 @@ def testCreateTableStringFilter(db, id, name, type, type2)
1263
1352
  end
1264
1353
 
1265
1354
  def doTestInsertStringFilter(tb)
1355
+ tb.beginBulkInsert(BULKBUFSIZE)
1266
1356
  tb.clearBuffer()
1267
1357
  id = 1
1268
1358
  tb.setFV('id', id)
@@ -1293,6 +1383,7 @@ def doTestInsertStringFilter(tb)
1293
1383
  tb.setFV('name', 'おめでとうございます。')
1294
1384
  tb.setFV('namew', 'おめでとうございます。')
1295
1385
  tb.insert()
1386
+ tb.commitBulkInsert()
1296
1387
  end
1297
1388
 
1298
1389
  def doTestReadStringFilter(tb)
@@ -1325,18 +1416,91 @@ end
1325
1416
  def doTestSetStringFilter(tb)
1326
1417
  tb.setKeyNum(0)
1327
1418
  tb.clearBuffer()
1419
+
1328
1420
  tb.setFilter("name = 'あい*'", 0, 10)
1421
+ expect(tb.stat()).to eq 0
1329
1422
  tb.seekFirst()
1423
+ expect(tb.stat()).to eq 0
1330
1424
  tb.findNext(false)
1331
1425
  expect(tb.stat()).to eq 0
1332
1426
  expect(tb.getFVstr(FDI_NAME)).to eq 'あいうえおかきくこ'
1333
1427
  expect(tb.recordCount()).to eq 2
1428
+
1334
1429
  tb.setFilter("name <> 'あい*'", 0, 10)
1335
1430
  expect(tb.recordCount()).to eq 3
1431
+ tb.clearBuffer()
1432
+ tb.seekFirst()
1433
+ expect(tb.stat()).to eq 0
1434
+ tb.findNext(false)
1435
+ expect(tb.stat()).to eq 0
1436
+ expect(tb.getFVstr(FDI_NAMEW)).to eq 'A123456'
1437
+
1438
+ tb.findNext()
1439
+ expect(tb.stat()).to eq 0
1440
+ expect(tb.getFVstr(FDI_NAMEW)).to eq 'おはようございます'
1441
+
1442
+ tb.findNext()
1443
+ expect(tb.stat()).to eq 0
1444
+ expect(tb.getFVstr(FDI_NAMEW)).to eq 'おめでとうございます。'
1445
+
1446
+ tb.findNext()
1447
+ expect(tb.stat()).to eq Transactd::STATUS_EOF
1448
+
1449
+ tb.clearBuffer()
1450
+ tb.seekLast()
1451
+ tb.findPrev(false)
1452
+ expect(tb.stat()).to eq 0
1453
+ expect(tb.getFVstr(FDI_NAMEW)).to eq 'おめでとうございます。'
1454
+
1455
+ tb.findPrev()
1456
+ expect(tb.stat()).to eq 0
1457
+ expect(tb.getFVstr(FDI_NAMEW)).to eq 'おはようございます'
1458
+
1459
+ tb.findPrev(false)
1460
+ expect(tb.stat()).to eq 0
1461
+ expect(tb.getFVstr(FDI_NAMEW)).to eq 'A123456'
1462
+
1463
+ tb.findPrev()
1464
+ expect(tb.stat()).to eq Transactd::STATUS_EOF
1465
+
1336
1466
  tb.setFilter("name = 'あい'", 0, 10)
1337
1467
  expect(tb.recordCount()).to eq 0
1468
+
1338
1469
  tb.setFilter("name <> ''", 0, 10)
1339
1470
  expect(tb.recordCount()).to eq 5
1471
+
1472
+ # testing that setFilter don't change field value
1473
+ tb.clearBuffer()
1474
+ tb.setFV('name', 'ABCDE')
1475
+ tb.setFilter("name = 'あい'", 0, 10)
1476
+ expect(tb.getFVstr(FDI_NAME)).to eq 'ABCDE'
1477
+ end
1478
+
1479
+ def doTestUpdateStringFilter(tb)
1480
+ tb.setKeyNum(0)
1481
+ tb.clearBuffer()
1482
+ tb.seekFirst()
1483
+ expect(tb.stat()).to eq 0
1484
+ tb.setFV('name', 'ABCDE')
1485
+ tb.setFV('namew', 'ABCDEW')
1486
+ tb.update()
1487
+ expect(tb.stat()).to eq 0
1488
+ tb.seekNext()
1489
+ expect(tb.stat()).to eq 0
1490
+
1491
+ tb.setFV('name', 'ABCDE2')
1492
+ tb.setFV('namew', 'ABCDEW2')
1493
+ tb.update()
1494
+ expect(tb.stat()).to eq 0
1495
+
1496
+ tb.seekFirst()
1497
+ expect(tb.stat()).to eq 0
1498
+ expect(tb.getFVstr(FDI_NAME)).to eq 'ABCDE'
1499
+ expect(tb.getFVstr(FDI_NAMEW)).to eq 'ABCDEW'
1500
+ tb.seekNext()
1501
+ expect(tb.stat()).to eq 0
1502
+ expect(tb.getFVstr(FDI_NAME)).to eq 'ABCDE2'
1503
+ expect(tb.getFVstr(FDI_NAMEW)).to eq 'ABCDEW2'
1340
1504
  end
1341
1505
 
1342
1506
  def doTestStringFilter(db, id, name, type, type2)
@@ -1346,6 +1510,7 @@ def doTestStringFilter(db, id, name, type, type2)
1346
1510
  doTestInsertStringFilter(tb)
1347
1511
  doTestReadStringFilter(tb)
1348
1512
  doTestSetStringFilter(tb)
1513
+ doTestUpdateStringFilter(tb)
1349
1514
  tb.close()
1350
1515
  end
1351
1516
 
@@ -1374,6 +1539,90 @@ def testDropDatabaseStringFilter(db)
1374
1539
  expect(db.stat()).to eq 0
1375
1540
  end
1376
1541
 
1542
+ def testQuery()
1543
+ q = Transactd::QueryBase.new()
1544
+ q.queryString("id = 0 and name = 'Abc efg'")
1545
+ expect(q.toString()).to eq "id = '0' and name = 'Abc efg'"
1546
+
1547
+ q.queryString('')
1548
+ q.where('id', '=', '0').andWhere('name', '=', 'Abc efg')
1549
+ expect(q.toString()).to eq "id = '0' and name = 'Abc efg'"
1550
+
1551
+ q.queryString("select id,name id = 0 AND name = 'Abc&' efg'")
1552
+ expect(q.toString()).to eq "select id,name id = '0' AND name = 'Abc&' efg'"
1553
+
1554
+ q.queryString('')
1555
+ q.select('id', 'name').where('id', '=', '0').andWhere('name', '=', "Abc' efg")
1556
+ expect(q.toString()).to eq "select id,name id = '0' and name = 'Abc&' efg'"
1557
+
1558
+ q.queryString("select id,name id = 0 AND name = 'Abc&& efg'")
1559
+ expect(q.toString()).to eq "select id,name id = '0' AND name = 'Abc&& efg'"
1560
+
1561
+ q.queryString('')
1562
+ q.select('id', 'name').where('id', '=', '0').andWhere('name', '=', 'Abc& efg')
1563
+ expect(q.toString()).to eq "select id,name id = '0' and name = 'Abc&& efg'"
1564
+
1565
+ q.queryString('*')
1566
+ expect(q.toString()).to eq '*'
1567
+
1568
+ q.all()
1569
+ expect(q.toString()).to eq '*'
1570
+
1571
+ q.queryString('Select id,name id = 2')
1572
+ expect(q.toString()).to eq "select id,name id = '2'"
1573
+
1574
+ q.queryString('')
1575
+ q.select('id', 'name').where('id', '=', '2')
1576
+ expect(q.toString()).to eq "select id,name id = '2'"
1577
+
1578
+ q.queryString('SELECT id,name,fc id = 2')
1579
+ expect(q.toString()).to eq "select id,name,fc id = '2'"
1580
+
1581
+ q.queryString('')
1582
+ q.select('id', 'name', 'fc').where('id', '=', '2')
1583
+ expect(q.toString()).to eq "select id,name,fc id = '2'"
1584
+
1585
+ q.queryString("select id,name,fc id = 2 and name = '3'")
1586
+ expect(q.toString()).to eq "select id,name,fc id = '2' and name = '3'"
1587
+
1588
+ q.queryString('')
1589
+ q.select('id', 'name', 'fc').where('id', '=', '2').andWhere('name', '=', '3')
1590
+ expect(q.toString()).to eq "select id,name,fc id = '2' and name = '3'"
1591
+
1592
+ # IN include
1593
+ q.queryString("select id,name,fc IN '1','2','3'")
1594
+ expect(q.toString()).to eq "select id,name,fc in '1','2','3'"
1595
+
1596
+ q.queryString('')
1597
+ q.select('id', 'name', 'fc').In('1', '2', '3')
1598
+ expect(q.toString()).to eq "select id,name,fc in '1','2','3'"
1599
+
1600
+ q.queryString("IN '1','2','3'")
1601
+ expect(q.toString()).to eq "in '1','2','3'"
1602
+
1603
+ q.queryString('IN 1,2,3')
1604
+ expect(q.toString()).to eq "in '1','2','3'"
1605
+
1606
+ q.queryString('')
1607
+ q.In('1', '2', '3')
1608
+ expect(q.toString()).to eq "in '1','2','3'"
1609
+
1610
+ # special field name
1611
+ q.queryString('select = 1')
1612
+ expect(q.toString()).to eq "select = '1'"
1613
+
1614
+ q.queryString('')
1615
+ q.where('select', '=', '1')
1616
+ expect(q.toString()).to eq "select = '1'"
1617
+
1618
+ q.queryString('in <> 1')
1619
+ expect(q.toString()).to eq "in <> '1'"
1620
+
1621
+ q.queryString('')
1622
+ q.where('in', '<>', '1')
1623
+ expect(q.toString()).to eq "in <> '1'"
1624
+ end
1625
+
1377
1626
 
1378
1627
  describe Transactd do
1379
1628
  before :each do
@@ -1405,6 +1654,9 @@ describe Transactd do
1405
1654
  it 'findNext' do
1406
1655
  testFindNext(@db)
1407
1656
  end
1657
+ it 'findIn' do
1658
+ testFindIn(@db)
1659
+ end
1408
1660
  it 'get percentage' do
1409
1661
  testGetPercentage(@db)
1410
1662
  end
@@ -1465,6 +1717,9 @@ describe Transactd do
1465
1717
  it 'login' do
1466
1718
  testLogin(@db)
1467
1719
  end
1720
+ it 'query' do
1721
+ testQuery()
1722
+ end
1468
1723
  end
1469
1724
 
1470
1725
  describe Transactd, 'var tables' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transactd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: x86-mswin32-100
6
6
  authors:
7
7
  - BizStation Corp.
@@ -20,8 +20,8 @@ files:
20
20
  - bin/1.9/transactd.so
21
21
  - bin/2.0/transactd.so
22
22
  - build/tdclrb/bldgem/extconf.rb
23
- - bin/common/tdclcpp_vc100_32m_1_1.dll
24
- - bin/common/tdclc_32_1_1.dll
23
+ - bin/common/tdclcpp_vc100_32m_1_2.dll
24
+ - bin/common/tdclc_32_1_2.dll
25
25
  - build/tdclrb/gem/detect.rb
26
26
  - build/tdclrb/gem/helper.rb
27
27
  - build/tdclrb/gem/INSTALLLOG.win32
@@ -33,6 +33,7 @@ files:
33
33
  - build/common/system.cmake
34
34
  - source/bzs/test/tdclrb/bench_tdclcpp.rb
35
35
  - source/bzs/test/tdclrb/prepare.rb
36
+ - source/bzs/test/tdclrb/transactd_blob_spec.rb
36
37
  - source/bzs/test/tdclrb/transactd_datetime_spec.rb
37
38
  - source/bzs/test/tdclrb/transactd_kanjischema_spec.rb
38
39
  - source/bzs/test/tdclrb/transactd_spec.rb
Binary file
Binary file