rubyfb 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- 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/Backup.c
CHANGED
@@ -79,37 +79,30 @@ VALUE cBackup;
|
|
79
79
|
* @return A reference to the newly initialized Backup object.
|
80
80
|
*
|
81
81
|
*/
|
82
|
-
VALUE initializeBackup(VALUE self, VALUE database, VALUE file)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
rb_iv_set(self, "@database", path);
|
108
|
-
rb_iv_set(self, "@files", files);
|
109
|
-
rb_iv_set(self, "@options", rb_hash_new());
|
110
|
-
rb_iv_set(self, "@log", Qnil);
|
111
|
-
|
112
|
-
return(self);
|
82
|
+
VALUE initializeBackup(VALUE self, VALUE database, VALUE file) {
|
83
|
+
VALUE path = Qnil,
|
84
|
+
files = rb_hash_new();
|
85
|
+
|
86
|
+
/* Extract the database file details. */
|
87
|
+
if(TYPE(database) == T_FILE) {
|
88
|
+
path = rb_funcall(database, rb_intern("path"), 0);
|
89
|
+
} else {
|
90
|
+
path = rb_funcall(database, rb_intern("to_s"), 0);
|
91
|
+
}
|
92
|
+
|
93
|
+
/* Get the back file details. */
|
94
|
+
if(TYPE(file) == T_FILE) {
|
95
|
+
rb_hash_aset(files, rb_funcall(file, rb_intern("path"), 0), Qnil);
|
96
|
+
} else {
|
97
|
+
rb_hash_aset(files, rb_funcall(file, rb_intern("to_s"), 0), Qnil);
|
98
|
+
}
|
99
|
+
|
100
|
+
rb_iv_set(self, "@database", path);
|
101
|
+
rb_iv_set(self, "@files", files);
|
102
|
+
rb_iv_set(self, "@options", rb_hash_new());
|
103
|
+
rb_iv_set(self, "@log", Qnil);
|
104
|
+
|
105
|
+
return(self);
|
113
106
|
}
|
114
107
|
|
115
108
|
|
@@ -122,11 +115,10 @@ VALUE initializeBackup(VALUE self, VALUE database, VALUE file)
|
|
122
115
|
* @return A reference to a String containing the backup file path/name.
|
123
116
|
*
|
124
117
|
*/
|
125
|
-
VALUE getBackupFile(VALUE self)
|
126
|
-
|
127
|
-
VALUE files = rb_iv_get(self, "@files");
|
118
|
+
VALUE getBackupFile(VALUE self) {
|
119
|
+
VALUE files = rb_iv_get(self, "@files");
|
128
120
|
|
129
|
-
|
121
|
+
return(rb_ary_entry(rb_funcall(files, rb_intern("keys"), 0), 0));
|
130
122
|
}
|
131
123
|
|
132
124
|
|
@@ -139,21 +131,17 @@ VALUE getBackupFile(VALUE self)
|
|
139
131
|
* of the backup file.
|
140
132
|
*
|
141
133
|
*/
|
142
|
-
VALUE setBackupFile(VALUE self, VALUE file)
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
}
|
154
|
-
rb_iv_set(self, "@files", files);
|
155
|
-
|
156
|
-
return(self);
|
134
|
+
VALUE setBackupFile(VALUE self, VALUE file) {
|
135
|
+
VALUE files = rb_hash_new();
|
136
|
+
|
137
|
+
if(TYPE(file) == T_FILE) {
|
138
|
+
rb_hash_aset(files, rb_funcall(file, rb_intern("path"), 0), Qnil);
|
139
|
+
} else {
|
140
|
+
rb_hash_aset(files, rb_funcall(file, rb_intern("to_s"), 0), Qnil);
|
141
|
+
}
|
142
|
+
rb_iv_set(self, "@files", files);
|
143
|
+
|
144
|
+
return(self);
|
157
145
|
}
|
158
146
|
|
159
147
|
|
@@ -166,9 +154,8 @@ VALUE setBackupFile(VALUE self, VALUE file)
|
|
166
154
|
* database file to be backed up.
|
167
155
|
*
|
168
156
|
*/
|
169
|
-
VALUE getBackupDatabase(VALUE self)
|
170
|
-
|
171
|
-
return(rb_iv_get(self, "@database"));
|
157
|
+
VALUE getBackupDatabase(VALUE self) {
|
158
|
+
return(rb_iv_get(self, "@database"));
|
172
159
|
}
|
173
160
|
|
174
161
|
|
@@ -182,18 +169,14 @@ VALUE getBackupDatabase(VALUE self)
|
|
182
169
|
* @return A reference to the Backup object that has been updated.
|
183
170
|
*
|
184
171
|
*/
|
185
|
-
VALUE setBackupDatabase(VALUE self, VALUE setting)
|
186
|
-
{
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
rb_iv_set(self, "@database", rb_funcall(setting, rb_intern("to_s"), 0));
|
194
|
-
}
|
195
|
-
|
196
|
-
return(self);
|
172
|
+
VALUE setBackupDatabase(VALUE self, VALUE setting) {
|
173
|
+
if(TYPE(setting) == T_FILE) {
|
174
|
+
rb_iv_set(self, "@database", rb_funcall(setting, rb_intern("path"), 0));
|
175
|
+
} else {
|
176
|
+
rb_iv_set(self, "@database", rb_funcall(setting, rb_intern("to_s"), 0));
|
177
|
+
}
|
178
|
+
|
179
|
+
return(self);
|
197
180
|
}
|
198
181
|
|
199
182
|
|
@@ -207,11 +190,10 @@ VALUE setBackupDatabase(VALUE self, VALUE setting)
|
|
207
190
|
* Backup object.
|
208
191
|
*
|
209
192
|
*/
|
210
|
-
VALUE getBackupBlockingFactor(VALUE self)
|
211
|
-
|
212
|
-
VALUE options = rb_iv_get(self, "@options");
|
193
|
+
VALUE getBackupBlockingFactor(VALUE self) {
|
194
|
+
VALUE options = rb_iv_get(self, "@options");
|
213
195
|
|
214
|
-
|
196
|
+
return(rb_hash_aref(options, INT2FIX(isc_spb_bkp_factor)));
|
215
197
|
}
|
216
198
|
|
217
199
|
|
@@ -226,17 +208,15 @@ VALUE getBackupBlockingFactor(VALUE self)
|
|
226
208
|
* @return A reference to the newly updated Backup object.
|
227
209
|
*
|
228
210
|
*/
|
229
|
-
VALUE setBackupBlockingFactor(VALUE self, VALUE setting)
|
230
|
-
|
231
|
-
VALUE options = rb_iv_get(self, "@options");
|
211
|
+
VALUE setBackupBlockingFactor(VALUE self, VALUE setting) {
|
212
|
+
VALUE options = rb_iv_get(self, "@options");
|
232
213
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
rb_hash_aset(options, INT2FIX(isc_spb_bkp_factor), setting);
|
214
|
+
if(rb_obj_is_kind_of(setting, rb_cInteger) == Qfalse) {
|
215
|
+
rb_fireruby_raise(NULL, "Invalid blocking factor specified for Backup.");
|
216
|
+
}
|
217
|
+
rb_hash_aset(options, INT2FIX(isc_spb_bkp_factor), setting);
|
238
218
|
|
239
|
-
|
219
|
+
return(self);
|
240
220
|
}
|
241
221
|
|
242
222
|
|
@@ -249,18 +229,16 @@ VALUE setBackupBlockingFactor(VALUE self, VALUE setting)
|
|
249
229
|
* @return Either true or false.
|
250
230
|
*
|
251
231
|
*/
|
252
|
-
VALUE getBackupIgnoreChecksums(VALUE self)
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
return(result);
|
232
|
+
VALUE getBackupIgnoreChecksums(VALUE self) {
|
233
|
+
VALUE result = Qfalse,
|
234
|
+
options = rb_iv_get(self, "@options"),
|
235
|
+
value = rb_hash_aref(options, IGNORE_CHECKSUMS);
|
236
|
+
|
237
|
+
if(value != Qnil) {
|
238
|
+
result = value;
|
239
|
+
}
|
240
|
+
|
241
|
+
return(result);
|
264
242
|
}
|
265
243
|
|
266
244
|
|
@@ -274,16 +252,14 @@ VALUE getBackupIgnoreChecksums(VALUE self)
|
|
274
252
|
* @return A reference to the newly updated Backup object.
|
275
253
|
*
|
276
254
|
*/
|
277
|
-
VALUE setBackupIgnoreChecksums(VALUE self, VALUE setting)
|
278
|
-
|
279
|
-
VALUE options = rb_iv_get(self, "@options");
|
255
|
+
VALUE setBackupIgnoreChecksums(VALUE self, VALUE setting) {
|
256
|
+
VALUE options = rb_iv_get(self, "@options");
|
280
257
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
}
|
258
|
+
if(setting == Qtrue || setting == Qfalse) {
|
259
|
+
rb_hash_aset(options, IGNORE_CHECKSUMS, setting);
|
260
|
+
}
|
285
261
|
|
286
|
-
|
262
|
+
return(self);
|
287
263
|
}
|
288
264
|
|
289
265
|
|
@@ -296,18 +272,16 @@ VALUE setBackupIgnoreChecksums(VALUE self, VALUE setting)
|
|
296
272
|
* @return Either true or false.
|
297
273
|
*
|
298
274
|
*/
|
299
|
-
VALUE getBackupIgnoreLimbo(VALUE self)
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
return(result);
|
275
|
+
VALUE getBackupIgnoreLimbo(VALUE self) {
|
276
|
+
VALUE result = Qfalse,
|
277
|
+
options = rb_iv_get(self, "@options"),
|
278
|
+
value = rb_hash_aref(options, IGNORE_LIMBO);
|
279
|
+
|
280
|
+
if(value != Qnil) {
|
281
|
+
result = value;
|
282
|
+
}
|
283
|
+
|
284
|
+
return(result);
|
311
285
|
}
|
312
286
|
|
313
287
|
|
@@ -321,16 +295,14 @@ VALUE getBackupIgnoreLimbo(VALUE self)
|
|
321
295
|
* @return A reference to the newly updated Backup object.
|
322
296
|
*
|
323
297
|
*/
|
324
|
-
VALUE setBackupIgnoreLimbo(VALUE self, VALUE setting)
|
325
|
-
|
326
|
-
VALUE options = rb_iv_get(self, "@options");
|
298
|
+
VALUE setBackupIgnoreLimbo(VALUE self, VALUE setting) {
|
299
|
+
VALUE options = rb_iv_get(self, "@options");
|
327
300
|
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
}
|
301
|
+
if(setting == Qtrue || setting == Qfalse) {
|
302
|
+
rb_hash_aset(options, IGNORE_LIMBO, setting);
|
303
|
+
}
|
332
304
|
|
333
|
-
|
305
|
+
return(self);
|
334
306
|
}
|
335
307
|
|
336
308
|
|
@@ -343,18 +315,16 @@ VALUE setBackupIgnoreLimbo(VALUE self, VALUE setting)
|
|
343
315
|
* @return Either true or false.
|
344
316
|
*
|
345
317
|
*/
|
346
|
-
VALUE getBackupMetadataOnly(VALUE self)
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
return(result);
|
318
|
+
VALUE getBackupMetadataOnly(VALUE self) {
|
319
|
+
VALUE result = Qfalse,
|
320
|
+
options = rb_iv_get(self, "@options"),
|
321
|
+
value = rb_hash_aref(options, METADATA_ONLY);
|
322
|
+
|
323
|
+
if(value != Qnil) {
|
324
|
+
result = value;
|
325
|
+
}
|
326
|
+
|
327
|
+
return(result);
|
358
328
|
}
|
359
329
|
|
360
330
|
|
@@ -368,16 +338,14 @@ VALUE getBackupMetadataOnly(VALUE self)
|
|
368
338
|
* @return A reference to the newly updated Backup object.
|
369
339
|
*
|
370
340
|
*/
|
371
|
-
VALUE setBackupMetadataOnly(VALUE self, VALUE setting)
|
372
|
-
|
373
|
-
VALUE options = rb_iv_get(self, "@options");
|
341
|
+
VALUE setBackupMetadataOnly(VALUE self, VALUE setting) {
|
342
|
+
VALUE options = rb_iv_get(self, "@options");
|
374
343
|
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
}
|
344
|
+
if(setting == Qtrue || setting == Qfalse) {
|
345
|
+
rb_hash_aset(options, METADATA_ONLY, setting);
|
346
|
+
}
|
379
347
|
|
380
|
-
|
348
|
+
return(self);
|
381
349
|
}
|
382
350
|
|
383
351
|
|
@@ -390,18 +358,16 @@ VALUE setBackupMetadataOnly(VALUE self, VALUE setting)
|
|
390
358
|
* @return Either true or false.
|
391
359
|
*
|
392
360
|
*/
|
393
|
-
VALUE getBackupGarbageCollect(VALUE self)
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
return(result);
|
361
|
+
VALUE getBackupGarbageCollect(VALUE self) {
|
362
|
+
VALUE result = Qtrue,
|
363
|
+
options = rb_iv_get(self, "@options"),
|
364
|
+
value = rb_hash_aref(options, NO_GARBAGE_COLLECT);
|
365
|
+
|
366
|
+
if(value != Qnil) {
|
367
|
+
result = value;
|
368
|
+
}
|
369
|
+
|
370
|
+
return(result);
|
405
371
|
}
|
406
372
|
|
407
373
|
|
@@ -415,16 +381,14 @@ VALUE getBackupGarbageCollect(VALUE self)
|
|
415
381
|
* @return A reference to the newly updated Backup object.
|
416
382
|
*
|
417
383
|
*/
|
418
|
-
VALUE setBackupGarbageCollect(VALUE self, VALUE setting)
|
419
|
-
|
420
|
-
VALUE options = rb_iv_get(self, "@options");
|
384
|
+
VALUE setBackupGarbageCollect(VALUE self, VALUE setting) {
|
385
|
+
VALUE options = rb_iv_get(self, "@options");
|
421
386
|
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
}
|
387
|
+
if(setting == Qtrue || setting == Qfalse) {
|
388
|
+
rb_hash_aset(options, NO_GARBAGE_COLLECT, setting);
|
389
|
+
}
|
426
390
|
|
427
|
-
|
391
|
+
return(self);
|
428
392
|
}
|
429
393
|
|
430
394
|
|
@@ -437,18 +401,16 @@ VALUE setBackupGarbageCollect(VALUE self, VALUE setting)
|
|
437
401
|
* @return Either true or false.
|
438
402
|
*
|
439
403
|
*/
|
440
|
-
VALUE getBackupNonTransportable(VALUE self)
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
return(result);
|
404
|
+
VALUE getBackupNonTransportable(VALUE self) {
|
405
|
+
VALUE result = Qfalse,
|
406
|
+
options = rb_iv_get(self, "@options"),
|
407
|
+
value = rb_hash_aref(options, NON_TRANSPORTABLE);
|
408
|
+
|
409
|
+
if(value != Qnil) {
|
410
|
+
result = value;
|
411
|
+
}
|
412
|
+
|
413
|
+
return(result);
|
452
414
|
}
|
453
415
|
|
454
416
|
|
@@ -462,16 +424,14 @@ VALUE getBackupNonTransportable(VALUE self)
|
|
462
424
|
* @return A reference to the newly updated Backup object.
|
463
425
|
*
|
464
426
|
*/
|
465
|
-
VALUE setBackupNonTransportable(VALUE self, VALUE setting)
|
466
|
-
|
467
|
-
VALUE options = rb_iv_get(self, "@options");
|
427
|
+
VALUE setBackupNonTransportable(VALUE self, VALUE setting) {
|
428
|
+
VALUE options = rb_iv_get(self, "@options");
|
468
429
|
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
}
|
430
|
+
if(setting == Qtrue || setting == Qfalse) {
|
431
|
+
rb_hash_aset(options, NON_TRANSPORTABLE, setting);
|
432
|
+
}
|
473
433
|
|
474
|
-
|
434
|
+
return(self);
|
475
435
|
}
|
476
436
|
|
477
437
|
|
@@ -484,18 +444,16 @@ VALUE setBackupNonTransportable(VALUE self, VALUE setting)
|
|
484
444
|
* @return Either true or false.
|
485
445
|
*
|
486
446
|
*/
|
487
|
-
VALUE getBackupConvertTables(VALUE self)
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
return(result);
|
447
|
+
VALUE getBackupConvertTables(VALUE self) {
|
448
|
+
VALUE result = Qfalse,
|
449
|
+
options = rb_iv_get(self, "@options"),
|
450
|
+
value = rb_hash_aref(options, CONVERT_TABLES);
|
451
|
+
|
452
|
+
if(value != Qnil) {
|
453
|
+
result = value;
|
454
|
+
}
|
455
|
+
|
456
|
+
return(result);
|
499
457
|
}
|
500
458
|
|
501
459
|
|
@@ -509,16 +467,14 @@ VALUE getBackupConvertTables(VALUE self)
|
|
509
467
|
* @return A reference to the newly updated Backup object.
|
510
468
|
*
|
511
469
|
*/
|
512
|
-
VALUE setBackupConvertTables(VALUE self, VALUE setting)
|
513
|
-
|
514
|
-
VALUE options = rb_iv_get(self, "@options");
|
470
|
+
VALUE setBackupConvertTables(VALUE self, VALUE setting) {
|
471
|
+
VALUE options = rb_iv_get(self, "@options");
|
515
472
|
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
}
|
473
|
+
if(setting == Qtrue || setting == Qfalse) {
|
474
|
+
rb_hash_aset(options, CONVERT_TABLES, setting);
|
475
|
+
}
|
520
476
|
|
521
|
-
|
477
|
+
return(self);
|
522
478
|
}
|
523
479
|
|
524
480
|
|
@@ -532,36 +488,33 @@ VALUE setBackupConvertTables(VALUE self, VALUE setting)
|
|
532
488
|
* @return A reference to the Backup object executed.
|
533
489
|
*
|
534
490
|
*/
|
535
|
-
VALUE executeBackup(VALUE self, VALUE manager)
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
rb_iv_set(self, "@log", queryService(&handle->handle));
|
563
|
-
|
564
|
-
return(self);
|
491
|
+
VALUE executeBackup(VALUE self, VALUE manager) {
|
492
|
+
ManagerHandle *handle = NULL;
|
493
|
+
short length = 0;
|
494
|
+
char *buffer = NULL;
|
495
|
+
ISC_STATUS status[ISC_STATUS_LENGTH];
|
496
|
+
|
497
|
+
/* Check that the service manager is connected. */
|
498
|
+
Data_Get_Struct(manager, ManagerHandle, handle);
|
499
|
+
if(handle->handle == 0) {
|
500
|
+
rb_fireruby_raise(NULL,
|
501
|
+
"Database backup error. Service manager not connected.");
|
502
|
+
}
|
503
|
+
|
504
|
+
createBackupBuffer(rb_iv_get(self, "@database"), rb_iv_get(self, "@files"),
|
505
|
+
rb_iv_get(self, "@options"), &buffer, &length);
|
506
|
+
|
507
|
+
/* Start the service request. */
|
508
|
+
if(isc_service_start(status, &handle->handle, NULL, length, buffer)) {
|
509
|
+
free(buffer);
|
510
|
+
rb_fireruby_raise(status, "Error performing database backup.");
|
511
|
+
}
|
512
|
+
free(buffer);
|
513
|
+
|
514
|
+
/* Query the service until it has completed. */
|
515
|
+
rb_iv_set(self, "@log", queryService(&handle->handle));
|
516
|
+
|
517
|
+
return(self);
|
565
518
|
}
|
566
519
|
|
567
520
|
|
@@ -573,9 +526,8 @@ VALUE executeBackup(VALUE self, VALUE manager)
|
|
573
526
|
* @return A reference to the current log attribute value.
|
574
527
|
*
|
575
528
|
*/
|
576
|
-
VALUE getBackupLog(VALUE self)
|
577
|
-
|
578
|
-
return(rb_iv_get(self, "@log"));
|
529
|
+
VALUE getBackupLog(VALUE self) {
|
530
|
+
return(rb_iv_get(self, "@log"));
|
579
531
|
}
|
580
532
|
|
581
533
|
|
@@ -597,158 +549,140 @@ VALUE getBackupLog(VALUE self)
|
|
597
549
|
*
|
598
550
|
*/
|
599
551
|
void createBackupBuffer(VALUE from, VALUE to, VALUE options, char **buffer,
|
600
|
-
short *length)
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
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
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
VALUE
|
681
|
-
|
682
|
-
|
683
|
-
|
552
|
+
short *length) {
|
553
|
+
ID id = rb_intern("key?");
|
554
|
+
VALUE names = rb_funcall(to, rb_intern("keys"), 0),
|
555
|
+
sizes = rb_funcall(to, rb_intern("values"), 0),
|
556
|
+
count = rb_funcall(names, rb_intern("size"), 0),
|
557
|
+
tmp_str = Qnil;
|
558
|
+
char *position = NULL;
|
559
|
+
short number,
|
560
|
+
flags = 0,
|
561
|
+
extras = 0,
|
562
|
+
blocking = 0,
|
563
|
+
size = TYPE(count) == T_FIXNUM ? FIX2INT(count) : NUM2INT(count),
|
564
|
+
i;
|
565
|
+
|
566
|
+
/* Check if extra options have been provided. */
|
567
|
+
if(TYPE(options) != T_NIL) {
|
568
|
+
VALUE temp = rb_funcall(options, rb_intern("size"), 0);
|
569
|
+
|
570
|
+
extras = TYPE(temp) == T_FIXNUM ? FIX2INT(temp) : NUM2INT(temp);
|
571
|
+
}
|
572
|
+
|
573
|
+
/* Calculate the length needed for the buffer. */
|
574
|
+
*length = 2;
|
575
|
+
*length += strlen(StringValuePtr(from)) + 3;
|
576
|
+
|
577
|
+
/* Count file name and length sizes. */
|
578
|
+
for(i = 0; i < size; i++) {
|
579
|
+
tmp_str = rb_ary_entry(names, i);
|
580
|
+
*length += strlen(StringValuePtr(tmp_str)) + 3;
|
581
|
+
if(i != size - 1) {
|
582
|
+
VALUE num = rb_funcall(rb_ary_entry(sizes, i), rb_intern("to_s"), 0);
|
583
|
+
|
584
|
+
*length += strlen(StringValuePtr(num)) + 3;
|
585
|
+
}
|
586
|
+
}
|
587
|
+
|
588
|
+
if(extras) {
|
589
|
+
if(rb_funcall(options, id, 1, INT2FIX(isc_spb_bkp_factor)) == Qtrue) {
|
590
|
+
*length += 5;
|
591
|
+
blocking = 1;
|
592
|
+
}
|
593
|
+
|
594
|
+
if(rb_funcall(options, id, 1, IGNORE_CHECKSUMS) == Qtrue ||
|
595
|
+
rb_funcall(options, id, 1, IGNORE_LIMBO) == Qtrue ||
|
596
|
+
rb_funcall(options, id, 1, METADATA_ONLY) == Qtrue ||
|
597
|
+
rb_funcall(options, id, 1, NO_GARBAGE_COLLECT) == Qtrue ||
|
598
|
+
rb_funcall(options, id, 1, NON_TRANSPORTABLE) == Qtrue ||
|
599
|
+
rb_funcall(options, id, 1, CONVERT_TABLES) == Qtrue) {
|
600
|
+
*length += 5;
|
601
|
+
flags = 1;
|
602
|
+
}
|
603
|
+
}
|
604
|
+
|
605
|
+
/* Allocate the buffer. */
|
606
|
+
*buffer = position = ALLOC_N(char, *length);
|
607
|
+
if(*buffer == NULL) {
|
608
|
+
rb_raise(rb_eNoMemError,
|
609
|
+
"Memory allocation error preparing database back up.");
|
610
|
+
}
|
611
|
+
memset(*buffer, 0, *length);
|
612
|
+
|
613
|
+
/* Populate the buffer. */
|
614
|
+
*position++ = isc_action_svc_backup;
|
615
|
+
|
616
|
+
*position++ = isc_spb_dbname;
|
617
|
+
number = strlen(StringValuePtr(from));
|
618
|
+
ADD_SPB_LENGTH(position, number);
|
619
|
+
memcpy(position, StringValuePtr(from), number);
|
620
|
+
position += number;
|
621
|
+
|
622
|
+
for(i = 0; i < size; i++) {
|
623
|
+
VALUE name = rb_ary_entry(names, i);
|
624
|
+
|
625
|
+
*position++ = isc_spb_bkp_file;
|
626
|
+
number = strlen(StringValuePtr(name));
|
627
|
+
ADD_SPB_LENGTH(position, number);
|
628
|
+
memcpy(position, StringValuePtr(name), number);
|
629
|
+
position += number;
|
630
|
+
|
631
|
+
if(i != size - 1) {
|
632
|
+
VALUE max = rb_ary_entry(sizes, i);
|
633
|
+
|
634
|
+
max = rb_funcall(max, rb_intern("to_s"), 0);
|
635
|
+
*position++ = isc_spb_bkp_length;
|
636
|
+
number = strlen(StringValuePtr(max));
|
684
637
|
ADD_SPB_LENGTH(position, number);
|
685
|
-
memcpy(position, StringValuePtr(
|
638
|
+
memcpy(position, StringValuePtr(max), number);
|
686
639
|
position += number;
|
640
|
+
}
|
641
|
+
}
|
642
|
+
|
643
|
+
if(extras && blocking) {
|
644
|
+
VALUE key = INT2FIX(isc_spb_bkp_factor),
|
645
|
+
temp = rb_funcall(options, rb_intern("fetch"), 1, key);
|
646
|
+
unsigned long size = TYPE(temp) == T_FIXNUM ? FIX2INT(temp) : NUM2INT(temp);
|
647
|
+
|
648
|
+
*position++ = isc_spb_bkp_factor;
|
649
|
+
memcpy(position, &size, 4);
|
650
|
+
position += 4;
|
651
|
+
}
|
652
|
+
|
653
|
+
if(extras && flags) {
|
654
|
+
unsigned long mask = 0;
|
655
|
+
|
656
|
+
if(rb_funcall(options, id, 1, IGNORE_CHECKSUMS) == Qtrue) {
|
657
|
+
mask |= isc_spb_bkp_ignore_checksums;
|
658
|
+
}
|
659
|
+
|
660
|
+
if(rb_funcall(options, id, 1, IGNORE_LIMBO) == Qtrue) {
|
661
|
+
mask |= isc_spb_bkp_ignore_limbo;
|
662
|
+
}
|
663
|
+
|
664
|
+
if(rb_funcall(options, id, 1, METADATA_ONLY) == Qtrue) {
|
665
|
+
mask |= isc_spb_bkp_metadata_only;
|
666
|
+
}
|
667
|
+
|
668
|
+
if(rb_funcall(options, id, 1, NO_GARBAGE_COLLECT) == Qtrue) {
|
669
|
+
mask |= isc_spb_bkp_no_garbage_collect;
|
670
|
+
}
|
671
|
+
|
672
|
+
if(rb_funcall(options, id, 1, NON_TRANSPORTABLE) == Qtrue) {
|
673
|
+
mask |= isc_spb_bkp_non_transportable;
|
674
|
+
}
|
675
|
+
|
676
|
+
if(rb_funcall(options, id, 1, CONVERT_TABLES) == Qtrue) {
|
677
|
+
mask |= isc_spb_bkp_convert;
|
678
|
+
}
|
679
|
+
|
680
|
+
*position++ = isc_spb_options;
|
681
|
+
memcpy(position, &mask, 4);
|
682
|
+
position += 4;
|
683
|
+
}
|
687
684
|
|
688
|
-
|
689
|
-
{
|
690
|
-
VALUE max = rb_ary_entry(sizes, i);
|
691
|
-
|
692
|
-
max = rb_funcall(max, rb_intern("to_s"), 0);
|
693
|
-
*position++ = isc_spb_bkp_length;
|
694
|
-
number = strlen(StringValuePtr(max));
|
695
|
-
ADD_SPB_LENGTH(position, number);
|
696
|
-
memcpy(position, StringValuePtr(max), number);
|
697
|
-
position += number;
|
698
|
-
}
|
699
|
-
}
|
700
|
-
|
701
|
-
if(extras && blocking)
|
702
|
-
{
|
703
|
-
VALUE key = INT2FIX(isc_spb_bkp_factor),
|
704
|
-
temp = rb_funcall(options, rb_intern("fetch"), 1, key);
|
705
|
-
unsigned long size = TYPE(temp) == T_FIXNUM ? FIX2INT(temp) : NUM2INT(temp);
|
706
|
-
|
707
|
-
*position++ = isc_spb_bkp_factor;
|
708
|
-
memcpy(position, &size, 4);
|
709
|
-
position += 4;
|
710
|
-
}
|
711
|
-
|
712
|
-
if(extras && flags)
|
713
|
-
{
|
714
|
-
unsigned long mask = 0;
|
715
|
-
|
716
|
-
if(rb_funcall(options, id, 1, IGNORE_CHECKSUMS) == Qtrue)
|
717
|
-
{
|
718
|
-
mask |= isc_spb_bkp_ignore_checksums;
|
719
|
-
}
|
720
|
-
|
721
|
-
if(rb_funcall(options, id, 1, IGNORE_LIMBO) == Qtrue)
|
722
|
-
{
|
723
|
-
mask |= isc_spb_bkp_ignore_limbo;
|
724
|
-
}
|
725
|
-
|
726
|
-
if(rb_funcall(options, id, 1, METADATA_ONLY) == Qtrue)
|
727
|
-
{
|
728
|
-
mask |= isc_spb_bkp_metadata_only;
|
729
|
-
}
|
730
|
-
|
731
|
-
if(rb_funcall(options, id, 1, NO_GARBAGE_COLLECT) == Qtrue)
|
732
|
-
{
|
733
|
-
mask |= isc_spb_bkp_no_garbage_collect;
|
734
|
-
}
|
735
|
-
|
736
|
-
if(rb_funcall(options, id, 1, NON_TRANSPORTABLE) == Qtrue)
|
737
|
-
{
|
738
|
-
mask |= isc_spb_bkp_non_transportable;
|
739
|
-
}
|
740
|
-
|
741
|
-
if(rb_funcall(options, id, 1, CONVERT_TABLES) == Qtrue)
|
742
|
-
{
|
743
|
-
mask |= isc_spb_bkp_convert;
|
744
|
-
}
|
745
|
-
|
746
|
-
*position++ = isc_spb_options;
|
747
|
-
memcpy(position, &mask, 4);
|
748
|
-
position += 4;
|
749
|
-
}
|
750
|
-
|
751
|
-
*position++ = isc_spb_verbose;
|
685
|
+
*position++ = isc_spb_verbose;
|
752
686
|
}
|
753
687
|
|
754
688
|
|
@@ -758,28 +692,27 @@ void createBackupBuffer(VALUE from, VALUE to, VALUE options, char **buffer,
|
|
758
692
|
* @param module The module to create the new class definition under.
|
759
693
|
*
|
760
694
|
*/
|
761
|
-
void Init_Backup(VALUE module)
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
rb_define_method(cBackup, "log", getBackupLog, 0);
|
695
|
+
void Init_Backup(VALUE module) {
|
696
|
+
cBackup = rb_define_class_under(module, "Backup", rb_cObject);
|
697
|
+
rb_define_method(cBackup, "initialize", initializeBackup, 2);
|
698
|
+
rb_define_method(cBackup, "backup_file", getBackupFile, 0);
|
699
|
+
rb_define_method(cBackup, "backup_file=", setBackupFile, 1);
|
700
|
+
rb_define_method(cBackup, "database", getBackupDatabase, 0);
|
701
|
+
rb_define_method(cBackup, "database=", setBackupDatabase, 1);
|
702
|
+
rb_define_method(cBackup, "blocking_factor", getBackupBlockingFactor, 0);
|
703
|
+
rb_define_method(cBackup, "blocking_factor=", setBackupBlockingFactor, 1);
|
704
|
+
rb_define_method(cBackup, "ignore_checksums", getBackupIgnoreChecksums, 0);
|
705
|
+
rb_define_method(cBackup, "ignore_checksums=", setBackupIgnoreChecksums, 1);
|
706
|
+
rb_define_method(cBackup, "ignore_limbo", getBackupIgnoreLimbo, 0);
|
707
|
+
rb_define_method(cBackup, "ignore_limbo=", setBackupIgnoreLimbo, 1);
|
708
|
+
rb_define_method(cBackup, "metadata_only", getBackupMetadataOnly, 0);
|
709
|
+
rb_define_method(cBackup, "metadata_only=", setBackupMetadataOnly, 1);
|
710
|
+
rb_define_method(cBackup, "garbage_collect", getBackupGarbageCollect, 0);
|
711
|
+
rb_define_method(cBackup, "garbage_collect=", setBackupGarbageCollect, 1);
|
712
|
+
rb_define_method(cBackup, "non_transportable", getBackupNonTransportable, 0);
|
713
|
+
rb_define_method(cBackup, "non_transportable=", setBackupNonTransportable, 1);
|
714
|
+
rb_define_method(cBackup, "convert_tables", getBackupConvertTables, 0);
|
715
|
+
rb_define_method(cBackup, "convert_tables=", setBackupConvertTables, 1);
|
716
|
+
rb_define_method(cBackup, "execute", executeBackup, 1);
|
717
|
+
rb_define_method(cBackup, "log", getBackupLog, 0);
|
785
718
|
}
|