rubyfb 0.5.5 → 0.5.6
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.
- data/CHANGELOG +6 -0
- data/Manifest +0 -1
- data/Rakefile +1 -1
- data/ext/AddUser.c +217 -248
- data/ext/AddUser.h +3 -3
- data/ext/Backup.c +337 -404
- data/ext/Backup.h +3 -3
- data/ext/Blob.c +197 -248
- data/ext/Blob.h +30 -31
- data/ext/Common.c +17 -18
- data/ext/Common.h +10 -10
- data/ext/Connection.c +413 -487
- data/ext/Connection.h +18 -19
- data/ext/DataArea.c +172 -189
- data/ext/DataArea.h +11 -11
- data/ext/Database.c +198 -238
- data/ext/Database.h +16 -17
- data/ext/FireRuby.c +118 -142
- data/ext/FireRuby.h +17 -17
- data/ext/FireRubyException.c +68 -138
- data/ext/FireRubyException.h +14 -21
- data/ext/Generator.c +296 -377
- data/ext/Generator.h +17 -18
- data/ext/RemoveUser.c +91 -102
- data/ext/RemoveUser.h +3 -3
- data/ext/Restore.c +353 -423
- data/ext/Restore.h +3 -3
- data/ext/ResultSet.c +423 -456
- data/ext/ResultSet.h +26 -27
- data/ext/Row.c +505 -568
- data/ext/Row.h +27 -28
- data/ext/ServiceManager.c +143 -164
- data/ext/ServiceManager.h +17 -18
- data/ext/Services.c +58 -67
- data/ext/Services.h +3 -3
- data/ext/Statement.c +388 -449
- data/ext/Statement.h +30 -31
- data/ext/Transaction.c +374 -448
- data/ext/Transaction.h +17 -18
- data/ext/TypeMap.c +654 -774
- data/ext/TypeMap.h +17 -17
- data/ext/rfbint.h +3 -3
- data/lib/active_record/connection_adapters/rubyfb_adapter.rb +1 -1
- data/lib/rubyfb_lib.so +0 -0
- data/lib/src.rb +33 -0
- data/rubyfb.gemspec +3 -3
- data/test/ResultSetTest.rb +13 -0
- data/test/RowTest.rb +16 -0
- metadata +4 -5
- data/test/UnitTest.rb +0 -65
data/ext/Restore.c
CHANGED
@@ -88,39 +88,32 @@ VALUE cRestore;
|
|
88
88
|
* @return A reference to the newly initialized Restore object.
|
89
89
|
*
|
90
90
|
*/
|
91
|
-
VALUE initializeRestore(VALUE self, VALUE file, VALUE database)
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
/* Store the object attributes. */
|
118
|
-
rb_iv_set(self, "@backup_file", from);
|
119
|
-
rb_iv_set(self, "@database", to);
|
120
|
-
rb_iv_set(self, "@options", options);
|
121
|
-
rb_iv_set(self, "@log", Qnil);
|
122
|
-
|
123
|
-
return(self);
|
91
|
+
VALUE initializeRestore(VALUE self, VALUE file, VALUE database) {
|
92
|
+
VALUE from = Qnil,
|
93
|
+
to = rb_hash_new(),
|
94
|
+
options = rb_hash_new();
|
95
|
+
|
96
|
+
/* Extract the parameters. */
|
97
|
+
if(TYPE(file) == T_FILE) {
|
98
|
+
from = rb_funcall(file, rb_intern("path"), 0);
|
99
|
+
} else {
|
100
|
+
from = rb_funcall(file, rb_intern("to_s"), 0);
|
101
|
+
}
|
102
|
+
|
103
|
+
if(TYPE(database) == T_FILE) {
|
104
|
+
to = rb_funcall(database, rb_intern("path"), 0);
|
105
|
+
} else {
|
106
|
+
to = rb_funcall(database, rb_intern("to_s"), 0);
|
107
|
+
}
|
108
|
+
rb_hash_aset(options, RESTORE_MODE, CREATE_DATABASE);
|
109
|
+
|
110
|
+
/* Store the object attributes. */
|
111
|
+
rb_iv_set(self, "@backup_file", from);
|
112
|
+
rb_iv_set(self, "@database", to);
|
113
|
+
rb_iv_set(self, "@options", options);
|
114
|
+
rb_iv_set(self, "@log", Qnil);
|
115
|
+
|
116
|
+
return(self);
|
124
117
|
}
|
125
118
|
|
126
119
|
|
@@ -133,9 +126,8 @@ VALUE initializeRestore(VALUE self, VALUE file, VALUE database)
|
|
133
126
|
* @return A reference to the attribute value.
|
134
127
|
*
|
135
128
|
*/
|
136
|
-
VALUE getRestoreFile(VALUE self)
|
137
|
-
|
138
|
-
return(rb_iv_get(self, "@backup_file"));
|
129
|
+
VALUE getRestoreFile(VALUE self) {
|
130
|
+
return(rb_iv_get(self, "@backup_file"));
|
139
131
|
}
|
140
132
|
|
141
133
|
|
@@ -150,21 +142,17 @@ VALUE getRestoreFile(VALUE self)
|
|
150
142
|
* @return A reference to the newly update Restore object.
|
151
143
|
*
|
152
144
|
*/
|
153
|
-
VALUE setRestoreFile(VALUE self, VALUE setting)
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
}
|
165
|
-
rb_iv_set(self, "@backup_file", actual);
|
166
|
-
|
167
|
-
return(self);
|
145
|
+
VALUE setRestoreFile(VALUE self, VALUE setting) {
|
146
|
+
VALUE actual = Qnil;
|
147
|
+
|
148
|
+
if(TYPE(setting) == T_FILE) {
|
149
|
+
actual = rb_funcall(setting, rb_intern("path"), 0);
|
150
|
+
} else {
|
151
|
+
actual = rb_funcall(setting, rb_intern("to_s"), 0);
|
152
|
+
}
|
153
|
+
rb_iv_set(self, "@backup_file", actual);
|
154
|
+
|
155
|
+
return(self);
|
168
156
|
}
|
169
157
|
|
170
158
|
|
@@ -177,9 +165,8 @@ VALUE setRestoreFile(VALUE self, VALUE setting)
|
|
177
165
|
* @return A reference to the attribute value.
|
178
166
|
*
|
179
167
|
*/
|
180
|
-
VALUE getRestoreDatabase(VALUE self)
|
181
|
-
|
182
|
-
return(rb_iv_get(self, "@database"));
|
168
|
+
VALUE getRestoreDatabase(VALUE self) {
|
169
|
+
return(rb_iv_get(self, "@database"));
|
183
170
|
}
|
184
171
|
|
185
172
|
|
@@ -194,21 +181,17 @@ VALUE getRestoreDatabase(VALUE self)
|
|
194
181
|
* @return A reference to the newly update Restore object.
|
195
182
|
*
|
196
183
|
*/
|
197
|
-
VALUE setRestoreDatabase(VALUE self, VALUE setting)
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
}
|
209
|
-
rb_iv_set(self, "@database", actual);
|
210
|
-
|
211
|
-
return(self);
|
184
|
+
VALUE setRestoreDatabase(VALUE self, VALUE setting) {
|
185
|
+
VALUE actual = Qnil;
|
186
|
+
|
187
|
+
if(TYPE(setting) == T_FILE) {
|
188
|
+
actual = rb_funcall(setting, rb_intern("path"), 0);
|
189
|
+
} else {
|
190
|
+
actual = rb_funcall(setting, rb_intern("to_s"), 0);
|
191
|
+
}
|
192
|
+
rb_iv_set(self, "@database", actual);
|
193
|
+
|
194
|
+
return(self);
|
212
195
|
}
|
213
196
|
|
214
197
|
|
@@ -221,9 +204,8 @@ VALUE setRestoreDatabase(VALUE self, VALUE setting)
|
|
221
204
|
* @return A reference to the current cache buffers setting.
|
222
205
|
*
|
223
206
|
*/
|
224
|
-
VALUE getRestoreCacheBuffers(VALUE self)
|
225
|
-
|
226
|
-
return(rb_hash_aref(rb_iv_get(self, "@options"), CACHE_BUFFERS));
|
207
|
+
VALUE getRestoreCacheBuffers(VALUE self) {
|
208
|
+
return(rb_hash_aref(rb_iv_get(self, "@options"), CACHE_BUFFERS));
|
227
209
|
}
|
228
210
|
|
229
211
|
|
@@ -237,17 +219,15 @@ VALUE getRestoreCacheBuffers(VALUE self)
|
|
237
219
|
* @return A reference to the newly updated Restore object.
|
238
220
|
*
|
239
221
|
*/
|
240
|
-
VALUE setRestoreCacheBuffers(VALUE self, VALUE setting)
|
241
|
-
{
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
return(self);
|
222
|
+
VALUE setRestoreCacheBuffers(VALUE self, VALUE setting) {
|
223
|
+
if(rb_obj_is_kind_of(setting, rb_cInteger) == Qfalse) {
|
224
|
+
rb_fireruby_raise(NULL,
|
225
|
+
"Invalid cache buffers setting specified for database " \
|
226
|
+
"restore.");
|
227
|
+
}
|
228
|
+
rb_hash_aset(rb_iv_get(self, "@options"), CACHE_BUFFERS, setting);
|
229
|
+
|
230
|
+
return(self);
|
251
231
|
}
|
252
232
|
|
253
233
|
|
@@ -260,9 +240,8 @@ VALUE setRestoreCacheBuffers(VALUE self, VALUE setting)
|
|
260
240
|
* @return A reference to the current cache buffers setting.
|
261
241
|
*
|
262
242
|
*/
|
263
|
-
VALUE getRestorePageSize(VALUE self)
|
264
|
-
|
265
|
-
return(rb_hash_aref(rb_iv_get(self, "@options"), PAGE_SIZE));
|
243
|
+
VALUE getRestorePageSize(VALUE self) {
|
244
|
+
return(rb_hash_aref(rb_iv_get(self, "@options"), PAGE_SIZE));
|
266
245
|
}
|
267
246
|
|
268
247
|
|
@@ -276,17 +255,15 @@ VALUE getRestorePageSize(VALUE self)
|
|
276
255
|
* @return A reference to the newly updated Restore object.
|
277
256
|
*
|
278
257
|
*/
|
279
|
-
VALUE setRestorePageSize(VALUE self, VALUE setting)
|
280
|
-
{
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
return(self);
|
258
|
+
VALUE setRestorePageSize(VALUE self, VALUE setting) {
|
259
|
+
if(rb_obj_is_kind_of(setting, rb_cInteger) == Qfalse) {
|
260
|
+
rb_fireruby_raise(NULL,
|
261
|
+
"Invalid page size setting specified for database " \
|
262
|
+
"restore.");
|
263
|
+
}
|
264
|
+
rb_hash_aset(rb_iv_get(self, "@options"), PAGE_SIZE, setting);
|
265
|
+
|
266
|
+
return(self);
|
290
267
|
}
|
291
268
|
|
292
269
|
|
@@ -299,9 +276,8 @@ VALUE setRestorePageSize(VALUE self, VALUE setting)
|
|
299
276
|
* @return A reference to the current cache buffers setting.
|
300
277
|
*
|
301
278
|
*/
|
302
|
-
VALUE getRestoreAccessMode(VALUE self)
|
303
|
-
|
304
|
-
return(rb_hash_aref(rb_iv_get(self, "@options"), ACCESS_MODE));
|
279
|
+
VALUE getRestoreAccessMode(VALUE self) {
|
280
|
+
return(rb_hash_aref(rb_iv_get(self, "@options"), ACCESS_MODE));
|
305
281
|
}
|
306
282
|
|
307
283
|
|
@@ -315,28 +291,25 @@ VALUE getRestoreAccessMode(VALUE self)
|
|
315
291
|
* @return A reference to the newly updated Restore object.
|
316
292
|
*
|
317
293
|
*/
|
318
|
-
VALUE setRestoreAccessMode(VALUE self, VALUE setting)
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
rb_hash_aset(rb_iv_get(self, "@options"), ACCESS_MODE, setting);
|
338
|
-
|
339
|
-
return(self);
|
294
|
+
VALUE setRestoreAccessMode(VALUE self, VALUE setting) {
|
295
|
+
int value = 0;
|
296
|
+
|
297
|
+
if(rb_obj_is_kind_of(setting, rb_cInteger) == Qfalse) {
|
298
|
+
rb_fireruby_raise(NULL,
|
299
|
+
"Invalid access mode setting specified for database " \
|
300
|
+
"restore.");
|
301
|
+
}
|
302
|
+
|
303
|
+
value = TYPE(setting) == T_FIXNUM ? FIX2INT(setting) : NUM2INT(setting);
|
304
|
+
if(value != isc_spb_prp_am_readonly && value != isc_spb_prp_am_readwrite) {
|
305
|
+
rb_fireruby_raise(NULL,
|
306
|
+
"Invalid access mode value specified for database " \
|
307
|
+
"restore.");
|
308
|
+
}
|
309
|
+
|
310
|
+
rb_hash_aset(rb_iv_get(self, "@options"), ACCESS_MODE, setting);
|
311
|
+
|
312
|
+
return(self);
|
340
313
|
}
|
341
314
|
|
342
315
|
|
@@ -349,17 +322,15 @@ VALUE setRestoreAccessMode(VALUE self, VALUE setting)
|
|
349
322
|
* @return A reference to the current cache buffers setting.
|
350
323
|
*
|
351
324
|
*/
|
352
|
-
VALUE getRestoreBuildIndices(VALUE self)
|
353
|
-
|
354
|
-
|
355
|
-
setting = rb_hash_aref(rb_iv_get(self, "@options"), BUILD_INDICES);
|
325
|
+
VALUE getRestoreBuildIndices(VALUE self) {
|
326
|
+
VALUE result = Qtrue,
|
327
|
+
setting = rb_hash_aref(rb_iv_get(self, "@options"), BUILD_INDICES);
|
356
328
|
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
}
|
329
|
+
if(setting != Qnil) {
|
330
|
+
result = setting;
|
331
|
+
}
|
361
332
|
|
362
|
-
|
333
|
+
return(result);
|
363
334
|
}
|
364
335
|
|
365
336
|
|
@@ -373,17 +344,15 @@ VALUE getRestoreBuildIndices(VALUE self)
|
|
373
344
|
* @return A reference to the newly updated Restore object.
|
374
345
|
*
|
375
346
|
*/
|
376
|
-
VALUE setRestoreBuildIndices(VALUE self, VALUE setting)
|
377
|
-
{
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
return(self);
|
347
|
+
VALUE setRestoreBuildIndices(VALUE self, VALUE setting) {
|
348
|
+
if(setting != Qfalse && setting != Qtrue) {
|
349
|
+
rb_fireruby_raise(NULL,
|
350
|
+
"Invalid build indices setting specified for database " \
|
351
|
+
"restore.");
|
352
|
+
}
|
353
|
+
rb_hash_aset(rb_iv_get(self, "@options"), BUILD_INDICES, setting);
|
354
|
+
|
355
|
+
return(self);
|
387
356
|
}
|
388
357
|
|
389
358
|
|
@@ -396,17 +365,15 @@ VALUE setRestoreBuildIndices(VALUE self, VALUE setting)
|
|
396
365
|
* @return A reference to the current cache buffers setting.
|
397
366
|
*
|
398
367
|
*/
|
399
|
-
VALUE getRestoreCreateShadows(VALUE self)
|
400
|
-
|
401
|
-
|
402
|
-
setting = rb_hash_aref(rb_iv_get(self, "@options"), NO_SHADOWS);
|
368
|
+
VALUE getRestoreCreateShadows(VALUE self) {
|
369
|
+
VALUE result = Qfalse,
|
370
|
+
setting = rb_hash_aref(rb_iv_get(self, "@options"), NO_SHADOWS);
|
403
371
|
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
}
|
372
|
+
if(setting != Qnil) {
|
373
|
+
result = setting;
|
374
|
+
}
|
408
375
|
|
409
|
-
|
376
|
+
return(result);
|
410
377
|
}
|
411
378
|
|
412
379
|
|
@@ -420,17 +387,15 @@ VALUE getRestoreCreateShadows(VALUE self)
|
|
420
387
|
* @return A reference to the newly updated Restore object.
|
421
388
|
*
|
422
389
|
*/
|
423
|
-
VALUE setRestoreCreateShadows(VALUE self, VALUE setting)
|
424
|
-
{
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
return(self);
|
390
|
+
VALUE setRestoreCreateShadows(VALUE self, VALUE setting) {
|
391
|
+
if(setting != Qfalse && setting != Qtrue) {
|
392
|
+
rb_fireruby_raise(NULL,
|
393
|
+
"Invalid create shadows setting specified for " \
|
394
|
+
"database restore.");
|
395
|
+
}
|
396
|
+
rb_hash_aset(rb_iv_get(self, "@options"), NO_SHADOWS, setting);
|
397
|
+
|
398
|
+
return(self);
|
434
399
|
}
|
435
400
|
|
436
401
|
|
@@ -443,17 +408,15 @@ VALUE setRestoreCreateShadows(VALUE self, VALUE setting)
|
|
443
408
|
* @return A reference to the current cache buffers setting.
|
444
409
|
*
|
445
410
|
*/
|
446
|
-
VALUE getRestoreCheckValidity(VALUE self)
|
447
|
-
|
448
|
-
|
449
|
-
setting = rb_hash_aref(rb_iv_get(self, "@options"), VALIDITY_CHECKS);
|
411
|
+
VALUE getRestoreCheckValidity(VALUE self) {
|
412
|
+
VALUE result = Qtrue,
|
413
|
+
setting = rb_hash_aref(rb_iv_get(self, "@options"), VALIDITY_CHECKS);
|
450
414
|
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
}
|
415
|
+
if(setting != Qnil) {
|
416
|
+
result = setting;
|
417
|
+
}
|
455
418
|
|
456
|
-
|
419
|
+
return(result);
|
457
420
|
}
|
458
421
|
|
459
422
|
|
@@ -467,17 +430,15 @@ VALUE getRestoreCheckValidity(VALUE self)
|
|
467
430
|
* @return A reference to the newly updated Restore object.
|
468
431
|
*
|
469
432
|
*/
|
470
|
-
VALUE setRestoreCheckValidity(VALUE self, VALUE setting)
|
471
|
-
{
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
return(self);
|
433
|
+
VALUE setRestoreCheckValidity(VALUE self, VALUE setting) {
|
434
|
+
if(setting != Qfalse && setting != Qtrue) {
|
435
|
+
rb_fireruby_raise(NULL,
|
436
|
+
"Invalid validity checks setting specified for " \
|
437
|
+
"database restore.");
|
438
|
+
}
|
439
|
+
rb_hash_aset(rb_iv_get(self, "@options"), VALIDITY_CHECKS, setting);
|
440
|
+
|
441
|
+
return(self);
|
481
442
|
}
|
482
443
|
|
483
444
|
|
@@ -490,17 +451,15 @@ VALUE setRestoreCheckValidity(VALUE self, VALUE setting)
|
|
490
451
|
* @return A reference to the current cache buffers setting.
|
491
452
|
*
|
492
453
|
*/
|
493
|
-
VALUE getRestoreCommitTables(VALUE self)
|
494
|
-
|
495
|
-
|
496
|
-
setting = rb_hash_aref(rb_iv_get(self, "@options"), COMMIT_TABLES);
|
454
|
+
VALUE getRestoreCommitTables(VALUE self) {
|
455
|
+
VALUE result = Qfalse,
|
456
|
+
setting = rb_hash_aref(rb_iv_get(self, "@options"), COMMIT_TABLES);
|
497
457
|
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
}
|
458
|
+
if(setting != Qnil) {
|
459
|
+
result = setting;
|
460
|
+
}
|
502
461
|
|
503
|
-
|
462
|
+
return(result);
|
504
463
|
}
|
505
464
|
|
506
465
|
|
@@ -514,17 +473,15 @@ VALUE getRestoreCommitTables(VALUE self)
|
|
514
473
|
* @return A reference to the newly updated Restore object.
|
515
474
|
*
|
516
475
|
*/
|
517
|
-
VALUE setRestoreCommitTables(VALUE self, VALUE setting)
|
518
|
-
{
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
return(self);
|
476
|
+
VALUE setRestoreCommitTables(VALUE self, VALUE setting) {
|
477
|
+
if(setting != Qfalse && setting != Qtrue) {
|
478
|
+
rb_fireruby_raise(NULL,
|
479
|
+
"Invalid commit tables setting specified for " \
|
480
|
+
"database restore.");
|
481
|
+
}
|
482
|
+
rb_hash_aset(rb_iv_get(self, "@options"), COMMIT_TABLES, setting);
|
483
|
+
|
484
|
+
return(self);
|
528
485
|
}
|
529
486
|
|
530
487
|
|
@@ -536,17 +493,15 @@ VALUE setRestoreCommitTables(VALUE self, VALUE setting)
|
|
536
493
|
* @return A reference to the current cache buffers setting.
|
537
494
|
*
|
538
495
|
*/
|
539
|
-
VALUE getRestoreMode(VALUE self)
|
540
|
-
|
541
|
-
|
542
|
-
setting = rb_hash_aref(rb_iv_get(self, "@options"), RESTORE_MODE);
|
496
|
+
VALUE getRestoreMode(VALUE self) {
|
497
|
+
VALUE result = Qfalse,
|
498
|
+
setting = rb_hash_aref(rb_iv_get(self, "@options"), RESTORE_MODE);
|
543
499
|
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
}
|
500
|
+
if(setting != Qnil) {
|
501
|
+
result = setting;
|
502
|
+
}
|
548
503
|
|
549
|
-
|
504
|
+
return(result);
|
550
505
|
}
|
551
506
|
|
552
507
|
|
@@ -559,26 +514,23 @@ VALUE getRestoreMode(VALUE self)
|
|
559
514
|
* @return A reference to the newly updated Restore object.
|
560
515
|
*
|
561
516
|
*/
|
562
|
-
VALUE setRestoreMode(VALUE self, VALUE setting)
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
rb_hash_aset(rb_iv_get(self, "@options"), RESTORE_MODE, setting);
|
580
|
-
|
581
|
-
return(self);
|
517
|
+
VALUE setRestoreMode(VALUE self, VALUE setting) {
|
518
|
+
int value;
|
519
|
+
|
520
|
+
if(rb_obj_is_kind_of(setting, rb_cInteger) == Qfalse) {
|
521
|
+
rb_fireruby_raise(NULL,
|
522
|
+
"Invalid mode setting specified for database restore.");
|
523
|
+
}
|
524
|
+
|
525
|
+
value = TYPE(setting) == T_FIXNUM ? FIX2INT(setting) : NUM2INT(setting);
|
526
|
+
if(value != isc_spb_res_create && value != isc_spb_res_replace) {
|
527
|
+
rb_fireruby_raise(NULL,
|
528
|
+
"Unrecognised mode setting specified for database " \
|
529
|
+
"restore.");
|
530
|
+
}
|
531
|
+
rb_hash_aset(rb_iv_get(self, "@options"), RESTORE_MODE, setting);
|
532
|
+
|
533
|
+
return(self);
|
582
534
|
}
|
583
535
|
|
584
536
|
|
@@ -591,17 +543,15 @@ VALUE setRestoreMode(VALUE self, VALUE setting)
|
|
591
543
|
* @return A reference to the current cache buffers setting.
|
592
544
|
*
|
593
545
|
*/
|
594
|
-
VALUE getRestoreUseAllSpace(VALUE self)
|
595
|
-
|
596
|
-
|
597
|
-
setting = rb_hash_aref(rb_iv_get(self, "@options"), USE_ALL_SPACE);
|
546
|
+
VALUE getRestoreUseAllSpace(VALUE self) {
|
547
|
+
VALUE result = Qfalse,
|
548
|
+
setting = rb_hash_aref(rb_iv_get(self, "@options"), USE_ALL_SPACE);
|
598
549
|
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
}
|
550
|
+
if(setting != Qnil) {
|
551
|
+
result = setting;
|
552
|
+
}
|
603
553
|
|
604
|
-
|
554
|
+
return(result);
|
605
555
|
}
|
606
556
|
|
607
557
|
|
@@ -615,17 +565,15 @@ VALUE getRestoreUseAllSpace(VALUE self)
|
|
615
565
|
* @return A reference to the newly updated Restore object.
|
616
566
|
*
|
617
567
|
*/
|
618
|
-
VALUE setRestoreUseAllSpace(VALUE self, VALUE setting)
|
619
|
-
{
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
return(self);
|
568
|
+
VALUE setRestoreUseAllSpace(VALUE self, VALUE setting) {
|
569
|
+
if(setting != Qfalse && setting != Qtrue) {
|
570
|
+
rb_fireruby_raise(NULL,
|
571
|
+
"Invalid space usage setting specified for database " \
|
572
|
+
"restore.");
|
573
|
+
}
|
574
|
+
rb_hash_aset(rb_iv_get(self, "@options"), USE_ALL_SPACE, setting);
|
575
|
+
|
576
|
+
return(self);
|
629
577
|
}
|
630
578
|
|
631
579
|
|
@@ -639,37 +587,34 @@ VALUE setRestoreUseAllSpace(VALUE self, VALUE setting)
|
|
639
587
|
* @return A reference to the Restore object executed.
|
640
588
|
*
|
641
589
|
*/
|
642
|
-
VALUE executeRestore(VALUE self, VALUE manager)
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
rb_iv_set(self, "@log", queryService(&handle->handle));
|
671
|
-
|
672
|
-
return(self);
|
590
|
+
VALUE executeRestore(VALUE self, VALUE manager) {
|
591
|
+
ManagerHandle *handle = NULL;
|
592
|
+
char *buffer = NULL;
|
593
|
+
short length = 0;
|
594
|
+
ISC_STATUS status[ISC_STATUS_LENGTH];
|
595
|
+
|
596
|
+
/* Check that the service manager is connected. */
|
597
|
+
Data_Get_Struct(manager, ManagerHandle, handle);
|
598
|
+
if(handle->handle == 0) {
|
599
|
+
rb_fireruby_raise(NULL,
|
600
|
+
"Database restore error. Service manager not connected.");
|
601
|
+
}
|
602
|
+
|
603
|
+
createRestoreBuffer(rb_iv_get(self, "@backup_file"),
|
604
|
+
rb_iv_get(self, "@database"),
|
605
|
+
rb_iv_get(self, "@options"), &buffer, &length);
|
606
|
+
|
607
|
+
/* Start the service request. */
|
608
|
+
if(isc_service_start(status, &handle->handle, NULL, length, buffer)) {
|
609
|
+
free(buffer);
|
610
|
+
rb_fireruby_raise(status, "Error performing database restore.");
|
611
|
+
}
|
612
|
+
free(buffer);
|
613
|
+
|
614
|
+
/* Query the service until it is complete. */
|
615
|
+
rb_iv_set(self, "@log", queryService(&handle->handle));
|
616
|
+
|
617
|
+
return(self);
|
673
618
|
}
|
674
619
|
|
675
620
|
|
@@ -681,9 +626,8 @@ VALUE executeRestore(VALUE self, VALUE manager)
|
|
681
626
|
* @return A reference to the log attribute value.
|
682
627
|
*
|
683
628
|
*/
|
684
|
-
VALUE getRestoreLog(VALUE self)
|
685
|
-
|
686
|
-
return(rb_iv_get(self, "@log"));
|
629
|
+
VALUE getRestoreLog(VALUE self) {
|
630
|
+
return(rb_iv_get(self, "@log"));
|
687
631
|
}
|
688
632
|
|
689
633
|
|
@@ -705,111 +649,98 @@ VALUE getRestoreLog(VALUE self)
|
|
705
649
|
*
|
706
650
|
*/
|
707
651
|
void createRestoreBuffer(VALUE file, VALUE database, VALUE options,
|
708
|
-
char **buffer, short *length)
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
{
|
801
|
-
mask |= isc_spb_res_one_at_a_time;
|
802
|
-
}
|
803
|
-
|
804
|
-
if(rb_hash_aref(options, USE_ALL_SPACE) == Qtrue)
|
805
|
-
{
|
806
|
-
mask |= isc_spb_res_use_all_space;
|
807
|
-
}
|
808
|
-
|
809
|
-
*offset++ = isc_spb_options;
|
810
|
-
ADD_SPB_NUMERIC(offset, mask);
|
811
|
-
|
812
|
-
*offset++ = isc_spb_verbose;
|
652
|
+
char **buffer, short *length) {
|
653
|
+
char *offset = NULL;
|
654
|
+
int number = 0;
|
655
|
+
long mask = 0;
|
656
|
+
VALUE cache = rb_hash_aref(options, CACHE_BUFFERS),
|
657
|
+
page = rb_hash_aref(options, PAGE_SIZE),
|
658
|
+
mode = rb_hash_aref(options, ACCESS_MODE),
|
659
|
+
policy = rb_hash_aref(options, RESTORE_MODE);
|
660
|
+
|
661
|
+
/* Determine the length of the buffer. */
|
662
|
+
*length = 7;
|
663
|
+
*length += strlen(StringValuePtr(file)) + 3;
|
664
|
+
*length += strlen(StringValuePtr(database)) + 3;
|
665
|
+
if(cache != Qnil) {
|
666
|
+
*length += 5;
|
667
|
+
}
|
668
|
+
if(page != Qnil) {
|
669
|
+
*length += 5;
|
670
|
+
}
|
671
|
+
if(mode != Qnil) {
|
672
|
+
*length += 2;
|
673
|
+
}
|
674
|
+
|
675
|
+
/* Create and populate the buffer. */
|
676
|
+
offset = *buffer = ALLOC_N(char, *length);
|
677
|
+
if(buffer == NULL) {
|
678
|
+
rb_raise(rb_eNoMemError,
|
679
|
+
"Memory allocation error preparing database restore.");
|
680
|
+
}
|
681
|
+
memset(*buffer, 8, *length);
|
682
|
+
|
683
|
+
*offset++ = isc_action_svc_restore;
|
684
|
+
|
685
|
+
number = strlen(StringValuePtr(file));
|
686
|
+
*offset++ = isc_spb_bkp_file;
|
687
|
+
ADD_SPB_LENGTH(offset, number);
|
688
|
+
memcpy(offset, StringValuePtr(file), number);
|
689
|
+
offset += number;
|
690
|
+
|
691
|
+
number = strlen(StringValuePtr(database));
|
692
|
+
*offset++ = isc_spb_dbname;
|
693
|
+
ADD_SPB_LENGTH(offset, number);
|
694
|
+
memcpy(offset, StringValuePtr(database), number);
|
695
|
+
offset += number;
|
696
|
+
|
697
|
+
if(cache != Qnil) {
|
698
|
+
long value;
|
699
|
+
|
700
|
+
value = TYPE(cache) == T_FIXNUM ? FIX2INT(cache) : NUM2INT(cache);
|
701
|
+
*offset++ = isc_spb_res_buffers;
|
702
|
+
ADD_SPB_NUMERIC(offset, value);
|
703
|
+
}
|
704
|
+
|
705
|
+
if(page != Qnil) {
|
706
|
+
long value;
|
707
|
+
|
708
|
+
value = TYPE(page) == T_FIXNUM ? FIX2INT(page) : NUM2INT(page);
|
709
|
+
*offset++ = isc_spb_res_page_size;
|
710
|
+
ADD_SPB_NUMERIC(offset, value);
|
711
|
+
}
|
712
|
+
|
713
|
+
if(mode != Qnil) {
|
714
|
+
*offset++ = isc_spb_res_access_mode;
|
715
|
+
*offset++ = (char)FIX2INT(mode);
|
716
|
+
}
|
717
|
+
|
718
|
+
mask = FIX2INT(policy);
|
719
|
+
|
720
|
+
if(rb_hash_aref(options, BUILD_INDICES) == Qfalse) {
|
721
|
+
mask |= isc_spb_res_deactivate_idx;
|
722
|
+
}
|
723
|
+
|
724
|
+
if(rb_hash_aref(options, NO_SHADOWS) == Qtrue) {
|
725
|
+
mask |= isc_spb_res_no_shadow;
|
726
|
+
}
|
727
|
+
|
728
|
+
if(rb_hash_aref(options, VALIDITY_CHECKS) == Qfalse) {
|
729
|
+
mask |= isc_spb_res_no_validity;
|
730
|
+
}
|
731
|
+
|
732
|
+
if(rb_hash_aref(options, COMMIT_TABLES) == Qtrue) {
|
733
|
+
mask |= isc_spb_res_one_at_a_time;
|
734
|
+
}
|
735
|
+
|
736
|
+
if(rb_hash_aref(options, USE_ALL_SPACE) == Qtrue) {
|
737
|
+
mask |= isc_spb_res_use_all_space;
|
738
|
+
}
|
739
|
+
|
740
|
+
*offset++ = isc_spb_options;
|
741
|
+
ADD_SPB_NUMERIC(offset, mask);
|
742
|
+
|
743
|
+
*offset++ = isc_spb_verbose;
|
813
744
|
}
|
814
745
|
|
815
746
|
|
@@ -819,37 +750,36 @@ void createRestoreBuffer(VALUE file, VALUE database, VALUE options,
|
|
819
750
|
* @param module The module to create the new class definition under.
|
820
751
|
*
|
821
752
|
*/
|
822
|
-
void Init_Restore(VALUE module)
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
rb_define_const(cRestore, "MODE_REPLACE", INT2FIX(isc_spb_res_create));
|
753
|
+
void Init_Restore(VALUE module) {
|
754
|
+
cRestore = rb_define_class_under(module, "Restore", rb_cObject);
|
755
|
+
rb_define_method(cRestore, "initialize", initializeRestore, 2);
|
756
|
+
rb_define_method(cRestore, "backup_file", getRestoreFile, 0);
|
757
|
+
rb_define_method(cRestore, "backup_file=", setRestoreFile, 1);
|
758
|
+
rb_define_method(cRestore, "database", getRestoreDatabase, 0);
|
759
|
+
rb_define_method(cRestore, "database=", setRestoreDatabase, 1);
|
760
|
+
rb_define_method(cRestore, "cache_buffers", getRestoreCacheBuffers, 0);
|
761
|
+
rb_define_method(cRestore, "cache_buffers=", setRestoreCacheBuffers, 1);
|
762
|
+
rb_define_method(cRestore, "page_size", getRestorePageSize, 0);
|
763
|
+
rb_define_method(cRestore, "page_size=", setRestorePageSize, 1);
|
764
|
+
rb_define_method(cRestore, "access_mode", getRestoreAccessMode, 0);
|
765
|
+
rb_define_method(cRestore, "access_mode=", setRestoreAccessMode, 1);
|
766
|
+
rb_define_method(cRestore, "build_indices", getRestoreBuildIndices, 0);
|
767
|
+
rb_define_method(cRestore, "build_indices=", setRestoreBuildIndices, 1);
|
768
|
+
rb_define_method(cRestore, "no_shadows", getRestoreCreateShadows, 0);
|
769
|
+
rb_define_method(cRestore, "no_shadows=", setRestoreCreateShadows, 1);
|
770
|
+
rb_define_method(cRestore, "check_validity", getRestoreCheckValidity, 0);
|
771
|
+
rb_define_method(cRestore, "check_validity=", setRestoreCheckValidity, 1);
|
772
|
+
rb_define_method(cRestore, "commit_tables", getRestoreCommitTables, 0);
|
773
|
+
rb_define_method(cRestore, "commit_tables=", setRestoreCommitTables, 1);
|
774
|
+
rb_define_method(cRestore, "restore_mode", getRestoreMode, 0);
|
775
|
+
rb_define_method(cRestore, "restore_mode=", setRestoreMode, 1);
|
776
|
+
rb_define_method(cRestore, "use_all_space", getRestoreUseAllSpace, 0);
|
777
|
+
rb_define_method(cRestore, "use_all_space=", setRestoreUseAllSpace, 1);
|
778
|
+
rb_define_method(cRestore, "execute", executeRestore, 1);
|
779
|
+
rb_define_method(cRestore, "log", getRestoreLog, 0);
|
780
|
+
|
781
|
+
rb_define_const(cRestore, "ACCESS_READ_ONLY", INT2FIX(isc_spb_prp_am_readonly));
|
782
|
+
rb_define_const(cRestore, "ACCESS_READ_WRITE", INT2FIX(isc_spb_prp_am_readwrite));
|
783
|
+
rb_define_const(cRestore, "MODE_CREATE", INT2FIX(isc_spb_res_replace));
|
784
|
+
rb_define_const(cRestore, "MODE_REPLACE", INT2FIX(isc_spb_res_create));
|
855
785
|
}
|