ruby-informix 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +37 -1
- data/README +4 -2
- data/informix.c +1606 -658
- data/informix.ec +1176 -323
- metadata +4 -3
data/informix.c
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
#include <sqlhdr.h>
|
2
2
|
#include <sqliapi.h>
|
3
|
-
static const char _Cn1[] = "cur";
|
4
3
|
#line 1 "informix.ec"
|
5
|
-
/* $Id: informix.ec,v 1.
|
4
|
+
/* $Id: informix.ec,v 1.81 2006/12/27 20:57:39 santana Exp $ */
|
6
5
|
/*
|
7
6
|
* Copyright (c) 2006, Gerardo Santana Gomez Garrido <gerardo.santana@gmail.com>
|
8
7
|
* All rights reserved.
|
@@ -37,30 +36,30 @@ static const char _Cn1[] = "cur";
|
|
37
36
|
#include <sqlstype.h>
|
38
37
|
#include <sqltypes.h>
|
39
38
|
|
40
|
-
static VALUE rb_cDate;
|
39
|
+
static VALUE rb_cDate, rb_cBigDecimal;
|
41
40
|
|
42
41
|
static VALUE rb_mInformix;
|
43
42
|
static VALUE rb_mSequentialCursor;
|
44
43
|
static VALUE rb_mScrollCursor;
|
45
44
|
static VALUE rb_mInsertCursor;
|
46
45
|
|
47
|
-
static VALUE rb_cSlob;
|
46
|
+
static VALUE rb_cSlob, rb_cSlobStat;
|
48
47
|
static VALUE rb_cDatabase;
|
49
48
|
static VALUE rb_cStatement;
|
50
49
|
static VALUE rb_cCursor;
|
51
50
|
|
52
51
|
static ID s_read, s_new, s_utc, s_day, s_month, s_year;
|
53
52
|
static ID s_hour, s_min, s_sec, s_usec, s_to_s, s_to_i;
|
53
|
+
|
54
54
|
static VALUE sym_name, sym_type, sym_nullable, sym_stype, sym_length;
|
55
55
|
static VALUE sym_precision, sym_scale, sym_default, sym_xid;
|
56
56
|
static VALUE sym_scroll, sym_hold;
|
57
57
|
static VALUE sym_col_info, sym_sbspace, sym_estbytes, sym_extsz;
|
58
|
-
static VALUE sym_createflags, sym_openflags;
|
58
|
+
static VALUE sym_createflags, sym_openflags, sym_maxbytes;
|
59
|
+
static VALUE sym_params;
|
59
60
|
|
60
61
|
#define IDSIZE 30
|
61
62
|
|
62
|
-
static char *currentdid = NULL;
|
63
|
-
|
64
63
|
typedef struct {
|
65
64
|
short is_select, is_open;
|
66
65
|
struct sqlda daInput, *daOutput;
|
@@ -81,6 +80,11 @@ typedef struct {
|
|
81
80
|
char *database_id;
|
82
81
|
} slob_t;
|
83
82
|
|
83
|
+
typedef struct {
|
84
|
+
mint atime, ctime, mtime, refcnt;
|
85
|
+
ifx_int8_t size;
|
86
|
+
} slobstat_t;
|
87
|
+
|
84
88
|
#define NUM2INT8(num, int8addr) do { \
|
85
89
|
VALUE str = rb_funcall(num, s_to_s, 0); \
|
86
90
|
char *c_str = StringValueCStr(str); \
|
@@ -91,11 +95,201 @@ typedef struct {
|
|
91
95
|
|
92
96
|
#define INT82NUM(int8addr, num) do { \
|
93
97
|
char str[21]; \
|
94
|
-
|
98
|
+
ifx_int8toasc((int8addr), str, sizeof(str) - 1); \
|
95
99
|
str[sizeof(str) - 1] = 0; \
|
96
100
|
num = rb_cstr2inum(str, 10); \
|
97
101
|
}while(0)
|
98
102
|
|
103
|
+
/* class Slob::Stat ------------------------------------------------------ */
|
104
|
+
|
105
|
+
static void
|
106
|
+
slobstat_free(slobstat_t *stat)
|
107
|
+
{
|
108
|
+
xfree(stat);
|
109
|
+
}
|
110
|
+
|
111
|
+
static VALUE
|
112
|
+
slobstat_alloc(VALUE klass)
|
113
|
+
{
|
114
|
+
slobstat_t *stat;
|
115
|
+
|
116
|
+
stat = ALLOC(slobstat_t);
|
117
|
+
return Data_Wrap_Struct(klass, 0, slobstat_free, stat);
|
118
|
+
}
|
119
|
+
|
120
|
+
/*
|
121
|
+
* call-seq:
|
122
|
+
* Slob::Stat.new(slob) => stat
|
123
|
+
*
|
124
|
+
* Creates an Slob::Stat object with status information for the given Slob
|
125
|
+
* object.
|
126
|
+
*/
|
127
|
+
static VALUE
|
128
|
+
rb_slobstat_initialize(VALUE self, VALUE slob)
|
129
|
+
{
|
130
|
+
mint ret;
|
131
|
+
slob_t *sb;
|
132
|
+
slobstat_t *stat;
|
133
|
+
ifx_lo_stat_t *st;
|
134
|
+
/*
|
135
|
+
* EXEC SQL begin declare section;
|
136
|
+
*/
|
137
|
+
#line 131 "informix.ec"
|
138
|
+
#line 132 "informix.ec"
|
139
|
+
char *did;
|
140
|
+
/*
|
141
|
+
* EXEC SQL end declare section;
|
142
|
+
*/
|
143
|
+
#line 133 "informix.ec"
|
144
|
+
|
145
|
+
|
146
|
+
Data_Get_Struct(slob, slob_t, sb);
|
147
|
+
Data_Get_Struct(self, slobstat_t, stat);
|
148
|
+
|
149
|
+
if (sb->fd == -1)
|
150
|
+
rb_raise(rb_eRuntimeError,
|
151
|
+
"Open the Slob object before getting its status");
|
152
|
+
|
153
|
+
did = sb->database_id;
|
154
|
+
/*
|
155
|
+
* EXEC SQL set connection :did;
|
156
|
+
*/
|
157
|
+
#line 143 "informix.ec"
|
158
|
+
{
|
159
|
+
#line 143 "informix.ec"
|
160
|
+
sqli_connect_set(0, did, 0);
|
161
|
+
#line 143 "informix.ec"
|
162
|
+
}
|
163
|
+
if (SQLCODE < 0)
|
164
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
165
|
+
|
166
|
+
ret = ifx_lo_stat(sb->fd, &st);
|
167
|
+
|
168
|
+
if (ret < 0)
|
169
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
|
170
|
+
|
171
|
+
stat->atime = ifx_lo_stat_atime(st);
|
172
|
+
stat->ctime = ifx_lo_stat_ctime(st);
|
173
|
+
stat->mtime = ifx_lo_stat_mtime_sec(st);
|
174
|
+
stat->refcnt = ifx_lo_stat_refcnt(st);
|
175
|
+
ret = ifx_lo_stat_size(st, &stat->size);
|
176
|
+
|
177
|
+
ifx_lo_stat_free(st);
|
178
|
+
|
179
|
+
if (stat->atime == -1 || stat->ctime == -1 || stat->mtime == -1 ||
|
180
|
+
stat->refcnt == -1 || ret == -1) {
|
181
|
+
rb_raise(rb_eRuntimeError, "Unable to get status");
|
182
|
+
}
|
183
|
+
|
184
|
+
return self;
|
185
|
+
}
|
186
|
+
|
187
|
+
/*
|
188
|
+
* call-seq:
|
189
|
+
* stat <=> other_stat => -1, 0, 1
|
190
|
+
*
|
191
|
+
* Compares with another <code>Slob::Stat</code> object by comparing their
|
192
|
+
* modification times.
|
193
|
+
*/
|
194
|
+
static VALUE
|
195
|
+
rb_slobstat_cmp(VALUE self, VALUE other)
|
196
|
+
{
|
197
|
+
if (rb_obj_is_kind_of(other, rb_obj_class(self))) {
|
198
|
+
slobstat_t *stat;
|
199
|
+
time_t t1, t2;
|
200
|
+
|
201
|
+
Data_Get_Struct(self, slobstat_t, stat); t1 = stat->mtime;
|
202
|
+
Data_Get_Struct(other, slobstat_t, stat); t2 = stat->mtime;
|
203
|
+
|
204
|
+
if (t1 == t2)
|
205
|
+
return INT2FIX(0);
|
206
|
+
else if (t1 < t2)
|
207
|
+
return INT2FIX(-1);
|
208
|
+
else
|
209
|
+
return INT2FIX(1);
|
210
|
+
}
|
211
|
+
|
212
|
+
return Qnil;
|
213
|
+
}
|
214
|
+
|
215
|
+
/*
|
216
|
+
* call-seq:
|
217
|
+
* stat.atime => time
|
218
|
+
*
|
219
|
+
* Returns the time of last access as a Time object.
|
220
|
+
*/
|
221
|
+
static VALUE
|
222
|
+
rb_slobstat_atime(VALUE self)
|
223
|
+
{
|
224
|
+
slobstat_t *stat;
|
225
|
+
|
226
|
+
Data_Get_Struct(self, slobstat_t, stat);
|
227
|
+
return rb_time_new(stat->atime, 0);
|
228
|
+
}
|
229
|
+
|
230
|
+
/*
|
231
|
+
* call-seq:
|
232
|
+
* stat.ctime => time
|
233
|
+
*
|
234
|
+
* Returns the time of last change in status as a Time object.
|
235
|
+
*/
|
236
|
+
static VALUE
|
237
|
+
rb_slobstat_ctime(VALUE self)
|
238
|
+
{
|
239
|
+
slobstat_t *stat;
|
240
|
+
|
241
|
+
Data_Get_Struct(self, slobstat_t, stat);
|
242
|
+
return rb_time_new(stat->ctime, 0);
|
243
|
+
}
|
244
|
+
|
245
|
+
/*
|
246
|
+
* call-seq:
|
247
|
+
* stat.mtime => time
|
248
|
+
*
|
249
|
+
* Returns the time of last modification as a Time object.
|
250
|
+
*/
|
251
|
+
static VALUE
|
252
|
+
rb_slobstat_mtime(VALUE self)
|
253
|
+
{
|
254
|
+
slobstat_t *stat;
|
255
|
+
|
256
|
+
Data_Get_Struct(self, slobstat_t, stat);
|
257
|
+
return rb_time_new(stat->mtime, 0);
|
258
|
+
}
|
259
|
+
|
260
|
+
/*
|
261
|
+
* call-seq:
|
262
|
+
* stat.refcnt => fixnum
|
263
|
+
*
|
264
|
+
* Returns the number of references
|
265
|
+
*/
|
266
|
+
static VALUE
|
267
|
+
rb_slobstat_refcnt(VALUE self)
|
268
|
+
{
|
269
|
+
slobstat_t *stat;
|
270
|
+
|
271
|
+
Data_Get_Struct(self, slobstat_t, stat);
|
272
|
+
return INT2FIX(stat->refcnt);
|
273
|
+
}
|
274
|
+
|
275
|
+
/*
|
276
|
+
* call-seq:
|
277
|
+
* stat.size => fixnum or bignum
|
278
|
+
*
|
279
|
+
* Returns the size in bytes
|
280
|
+
*/
|
281
|
+
static VALUE
|
282
|
+
rb_slobstat_size(VALUE self)
|
283
|
+
{
|
284
|
+
slobstat_t *stat;
|
285
|
+
VALUE size;
|
286
|
+
|
287
|
+
Data_Get_Struct(self, slobstat_t, stat);
|
288
|
+
INT82NUM(&stat->size, size);
|
289
|
+
|
290
|
+
return size;
|
291
|
+
}
|
292
|
+
|
99
293
|
/* class Slob ------------------------------------------------------------ */
|
100
294
|
|
101
295
|
static void
|
@@ -111,34 +305,29 @@ slob_free(slob_t *slob)
|
|
111
305
|
/*
|
112
306
|
* EXEC SQL begin declare section;
|
113
307
|
*/
|
114
|
-
#line
|
115
|
-
#line
|
308
|
+
#line 286 "informix.ec"
|
309
|
+
#line 287 "informix.ec"
|
116
310
|
char *did;
|
117
311
|
/*
|
118
312
|
* EXEC SQL end declare section;
|
119
313
|
*/
|
120
|
-
#line
|
314
|
+
#line 288 "informix.ec"
|
121
315
|
|
122
316
|
|
123
317
|
did = slob->database_id;
|
124
|
-
if (currentdid != did) {
|
125
318
|
/*
|
126
|
-
*
|
319
|
+
* EXEC SQL set connection :did;
|
127
320
|
*/
|
128
|
-
#line
|
321
|
+
#line 291 "informix.ec"
|
129
322
|
{
|
130
|
-
#line
|
323
|
+
#line 291 "informix.ec"
|
131
324
|
sqli_connect_set(0, did, 0);
|
132
|
-
#line
|
325
|
+
#line 291 "informix.ec"
|
133
326
|
}
|
134
|
-
|
135
|
-
|
136
|
-
currentdid = did;
|
137
|
-
}
|
138
|
-
ifx_lo_close(slob->fd);
|
327
|
+
if (SQLCODE >= 0)
|
328
|
+
ifx_lo_close(slob->fd);
|
139
329
|
}
|
140
330
|
|
141
|
-
exit:
|
142
331
|
if (slob->spec)
|
143
332
|
ifx_lo_spec_free(slob->spec);
|
144
333
|
|
@@ -153,14 +342,17 @@ slob_alloc(VALUE klass)
|
|
153
342
|
slob = ALLOC(slob_t);
|
154
343
|
slob->spec = NULL;
|
155
344
|
slob->fd = -1;
|
345
|
+
slob->database_id = NULL;
|
156
346
|
slob->type = XID_CLOB;
|
347
|
+
slob->db = 0;
|
157
348
|
|
158
349
|
return Data_Wrap_Struct(klass, slob_mark, slob_free, slob);
|
159
350
|
}
|
160
351
|
|
161
352
|
/*
|
162
353
|
* call-seq:
|
163
|
-
* Slob.new(database, type = Slob::CLOB, options = nil)
|
354
|
+
* Slob.new(database, type = Slob::CLOB, options = nil) => slob
|
355
|
+
* Slob.new(database, type = Slob::CLOB, options = nil) {|slob| block } => obj
|
164
356
|
*
|
165
357
|
* Creates a Smart Large Object of type <i>type</i> in <i>database</i>.
|
166
358
|
* Returns a <code>Slob</code> object pointing to it.
|
@@ -179,7 +371,7 @@ slob_alloc(VALUE klass)
|
|
179
371
|
* characteristics for the specified database column
|
180
372
|
*/
|
181
373
|
static VALUE
|
182
|
-
|
374
|
+
rb_slob_initialize(int argc, VALUE *argv, VALUE self)
|
183
375
|
{
|
184
376
|
mint ret, error;
|
185
377
|
slob_t *slob;
|
@@ -188,38 +380,35 @@ slob_initialize(int argc, VALUE *argv, VALUE self)
|
|
188
380
|
/*
|
189
381
|
* EXEC SQL begin declare section;
|
190
382
|
*/
|
191
|
-
#line
|
192
|
-
#line
|
383
|
+
#line 345 "informix.ec"
|
384
|
+
#line 346 "informix.ec"
|
193
385
|
char *did;
|
194
386
|
/*
|
195
387
|
* EXEC SQL end declare section;
|
196
388
|
*/
|
197
|
-
#line
|
389
|
+
#line 347 "informix.ec"
|
198
390
|
|
199
391
|
|
200
392
|
rb_scan_args(argc, argv, "12", &db, &type, &options);
|
201
393
|
Data_Get_Struct(db, char, did);
|
202
394
|
|
203
|
-
if (currentdid != did) {
|
204
395
|
/*
|
205
|
-
*
|
396
|
+
* EXEC SQL set connection :did;
|
206
397
|
*/
|
207
|
-
#line
|
398
|
+
#line 352 "informix.ec"
|
208
399
|
{
|
209
|
-
#line
|
400
|
+
#line 352 "informix.ec"
|
210
401
|
sqli_connect_set(0, did, 0);
|
211
|
-
#line
|
402
|
+
#line 352 "informix.ec"
|
212
403
|
}
|
213
|
-
|
214
|
-
|
215
|
-
currentdid = did;
|
216
|
-
}
|
404
|
+
if (SQLCODE < 0)
|
405
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
217
406
|
|
218
407
|
Data_Get_Struct(self, slob_t, slob);
|
219
408
|
slob->db = db;
|
220
409
|
slob->database_id = did;
|
221
410
|
|
222
|
-
if (
|
411
|
+
if (!NIL_P(type)) {
|
223
412
|
int t = FIX2INT(type);
|
224
413
|
if (t != XID_CLOB && t != XID_BLOB)
|
225
414
|
rb_raise(rb_eRuntimeError, "Invalid type %d for an SLOB", t);
|
@@ -228,32 +417,34 @@ slob_initialize(int argc, VALUE *argv, VALUE self)
|
|
228
417
|
|
229
418
|
col_info = sbspace = estbytes = extsz = createflags = openflags = maxbytes = Qnil;
|
230
419
|
|
231
|
-
if (
|
420
|
+
if (!NIL_P(options)) {
|
421
|
+
Check_Type(options, T_HASH);
|
232
422
|
col_info = rb_hash_aref(options, sym_col_info);
|
233
423
|
sbspace = rb_hash_aref(options, sym_sbspace);
|
234
424
|
estbytes = rb_hash_aref(options, sym_estbytes);
|
235
425
|
extsz = rb_hash_aref(options, sym_extsz);
|
236
426
|
createflags = rb_hash_aref(options, sym_createflags);
|
237
427
|
openflags = rb_hash_aref(options, sym_openflags);
|
428
|
+
maxbytes = rb_hash_aref(options, sym_maxbytes);
|
238
429
|
}
|
239
430
|
|
240
431
|
ret = ifx_lo_def_create_spec(&slob->spec);
|
241
432
|
if (ret < 0)
|
242
433
|
rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
|
243
434
|
|
244
|
-
if (
|
435
|
+
if (!NIL_P(col_info)) {
|
245
436
|
ret = ifx_lo_col_info(StringValueCStr(col_info), slob->spec);
|
246
437
|
|
247
438
|
if (ret < 0)
|
248
439
|
rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
|
249
440
|
}
|
250
|
-
if (
|
441
|
+
if (!NIL_P(sbspace)) {
|
251
442
|
char *c_sbspace = StringValueCStr(sbspace);
|
252
443
|
ret = ifx_lo_specset_sbspace(slob->spec, c_sbspace);
|
253
444
|
if (ret == -1)
|
254
445
|
rb_raise(rb_eRuntimeError, "Could not set sbspace name to %s", c_sbspace);
|
255
446
|
}
|
256
|
-
if (
|
447
|
+
if (!NIL_P(estbytes)) {
|
257
448
|
ifx_int8_t estbytes8;
|
258
449
|
|
259
450
|
NUM2INT8(estbytes, &estbytes8);
|
@@ -261,17 +452,17 @@ slob_initialize(int argc, VALUE *argv, VALUE self)
|
|
261
452
|
if (ret == -1)
|
262
453
|
rb_raise(rb_eRuntimeError, "Could not set estbytes");
|
263
454
|
}
|
264
|
-
if (
|
455
|
+
if (!NIL_P(extsz)) {
|
265
456
|
ret = ifx_lo_specset_extsz(slob->spec, FIX2LONG(extsz));
|
266
457
|
if (ret == -1)
|
267
458
|
rb_raise(rb_eRuntimeError, "Could not set extsz to %d", FIX2LONG(extsz));
|
268
459
|
}
|
269
|
-
if (
|
460
|
+
if (!NIL_P(createflags)) {
|
270
461
|
ret = ifx_lo_specset_flags(slob->spec, FIX2LONG(createflags));
|
271
462
|
if (ret == -1)
|
272
463
|
rb_raise(rb_eRuntimeError, "Could not set crate-time flags to 0x%X", FIX2LONG(createflags));
|
273
464
|
}
|
274
|
-
if (
|
465
|
+
if (!NIL_P(maxbytes)) {
|
275
466
|
ifx_int8_t maxbytes8;
|
276
467
|
|
277
468
|
NUM2INT8(maxbytes, (&maxbytes8));
|
@@ -279,26 +470,62 @@ slob_initialize(int argc, VALUE *argv, VALUE self)
|
|
279
470
|
if (ret == -1)
|
280
471
|
rb_raise(rb_eRuntimeError, "Could not set maxbytes");
|
281
472
|
}
|
473
|
+
|
282
474
|
slob->fd = ifx_lo_create(slob->spec, RTEST(openflags)? FIX2LONG(openflags): LO_RDWR, &slob->lo, &error);
|
283
|
-
if (slob->fd == -1)
|
475
|
+
if (slob->fd == -1)
|
284
476
|
rb_raise(rb_eRuntimeError, "Informix Error: %d\n", error);
|
285
|
-
|
477
|
+
|
286
478
|
return self;
|
287
479
|
}
|
288
480
|
|
481
|
+
/*
|
482
|
+
* call-seq:
|
483
|
+
* Slob.new(database, type = Slob::CLOB, options = nil) => slob
|
484
|
+
* Slob.new(database, type = Slob::CLOB, options = nil) {|slob| block } => obj
|
485
|
+
*
|
486
|
+
* Creates a Smart Large Object of type <i>type</i> in <i>database</i>.
|
487
|
+
* Returns a <code>Slob</code> object pointing to it.
|
488
|
+
*
|
489
|
+
* <i>type</i> can be Slob::BLOB or Slob::CLOB
|
490
|
+
*
|
491
|
+
* <i>options</i> can be nil or a Hash object with the following possible keys:
|
492
|
+
*
|
493
|
+
* :sbspace => Sbspace name
|
494
|
+
* :estbytes => Estimated size, in bytes
|
495
|
+
* :extsz => Allocation extent size
|
496
|
+
* :createflags => Create-time flags
|
497
|
+
* :openflags => Access mode
|
498
|
+
* :maxbytes => Maximum size
|
499
|
+
* :col_info => Get the previous values from the column-level storage
|
500
|
+
* characteristics for the specified database column
|
501
|
+
*/
|
502
|
+
static VALUE rb_slob_close(VALUE self);
|
503
|
+
static VALUE
|
504
|
+
rb_slob_s_new(int argc, VALUE *argv, VALUE klass)
|
505
|
+
{
|
506
|
+
VALUE slob;
|
507
|
+
|
508
|
+
slob = rb_class_new_instance(argc, argv, klass);
|
509
|
+
|
510
|
+
if (rb_block_given_p())
|
511
|
+
return rb_ensure(rb_yield, slob, rb_slob_close, slob);
|
512
|
+
|
513
|
+
return slob;
|
514
|
+
}
|
515
|
+
|
289
516
|
/*
|
290
517
|
* call-seq:
|
291
518
|
* slob.open(access = Slob::RDONLY) => slob
|
292
519
|
*
|
293
520
|
* Opens the Smart Large Object in <i>access</i> mode.
|
294
521
|
*
|
295
|
-
*
|
522
|
+
* Access modes:
|
296
523
|
*
|
297
524
|
* Slob::RDONLY:: Read only
|
298
525
|
* Slob::DIRTY_READ:: Read uncommitted data
|
299
526
|
* Slob::WRONLY:: Write only
|
300
|
-
* Slob::APPEND:: Append data to the end, if combined with
|
301
|
-
* Slob::
|
527
|
+
* Slob::APPEND:: Append data to the end, if combined with RDWR or WRONLY; read only otherwise
|
528
|
+
* Slob::RDWR:: Read/Write
|
302
529
|
* Slob::BUFFER:: Use standard database server buffer pool
|
303
530
|
* Slob::NOBUFFER:: Use private buffer from the session pool of the database server
|
304
531
|
* Slob::LOCKALL:: Lock the entire Smart Large Object
|
@@ -307,7 +534,7 @@ slob_initialize(int argc, VALUE *argv, VALUE self)
|
|
307
534
|
* Returns __self__.
|
308
535
|
*/
|
309
536
|
static VALUE
|
310
|
-
|
537
|
+
rb_slob_open(int argc, VALUE *argv, VALUE self)
|
311
538
|
{
|
312
539
|
VALUE access;
|
313
540
|
slob_t *slob;
|
@@ -315,13 +542,13 @@ slob_open(int argc, VALUE *argv, VALUE self)
|
|
315
542
|
/*
|
316
543
|
* EXEC SQL begin declare section;
|
317
544
|
*/
|
318
|
-
#line
|
319
|
-
#line
|
545
|
+
#line 491 "informix.ec"
|
546
|
+
#line 492 "informix.ec"
|
320
547
|
char *did;
|
321
548
|
/*
|
322
549
|
* EXEC SQL end declare section;
|
323
550
|
*/
|
324
|
-
#line
|
551
|
+
#line 493 "informix.ec"
|
325
552
|
|
326
553
|
|
327
554
|
Data_Get_Struct(self, slob_t, slob);
|
@@ -330,20 +557,17 @@ slob_open(int argc, VALUE *argv, VALUE self)
|
|
330
557
|
return self;
|
331
558
|
|
332
559
|
did = slob->database_id;
|
333
|
-
if (currentdid != did) {
|
334
560
|
/*
|
335
|
-
*
|
561
|
+
* EXEC SQL set connection :did;
|
336
562
|
*/
|
337
|
-
#line
|
563
|
+
#line 501 "informix.ec"
|
338
564
|
{
|
339
|
-
#line
|
565
|
+
#line 501 "informix.ec"
|
340
566
|
sqli_connect_set(0, did, 0);
|
341
|
-
#line
|
567
|
+
#line 501 "informix.ec"
|
342
568
|
}
|
343
|
-
|
344
|
-
|
345
|
-
currentdid = did;
|
346
|
-
}
|
569
|
+
if (SQLCODE < 0)
|
570
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
347
571
|
|
348
572
|
rb_scan_args(argc, argv, "01", &access);
|
349
573
|
|
@@ -362,7 +586,7 @@ slob_open(int argc, VALUE *argv, VALUE self)
|
|
362
586
|
* Closes the Smart Large Object and returns __self__.
|
363
587
|
*/
|
364
588
|
static VALUE
|
365
|
-
|
589
|
+
rb_slob_close(VALUE self)
|
366
590
|
{
|
367
591
|
slob_t *slob;
|
368
592
|
|
@@ -371,30 +595,27 @@ slob_close(VALUE self)
|
|
371
595
|
/*
|
372
596
|
* EXEC SQL begin declare section;
|
373
597
|
*/
|
374
|
-
#line
|
375
|
-
#line
|
598
|
+
#line 528 "informix.ec"
|
599
|
+
#line 529 "informix.ec"
|
376
600
|
char *did;
|
377
601
|
/*
|
378
602
|
* EXEC SQL end declare section;
|
379
603
|
*/
|
380
|
-
#line
|
604
|
+
#line 530 "informix.ec"
|
381
605
|
|
382
606
|
|
383
607
|
did = slob->database_id;
|
384
|
-
if (currentdid != did) {
|
385
608
|
/*
|
386
|
-
*
|
609
|
+
* EXEC SQL set connection :did;
|
387
610
|
*/
|
388
|
-
#line
|
611
|
+
#line 533 "informix.ec"
|
389
612
|
{
|
390
|
-
#line
|
613
|
+
#line 533 "informix.ec"
|
391
614
|
sqli_connect_set(0, did, 0);
|
392
|
-
#line
|
615
|
+
#line 533 "informix.ec"
|
393
616
|
}
|
394
|
-
|
395
|
-
|
396
|
-
currentdid = did;
|
397
|
-
}
|
617
|
+
if (SQLCODE < 0)
|
618
|
+
return self;
|
398
619
|
|
399
620
|
ifx_lo_close(slob->fd);
|
400
621
|
slob->fd = -1;
|
@@ -412,7 +633,7 @@ slob_close(VALUE self)
|
|
412
633
|
* Returns the bytes read as a String object.
|
413
634
|
*/
|
414
635
|
static VALUE
|
415
|
-
|
636
|
+
rb_slob_read(VALUE self, VALUE nbytes)
|
416
637
|
{
|
417
638
|
slob_t *slob;
|
418
639
|
mint error, ret;
|
@@ -422,13 +643,13 @@ slob_read(VALUE self, VALUE nbytes)
|
|
422
643
|
/*
|
423
644
|
* EXEC SQL begin declare section;
|
424
645
|
*/
|
425
|
-
#line
|
426
|
-
#line
|
646
|
+
#line 560 "informix.ec"
|
647
|
+
#line 561 "informix.ec"
|
427
648
|
char *did;
|
428
649
|
/*
|
429
650
|
* EXEC SQL end declare section;
|
430
651
|
*/
|
431
|
-
#line
|
652
|
+
#line 562 "informix.ec"
|
432
653
|
|
433
654
|
|
434
655
|
|
@@ -438,27 +659,26 @@ slob_read(VALUE self, VALUE nbytes)
|
|
438
659
|
rb_raise(rb_eRuntimeError, "Open the Slob object before reading");
|
439
660
|
|
440
661
|
did = slob->database_id;
|
441
|
-
if (currentdid != did) {
|
442
662
|
/*
|
443
|
-
*
|
663
|
+
* EXEC SQL set connection :did;
|
444
664
|
*/
|
445
|
-
#line
|
665
|
+
#line 571 "informix.ec"
|
446
666
|
{
|
447
|
-
#line
|
667
|
+
#line 571 "informix.ec"
|
448
668
|
sqli_connect_set(0, did, 0);
|
449
|
-
#line
|
669
|
+
#line 571 "informix.ec"
|
450
670
|
}
|
451
|
-
|
452
|
-
|
453
|
-
currentdid = did;
|
454
|
-
}
|
671
|
+
if (SQLCODE < 0)
|
672
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
455
673
|
|
456
674
|
c_nbytes = FIX2LONG(nbytes);
|
457
675
|
buffer = ALLOC_N(char, c_nbytes);
|
458
676
|
ret = ifx_lo_read(slob->fd, buffer, c_nbytes, &error);
|
459
677
|
|
460
|
-
if (ret == -1)
|
678
|
+
if (ret == -1) {
|
679
|
+
xfree(buffer);
|
461
680
|
rb_raise(rb_eRuntimeError, "Informix Error: %d\n", error);
|
681
|
+
}
|
462
682
|
|
463
683
|
str = rb_str_new(buffer, ret);
|
464
684
|
xfree(buffer);
|
@@ -470,12 +690,13 @@ slob_read(VALUE self, VALUE nbytes)
|
|
470
690
|
* call-seq:
|
471
691
|
* slob.write(data) => fixnum or bignum
|
472
692
|
*
|
473
|
-
* Writes <i>data</i> to the Smart Large Object.
|
693
|
+
* Writes <i>data</i> to the Smart Large Object. If <i>data</i> is not a
|
694
|
+
* String object it will be converted to String using <code>to_s</code>.
|
474
695
|
*
|
475
696
|
* Returns the number of bytes written.
|
476
697
|
*/
|
477
698
|
static VALUE
|
478
|
-
|
699
|
+
rb_slob_write(VALUE self, VALUE data)
|
479
700
|
{
|
480
701
|
slob_t *slob;
|
481
702
|
mint error, ret;
|
@@ -485,13 +706,13 @@ slob_write(VALUE self, VALUE data)
|
|
485
706
|
/*
|
486
707
|
* EXEC SQL begin declare section;
|
487
708
|
*/
|
488
|
-
#line
|
489
|
-
#line
|
709
|
+
#line 607 "informix.ec"
|
710
|
+
#line 608 "informix.ec"
|
490
711
|
char *did;
|
491
712
|
/*
|
492
713
|
* EXEC SQL end declare section;
|
493
714
|
*/
|
494
|
-
#line
|
715
|
+
#line 609 "informix.ec"
|
495
716
|
|
496
717
|
|
497
718
|
Data_Get_Struct(self, slob_t, slob);
|
@@ -500,22 +721,19 @@ slob_write(VALUE self, VALUE data)
|
|
500
721
|
rb_raise(rb_eRuntimeError, "Open the Slob object before writing");
|
501
722
|
|
502
723
|
did = slob->database_id;
|
503
|
-
if (currentdid != did) {
|
504
724
|
/*
|
505
|
-
*
|
725
|
+
* EXEC SQL set connection :did;
|
506
726
|
*/
|
507
|
-
#line
|
727
|
+
#line 617 "informix.ec"
|
508
728
|
{
|
509
|
-
#line
|
729
|
+
#line 617 "informix.ec"
|
510
730
|
sqli_connect_set(0, did, 0);
|
511
|
-
#line
|
731
|
+
#line 617 "informix.ec"
|
512
732
|
}
|
513
|
-
|
514
|
-
|
515
|
-
currentdid = did;
|
516
|
-
}
|
733
|
+
if (SQLCODE < 0)
|
734
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
517
735
|
|
518
|
-
str =
|
736
|
+
str = rb_obj_as_string(data);
|
519
737
|
buffer = RSTRING(str)->ptr;
|
520
738
|
nbytes = RSTRING(str)->len;
|
521
739
|
|
@@ -527,6 +745,22 @@ slob_write(VALUE self, VALUE data)
|
|
527
745
|
return LONG2NUM(ret);
|
528
746
|
}
|
529
747
|
|
748
|
+
/*
|
749
|
+
* call-seq:
|
750
|
+
* slob << data => slob
|
751
|
+
*
|
752
|
+
* Writes <i>data</i> to the Smart Large Object. If <i>data</i> is not a
|
753
|
+
* String object it will be converted to String using <code>to_s</code>.
|
754
|
+
*
|
755
|
+
* Returns self.
|
756
|
+
*/
|
757
|
+
static VALUE
|
758
|
+
rb_slob_addstr(VALUE self, VALUE data)
|
759
|
+
{
|
760
|
+
rb_slob_write(self, data);
|
761
|
+
return self;
|
762
|
+
}
|
763
|
+
|
530
764
|
/*
|
531
765
|
* call-seq:
|
532
766
|
* slob.seek(offset, whence) => fixnum or bignum
|
@@ -547,7 +781,7 @@ slob_write(VALUE self, VALUE data)
|
|
547
781
|
* Returns the new position.
|
548
782
|
*/
|
549
783
|
static VALUE
|
550
|
-
|
784
|
+
rb_slob_seek(VALUE self, VALUE offset, VALUE whence)
|
551
785
|
{
|
552
786
|
slob_t *slob;
|
553
787
|
mint ret;
|
@@ -556,13 +790,13 @@ slob_seek(VALUE self, VALUE offset, VALUE whence)
|
|
556
790
|
/*
|
557
791
|
* EXEC SQL begin declare section;
|
558
792
|
*/
|
559
|
-
#line
|
560
|
-
#line
|
793
|
+
#line 675 "informix.ec"
|
794
|
+
#line 676 "informix.ec"
|
561
795
|
char *did;
|
562
796
|
/*
|
563
797
|
* EXEC SQL end declare section;
|
564
798
|
*/
|
565
|
-
#line
|
799
|
+
#line 677 "informix.ec"
|
566
800
|
|
567
801
|
|
568
802
|
Data_Get_Struct(self, slob_t, slob);
|
@@ -571,20 +805,17 @@ slob_seek(VALUE self, VALUE offset, VALUE whence)
|
|
571
805
|
rb_raise(rb_eRuntimeError, "Open the Slob object first");
|
572
806
|
|
573
807
|
did = slob->database_id;
|
574
|
-
if (currentdid != did) {
|
575
808
|
/*
|
576
|
-
*
|
809
|
+
* EXEC SQL set connection :did;
|
577
810
|
*/
|
578
|
-
#line
|
811
|
+
#line 685 "informix.ec"
|
579
812
|
{
|
580
|
-
#line
|
813
|
+
#line 685 "informix.ec"
|
581
814
|
sqli_connect_set(0, did, 0);
|
582
|
-
#line
|
815
|
+
#line 685 "informix.ec"
|
583
816
|
}
|
584
|
-
|
585
|
-
|
586
|
-
currentdid = did;
|
587
|
-
}
|
817
|
+
if (SQLCODE < 0)
|
818
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
588
819
|
|
589
820
|
NUM2INT8(offset, &offset8);
|
590
821
|
ret = ifx_lo_seek(slob->fd, &offset8, FIX2INT(whence), &seek_pos8);
|
@@ -598,13 +829,37 @@ slob_seek(VALUE self, VALUE offset, VALUE whence)
|
|
598
829
|
|
599
830
|
/*
|
600
831
|
* call-seq:
|
601
|
-
* slob.
|
832
|
+
* slob.pos = integer => integer
|
833
|
+
*
|
834
|
+
* Seeks to the given position (in bytes) in _slob_.
|
835
|
+
*/
|
836
|
+
static VALUE
|
837
|
+
rb_slob_set_pos(VALUE self, VALUE pos)
|
838
|
+
{
|
839
|
+
return rb_slob_seek(self, pos, LO_SEEK_SET);
|
840
|
+
}
|
841
|
+
|
842
|
+
/*
|
843
|
+
* call-seq:
|
844
|
+
* slob.rewind => fixnum
|
845
|
+
*
|
846
|
+
* Moves the cursor position to the start of the Smart Large Object.
|
847
|
+
*/
|
848
|
+
static VALUE
|
849
|
+
rb_slob_rewind(VALUE self)
|
850
|
+
{
|
851
|
+
return rb_slob_seek(self, INT2FIX(0), LO_SEEK_SET);
|
852
|
+
}
|
853
|
+
|
854
|
+
/*
|
855
|
+
* call-seq:
|
856
|
+
* slob.tell => integer
|
857
|
+
* slob.pos => integer
|
602
858
|
*
|
603
|
-
* Returns the current file or seek position for an
|
604
|
-
* open Smart Large Object
|
859
|
+
* Returns the current file or seek position for an open Smart Large Object
|
605
860
|
*/
|
606
861
|
static VALUE
|
607
|
-
|
862
|
+
rb_slob_tell(VALUE self)
|
608
863
|
{
|
609
864
|
slob_t *slob;
|
610
865
|
mint ret;
|
@@ -613,13 +868,13 @@ slob_tell(VALUE self)
|
|
613
868
|
/*
|
614
869
|
* EXEC SQL begin declare section;
|
615
870
|
*/
|
616
|
-
#line
|
617
|
-
#line
|
871
|
+
#line 737 "informix.ec"
|
872
|
+
#line 738 "informix.ec"
|
618
873
|
char *did;
|
619
874
|
/*
|
620
875
|
* EXEC SQL end declare section;
|
621
876
|
*/
|
622
|
-
#line
|
877
|
+
#line 739 "informix.ec"
|
623
878
|
|
624
879
|
|
625
880
|
Data_Get_Struct(self, slob_t, slob);
|
@@ -628,20 +883,17 @@ slob_tell(VALUE self)
|
|
628
883
|
rb_raise(rb_eRuntimeError, "Open the Slob object first");
|
629
884
|
|
630
885
|
did = slob->database_id;
|
631
|
-
if (currentdid != did) {
|
632
886
|
/*
|
633
|
-
*
|
887
|
+
* EXEC SQL set connection :did;
|
634
888
|
*/
|
635
|
-
#line
|
889
|
+
#line 747 "informix.ec"
|
636
890
|
{
|
637
|
-
#line
|
891
|
+
#line 747 "informix.ec"
|
638
892
|
sqli_connect_set(0, did, 0);
|
639
|
-
#line
|
893
|
+
#line 747 "informix.ec"
|
640
894
|
}
|
641
|
-
|
642
|
-
|
643
|
-
currentdid = did;
|
644
|
-
}
|
895
|
+
if (SQLCODE < 0)
|
896
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
645
897
|
|
646
898
|
ret = ifx_lo_tell(slob->fd, &seek_pos8);
|
647
899
|
if (ret < 0)
|
@@ -661,7 +913,7 @@ slob_tell(VALUE self)
|
|
661
913
|
* Returns __self__.
|
662
914
|
*/
|
663
915
|
static VALUE
|
664
|
-
|
916
|
+
rb_slob_truncate(VALUE self, VALUE offset)
|
665
917
|
{
|
666
918
|
slob_t *slob;
|
667
919
|
mint ret;
|
@@ -669,13 +921,13 @@ slob_truncate(VALUE self, VALUE offset)
|
|
669
921
|
/*
|
670
922
|
* EXEC SQL begin declare section;
|
671
923
|
*/
|
672
|
-
#line
|
673
|
-
#line
|
924
|
+
#line 774 "informix.ec"
|
925
|
+
#line 775 "informix.ec"
|
674
926
|
char *did;
|
675
927
|
/*
|
676
928
|
* EXEC SQL end declare section;
|
677
929
|
*/
|
678
|
-
#line
|
930
|
+
#line 776 "informix.ec"
|
679
931
|
|
680
932
|
|
681
933
|
Data_Get_Struct(self, slob_t, slob);
|
@@ -684,27 +936,552 @@ slob_truncate(VALUE self, VALUE offset)
|
|
684
936
|
rb_raise(rb_eRuntimeError, "Open the Slob object first");
|
685
937
|
|
686
938
|
did = slob->database_id;
|
687
|
-
if (currentdid != did) {
|
688
939
|
/*
|
689
|
-
*
|
940
|
+
* EXEC SQL set connection :did;
|
690
941
|
*/
|
691
|
-
#line
|
942
|
+
#line 784 "informix.ec"
|
692
943
|
{
|
693
|
-
#line
|
944
|
+
#line 784 "informix.ec"
|
694
945
|
sqli_connect_set(0, did, 0);
|
695
|
-
#line
|
946
|
+
#line 784 "informix.ec"
|
696
947
|
}
|
697
|
-
|
698
|
-
|
699
|
-
currentdid = did;
|
700
|
-
}
|
948
|
+
if (SQLCODE < 0)
|
949
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
701
950
|
|
702
951
|
NUM2INT8(offset, &offset8);
|
703
952
|
ret = ifx_lo_truncate(slob->fd, &offset8);
|
704
953
|
if (ret < 0)
|
705
954
|
rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
|
706
955
|
|
707
|
-
return self;
|
956
|
+
return self;
|
957
|
+
}
|
958
|
+
|
959
|
+
/*
|
960
|
+
* call-seq:
|
961
|
+
* slob.stat => stat
|
962
|
+
*
|
963
|
+
* Creates and returns an Slob::Stat object with status information for _slob_.
|
964
|
+
*/
|
965
|
+
static VALUE
|
966
|
+
rb_slob_stat(VALUE self)
|
967
|
+
{
|
968
|
+
return rb_class_new_instance(1, &self, rb_cSlobStat);
|
969
|
+
}
|
970
|
+
|
971
|
+
/*
|
972
|
+
* call-seq:
|
973
|
+
* slob.lock(offset, whence, range, mode) => slob
|
974
|
+
*
|
975
|
+
* Locks _range_ number of bytes, starting from _offset_ bytes from
|
976
|
+
* _whence_, in _mode_ mode.
|
977
|
+
*
|
978
|
+
* Returns _self_.
|
979
|
+
*
|
980
|
+
* Possible values:
|
981
|
+
*
|
982
|
+
* offset => integer
|
983
|
+
* whence => Slob::SEEK_SET, Slob::SEEK_CUR, Slob::SEEK_END
|
984
|
+
* range => integer, Slob::CURRENT_END, Slob::MAX_END
|
985
|
+
* mode => Slob::SHARED_MODE, Slob::EXCLUSIVE_MODE
|
986
|
+
*/
|
987
|
+
static VALUE
|
988
|
+
rb_slob_lock(VALUE self, VALUE offset, VALUE whence, VALUE range, VALUE mode)
|
989
|
+
{
|
990
|
+
slob_t *slob;
|
991
|
+
mint ret;
|
992
|
+
ifx_int8_t offset8, range8;
|
993
|
+
/*
|
994
|
+
* EXEC SQL begin declare section;
|
995
|
+
*/
|
996
|
+
#line 830 "informix.ec"
|
997
|
+
#line 831 "informix.ec"
|
998
|
+
char *did;
|
999
|
+
/*
|
1000
|
+
* EXEC SQL end declare section;
|
1001
|
+
*/
|
1002
|
+
#line 832 "informix.ec"
|
1003
|
+
|
1004
|
+
|
1005
|
+
Data_Get_Struct(self, slob_t, slob);
|
1006
|
+
|
1007
|
+
if (slob->fd == -1)
|
1008
|
+
rb_raise(rb_eRuntimeError, "Open the Slob object first");
|
1009
|
+
|
1010
|
+
did = slob->database_id;
|
1011
|
+
/*
|
1012
|
+
* EXEC SQL set connection :did;
|
1013
|
+
*/
|
1014
|
+
#line 840 "informix.ec"
|
1015
|
+
{
|
1016
|
+
#line 840 "informix.ec"
|
1017
|
+
sqli_connect_set(0, did, 0);
|
1018
|
+
#line 840 "informix.ec"
|
1019
|
+
}
|
1020
|
+
if (SQLCODE < 0)
|
1021
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
1022
|
+
|
1023
|
+
NUM2INT8(offset, &offset8);
|
1024
|
+
NUM2INT8(range, &range8);
|
1025
|
+
ret = ifx_lo_lock(slob->fd, &offset8, FIX2INT(whence), &range8, FIX2INT(mode));
|
1026
|
+
if (ret < 0)
|
1027
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
|
1028
|
+
|
1029
|
+
return self;
|
1030
|
+
}
|
1031
|
+
|
1032
|
+
/*
|
1033
|
+
* call-seq:
|
1034
|
+
* slob.unlock(offset, whence, range) => slob
|
1035
|
+
*
|
1036
|
+
* Unlocks _range_ number of bytes, starting from _offset_ bytes from
|
1037
|
+
* _whence_.
|
1038
|
+
*
|
1039
|
+
* Returns _self_.
|
1040
|
+
*
|
1041
|
+
* Possible values:
|
1042
|
+
*
|
1043
|
+
* offset => integer
|
1044
|
+
* whence => Slob::SEEK_SET, Slob::SEEK_CUR, Slob::SEEK_END
|
1045
|
+
* range => integer
|
1046
|
+
*/
|
1047
|
+
static VALUE
|
1048
|
+
rb_slob_unlock(VALUE self, VALUE offset, VALUE whence, VALUE range)
|
1049
|
+
{
|
1050
|
+
slob_t *slob;
|
1051
|
+
mint ret;
|
1052
|
+
ifx_int8_t offset8, range8;
|
1053
|
+
/*
|
1054
|
+
* EXEC SQL begin declare section;
|
1055
|
+
*/
|
1056
|
+
#line 874 "informix.ec"
|
1057
|
+
#line 875 "informix.ec"
|
1058
|
+
char *did;
|
1059
|
+
/*
|
1060
|
+
* EXEC SQL end declare section;
|
1061
|
+
*/
|
1062
|
+
#line 876 "informix.ec"
|
1063
|
+
|
1064
|
+
|
1065
|
+
Data_Get_Struct(self, slob_t, slob);
|
1066
|
+
|
1067
|
+
if (slob->fd == -1)
|
1068
|
+
rb_raise(rb_eRuntimeError, "Open the Slob object first");
|
1069
|
+
|
1070
|
+
did = slob->database_id;
|
1071
|
+
/*
|
1072
|
+
* EXEC SQL set connection :did;
|
1073
|
+
*/
|
1074
|
+
#line 884 "informix.ec"
|
1075
|
+
{
|
1076
|
+
#line 884 "informix.ec"
|
1077
|
+
sqli_connect_set(0, did, 0);
|
1078
|
+
#line 884 "informix.ec"
|
1079
|
+
}
|
1080
|
+
if (SQLCODE < 0)
|
1081
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
1082
|
+
|
1083
|
+
NUM2INT8(offset, &offset8);
|
1084
|
+
NUM2INT8(range, &range8);
|
1085
|
+
ret = ifx_lo_unlock(slob->fd, &offset8, FIX2INT(whence), &range8);
|
1086
|
+
if (ret < 0)
|
1087
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
|
1088
|
+
|
1089
|
+
return self;
|
1090
|
+
}
|
1091
|
+
|
1092
|
+
typedef enum {
|
1093
|
+
slob_estbytes, slob_extsz, slob_flags, slob_maxbytes, slob_sbspace
|
1094
|
+
} slob_option_t;
|
1095
|
+
static char *str_slob_options[] = {
|
1096
|
+
"estbytes", "extsz", "flags", "maxbytes", "sbspace"};
|
1097
|
+
/*
|
1098
|
+
* Base function for getting storage charasteristics
|
1099
|
+
*/
|
1100
|
+
static VALUE
|
1101
|
+
slob_specget(VALUE self, slob_option_t option)
|
1102
|
+
{
|
1103
|
+
slob_t *slob;
|
1104
|
+
mint ret;
|
1105
|
+
ifx_lo_stat_t *stat;
|
1106
|
+
ifx_lo_create_spec_t *spec;
|
1107
|
+
ifx_int8_t int8;
|
1108
|
+
char buffer[129];
|
1109
|
+
VALUE item;
|
1110
|
+
/*
|
1111
|
+
* EXEC SQL begin declare section;
|
1112
|
+
*/
|
1113
|
+
#line 915 "informix.ec"
|
1114
|
+
#line 916 "informix.ec"
|
1115
|
+
char *did;
|
1116
|
+
/*
|
1117
|
+
* EXEC SQL end declare section;
|
1118
|
+
*/
|
1119
|
+
#line 917 "informix.ec"
|
1120
|
+
|
1121
|
+
|
1122
|
+
Data_Get_Struct(self, slob_t, slob);
|
1123
|
+
|
1124
|
+
if (slob->fd == -1)
|
1125
|
+
rb_raise(rb_eRuntimeError, "Open the Slob object first");
|
1126
|
+
|
1127
|
+
did = slob->database_id;
|
1128
|
+
/*
|
1129
|
+
* EXEC SQL set connection :did;
|
1130
|
+
*/
|
1131
|
+
#line 925 "informix.ec"
|
1132
|
+
{
|
1133
|
+
#line 925 "informix.ec"
|
1134
|
+
sqli_connect_set(0, did, 0);
|
1135
|
+
#line 925 "informix.ec"
|
1136
|
+
}
|
1137
|
+
if (SQLCODE < 0)
|
1138
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
1139
|
+
|
1140
|
+
ret = ifx_lo_stat(slob->fd, &stat);
|
1141
|
+
if (ret < 0)
|
1142
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
|
1143
|
+
|
1144
|
+
spec = ifx_lo_stat_cspec(stat);
|
1145
|
+
if (spec == NULL) {
|
1146
|
+
ifx_lo_stat_free(stat);
|
1147
|
+
rb_raise(rb_eRuntimeError, "Unable to get storage characteristics");
|
1148
|
+
}
|
1149
|
+
|
1150
|
+
switch(option) {
|
1151
|
+
case slob_estbytes:
|
1152
|
+
ret = ifx_lo_specget_estbytes(spec, &int8);
|
1153
|
+
break;
|
1154
|
+
case slob_extsz:
|
1155
|
+
ret = ifx_lo_specget_extsz(spec);
|
1156
|
+
break;
|
1157
|
+
case slob_flags:
|
1158
|
+
ret = ifx_lo_specget_flags(spec);
|
1159
|
+
break;
|
1160
|
+
case slob_maxbytes:
|
1161
|
+
ret = ifx_lo_specget_maxbytes(spec, &int8);
|
1162
|
+
break;
|
1163
|
+
case slob_sbspace:
|
1164
|
+
ret = ifx_lo_specget_sbspace(spec, buffer, sizeof(buffer));
|
1165
|
+
}
|
1166
|
+
|
1167
|
+
ifx_lo_stat_free(stat);
|
1168
|
+
if (ret == -1)
|
1169
|
+
rb_raise(rb_eRuntimeError, "Unable to get information for %s", str_slob_options[option]);
|
1170
|
+
|
1171
|
+
switch(option) {
|
1172
|
+
case slob_estbytes:
|
1173
|
+
case slob_maxbytes:
|
1174
|
+
INT82NUM(&int8, item);
|
1175
|
+
return item;
|
1176
|
+
case slob_extsz:
|
1177
|
+
case slob_flags:
|
1178
|
+
return INT2FIX(ret);
|
1179
|
+
case slob_sbspace:
|
1180
|
+
return rb_str_new2(buffer);
|
1181
|
+
}
|
1182
|
+
|
1183
|
+
return Qnil; /* Not reached */
|
1184
|
+
}
|
1185
|
+
|
1186
|
+
/*
|
1187
|
+
* Base function for setting extsz and flags
|
1188
|
+
*/
|
1189
|
+
static VALUE
|
1190
|
+
slob_specset(VALUE self, slob_option_t option, VALUE value)
|
1191
|
+
{
|
1192
|
+
slob_t *slob;
|
1193
|
+
mint ret;
|
1194
|
+
ifx_lo_stat_t *stat;
|
1195
|
+
ifx_lo_create_spec_t *spec;
|
1196
|
+
/*
|
1197
|
+
* EXEC SQL begin declare section;
|
1198
|
+
*/
|
1199
|
+
#line 985 "informix.ec"
|
1200
|
+
#line 986 "informix.ec"
|
1201
|
+
char *did;
|
1202
|
+
/*
|
1203
|
+
* EXEC SQL end declare section;
|
1204
|
+
*/
|
1205
|
+
#line 987 "informix.ec"
|
1206
|
+
|
1207
|
+
|
1208
|
+
Data_Get_Struct(self, slob_t, slob);
|
1209
|
+
|
1210
|
+
if (slob->fd == -1)
|
1211
|
+
rb_raise(rb_eRuntimeError, "Open the Slob object first");
|
1212
|
+
|
1213
|
+
did = slob->database_id;
|
1214
|
+
/*
|
1215
|
+
* EXEC SQL set connection :did;
|
1216
|
+
*/
|
1217
|
+
#line 995 "informix.ec"
|
1218
|
+
{
|
1219
|
+
#line 995 "informix.ec"
|
1220
|
+
sqli_connect_set(0, did, 0);
|
1221
|
+
#line 995 "informix.ec"
|
1222
|
+
}
|
1223
|
+
if (SQLCODE < 0)
|
1224
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
1225
|
+
|
1226
|
+
ret = ifx_lo_stat(slob->fd, &stat);
|
1227
|
+
if (ret < 0)
|
1228
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
|
1229
|
+
|
1230
|
+
spec = ifx_lo_stat_cspec(stat);
|
1231
|
+
if (spec == NULL) {
|
1232
|
+
ifx_lo_stat_free(stat);
|
1233
|
+
rb_raise(rb_eRuntimeError, "Unable to get storage characteristics");
|
1234
|
+
}
|
1235
|
+
|
1236
|
+
switch(option) {
|
1237
|
+
case slob_extsz:
|
1238
|
+
ret = ifx_lo_specset_extsz(spec, FIX2INT(value));
|
1239
|
+
break;
|
1240
|
+
case slob_flags:
|
1241
|
+
ret = ifx_lo_specset_flags(spec, FIX2INT(value));
|
1242
|
+
break;
|
1243
|
+
default:
|
1244
|
+
break; /* Not reached */
|
1245
|
+
}
|
1246
|
+
|
1247
|
+
ifx_lo_stat_free(stat);
|
1248
|
+
if (ret == -1)
|
1249
|
+
rb_raise(rb_eRuntimeError, "Unable to set information for %s", str_slob_options[option]);
|
1250
|
+
|
1251
|
+
return value;
|
1252
|
+
}
|
1253
|
+
|
1254
|
+
/*
|
1255
|
+
* call-seq:
|
1256
|
+
* slob.estbytes => fixnum or bignum
|
1257
|
+
*
|
1258
|
+
* Returns the estimated size of the SLOB
|
1259
|
+
*/
|
1260
|
+
static VALUE
|
1261
|
+
rb_slob_estbytes(VALUE self)
|
1262
|
+
{
|
1263
|
+
return slob_specget(self, slob_estbytes);
|
1264
|
+
}
|
1265
|
+
|
1266
|
+
/*
|
1267
|
+
* call-seq:
|
1268
|
+
* slob.extsz => fixnum
|
1269
|
+
*
|
1270
|
+
* Returns the allocation extent size of the SLOB
|
1271
|
+
*/
|
1272
|
+
static VALUE
|
1273
|
+
rb_slob_extsz(VALUE self)
|
1274
|
+
{
|
1275
|
+
return slob_specget(self, slob_extsz);
|
1276
|
+
}
|
1277
|
+
|
1278
|
+
/*
|
1279
|
+
* call-seq:
|
1280
|
+
* slob.flags => fixnum
|
1281
|
+
*
|
1282
|
+
* Returns the create-time flags of the SLOB
|
1283
|
+
*/
|
1284
|
+
static VALUE
|
1285
|
+
rb_slob_flags(VALUE self)
|
1286
|
+
{
|
1287
|
+
return slob_specget(self, slob_flags);
|
1288
|
+
}
|
1289
|
+
|
1290
|
+
/*
|
1291
|
+
* call-seq:
|
1292
|
+
* slob.maxbytes => fixnum or bignum
|
1293
|
+
*
|
1294
|
+
* Returns the maximum size of the SLOB
|
1295
|
+
*/
|
1296
|
+
static VALUE
|
1297
|
+
rb_slob_maxbytes(VALUE self)
|
1298
|
+
{
|
1299
|
+
return slob_specget(self, slob_maxbytes);
|
1300
|
+
}
|
1301
|
+
|
1302
|
+
/*
|
1303
|
+
* call-seq:
|
1304
|
+
* slob.sbspace => string
|
1305
|
+
*
|
1306
|
+
* Returns the name of the sbspace where the SLOB is stored
|
1307
|
+
*/
|
1308
|
+
static VALUE
|
1309
|
+
rb_slob_sbspace(VALUE self)
|
1310
|
+
{
|
1311
|
+
return slob_specget(self, slob_sbspace);
|
1312
|
+
}
|
1313
|
+
|
1314
|
+
/*
|
1315
|
+
* call-seq:
|
1316
|
+
* slob.extsz = fixnum => fixnum
|
1317
|
+
*
|
1318
|
+
* Sets the allocation extent size for the SLOB
|
1319
|
+
*/
|
1320
|
+
static VALUE
|
1321
|
+
rb_slob_set_extsz(VALUE self, VALUE value)
|
1322
|
+
{
|
1323
|
+
return slob_specset(self, slob_extsz, value);
|
1324
|
+
}
|
1325
|
+
|
1326
|
+
/*
|
1327
|
+
* call-seq:
|
1328
|
+
* slob.flags = fixnum => fixnum
|
1329
|
+
*
|
1330
|
+
* Sets the create-time flags of the SLOB
|
1331
|
+
*/
|
1332
|
+
static VALUE
|
1333
|
+
rb_slob_set_flags(VALUE self, VALUE value)
|
1334
|
+
{
|
1335
|
+
return slob_specset(self, slob_flags, value);
|
1336
|
+
}
|
1337
|
+
|
1338
|
+
typedef enum { slob_atime, slob_ctime, slob_mtime, slob_refcnt, slob_size } slob_stat_t;
|
1339
|
+
static char *str_slob_stats[] = {
|
1340
|
+
"atime", "ctime", "mtime", "refcnt", "size"
|
1341
|
+
};
|
1342
|
+
|
1343
|
+
/*
|
1344
|
+
* Base function for getting status information
|
1345
|
+
*/
|
1346
|
+
static VALUE
|
1347
|
+
slob_stat(VALUE self, slob_stat_t stat)
|
1348
|
+
{
|
1349
|
+
mint ret;
|
1350
|
+
slob_t *slob;
|
1351
|
+
ifx_lo_stat_t *st;
|
1352
|
+
ifx_int8_t int8;
|
1353
|
+
VALUE result;
|
1354
|
+
/*
|
1355
|
+
* EXEC SQL begin declare section;
|
1356
|
+
*/
|
1357
|
+
#line 1127 "informix.ec"
|
1358
|
+
#line 1128 "informix.ec"
|
1359
|
+
char *did;
|
1360
|
+
/*
|
1361
|
+
* EXEC SQL end declare section;
|
1362
|
+
*/
|
1363
|
+
#line 1129 "informix.ec"
|
1364
|
+
|
1365
|
+
|
1366
|
+
Data_Get_Struct(self, slob_t, slob);
|
1367
|
+
|
1368
|
+
if (slob->fd == -1)
|
1369
|
+
rb_raise(rb_eRuntimeError,
|
1370
|
+
"Open the Slob object before getting its status");
|
1371
|
+
|
1372
|
+
did = slob->database_id;
|
1373
|
+
/*
|
1374
|
+
* EXEC SQL set connection :did;
|
1375
|
+
*/
|
1376
|
+
#line 1138 "informix.ec"
|
1377
|
+
{
|
1378
|
+
#line 1138 "informix.ec"
|
1379
|
+
sqli_connect_set(0, did, 0);
|
1380
|
+
#line 1138 "informix.ec"
|
1381
|
+
}
|
1382
|
+
if (SQLCODE < 0)
|
1383
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
1384
|
+
|
1385
|
+
ret = ifx_lo_stat(slob->fd, &st);
|
1386
|
+
|
1387
|
+
if (ret < 0)
|
1388
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
|
1389
|
+
|
1390
|
+
switch(stat) {
|
1391
|
+
case slob_atime:
|
1392
|
+
ret = ifx_lo_stat_atime(st);
|
1393
|
+
break;
|
1394
|
+
case slob_ctime:
|
1395
|
+
ret = ifx_lo_stat_ctime(st);
|
1396
|
+
break;
|
1397
|
+
case slob_mtime:
|
1398
|
+
ret = ifx_lo_stat_mtime_sec(st);
|
1399
|
+
break;
|
1400
|
+
case slob_refcnt:
|
1401
|
+
ret = ifx_lo_stat_refcnt(st);
|
1402
|
+
break;
|
1403
|
+
case slob_size:
|
1404
|
+
ret = ifx_lo_stat_size(st, &int8);
|
1405
|
+
}
|
1406
|
+
|
1407
|
+
ifx_lo_stat_free(st);
|
1408
|
+
|
1409
|
+
if (ret == -1)
|
1410
|
+
rb_raise(rb_eRuntimeError, "Unable to get value of %s", str_slob_stats[stat]);
|
1411
|
+
|
1412
|
+
switch(stat) {
|
1413
|
+
case slob_atime:
|
1414
|
+
case slob_ctime:
|
1415
|
+
case slob_mtime:
|
1416
|
+
return rb_time_new(ret, 0);
|
1417
|
+
case slob_refcnt:
|
1418
|
+
return INT2FIX(ret);
|
1419
|
+
case slob_size:
|
1420
|
+
INT82NUM(&int8, result);
|
1421
|
+
return result;
|
1422
|
+
}
|
1423
|
+
|
1424
|
+
return Qnil; /* Not reached */
|
1425
|
+
}
|
1426
|
+
|
1427
|
+
/*
|
1428
|
+
* call-seq:
|
1429
|
+
* slob.atime => time
|
1430
|
+
*
|
1431
|
+
* Returns the time of last access as a Time object.
|
1432
|
+
*/
|
1433
|
+
static VALUE
|
1434
|
+
rb_slob_atime(VALUE self)
|
1435
|
+
{
|
1436
|
+
return slob_stat(self, slob_atime);
|
1437
|
+
}
|
1438
|
+
|
1439
|
+
/*
|
1440
|
+
* call-seq:
|
1441
|
+
* stat.ctime => time
|
1442
|
+
*
|
1443
|
+
* Returns the time of last change in status as a Time object.
|
1444
|
+
*/
|
1445
|
+
static VALUE
|
1446
|
+
rb_slob_ctime(VALUE self)
|
1447
|
+
{
|
1448
|
+
return slob_stat(self, slob_ctime);
|
1449
|
+
}
|
1450
|
+
|
1451
|
+
/*
|
1452
|
+
* call-seq:
|
1453
|
+
* stat.mtime => time
|
1454
|
+
*
|
1455
|
+
* Returns the time of last modification as a Time object.
|
1456
|
+
*/
|
1457
|
+
static VALUE
|
1458
|
+
rb_slob_mtime(VALUE self)
|
1459
|
+
{
|
1460
|
+
return slob_stat(self, slob_mtime);
|
1461
|
+
}
|
1462
|
+
|
1463
|
+
/*
|
1464
|
+
* call-seq:
|
1465
|
+
* stat.refcnt => fixnum
|
1466
|
+
*
|
1467
|
+
* Returns the number of references
|
1468
|
+
*/
|
1469
|
+
static VALUE
|
1470
|
+
rb_slob_refcnt(VALUE self)
|
1471
|
+
{
|
1472
|
+
return slob_stat(self, slob_refcnt);
|
1473
|
+
}
|
1474
|
+
|
1475
|
+
/*
|
1476
|
+
* call-seq:
|
1477
|
+
* stat.size => fixnum or bignum
|
1478
|
+
*
|
1479
|
+
* Returns the size in bytes
|
1480
|
+
*/
|
1481
|
+
static VALUE
|
1482
|
+
rb_slob_size(VALUE self)
|
1483
|
+
{
|
1484
|
+
return slob_stat(self, slob_size);
|
708
1485
|
}
|
709
1486
|
|
710
1487
|
/* Helper functions ------------------------------------------------------- */
|
@@ -712,7 +1489,8 @@ slob_truncate(VALUE self, VALUE offset)
|
|
712
1489
|
/*
|
713
1490
|
* Counts the number of markers '?' in the query
|
714
1491
|
*/
|
715
|
-
static int
|
1492
|
+
static int
|
1493
|
+
count_markers(const char *query)
|
716
1494
|
{
|
717
1495
|
register char c, quote = 0;
|
718
1496
|
register int count = 0;
|
@@ -992,6 +1770,16 @@ bind_input_params(cursor_t *c, VALUE *argv)
|
|
992
1770
|
*var->sqlind = 0;
|
993
1771
|
break;
|
994
1772
|
}
|
1773
|
+
if (klass == rb_cBigDecimal) {
|
1774
|
+
data = rb_funcall(data, s_to_s, 0);
|
1775
|
+
var->sqldata = (char *)ALLOC(dec_t);
|
1776
|
+
deccvasc(RSTRING(data)->ptr, RSTRING(data)->len,
|
1777
|
+
(dec_t *)var->sqldata);
|
1778
|
+
var->sqltype = CDECIMALTYPE;
|
1779
|
+
var->sqllen = sizeof(dec_t);
|
1780
|
+
*var->sqlind = 0;
|
1781
|
+
break;
|
1782
|
+
}
|
995
1783
|
if (rb_respond_to(data, s_read)) {
|
996
1784
|
char *str;
|
997
1785
|
loc_t *loc;
|
@@ -1153,9 +1941,17 @@ make_result(cursor_t *c, VALUE record)
|
|
1153
1941
|
}
|
1154
1942
|
case SQLDECIMAL:
|
1155
1943
|
case SQLMONEY: {
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1944
|
+
char buffer[40];
|
1945
|
+
mint ret;
|
1946
|
+
|
1947
|
+
ret = dectoasc((dec_t *)var->sqldata, buffer,
|
1948
|
+
sizeof(buffer) - 1, -1);
|
1949
|
+
if (ret)
|
1950
|
+
rb_raise(rb_eRuntimeError,
|
1951
|
+
"Unable to convert DECIMAL to BigDecimal");
|
1952
|
+
|
1953
|
+
buffer[sizeof(buffer) - 1] = 0;
|
1954
|
+
item = rb_funcall(rb_cBigDecimal, s_new, 1, rb_str_new2(buffer));
|
1159
1955
|
break;
|
1160
1956
|
}
|
1161
1957
|
case SQLBOOL:
|
@@ -1176,6 +1972,8 @@ make_result(cursor_t *c, VALUE record)
|
|
1176
1972
|
Data_Get_Struct(item, slob_t, slob);
|
1177
1973
|
memcpy(&slob->lo, var->sqldata, sizeof(ifx_lo_t));
|
1178
1974
|
slob->type = var->sqlxid;
|
1975
|
+
slob->database_id = c->database_id;
|
1976
|
+
slob->db = c->db;
|
1179
1977
|
break;
|
1180
1978
|
}
|
1181
1979
|
case SQLSET:
|
@@ -1210,16 +2008,22 @@ make_result(cursor_t *c, VALUE record)
|
|
1210
2008
|
|
1211
2009
|
/*
|
1212
2010
|
* call-seq:
|
1213
|
-
* Informix.connect(dbname, user
|
2011
|
+
* Informix.connect(dbname, user=nil, password=nil) => database
|
2012
|
+
* Informix.connect(dbname, user=nil, password=nil) {|database| block } => obj
|
1214
2013
|
*
|
1215
|
-
*
|
2014
|
+
* Creates a <code>Database</code> object connected to <i>dbname</i> as
|
1216
2015
|
* <i>user</i> with <i>password</i>. If these are not given, connects to
|
1217
2016
|
* <i>dbname</i> as the current user.
|
2017
|
+
*
|
2018
|
+
* The Database object is passed to the block if it's given, and automatically
|
2019
|
+
* closes the connection when the block terminates, returning the value of
|
2020
|
+
* the block.
|
1218
2021
|
*/
|
2022
|
+
static VALUE rb_database_s_open(int argc, VALUE *argv, VALUE klass);
|
1219
2023
|
static VALUE
|
1220
2024
|
informix_connect(int argc, VALUE *argv, VALUE self)
|
1221
2025
|
{
|
1222
|
-
return
|
2026
|
+
return rb_database_s_open(argc, argv, rb_cDatabase);
|
1223
2027
|
}
|
1224
2028
|
|
1225
2029
|
|
@@ -1231,27 +2035,25 @@ database_free(void *p)
|
|
1231
2035
|
/*
|
1232
2036
|
* EXEC SQL begin declare section;
|
1233
2037
|
*/
|
1234
|
-
#line
|
1235
|
-
#line
|
2038
|
+
#line 1792 "informix.ec"
|
2039
|
+
#line 1793 "informix.ec"
|
1236
2040
|
char *did;
|
1237
2041
|
/*
|
1238
2042
|
* EXEC SQL end declare section;
|
1239
2043
|
*/
|
1240
|
-
#line
|
2044
|
+
#line 1794 "informix.ec"
|
1241
2045
|
|
1242
2046
|
|
1243
2047
|
did = p;
|
1244
2048
|
/*
|
1245
2049
|
* EXEC SQL disconnect :did;
|
1246
2050
|
*/
|
1247
|
-
#line
|
2051
|
+
#line 1797 "informix.ec"
|
1248
2052
|
{
|
1249
|
-
#line
|
2053
|
+
#line 1797 "informix.ec"
|
1250
2054
|
sqli_connect_close(0, did, 0, 0);
|
1251
|
-
#line
|
2055
|
+
#line 1797 "informix.ec"
|
1252
2056
|
}
|
1253
|
-
if (currentdid == did)
|
1254
|
-
currentdid = NULL;
|
1255
2057
|
xfree(p);
|
1256
2058
|
}
|
1257
2059
|
|
@@ -1260,34 +2062,26 @@ database_alloc(VALUE klass)
|
|
1260
2062
|
{
|
1261
2063
|
char *did;
|
1262
2064
|
|
1263
|
-
did = ALLOC_N(char, IDSIZE);
|
1264
|
-
did[0] = 0;
|
2065
|
+
did = ALLOC_N(char, IDSIZE<<1);
|
2066
|
+
did[0] = did[IDSIZE] = 0;
|
1265
2067
|
return Data_Wrap_Struct(klass, 0, database_free, did);
|
1266
2068
|
}
|
1267
2069
|
|
1268
|
-
/*
|
1269
|
-
* call-seq:
|
1270
|
-
* Database.new(dbname, user = nil, password = nil) => database
|
1271
|
-
*
|
1272
|
-
* Returns a <code>Database</code> object connected to <i>dbname</i> as
|
1273
|
-
* <i>user</i> with <i>password</i>. If these are not given, connects to
|
1274
|
-
* <i>dbname</i> as the current user.
|
1275
|
-
*/
|
1276
2070
|
static VALUE
|
1277
|
-
|
2071
|
+
rb_database_initialize(int argc, VALUE *argv, VALUE self)
|
1278
2072
|
{
|
1279
2073
|
VALUE arg[3];
|
1280
2074
|
|
1281
2075
|
/*
|
1282
2076
|
* EXEC SQL begin declare section;
|
1283
2077
|
*/
|
1284
|
-
#line
|
1285
|
-
#line
|
2078
|
+
#line 1816 "informix.ec"
|
2079
|
+
#line 1817 "informix.ec"
|
1286
2080
|
char *dbname, *user = NULL, *pass = NULL, *did;
|
1287
2081
|
/*
|
1288
2082
|
* EXEC SQL end declare section;
|
1289
2083
|
*/
|
1290
|
-
#line
|
2084
|
+
#line 1818 "informix.ec"
|
1291
2085
|
|
1292
2086
|
|
1293
2087
|
rb_scan_args(argc, argv, "12", &arg[0], &arg[1], &arg[2]);
|
@@ -1311,34 +2105,61 @@ database_initialize(int argc, VALUE *argv, VALUE self)
|
|
1311
2105
|
* EXEC SQL connect to :dbname as :did user :user
|
1312
2106
|
* using :pass with concurrent transaction;
|
1313
2107
|
*/
|
1314
|
-
#line
|
2108
|
+
#line 1837 "informix.ec"
|
1315
2109
|
{
|
1316
|
-
#line
|
2110
|
+
#line 1838 "informix.ec"
|
1317
2111
|
ifx_conn_t *_sqiconn;
|
1318
2112
|
_sqiconn = (ifx_conn_t *)ifx_alloc_conn_user(user, pass);
|
1319
2113
|
sqli_connect_open(ESQLINTVERSION, 0, dbname, did, _sqiconn, 1);
|
1320
2114
|
ifx_free_conn_user(&_sqiconn);
|
1321
|
-
#line
|
2115
|
+
#line 1838 "informix.ec"
|
1322
2116
|
}
|
1323
2117
|
else
|
1324
2118
|
/*
|
1325
2119
|
* EXEC SQL connect to :dbname as :did with concurrent transaction;
|
1326
2120
|
*/
|
1327
|
-
#line
|
2121
|
+
#line 1840 "informix.ec"
|
1328
2122
|
{
|
1329
|
-
#line
|
2123
|
+
#line 1840 "informix.ec"
|
1330
2124
|
sqli_connect_open(ESQLINTVERSION, 0, dbname, did, (ifx_conn_t *)0, 1);
|
1331
|
-
#line
|
2125
|
+
#line 1840 "informix.ec"
|
1332
2126
|
}
|
1333
2127
|
|
1334
2128
|
if (SQLCODE < 0)
|
1335
2129
|
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
1336
2130
|
|
1337
|
-
currentdid = did;
|
1338
|
-
|
1339
2131
|
return self;
|
1340
2132
|
}
|
1341
2133
|
|
2134
|
+
/*
|
2135
|
+
* call-seq:
|
2136
|
+
* Database.new(dbname, user = nil, password = nil) => database
|
2137
|
+
* Database.open(dbname, user = nil, password = nil) => database
|
2138
|
+
* Database.new(dbname, user = nil, password = nil) {|database| block } => obj
|
2139
|
+
* Database.open(dbname, user = nil, password = nil) {|database| block } => obj
|
2140
|
+
*
|
2141
|
+
* Creates a <code>Database</code> object connected to <i>dbname</i> as
|
2142
|
+
* <i>user</i> with <i>password</i>. If these are not given, connects to
|
2143
|
+
* <i>dbname</i> as the current user.
|
2144
|
+
*
|
2145
|
+
* The Database object is passed to the block if it's given, and automatically
|
2146
|
+
* closes the connection when the block terminates, returning the value of
|
2147
|
+
* the block.
|
2148
|
+
*/
|
2149
|
+
static VALUE rb_database_close(VALUE self);
|
2150
|
+
static VALUE
|
2151
|
+
rb_database_s_open(int argc, VALUE *argv, VALUE klass)
|
2152
|
+
{
|
2153
|
+
VALUE database;
|
2154
|
+
|
2155
|
+
database = rb_class_new_instance(argc, argv, klass);
|
2156
|
+
|
2157
|
+
if (rb_block_given_p())
|
2158
|
+
return rb_ensure(rb_yield, database, rb_database_close, database);
|
2159
|
+
|
2160
|
+
return database;
|
2161
|
+
}
|
2162
|
+
|
1342
2163
|
/*
|
1343
2164
|
* call-seq:
|
1344
2165
|
* db.close => db
|
@@ -1346,32 +2167,42 @@ database_initialize(int argc, VALUE *argv, VALUE self)
|
|
1346
2167
|
* Disconnects <i>db</i> and returns __self__
|
1347
2168
|
*/
|
1348
2169
|
static VALUE
|
1349
|
-
|
2170
|
+
rb_database_close(VALUE self)
|
1350
2171
|
{
|
1351
2172
|
/*
|
1352
2173
|
* EXEC SQL begin declare section;
|
1353
2174
|
*/
|
1354
|
-
#line
|
1355
|
-
#line
|
2175
|
+
#line 1886 "informix.ec"
|
2176
|
+
#line 1887 "informix.ec"
|
1356
2177
|
char *did;
|
1357
2178
|
/*
|
1358
2179
|
* EXEC SQL end declare section;
|
1359
2180
|
*/
|
1360
|
-
#line
|
2181
|
+
#line 1888 "informix.ec"
|
1361
2182
|
|
1362
2183
|
|
1363
2184
|
Data_Get_Struct(self, char, did);
|
2185
|
+
did += IDSIZE;
|
2186
|
+
if (*did)
|
2187
|
+
/*
|
2188
|
+
* EXEC SQL free :did;
|
2189
|
+
*/
|
2190
|
+
#line 1893 "informix.ec"
|
2191
|
+
{
|
2192
|
+
#line 1893 "informix.ec"
|
2193
|
+
sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, did, 258));
|
2194
|
+
#line 1893 "informix.ec"
|
2195
|
+
}
|
2196
|
+
did -= IDSIZE;
|
1364
2197
|
/*
|
1365
2198
|
* EXEC SQL disconnect :did;
|
1366
2199
|
*/
|
1367
|
-
#line
|
2200
|
+
#line 1895 "informix.ec"
|
1368
2201
|
{
|
1369
|
-
#line
|
2202
|
+
#line 1895 "informix.ec"
|
1370
2203
|
sqli_connect_close(0, did, 0, 0);
|
1371
|
-
#line
|
2204
|
+
#line 1895 "informix.ec"
|
1372
2205
|
}
|
1373
|
-
if (did == currentdid)
|
1374
|
-
currentdid = NULL;
|
1375
2206
|
|
1376
2207
|
return self;
|
1377
2208
|
}
|
@@ -1386,46 +2217,43 @@ database_close(VALUE self)
|
|
1386
2217
|
*/
|
1387
2218
|
|
1388
2219
|
static VALUE
|
1389
|
-
|
2220
|
+
rb_database_immediate(VALUE self, VALUE arg)
|
1390
2221
|
{
|
1391
2222
|
/*
|
1392
2223
|
* EXEC SQL begin declare section;
|
1393
2224
|
*/
|
1394
|
-
#line
|
1395
|
-
#line
|
2225
|
+
#line 1912 "informix.ec"
|
2226
|
+
#line 1913 "informix.ec"
|
1396
2227
|
char *query, *did;
|
1397
2228
|
/*
|
1398
2229
|
* EXEC SQL end declare section;
|
1399
2230
|
*/
|
1400
|
-
#line
|
2231
|
+
#line 1914 "informix.ec"
|
1401
2232
|
|
1402
2233
|
|
1403
2234
|
Data_Get_Struct(self, char, did);
|
1404
2235
|
|
1405
|
-
if (currentdid != did) {
|
1406
2236
|
/*
|
1407
|
-
*
|
2237
|
+
* EXEC SQL set connection :did;
|
1408
2238
|
*/
|
1409
|
-
#line
|
2239
|
+
#line 1918 "informix.ec"
|
1410
2240
|
{
|
1411
|
-
#line
|
2241
|
+
#line 1918 "informix.ec"
|
1412
2242
|
sqli_connect_set(0, did, 0);
|
1413
|
-
#line
|
2243
|
+
#line 1918 "informix.ec"
|
1414
2244
|
}
|
1415
|
-
|
1416
|
-
|
1417
|
-
currentdid = did;
|
1418
|
-
}
|
2245
|
+
if (SQLCODE < 0)
|
2246
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
1419
2247
|
|
1420
2248
|
query = StringValueCStr(arg);
|
1421
2249
|
/*
|
1422
2250
|
* EXEC SQL execute immediate :query;
|
1423
2251
|
*/
|
1424
|
-
#line
|
2252
|
+
#line 1923 "informix.ec"
|
1425
2253
|
{
|
1426
|
-
#line
|
2254
|
+
#line 1923 "informix.ec"
|
1427
2255
|
sqli_exec_immed(query);
|
1428
|
-
#line
|
2256
|
+
#line 1923 "informix.ec"
|
1429
2257
|
}
|
1430
2258
|
if (SQLCODE < 0)
|
1431
2259
|
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
@@ -1440,45 +2268,42 @@ database_immediate(VALUE self, VALUE arg)
|
|
1440
2268
|
* Rolls back a transaction and returns __self__.
|
1441
2269
|
*/
|
1442
2270
|
static VALUE
|
1443
|
-
|
2271
|
+
rb_database_rollback(VALUE self)
|
1444
2272
|
{
|
1445
2273
|
/*
|
1446
2274
|
* EXEC SQL begin declare section;
|
1447
2275
|
*/
|
1448
|
-
#line
|
1449
|
-
#line
|
2276
|
+
#line 1939 "informix.ec"
|
2277
|
+
#line 1940 "informix.ec"
|
1450
2278
|
char *did;
|
1451
2279
|
/*
|
1452
2280
|
* EXEC SQL end declare section;
|
1453
2281
|
*/
|
1454
|
-
#line
|
2282
|
+
#line 1941 "informix.ec"
|
1455
2283
|
|
1456
2284
|
|
1457
2285
|
Data_Get_Struct(self, char, did);
|
1458
2286
|
|
1459
|
-
if (currentdid != did) {
|
1460
2287
|
/*
|
1461
|
-
*
|
2288
|
+
* EXEC SQL set connection :did;
|
1462
2289
|
*/
|
1463
|
-
#line
|
2290
|
+
#line 1945 "informix.ec"
|
1464
2291
|
{
|
1465
|
-
#line
|
2292
|
+
#line 1945 "informix.ec"
|
1466
2293
|
sqli_connect_set(0, did, 0);
|
1467
|
-
#line
|
2294
|
+
#line 1945 "informix.ec"
|
1468
2295
|
}
|
1469
|
-
|
1470
|
-
|
1471
|
-
currentdid = did;
|
1472
|
-
}
|
2296
|
+
if (SQLCODE < 0)
|
2297
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
1473
2298
|
|
1474
2299
|
/*
|
1475
2300
|
* EXEC SQL rollback;
|
1476
2301
|
*/
|
1477
|
-
#line
|
2302
|
+
#line 1949 "informix.ec"
|
1478
2303
|
{
|
1479
|
-
#line
|
2304
|
+
#line 1949 "informix.ec"
|
1480
2305
|
sqli_trans_rollback();
|
1481
|
-
#line
|
2306
|
+
#line 1949 "informix.ec"
|
1482
2307
|
}
|
1483
2308
|
return self;
|
1484
2309
|
}
|
@@ -1490,45 +2315,42 @@ database_rollback(VALUE self)
|
|
1490
2315
|
* Commits a transaction and returns __self__.
|
1491
2316
|
*/
|
1492
2317
|
static VALUE
|
1493
|
-
|
2318
|
+
rb_database_commit(VALUE self)
|
1494
2319
|
{
|
1495
2320
|
/*
|
1496
2321
|
* EXEC SQL begin declare section;
|
1497
2322
|
*/
|
1498
|
-
#line
|
1499
|
-
#line
|
2323
|
+
#line 1962 "informix.ec"
|
2324
|
+
#line 1963 "informix.ec"
|
1500
2325
|
char *did;
|
1501
2326
|
/*
|
1502
2327
|
* EXEC SQL end declare section;
|
1503
2328
|
*/
|
1504
|
-
#line
|
2329
|
+
#line 1964 "informix.ec"
|
1505
2330
|
|
1506
2331
|
|
1507
2332
|
Data_Get_Struct(self, char, did);
|
1508
2333
|
|
1509
|
-
if (currentdid != did) {
|
1510
2334
|
/*
|
1511
|
-
*
|
2335
|
+
* EXEC SQL set connection :did;
|
1512
2336
|
*/
|
1513
|
-
#line
|
2337
|
+
#line 1968 "informix.ec"
|
1514
2338
|
{
|
1515
|
-
#line
|
2339
|
+
#line 1968 "informix.ec"
|
1516
2340
|
sqli_connect_set(0, did, 0);
|
1517
|
-
#line
|
2341
|
+
#line 1968 "informix.ec"
|
1518
2342
|
}
|
1519
|
-
|
1520
|
-
|
1521
|
-
currentdid = did;
|
1522
|
-
}
|
2343
|
+
if (SQLCODE < 0)
|
2344
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
1523
2345
|
|
1524
2346
|
/*
|
1525
2347
|
* EXEC SQL commit;
|
1526
2348
|
*/
|
1527
|
-
#line
|
2349
|
+
#line 1972 "informix.ec"
|
1528
2350
|
{
|
1529
|
-
#line
|
2351
|
+
#line 1972 "informix.ec"
|
1530
2352
|
sqli_trans_commit();
|
1531
|
-
#line
|
2353
|
+
#line 1972 "informix.ec"
|
1532
2354
|
}
|
1533
2355
|
return self;
|
1534
2356
|
}
|
@@ -1536,7 +2358,7 @@ database_commit(VALUE self)
|
|
1536
2358
|
static VALUE
|
1537
2359
|
database_transfail(VALUE self)
|
1538
2360
|
{
|
1539
|
-
|
2361
|
+
rb_database_rollback(self);
|
1540
2362
|
return Qundef;
|
1541
2363
|
}
|
1542
2364
|
|
@@ -1551,56 +2373,53 @@ database_transfail(VALUE self)
|
|
1551
2373
|
* Returns __self__.
|
1552
2374
|
*/
|
1553
2375
|
static VALUE
|
1554
|
-
|
2376
|
+
rb_database_transaction(VALUE self)
|
1555
2377
|
{
|
1556
2378
|
VALUE ret;
|
1557
2379
|
/*
|
1558
2380
|
* EXEC SQL begin declare section;
|
1559
2381
|
*/
|
1560
|
-
#line
|
1561
|
-
#line
|
2382
|
+
#line 1997 "informix.ec"
|
2383
|
+
#line 1998 "informix.ec"
|
1562
2384
|
char *did;
|
1563
2385
|
/*
|
1564
2386
|
* EXEC SQL end declare section;
|
1565
2387
|
*/
|
1566
|
-
#line
|
2388
|
+
#line 1999 "informix.ec"
|
1567
2389
|
|
1568
2390
|
|
1569
2391
|
Data_Get_Struct(self, char, did);
|
1570
2392
|
|
1571
|
-
if (currentdid != did) {
|
1572
2393
|
/*
|
1573
|
-
*
|
2394
|
+
* EXEC SQL set connection :did;
|
1574
2395
|
*/
|
1575
|
-
#line
|
2396
|
+
#line 2003 "informix.ec"
|
1576
2397
|
{
|
1577
|
-
#line
|
2398
|
+
#line 2003 "informix.ec"
|
1578
2399
|
sqli_connect_set(0, did, 0);
|
1579
|
-
#line
|
2400
|
+
#line 2003 "informix.ec"
|
1580
2401
|
}
|
1581
|
-
|
1582
|
-
|
1583
|
-
currentdid = did;
|
1584
|
-
}
|
2402
|
+
if (SQLCODE < 0)
|
2403
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
1585
2404
|
|
1586
2405
|
/*
|
1587
2406
|
* EXEC SQL commit;
|
1588
2407
|
*/
|
1589
|
-
#line
|
2408
|
+
#line 2007 "informix.ec"
|
1590
2409
|
{
|
1591
|
-
#line
|
2410
|
+
#line 2007 "informix.ec"
|
1592
2411
|
sqli_trans_commit();
|
1593
|
-
#line
|
2412
|
+
#line 2007 "informix.ec"
|
1594
2413
|
}
|
1595
2414
|
|
1596
2415
|
/*
|
1597
2416
|
* EXEC SQL begin work;
|
1598
2417
|
*/
|
1599
|
-
#line
|
2418
|
+
#line 2009 "informix.ec"
|
1600
2419
|
{
|
1601
|
-
#line
|
2420
|
+
#line 2009 "informix.ec"
|
1602
2421
|
sqli_trans_begin2((mint)1);
|
1603
|
-
#line
|
2422
|
+
#line 2009 "informix.ec"
|
1604
2423
|
}
|
1605
2424
|
ret = rb_rescue(rb_yield, self, database_transfail, self);
|
1606
2425
|
if (ret == Qundef)
|
@@ -1608,31 +2427,38 @@ database_transaction(VALUE self)
|
|
1608
2427
|
/*
|
1609
2428
|
* EXEC SQL commit;
|
1610
2429
|
*/
|
1611
|
-
#line
|
2430
|
+
#line 2013 "informix.ec"
|
1612
2431
|
{
|
1613
|
-
#line
|
2432
|
+
#line 2013 "informix.ec"
|
1614
2433
|
sqli_trans_commit();
|
1615
|
-
#line
|
2434
|
+
#line 2013 "informix.ec"
|
1616
2435
|
}
|
1617
2436
|
return self;
|
1618
2437
|
}
|
1619
2438
|
|
1620
2439
|
/*
|
1621
2440
|
* call-seq:
|
1622
|
-
* db.prepare(query)
|
2441
|
+
* db.prepare(query) => statement
|
2442
|
+
* db.prepare(query) {|stmt| block } => obj
|
2443
|
+
*
|
2444
|
+
* Creates a <code>Statement</code> object based on <i>query</i>.
|
2445
|
+
* In the first form the Statement object is returned.
|
2446
|
+
* In the second form the Statement object is passed to the block and when it
|
2447
|
+
* terminates, the Statement object is dropped, returning the value of the
|
2448
|
+
* block.
|
1623
2449
|
*
|
1624
|
-
* Returns a <code>Statement</code> object based on <i>query</i>.
|
1625
2450
|
* <i>query</i> may contain '?' placeholders for input parameters;
|
1626
2451
|
* it must not be a query returning more than one row
|
1627
2452
|
* (use <code>Database#cursor</code> instead.)
|
1628
2453
|
*/
|
2454
|
+
static VALUE statement_s_new(int, VALUE *, VALUE);
|
1629
2455
|
static VALUE
|
1630
|
-
|
2456
|
+
rb_database_prepare(VALUE self, VALUE query)
|
1631
2457
|
{
|
1632
2458
|
VALUE argv[2];
|
1633
2459
|
|
1634
2460
|
argv[0] = self; argv[1] = query;
|
1635
|
-
return
|
2461
|
+
return statement_s_new(2, argv, rb_cStatement);
|
1636
2462
|
}
|
1637
2463
|
|
1638
2464
|
/*
|
@@ -1649,7 +2475,7 @@ database_prepare(VALUE self, VALUE query)
|
|
1649
2475
|
*
|
1650
2476
|
*/
|
1651
2477
|
static VALUE
|
1652
|
-
|
2478
|
+
rb_database_cursor(int argc, VALUE *argv, VALUE self)
|
1653
2479
|
{
|
1654
2480
|
VALUE arg[3];
|
1655
2481
|
|
@@ -1658,6 +2484,37 @@ database_cursor(int argc, VALUE *argv, VALUE self)
|
|
1658
2484
|
return rb_class_new_instance(3, arg, rb_cCursor);
|
1659
2485
|
}
|
1660
2486
|
|
2487
|
+
/*
|
2488
|
+
* call-seq:
|
2489
|
+
* db.slob(type = Slob::CLOB, options = nil) => slob
|
2490
|
+
* db.slob(type = Slob::CLOB, options = nil) {|slob| block } => obj
|
2491
|
+
*
|
2492
|
+
* Creates a Smart Large Object of type <i>type</i>.
|
2493
|
+
* Returns a <code>Slob</code> object pointing to it.
|
2494
|
+
*
|
2495
|
+
* <i>type</i> can be Slob::BLOB or Slob::CLOB
|
2496
|
+
*
|
2497
|
+
* <i>options</i> can be nil or a Hash object with the following possible keys:
|
2498
|
+
*
|
2499
|
+
* :sbspace => Sbspace name
|
2500
|
+
* :estbytes => Estimated size, in bytes
|
2501
|
+
* :extsz => Allocation extent size
|
2502
|
+
* :createflags => Create-time flags
|
2503
|
+
* :openflags => Access mode
|
2504
|
+
* :maxbytes => Maximum size
|
2505
|
+
* :col_info => Get the previous values from the column-level storage
|
2506
|
+
* characteristics for the specified database column
|
2507
|
+
*/
|
2508
|
+
static VALUE
|
2509
|
+
rb_database_slob(int argc, VALUE *argv, VALUE self)
|
2510
|
+
{
|
2511
|
+
VALUE arg[3];
|
2512
|
+
|
2513
|
+
arg[0] = self;
|
2514
|
+
rb_scan_args(argc, argv, "02", &arg[1], &arg[2]);
|
2515
|
+
return rb_slob_s_new(3, arg, rb_cSlob);
|
2516
|
+
}
|
2517
|
+
|
1661
2518
|
/*
|
1662
2519
|
* call-seq:
|
1663
2520
|
* db.columns(tablename) => array
|
@@ -1665,7 +2522,7 @@ database_cursor(int argc, VALUE *argv, VALUE self)
|
|
1665
2522
|
* Returns an array with information for every column of the given table.
|
1666
2523
|
*/
|
1667
2524
|
static VALUE
|
1668
|
-
|
2525
|
+
rb_database_columns(VALUE self, VALUE tablename)
|
1669
2526
|
{
|
1670
2527
|
VALUE v, column, result;
|
1671
2528
|
char *stype;
|
@@ -1684,9 +2541,9 @@ database_columns(VALUE self, VALUE tablename)
|
|
1684
2541
|
/*
|
1685
2542
|
* EXEC SQL begin declare section;
|
1686
2543
|
*/
|
1687
|
-
#line
|
1688
|
-
#line
|
1689
|
-
char *did;
|
2544
|
+
#line 2119 "informix.ec"
|
2545
|
+
#line 2120 "informix.ec"
|
2546
|
+
char *did, *cid;
|
1690
2547
|
char *tabname;
|
1691
2548
|
int tabid, xid;
|
1692
2549
|
char colname[129];
|
@@ -1696,60 +2553,57 @@ short coltype, collength;
|
|
1696
2553
|
/*
|
1697
2554
|
* EXEC SQL end declare section;
|
1698
2555
|
*/
|
1699
|
-
#line
|
2556
|
+
#line 2127 "informix.ec"
|
1700
2557
|
|
1701
2558
|
|
1702
2559
|
Data_Get_Struct(self, char, did);
|
1703
2560
|
|
1704
|
-
if (currentdid != did) {
|
1705
2561
|
/*
|
1706
|
-
*
|
2562
|
+
* EXEC SQL set connection :did;
|
1707
2563
|
*/
|
1708
|
-
#line
|
2564
|
+
#line 2131 "informix.ec"
|
1709
2565
|
{
|
1710
|
-
#line
|
2566
|
+
#line 2131 "informix.ec"
|
1711
2567
|
sqli_connect_set(0, did, 0);
|
1712
|
-
#line
|
2568
|
+
#line 2131 "informix.ec"
|
1713
2569
|
}
|
1714
|
-
|
1715
|
-
|
1716
|
-
currentdid = did;
|
1717
|
-
}
|
2570
|
+
if (SQLCODE < 0)
|
2571
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
1718
2572
|
|
1719
2573
|
tabname = StringValueCStr(tablename);
|
1720
2574
|
|
1721
2575
|
/*
|
1722
2576
|
* EXEC SQL select tabid into :tabid from systables where tabname = :tabname;
|
1723
2577
|
*/
|
1724
|
-
#line
|
2578
|
+
#line 2137 "informix.ec"
|
1725
2579
|
{
|
1726
|
-
#line
|
2580
|
+
#line 2137 "informix.ec"
|
1727
2581
|
static const char *sqlcmdtxt[] =
|
1728
|
-
#line
|
2582
|
+
#line 2137 "informix.ec"
|
1729
2583
|
{
|
1730
|
-
#line
|
2584
|
+
#line 2137 "informix.ec"
|
1731
2585
|
"select tabid from systables where tabname = ?",
|
1732
2586
|
0
|
1733
2587
|
};
|
1734
|
-
#line
|
2588
|
+
#line 2137 "informix.ec"
|
1735
2589
|
static ifx_cursor_t _SQ0 = {0};
|
1736
2590
|
static ifx_sqlvar_t _sqibind[] =
|
1737
2591
|
{
|
1738
2592
|
{ 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
1739
|
-
#line
|
2593
|
+
#line 2137 "informix.ec"
|
1740
2594
|
};
|
1741
2595
|
static ifx_sqlvar_t _sqobind[] =
|
1742
2596
|
{
|
1743
2597
|
{ 102, sizeof(tabid), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
1744
|
-
#line
|
2598
|
+
#line 2137 "informix.ec"
|
1745
2599
|
};
|
1746
|
-
#line
|
2600
|
+
#line 2137 "informix.ec"
|
1747
2601
|
_sqibind[0].sqldata = tabname;
|
1748
|
-
#line
|
2602
|
+
#line 2137 "informix.ec"
|
1749
2603
|
_sqobind[0].sqldata = (char *) &tabid;
|
1750
|
-
#line
|
2604
|
+
#line 2137 "informix.ec"
|
1751
2605
|
sqli_slct(ESQLINTVERSION, &_SQ0,sqlcmdtxt,1,_sqibind,1,_sqobind,0,(ifx_literal_t *)0,(ifx_namelist_t *)0,0);
|
1752
|
-
#line
|
2606
|
+
#line 2137 "informix.ec"
|
1753
2607
|
}
|
1754
2608
|
|
1755
2609
|
if (SQLCODE == SQLNOTFOUND)
|
@@ -1757,60 +2611,67 @@ static ifx_cursor_t _SQ0 = {0};
|
|
1757
2611
|
|
1758
2612
|
result = rb_ary_new();
|
1759
2613
|
|
2614
|
+
cid = did + IDSIZE;
|
2615
|
+
if (!*cid) {
|
2616
|
+
snprintf(cid, IDSIZE, "COLS%lX", self);
|
1760
2617
|
/*
|
1761
|
-
*
|
1762
|
-
*
|
1763
|
-
*
|
1764
|
-
*
|
1765
|
-
*
|
2618
|
+
* EXEC SQL declare :cid cursor for
|
2619
|
+
* select colname, coltype, collength, extended_id,
|
2620
|
+
* type, default, c.colno
|
2621
|
+
* from syscolumns c, outer sysdefaults d
|
2622
|
+
* where c.tabid = :tabid and c.tabid = d.tabid
|
2623
|
+
* and c.colno = d.colno
|
2624
|
+
* order by c.colno;
|
1766
2625
|
*/
|
1767
|
-
#line
|
2626
|
+
#line 2147 "informix.ec"
|
1768
2627
|
{
|
1769
|
-
#line
|
2628
|
+
#line 2153 "informix.ec"
|
1770
2629
|
static const char *sqlcmdtxt[] =
|
1771
|
-
#line
|
2630
|
+
#line 2153 "informix.ec"
|
1772
2631
|
{
|
1773
|
-
#line
|
2632
|
+
#line 2153 "informix.ec"
|
1774
2633
|
"select colname , coltype , collength , extended_id , type , default , c . colno from syscolumns c , outer sysdefaults d where c . tabid = ? and c . tabid = d . tabid and c . colno = d . colno order by c . colno",
|
1775
2634
|
0
|
1776
2635
|
};
|
1777
|
-
#line
|
2636
|
+
#line 2153 "informix.ec"
|
1778
2637
|
static ifx_sqlvar_t _sqibind[] =
|
1779
2638
|
{
|
1780
2639
|
{ 102, sizeof(tabid), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
1781
|
-
#line
|
2640
|
+
#line 2153 "informix.ec"
|
1782
2641
|
};
|
1783
2642
|
static ifx_sqlda_t _SD0 = { 1, _sqibind, {0}, 1, 0 };
|
1784
|
-
#line
|
2643
|
+
#line 2153 "informix.ec"
|
1785
2644
|
_sqibind[0].sqldata = (char *) &tabid;
|
1786
|
-
#line
|
1787
|
-
sqli_curs_decl_stat(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION,
|
1788
|
-
#line
|
2645
|
+
#line 2153 "informix.ec"
|
2646
|
+
sqli_curs_decl_stat(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 0), cid, sqlcmdtxt, &_SD0, (ifx_sqlda_t *)0, 0, (ifx_literal_t *)0, (ifx_namelist_t *)0, 2, 0, 0);
|
2647
|
+
#line 2153 "informix.ec"
|
1789
2648
|
}
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
2649
|
+
if (SQLCODE < 0) {
|
2650
|
+
cid[0] = 0;
|
2651
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
2652
|
+
}
|
2653
|
+
}
|
1793
2654
|
|
1794
2655
|
/*
|
1795
|
-
* EXEC SQL open
|
2656
|
+
* EXEC SQL open :cid;
|
1796
2657
|
*/
|
1797
|
-
#line
|
2658
|
+
#line 2160 "informix.ec"
|
1798
2659
|
{
|
1799
|
-
#line
|
1800
|
-
sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION,
|
1801
|
-
#line
|
2660
|
+
#line 2160 "informix.ec"
|
2661
|
+
sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 0);
|
2662
|
+
#line 2160 "informix.ec"
|
1802
2663
|
}
|
1803
2664
|
if (SQLCODE < 0)
|
1804
2665
|
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
1805
2666
|
|
1806
2667
|
for(;;) {
|
1807
2668
|
/*
|
1808
|
-
* EXEC SQL fetch
|
2669
|
+
* EXEC SQL fetch :cid into :colname, :coltype, :collength, :xid,
|
1809
2670
|
* :deftype, :defvalue;
|
1810
2671
|
*/
|
1811
|
-
#line
|
2672
|
+
#line 2165 "informix.ec"
|
1812
2673
|
{
|
1813
|
-
#line
|
2674
|
+
#line 2166 "informix.ec"
|
1814
2675
|
static ifx_sqlvar_t _sqobind[] =
|
1815
2676
|
{
|
1816
2677
|
{ 114, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
@@ -1819,24 +2680,24 @@ sqli_curs_decl_stat(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 512),
|
|
1819
2680
|
{ 102, sizeof(xid), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
1820
2681
|
{ 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
1821
2682
|
{ 114, 257, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
1822
|
-
#line
|
2683
|
+
#line 2166 "informix.ec"
|
1823
2684
|
};
|
1824
2685
|
static ifx_sqlda_t _SD0 = { 6, _sqobind, {0}, 6, 0 };
|
1825
2686
|
static _FetchSpec _FS1 = { 0, 1, 0 };
|
1826
|
-
#line
|
2687
|
+
#line 2166 "informix.ec"
|
1827
2688
|
_sqobind[0].sqldata = colname;
|
1828
|
-
#line
|
2689
|
+
#line 2166 "informix.ec"
|
1829
2690
|
_sqobind[1].sqldata = (char *) &coltype;
|
1830
|
-
#line
|
2691
|
+
#line 2166 "informix.ec"
|
1831
2692
|
_sqobind[2].sqldata = (char *) &collength;
|
1832
|
-
#line
|
2693
|
+
#line 2166 "informix.ec"
|
1833
2694
|
_sqobind[3].sqldata = (char *) &xid;
|
1834
|
-
#line
|
2695
|
+
#line 2166 "informix.ec"
|
1835
2696
|
_sqobind[4].sqldata = deftype;
|
1836
|
-
#line
|
2697
|
+
#line 2166 "informix.ec"
|
1837
2698
|
_sqobind[5].sqldata = defvalue;
|
1838
|
-
sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION,
|
1839
|
-
#line
|
2699
|
+
sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, &_SD0, (char *)0, &_FS1);
|
2700
|
+
#line 2166 "informix.ec"
|
1840
2701
|
}
|
1841
2702
|
if (SQLCODE < 0)
|
1842
2703
|
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
@@ -1932,22 +2793,13 @@ sqli_curs_decl_stat(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 512),
|
|
1932
2793
|
}
|
1933
2794
|
|
1934
2795
|
/*
|
1935
|
-
* EXEC SQL close
|
1936
|
-
*/
|
1937
|
-
#line 1502 "informix.ec"
|
1938
|
-
{
|
1939
|
-
#line 1502 "informix.ec"
|
1940
|
-
sqli_curs_close(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn1, 768));
|
1941
|
-
#line 1502 "informix.ec"
|
1942
|
-
}
|
1943
|
-
/*
|
1944
|
-
* EXEC SQL free cur;
|
2796
|
+
* EXEC SQL close :cid;
|
1945
2797
|
*/
|
1946
|
-
#line
|
2798
|
+
#line 2260 "informix.ec"
|
1947
2799
|
{
|
1948
|
-
#line
|
1949
|
-
|
1950
|
-
#line
|
2800
|
+
#line 2260 "informix.ec"
|
2801
|
+
sqli_curs_close(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256));
|
2802
|
+
#line 2260 "informix.ec"
|
1951
2803
|
}
|
1952
2804
|
|
1953
2805
|
return result;
|
@@ -1973,46 +2825,41 @@ statement_free(void *p)
|
|
1973
2825
|
/*
|
1974
2826
|
* EXEC SQL begin declare section;
|
1975
2827
|
*/
|
1976
|
-
#line
|
1977
|
-
#line
|
2828
|
+
#line 2282 "informix.ec"
|
2829
|
+
#line 2283 "informix.ec"
|
1978
2830
|
char *sid, *did;
|
1979
2831
|
/*
|
1980
2832
|
* EXEC SQL end declare section;
|
1981
2833
|
*/
|
1982
|
-
#line
|
2834
|
+
#line 2284 "informix.ec"
|
1983
2835
|
|
1984
2836
|
|
1985
2837
|
free_input_slots(p);
|
1986
2838
|
free_output_slots(p);
|
1987
2839
|
|
1988
2840
|
did = ((cursor_t *)p)->database_id;
|
1989
|
-
if (currentdid != did) {
|
1990
2841
|
/*
|
1991
|
-
*
|
2842
|
+
* EXEC SQL set connection :did;
|
1992
2843
|
*/
|
1993
|
-
#line
|
2844
|
+
#line 2290 "informix.ec"
|
1994
2845
|
{
|
1995
|
-
#line
|
2846
|
+
#line 2290 "informix.ec"
|
1996
2847
|
sqli_connect_set(0, did, 0);
|
1997
|
-
#line
|
2848
|
+
#line 2290 "informix.ec"
|
1998
2849
|
}
|
1999
|
-
|
2000
|
-
|
2001
|
-
currentdid = did;
|
2002
|
-
}
|
2003
|
-
|
2004
|
-
sid = ((cursor_t *)p)->stmt_id;
|
2850
|
+
if (SQLCODE >= 0) {
|
2851
|
+
sid = ((cursor_t *)p)->stmt_id;
|
2005
2852
|
/*
|
2006
|
-
*
|
2853
|
+
* EXEC SQL free :sid;
|
2007
2854
|
*/
|
2008
|
-
#line
|
2855
|
+
#line 2293 "informix.ec"
|
2009
2856
|
{
|
2010
|
-
#line
|
2857
|
+
#line 2293 "informix.ec"
|
2011
2858
|
sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, sid, 258));
|
2012
|
-
#line
|
2859
|
+
#line 2293 "informix.ec"
|
2013
2860
|
}
|
2861
|
+
}
|
2014
2862
|
|
2015
|
-
exit:
|
2016
2863
|
xfree(p);
|
2017
2864
|
}
|
2018
2865
|
|
@@ -2028,10 +2875,19 @@ statement_alloc(VALUE klass)
|
|
2028
2875
|
|
2029
2876
|
/*
|
2030
2877
|
* call-seq:
|
2031
|
-
* Statement.new(database, query)
|
2878
|
+
* Statement.new(database, query) => statement
|
2879
|
+
* Statement.new(database, query) {|stmt| block } => obj
|
2880
|
+
*
|
2881
|
+
* Creates a <code>Statement</code> object based on <i>query</i> in the
|
2882
|
+
* context of <i>database</i>.
|
2883
|
+
* In the first form the <code>Statement</code> object is returned.
|
2884
|
+
* In the second form the Statement object is passed to the block and when it
|
2885
|
+
* terminates, the Statement object is dropped, returning the value of the
|
2886
|
+
* block.
|
2032
2887
|
*
|
2033
|
-
*
|
2034
|
-
* a
|
2888
|
+
* <i>query</i> may contain '?' placeholders for input parameters;
|
2889
|
+
* it must not be a query returning more than one row
|
2890
|
+
* (use <code>Cursor</code> instead.)
|
2035
2891
|
*/
|
2036
2892
|
static VALUE
|
2037
2893
|
statement_initialize(VALUE self, VALUE db, VALUE query)
|
@@ -2041,30 +2897,27 @@ statement_initialize(VALUE self, VALUE db, VALUE query)
|
|
2041
2897
|
/*
|
2042
2898
|
* EXEC SQL begin declare section;
|
2043
2899
|
*/
|
2044
|
-
#line
|
2045
|
-
#line
|
2900
|
+
#line 2330 "informix.ec"
|
2901
|
+
#line 2331 "informix.ec"
|
2046
2902
|
char *c_query, *sid, *did;
|
2047
2903
|
/*
|
2048
2904
|
* EXEC SQL end declare section;
|
2049
2905
|
*/
|
2050
|
-
#line
|
2906
|
+
#line 2332 "informix.ec"
|
2051
2907
|
|
2052
2908
|
|
2053
2909
|
Data_Get_Struct(db, char, did);
|
2054
|
-
if (currentdid != did) {
|
2055
2910
|
/*
|
2056
|
-
*
|
2911
|
+
* EXEC SQL set connection :did;
|
2057
2912
|
*/
|
2058
|
-
#line
|
2913
|
+
#line 2335 "informix.ec"
|
2059
2914
|
{
|
2060
|
-
#line
|
2915
|
+
#line 2335 "informix.ec"
|
2061
2916
|
sqli_connect_set(0, did, 0);
|
2062
|
-
#line
|
2917
|
+
#line 2335 "informix.ec"
|
2063
2918
|
}
|
2064
|
-
|
2065
|
-
|
2066
|
-
currentdid = did;
|
2067
|
-
}
|
2919
|
+
if (SQLCODE < 0)
|
2920
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
2068
2921
|
|
2069
2922
|
Data_Get_Struct(self, cursor_t, c);
|
2070
2923
|
c->db = db;
|
@@ -2077,11 +2930,11 @@ statement_initialize(VALUE self, VALUE db, VALUE query)
|
|
2077
2930
|
/*
|
2078
2931
|
* EXEC SQL prepare :sid from :c_query;
|
2079
2932
|
*/
|
2080
|
-
#line
|
2933
|
+
#line 2347 "informix.ec"
|
2081
2934
|
{
|
2082
|
-
#line
|
2935
|
+
#line 2347 "informix.ec"
|
2083
2936
|
sqli_prep(ESQLINTVERSION, sid, c_query,(ifx_literal_t *)0, (ifx_namelist_t *)0, -1, 0, 0 );
|
2084
|
-
#line
|
2937
|
+
#line 2347 "informix.ec"
|
2085
2938
|
}
|
2086
2939
|
if (SQLCODE < 0)
|
2087
2940
|
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
@@ -2090,11 +2943,11 @@ statement_initialize(VALUE self, VALUE db, VALUE query)
|
|
2090
2943
|
/*
|
2091
2944
|
* EXEC SQL describe :sid into output;
|
2092
2945
|
*/
|
2093
|
-
#line
|
2946
|
+
#line 2352 "informix.ec"
|
2094
2947
|
{
|
2095
|
-
#line
|
2948
|
+
#line 2352 "informix.ec"
|
2096
2949
|
sqli_describe_stmt(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, sid, 257), &output, 0);
|
2097
|
-
#line
|
2950
|
+
#line 2352 "informix.ec"
|
2098
2951
|
}
|
2099
2952
|
c->daOutput = output;
|
2100
2953
|
|
@@ -2110,6 +2963,35 @@ statement_initialize(VALUE self, VALUE db, VALUE query)
|
|
2110
2963
|
return self;
|
2111
2964
|
}
|
2112
2965
|
|
2966
|
+
/*
|
2967
|
+
* call-seq:
|
2968
|
+
* Statement.new(database, query) => statement
|
2969
|
+
* Statement.new(database, query) {|stmt| block } => obj
|
2970
|
+
*
|
2971
|
+
* Creates a <code>Statement</code> object based on <i>query</i> in the
|
2972
|
+
* context of <i>database</i>.
|
2973
|
+
* In the first form the <code>Statement</code> object is returned.
|
2974
|
+
* In the second form the Statement object is passed to the block and when it
|
2975
|
+
* terminates, the Statement object is dropped, returning the value of the
|
2976
|
+
* block.
|
2977
|
+
*
|
2978
|
+
* <i>query</i> may contain '?' placeholders for input parameters;
|
2979
|
+
* it must not be a query returning more than one row
|
2980
|
+
* (use <code>Cursor</code> instead.)
|
2981
|
+
*/
|
2982
|
+
static VALUE statement_drop(VALUE);
|
2983
|
+
static VALUE
|
2984
|
+
statement_s_new(int argc, VALUE *argv, VALUE klass)
|
2985
|
+
{
|
2986
|
+
VALUE stmt;
|
2987
|
+
|
2988
|
+
stmt = rb_class_new_instance(argc, argv, klass);
|
2989
|
+
|
2990
|
+
if (rb_block_given_p())
|
2991
|
+
return rb_ensure(rb_yield, stmt, statement_drop, stmt);
|
2992
|
+
|
2993
|
+
return stmt;
|
2994
|
+
}
|
2113
2995
|
|
2114
2996
|
/*
|
2115
2997
|
* call-seq:
|
@@ -2129,32 +3011,29 @@ statement_call(int argc, VALUE *argv, VALUE self)
|
|
2129
3011
|
/*
|
2130
3012
|
* EXEC SQL begin declare section;
|
2131
3013
|
*/
|
2132
|
-
#line
|
2133
|
-
#line
|
3014
|
+
#line 2412 "informix.ec"
|
3015
|
+
#line 2413 "informix.ec"
|
2134
3016
|
char *sid, *did;
|
2135
3017
|
/*
|
2136
3018
|
* EXEC SQL end declare section;
|
2137
3019
|
*/
|
2138
|
-
#line
|
3020
|
+
#line 2414 "informix.ec"
|
2139
3021
|
|
2140
3022
|
|
2141
3023
|
Data_Get_Struct(self, cursor_t, c);
|
2142
3024
|
|
2143
3025
|
did = c->database_id;
|
2144
|
-
if (currentdid != did) {
|
2145
3026
|
/*
|
2146
|
-
*
|
3027
|
+
* EXEC SQL set connection :did;
|
2147
3028
|
*/
|
2148
|
-
#line
|
3029
|
+
#line 2419 "informix.ec"
|
2149
3030
|
{
|
2150
|
-
#line
|
3031
|
+
#line 2419 "informix.ec"
|
2151
3032
|
sqli_connect_set(0, did, 0);
|
2152
|
-
#line
|
3033
|
+
#line 2419 "informix.ec"
|
2153
3034
|
}
|
2154
|
-
|
2155
|
-
|
2156
|
-
currentdid = did;
|
2157
|
-
}
|
3035
|
+
if (SQLCODE < 0)
|
3036
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
2158
3037
|
|
2159
3038
|
output = c->daOutput;
|
2160
3039
|
input = &c->daInput;
|
@@ -2171,11 +3050,11 @@ statement_call(int argc, VALUE *argv, VALUE self)
|
|
2171
3050
|
* EXEC SQL execute :sid into descriptor output
|
2172
3051
|
* using descriptor input;
|
2173
3052
|
*/
|
2174
|
-
#line
|
3053
|
+
#line 2434 "informix.ec"
|
2175
3054
|
{
|
2176
|
-
#line
|
3055
|
+
#line 2435 "informix.ec"
|
2177
3056
|
sqli_exec(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, sid, 257), input, (char *)0, (struct value *)0, output, (char *)0, (struct value *)0, 0);
|
2178
|
-
#line
|
3057
|
+
#line 2435 "informix.ec"
|
2179
3058
|
}
|
2180
3059
|
clean_input_slots(c);
|
2181
3060
|
}
|
@@ -2183,11 +3062,11 @@ statement_call(int argc, VALUE *argv, VALUE self)
|
|
2183
3062
|
/*
|
2184
3063
|
* EXEC SQL execute :sid into descriptor output;
|
2185
3064
|
*/
|
2186
|
-
#line
|
3065
|
+
#line 2439 "informix.ec"
|
2187
3066
|
{
|
2188
|
-
#line
|
3067
|
+
#line 2439 "informix.ec"
|
2189
3068
|
sqli_exec(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, sid, 257), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, output, (char *)0, (struct value *)0, 0);
|
2190
|
-
#line
|
3069
|
+
#line 2439 "informix.ec"
|
2191
3070
|
}
|
2192
3071
|
|
2193
3072
|
if (SQLCODE < 0)
|
@@ -2203,11 +3082,11 @@ statement_call(int argc, VALUE *argv, VALUE self)
|
|
2203
3082
|
/*
|
2204
3083
|
* EXEC SQL execute :sid using descriptor input;
|
2205
3084
|
*/
|
2206
|
-
#line
|
3085
|
+
#line 2451 "informix.ec"
|
2207
3086
|
{
|
2208
|
-
#line
|
3087
|
+
#line 2451 "informix.ec"
|
2209
3088
|
sqli_exec(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, sid, 257), input, (char *)0, (struct value *)0, (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0);
|
2210
|
-
#line
|
3089
|
+
#line 2451 "informix.ec"
|
2211
3090
|
}
|
2212
3091
|
clean_input_slots(c);
|
2213
3092
|
}
|
@@ -2215,11 +3094,11 @@ statement_call(int argc, VALUE *argv, VALUE self)
|
|
2215
3094
|
/*
|
2216
3095
|
* EXEC SQL execute :sid;
|
2217
3096
|
*/
|
2218
|
-
#line
|
3097
|
+
#line 2455 "informix.ec"
|
2219
3098
|
{
|
2220
|
-
#line
|
3099
|
+
#line 2455 "informix.ec"
|
2221
3100
|
sqli_exec(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, sid, 257), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0);
|
2222
|
-
#line
|
3101
|
+
#line 2455 "informix.ec"
|
2223
3102
|
}
|
2224
3103
|
}
|
2225
3104
|
if (SQLCODE < 0)
|
@@ -2241,13 +3120,13 @@ statement_drop(VALUE self)
|
|
2241
3120
|
/*
|
2242
3121
|
* EXEC SQL begin declare section;
|
2243
3122
|
*/
|
2244
|
-
#line
|
2245
|
-
#line
|
3123
|
+
#line 2473 "informix.ec"
|
3124
|
+
#line 2474 "informix.ec"
|
2246
3125
|
char *sid, *did;
|
2247
3126
|
/*
|
2248
3127
|
* EXEC SQL end declare section;
|
2249
3128
|
*/
|
2250
|
-
#line
|
3129
|
+
#line 2475 "informix.ec"
|
2251
3130
|
|
2252
3131
|
|
2253
3132
|
Data_Get_Struct(self, cursor_t, c);
|
@@ -2255,35 +3134,31 @@ statement_drop(VALUE self)
|
|
2255
3134
|
free_output_slots(c);
|
2256
3135
|
|
2257
3136
|
did = c->database_id;
|
2258
|
-
if (currentdid != did) {
|
2259
3137
|
/*
|
2260
|
-
*
|
3138
|
+
* EXEC SQL set connection :did;
|
2261
3139
|
*/
|
2262
|
-
#line
|
3140
|
+
#line 2482 "informix.ec"
|
2263
3141
|
{
|
2264
|
-
#line
|
3142
|
+
#line 2482 "informix.ec"
|
2265
3143
|
sqli_connect_set(0, did, 0);
|
2266
|
-
#line
|
3144
|
+
#line 2482 "informix.ec"
|
2267
3145
|
}
|
2268
|
-
|
2269
|
-
|
2270
|
-
currentdid = did;
|
2271
|
-
}
|
3146
|
+
if (SQLCODE < 0)
|
3147
|
+
return Qnil;
|
2272
3148
|
sid = c->stmt_id;
|
2273
3149
|
/*
|
2274
3150
|
* EXEC SQL free :sid;
|
2275
3151
|
*/
|
2276
|
-
#line
|
3152
|
+
#line 2486 "informix.ec"
|
2277
3153
|
{
|
2278
|
-
#line
|
3154
|
+
#line 2486 "informix.ec"
|
2279
3155
|
sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, sid, 258));
|
2280
|
-
#line
|
3156
|
+
#line 2486 "informix.ec"
|
2281
3157
|
}
|
2282
3158
|
|
2283
3159
|
return Qnil;
|
2284
3160
|
}
|
2285
3161
|
|
2286
|
-
|
2287
3162
|
/* module SequentialCursor ----------------------------------------------- */
|
2288
3163
|
|
2289
3164
|
/* Decides whether to use an Array or a Hash, and instantiate a new
|
@@ -2319,13 +3194,13 @@ fetch(VALUE self, VALUE type, int bang)
|
|
2319
3194
|
/*
|
2320
3195
|
* EXEC SQL begin declare section;
|
2321
3196
|
*/
|
2322
|
-
#line
|
2323
|
-
#line
|
3197
|
+
#line 2523 "informix.ec"
|
3198
|
+
#line 2524 "informix.ec"
|
2324
3199
|
char *cid, *did;
|
2325
3200
|
/*
|
2326
3201
|
* EXEC SQL end declare section;
|
2327
3202
|
*/
|
2328
|
-
#line
|
3203
|
+
#line 2525 "informix.ec"
|
2329
3204
|
|
2330
3205
|
cursor_t *c;
|
2331
3206
|
struct sqlda *output;
|
@@ -2336,20 +3211,17 @@ fetch(VALUE self, VALUE type, int bang)
|
|
2336
3211
|
rb_raise(rb_eRuntimeError, "Open the cursor object first");
|
2337
3212
|
|
2338
3213
|
did = c->database_id;
|
2339
|
-
if (currentdid != did) {
|
2340
3214
|
/*
|
2341
|
-
*
|
3215
|
+
* EXEC SQL set connection :did;
|
2342
3216
|
*/
|
2343
|
-
#line
|
3217
|
+
#line 2535 "informix.ec"
|
2344
3218
|
{
|
2345
|
-
#line
|
3219
|
+
#line 2535 "informix.ec"
|
2346
3220
|
sqli_connect_set(0, did, 0);
|
2347
|
-
#line
|
3221
|
+
#line 2535 "informix.ec"
|
2348
3222
|
}
|
2349
|
-
|
2350
|
-
|
2351
|
-
currentdid = did;
|
2352
|
-
}
|
3223
|
+
if (SQLCODE < 0)
|
3224
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
2353
3225
|
|
2354
3226
|
output = c->daOutput;
|
2355
3227
|
cid = c->cursor_id;
|
@@ -2357,12 +3229,12 @@ fetch(VALUE self, VALUE type, int bang)
|
|
2357
3229
|
/*
|
2358
3230
|
* EXEC SQL fetch :cid using descriptor output;
|
2359
3231
|
*/
|
2360
|
-
#line
|
3232
|
+
#line 2542 "informix.ec"
|
2361
3233
|
{
|
2362
|
-
#line
|
3234
|
+
#line 2542 "informix.ec"
|
2363
3235
|
static _FetchSpec _FS0 = { 0, 1, 0 };
|
2364
3236
|
sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, output, (char *)0, &_FS0);
|
2365
|
-
#line
|
3237
|
+
#line 2542 "informix.ec"
|
2366
3238
|
}
|
2367
3239
|
if (SQLCODE < 0)
|
2368
3240
|
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
@@ -2445,13 +3317,13 @@ fetch_many(VALUE self, VALUE n, VALUE type)
|
|
2445
3317
|
/*
|
2446
3318
|
* EXEC SQL begin declare section;
|
2447
3319
|
*/
|
2448
|
-
#line
|
2449
|
-
#line
|
3320
|
+
#line 2621 "informix.ec"
|
3321
|
+
#line 2622 "informix.ec"
|
2450
3322
|
char *cid, *did;
|
2451
3323
|
/*
|
2452
3324
|
* EXEC SQL end declare section;
|
2453
3325
|
*/
|
2454
|
-
#line
|
3326
|
+
#line 2623 "informix.ec"
|
2455
3327
|
|
2456
3328
|
cursor_t *c;
|
2457
3329
|
struct sqlda *output;
|
@@ -2464,20 +3336,17 @@ fetch_many(VALUE self, VALUE n, VALUE type)
|
|
2464
3336
|
rb_raise(rb_eRuntimeError, "Open the cursor object first");
|
2465
3337
|
|
2466
3338
|
did = c->database_id;
|
2467
|
-
if (currentdid != did) {
|
2468
3339
|
/*
|
2469
|
-
*
|
3340
|
+
* EXEC SQL set connection :did;
|
2470
3341
|
*/
|
2471
|
-
#line
|
3342
|
+
#line 2635 "informix.ec"
|
2472
3343
|
{
|
2473
|
-
#line
|
3344
|
+
#line 2635 "informix.ec"
|
2474
3345
|
sqli_connect_set(0, did, 0);
|
2475
|
-
#line
|
3346
|
+
#line 2635 "informix.ec"
|
2476
3347
|
}
|
2477
|
-
|
2478
|
-
|
2479
|
-
currentdid = did;
|
2480
|
-
}
|
3348
|
+
if (SQLCODE < 0)
|
3349
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
2481
3350
|
|
2482
3351
|
output = c->daOutput;
|
2483
3352
|
cid = c->cursor_id;
|
@@ -2494,12 +3363,12 @@ fetch_many(VALUE self, VALUE n, VALUE type)
|
|
2494
3363
|
/*
|
2495
3364
|
* EXEC SQL fetch :cid using descriptor output;
|
2496
3365
|
*/
|
2497
|
-
#line
|
3366
|
+
#line 2651 "informix.ec"
|
2498
3367
|
{
|
2499
|
-
#line
|
3368
|
+
#line 2651 "informix.ec"
|
2500
3369
|
static _FetchSpec _FS0 = { 0, 1, 0 };
|
2501
3370
|
sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, output, (char *)0, &_FS0);
|
2502
|
-
#line
|
3371
|
+
#line 2651 "informix.ec"
|
2503
3372
|
}
|
2504
3373
|
if (SQLCODE < 0)
|
2505
3374
|
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
@@ -2578,13 +3447,13 @@ each(VALUE self, VALUE type, int bang)
|
|
2578
3447
|
/*
|
2579
3448
|
* EXEC SQL begin declare section;
|
2580
3449
|
*/
|
2581
|
-
#line
|
2582
|
-
#line
|
3450
|
+
#line 2726 "informix.ec"
|
3451
|
+
#line 2727 "informix.ec"
|
2583
3452
|
char *cid, *did;
|
2584
3453
|
/*
|
2585
3454
|
* EXEC SQL end declare section;
|
2586
3455
|
*/
|
2587
|
-
#line
|
3456
|
+
#line 2728 "informix.ec"
|
2588
3457
|
|
2589
3458
|
struct sqlda *output;
|
2590
3459
|
VALUE record;
|
@@ -2594,20 +3463,17 @@ each(VALUE self, VALUE type, int bang)
|
|
2594
3463
|
rb_raise(rb_eRuntimeError, "Open the cursor object first");
|
2595
3464
|
|
2596
3465
|
did = c->database_id;
|
2597
|
-
if (currentdid != did) {
|
2598
3466
|
/*
|
2599
|
-
*
|
3467
|
+
* EXEC SQL set connection :did;
|
2600
3468
|
*/
|
2601
|
-
#line
|
3469
|
+
#line 2737 "informix.ec"
|
2602
3470
|
{
|
2603
|
-
#line
|
3471
|
+
#line 2737 "informix.ec"
|
2604
3472
|
sqli_connect_set(0, did, 0);
|
2605
|
-
#line
|
3473
|
+
#line 2737 "informix.ec"
|
2606
3474
|
}
|
2607
|
-
|
2608
|
-
|
2609
|
-
currentdid = did;
|
2610
|
-
}
|
3475
|
+
if (SQLCODE < 0)
|
3476
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
2611
3477
|
|
2612
3478
|
output = c->daOutput;
|
2613
3479
|
cid = c->cursor_id;
|
@@ -2616,12 +3482,12 @@ each(VALUE self, VALUE type, int bang)
|
|
2616
3482
|
/*
|
2617
3483
|
* EXEC SQL fetch :cid using descriptor output;
|
2618
3484
|
*/
|
2619
|
-
#line
|
3485
|
+
#line 2745 "informix.ec"
|
2620
3486
|
{
|
2621
|
-
#line
|
3487
|
+
#line 2745 "informix.ec"
|
2622
3488
|
static _FetchSpec _FS0 = { 0, 1, 0 };
|
2623
3489
|
sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, output, (char *)0, &_FS0);
|
2624
|
-
#line
|
3490
|
+
#line 2745 "informix.ec"
|
2625
3491
|
}
|
2626
3492
|
if (SQLCODE < 0)
|
2627
3493
|
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
@@ -2760,13 +3626,13 @@ inscur_put(int argc, VALUE *argv, VALUE self)
|
|
2760
3626
|
/*
|
2761
3627
|
* EXEC SQL begin declare section;
|
2762
3628
|
*/
|
2763
|
-
#line
|
2764
|
-
#line
|
3629
|
+
#line 2880 "informix.ec"
|
3630
|
+
#line 2881 "informix.ec"
|
2765
3631
|
char *cid, *did;
|
2766
3632
|
/*
|
2767
3633
|
* EXEC SQL end declare section;
|
2768
3634
|
*/
|
2769
|
-
#line
|
3635
|
+
#line 2882 "informix.ec"
|
2770
3636
|
|
2771
3637
|
|
2772
3638
|
Data_Get_Struct(self, cursor_t, c);
|
@@ -2774,20 +3640,17 @@ inscur_put(int argc, VALUE *argv, VALUE self)
|
|
2774
3640
|
rb_raise(rb_eRuntimeError, "Open the cursor object first");
|
2775
3641
|
|
2776
3642
|
did = c->database_id;
|
2777
|
-
if (currentdid != did) {
|
2778
3643
|
/*
|
2779
|
-
*
|
3644
|
+
* EXEC SQL set connection :did;
|
2780
3645
|
*/
|
2781
|
-
#line
|
3646
|
+
#line 2889 "informix.ec"
|
2782
3647
|
{
|
2783
|
-
#line
|
3648
|
+
#line 2889 "informix.ec"
|
2784
3649
|
sqli_connect_set(0, did, 0);
|
2785
|
-
#line
|
3650
|
+
#line 2889 "informix.ec"
|
2786
3651
|
}
|
2787
|
-
|
2788
|
-
|
2789
|
-
currentdid = did;
|
2790
|
-
}
|
3652
|
+
if (SQLCODE < 0)
|
3653
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
2791
3654
|
|
2792
3655
|
input = &c->daInput;
|
2793
3656
|
cid = c->cursor_id;
|
@@ -2800,11 +3663,11 @@ inscur_put(int argc, VALUE *argv, VALUE self)
|
|
2800
3663
|
/*
|
2801
3664
|
* EXEC SQL put :cid using descriptor input;
|
2802
3665
|
*/
|
2803
|
-
#line
|
3666
|
+
#line 2901 "informix.ec"
|
2804
3667
|
{
|
2805
|
-
#line
|
3668
|
+
#line 2901 "informix.ec"
|
2806
3669
|
sqli_curs_put(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), input, (char *)0);
|
2807
|
-
#line
|
3670
|
+
#line 2901 "informix.ec"
|
2808
3671
|
}
|
2809
3672
|
clean_input_slots(c);
|
2810
3673
|
if (SQLCODE < 0)
|
@@ -2829,13 +3692,13 @@ inscur_flush(VALUE self)
|
|
2829
3692
|
/*
|
2830
3693
|
* EXEC SQL begin declare section;
|
2831
3694
|
*/
|
2832
|
-
#line
|
2833
|
-
#line
|
3695
|
+
#line 2922 "informix.ec"
|
3696
|
+
#line 2923 "informix.ec"
|
2834
3697
|
char *cid, *did;
|
2835
3698
|
/*
|
2836
3699
|
* EXEC SQL end declare section;
|
2837
3700
|
*/
|
2838
|
-
#line
|
3701
|
+
#line 2924 "informix.ec"
|
2839
3702
|
|
2840
3703
|
|
2841
3704
|
Data_Get_Struct(self, cursor_t, c);
|
@@ -2843,30 +3706,27 @@ inscur_flush(VALUE self)
|
|
2843
3706
|
rb_raise(rb_eRuntimeError, "Open the cursor object first");
|
2844
3707
|
|
2845
3708
|
did = c->database_id;
|
2846
|
-
if (currentdid != did) {
|
2847
3709
|
/*
|
2848
|
-
*
|
3710
|
+
* EXEC SQL set connection :did;
|
2849
3711
|
*/
|
2850
|
-
#line
|
3712
|
+
#line 2931 "informix.ec"
|
2851
3713
|
{
|
2852
|
-
#line
|
3714
|
+
#line 2931 "informix.ec"
|
2853
3715
|
sqli_connect_set(0, did, 0);
|
2854
|
-
#line
|
3716
|
+
#line 2931 "informix.ec"
|
2855
3717
|
}
|
2856
|
-
|
2857
|
-
|
2858
|
-
currentdid = did;
|
2859
|
-
}
|
3718
|
+
if (SQLCODE < 0)
|
3719
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
2860
3720
|
|
2861
3721
|
cid = c->cursor_id;
|
2862
3722
|
/*
|
2863
3723
|
* EXEC SQL flush :cid;
|
2864
3724
|
*/
|
2865
|
-
#line
|
3725
|
+
#line 2936 "informix.ec"
|
2866
3726
|
{
|
2867
|
-
#line
|
3727
|
+
#line 2936 "informix.ec"
|
2868
3728
|
sqli_curs_flush(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256));
|
2869
|
-
#line
|
3729
|
+
#line 2936 "informix.ec"
|
2870
3730
|
}
|
2871
3731
|
return self;
|
2872
3732
|
}
|
@@ -2886,14 +3746,14 @@ scrollcur_entry(VALUE self, VALUE index, VALUE type, int bang)
|
|
2886
3746
|
/*
|
2887
3747
|
* EXEC SQL begin declare section;
|
2888
3748
|
*/
|
2889
|
-
#line
|
2890
|
-
#line
|
3749
|
+
#line 2952 "informix.ec"
|
3750
|
+
#line 2953 "informix.ec"
|
2891
3751
|
char *cid, *did;
|
2892
3752
|
long pos;
|
2893
3753
|
/*
|
2894
3754
|
* EXEC SQL end declare section;
|
2895
3755
|
*/
|
2896
|
-
#line
|
3756
|
+
#line 2955 "informix.ec"
|
2897
3757
|
|
2898
3758
|
|
2899
3759
|
Data_Get_Struct(self, cursor_t, c);
|
@@ -2901,20 +3761,17 @@ long pos;
|
|
2901
3761
|
rb_raise(rb_eRuntimeError, "Open the cursor object first");
|
2902
3762
|
|
2903
3763
|
did = c->database_id;
|
2904
|
-
if (currentdid != did) {
|
2905
3764
|
/*
|
2906
|
-
*
|
3765
|
+
* EXEC SQL set connection :did;
|
2907
3766
|
*/
|
2908
|
-
#line
|
3767
|
+
#line 2962 "informix.ec"
|
2909
3768
|
{
|
2910
|
-
#line
|
3769
|
+
#line 2962 "informix.ec"
|
2911
3770
|
sqli_connect_set(0, did, 0);
|
2912
|
-
#line
|
3771
|
+
#line 2962 "informix.ec"
|
2913
3772
|
}
|
2914
|
-
|
2915
|
-
|
2916
|
-
currentdid = did;
|
2917
|
-
}
|
3773
|
+
if (SQLCODE < 0)
|
3774
|
+
return Qnil;
|
2918
3775
|
|
2919
3776
|
output = c->daOutput;
|
2920
3777
|
cid = c->cursor_id;
|
@@ -2923,60 +3780,60 @@ long pos;
|
|
2923
3780
|
/*
|
2924
3781
|
* EXEC SQL fetch current :cid using descriptor output;
|
2925
3782
|
*/
|
2926
|
-
#line
|
3783
|
+
#line 2970 "informix.ec"
|
2927
3784
|
{
|
2928
|
-
#line
|
3785
|
+
#line 2970 "informix.ec"
|
2929
3786
|
static _FetchSpec _FS0 = { 0, 5, 0 };
|
2930
3787
|
sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, output, (char *)0, &_FS0);
|
2931
|
-
#line
|
3788
|
+
#line 2970 "informix.ec"
|
2932
3789
|
}
|
2933
3790
|
else if ((pos = NUM2LONG(index) + 1) > 0)
|
2934
3791
|
/*
|
2935
3792
|
* EXEC SQL fetch absolute :pos :cid using descriptor output;
|
2936
3793
|
*/
|
2937
|
-
#line
|
3794
|
+
#line 2972 "informix.ec"
|
2938
3795
|
{
|
2939
|
-
#line
|
3796
|
+
#line 2972 "informix.ec"
|
2940
3797
|
static ifx_sqlvar_t _sqibind[] =
|
2941
3798
|
{
|
2942
3799
|
{ 103, sizeof(pos), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
2943
|
-
#line
|
3800
|
+
#line 2972 "informix.ec"
|
2944
3801
|
};
|
2945
3802
|
static ifx_sqlda_t _SD0 = { 1, _sqibind, {0}, 1, 0 };
|
2946
3803
|
static _FetchSpec _FS1 = { 0, 6, 0 };
|
2947
|
-
#line
|
3804
|
+
#line 2972 "informix.ec"
|
2948
3805
|
_sqibind[0].sqldata = (char *) &pos;
|
2949
3806
|
sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), &_SD0, output, (char *)0, &_FS1);
|
2950
|
-
#line
|
3807
|
+
#line 2972 "informix.ec"
|
2951
3808
|
}
|
2952
3809
|
else {
|
2953
3810
|
/*
|
2954
3811
|
* EXEC SQL fetch last :cid;
|
2955
3812
|
*/
|
2956
|
-
#line
|
3813
|
+
#line 2974 "informix.ec"
|
2957
3814
|
{
|
2958
|
-
#line
|
3815
|
+
#line 2974 "informix.ec"
|
2959
3816
|
static _FetchSpec _FS0 = { 0, 4, 0 };
|
2960
3817
|
sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, (ifx_sqlda_t *)0, (char *)0, &_FS0);
|
2961
|
-
#line
|
3818
|
+
#line 2974 "informix.ec"
|
2962
3819
|
}
|
2963
3820
|
/*
|
2964
3821
|
* EXEC SQL fetch relative :pos :cid using descriptor output;
|
2965
3822
|
*/
|
2966
|
-
#line
|
3823
|
+
#line 2975 "informix.ec"
|
2967
3824
|
{
|
2968
|
-
#line
|
3825
|
+
#line 2975 "informix.ec"
|
2969
3826
|
static ifx_sqlvar_t _sqibind[] =
|
2970
3827
|
{
|
2971
3828
|
{ 103, sizeof(pos), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
2972
|
-
#line
|
3829
|
+
#line 2975 "informix.ec"
|
2973
3830
|
};
|
2974
3831
|
static ifx_sqlda_t _SD0 = { 1, _sqibind, {0}, 1, 0 };
|
2975
3832
|
static _FetchSpec _FS1 = { 0, 7, 0 };
|
2976
|
-
#line
|
3833
|
+
#line 2975 "informix.ec"
|
2977
3834
|
_sqibind[0].sqldata = (char *) &pos;
|
2978
3835
|
sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), &_SD0, output, (char *)0, &_FS1);
|
2979
|
-
#line
|
3836
|
+
#line 2975 "informix.ec"
|
2980
3837
|
}
|
2981
3838
|
}
|
2982
3839
|
|
@@ -2997,20 +3854,17 @@ long pos;
|
|
2997
3854
|
static VALUE
|
2998
3855
|
scrollcur_subseq(VALUE self, VALUE start, VALUE length, VALUE type)
|
2999
3856
|
{
|
3000
|
-
cursor_t *c;
|
3001
|
-
struct sqlda *output;
|
3002
3857
|
VALUE first, records;
|
3003
3858
|
/*
|
3004
3859
|
* EXEC SQL begin declare section;
|
3005
3860
|
*/
|
3006
|
-
#line
|
3007
|
-
#line
|
3008
|
-
char *cid, *did;
|
3861
|
+
#line 2996 "informix.ec"
|
3862
|
+
#line 2997 "informix.ec"
|
3009
3863
|
long pos;
|
3010
3864
|
/*
|
3011
3865
|
* EXEC SQL end declare section;
|
3012
3866
|
*/
|
3013
|
-
#line
|
3867
|
+
#line 2998 "informix.ec"
|
3014
3868
|
|
3015
3869
|
|
3016
3870
|
first = scrollcur_entry(self, start, type, 0);
|
@@ -3142,14 +3996,14 @@ scrollcur_rel(int argc, VALUE *argv, VALUE self, int dir, VALUE type, int bang)
|
|
3142
3996
|
/*
|
3143
3997
|
* EXEC SQL begin declare section;
|
3144
3998
|
*/
|
3145
|
-
#line
|
3146
|
-
#line
|
3999
|
+
#line 3126 "informix.ec"
|
4000
|
+
#line 3127 "informix.ec"
|
3147
4001
|
char *cid, *did;
|
3148
4002
|
long pos;
|
3149
4003
|
/*
|
3150
4004
|
* EXEC SQL end declare section;
|
3151
4005
|
*/
|
3152
|
-
#line
|
4006
|
+
#line 3129 "informix.ec"
|
3153
4007
|
|
3154
4008
|
|
3155
4009
|
Data_Get_Struct(self, cursor_t, c);
|
@@ -3157,20 +4011,17 @@ long pos;
|
|
3157
4011
|
rb_raise(rb_eRuntimeError, "Open the cursor object first");
|
3158
4012
|
|
3159
4013
|
did = c->database_id;
|
3160
|
-
if (currentdid != did) {
|
3161
4014
|
/*
|
3162
|
-
*
|
4015
|
+
* EXEC SQL set connection :did;
|
3163
4016
|
*/
|
3164
|
-
#line
|
4017
|
+
#line 3136 "informix.ec"
|
3165
4018
|
{
|
3166
|
-
#line
|
4019
|
+
#line 3136 "informix.ec"
|
3167
4020
|
sqli_connect_set(0, did, 0);
|
3168
|
-
#line
|
4021
|
+
#line 3136 "informix.ec"
|
3169
4022
|
}
|
3170
|
-
|
3171
|
-
|
3172
|
-
currentdid = did;
|
3173
|
-
}
|
4023
|
+
if (SQLCODE < 0)
|
4024
|
+
return Qnil;
|
3174
4025
|
|
3175
4026
|
rb_scan_args(argc, argv, "01", &offset);
|
3176
4027
|
pos = dir*(NIL_P(offset)? 1: NUM2LONG(offset));
|
@@ -3180,20 +4031,20 @@ long pos;
|
|
3180
4031
|
/*
|
3181
4032
|
* EXEC SQL fetch relative :pos :cid using descriptor output;
|
3182
4033
|
*/
|
3183
|
-
#line
|
4034
|
+
#line 3145 "informix.ec"
|
3184
4035
|
{
|
3185
|
-
#line
|
4036
|
+
#line 3145 "informix.ec"
|
3186
4037
|
static ifx_sqlvar_t _sqibind[] =
|
3187
4038
|
{
|
3188
4039
|
{ 103, sizeof(pos), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
3189
|
-
#line
|
4040
|
+
#line 3145 "informix.ec"
|
3190
4041
|
};
|
3191
4042
|
static ifx_sqlda_t _SD0 = { 1, _sqibind, {0}, 1, 0 };
|
3192
4043
|
static _FetchSpec _FS1 = { 0, 7, 0 };
|
3193
|
-
#line
|
4044
|
+
#line 3145 "informix.ec"
|
3194
4045
|
_sqibind[0].sqldata = (char *) &pos;
|
3195
4046
|
sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), &_SD0, output, (char *)0, &_FS1);
|
3196
|
-
#line
|
4047
|
+
#line 3145 "informix.ec"
|
3197
4048
|
}
|
3198
4049
|
|
3199
4050
|
if (SQLCODE == SQLNOTFOUND)
|
@@ -3493,13 +4344,13 @@ cursor_close_or_free(cursor_t *c, short op)
|
|
3493
4344
|
/*
|
3494
4345
|
* EXEC SQL begin declare section;
|
3495
4346
|
*/
|
3496
|
-
#line
|
3497
|
-
#line
|
4347
|
+
#line 3441 "informix.ec"
|
4348
|
+
#line 3442 "informix.ec"
|
3498
4349
|
char *cid, *sid, *did;
|
3499
4350
|
/*
|
3500
4351
|
* EXEC SQL end declare section;
|
3501
4352
|
*/
|
3502
|
-
#line
|
4353
|
+
#line 3443 "informix.ec"
|
3503
4354
|
|
3504
4355
|
|
3505
4356
|
if (op == 1 && !c->is_open)
|
@@ -3514,30 +4365,27 @@ cursor_close_or_free(cursor_t *c, short op)
|
|
3514
4365
|
}
|
3515
4366
|
|
3516
4367
|
did = c->database_id;
|
3517
|
-
if (currentdid != did) {
|
3518
4368
|
/*
|
3519
|
-
*
|
4369
|
+
* EXEC SQL set connection :did;
|
3520
4370
|
*/
|
3521
|
-
#line
|
4371
|
+
#line 3457 "informix.ec"
|
3522
4372
|
{
|
3523
|
-
#line
|
4373
|
+
#line 3457 "informix.ec"
|
3524
4374
|
sqli_connect_set(0, did, 0);
|
3525
|
-
#line
|
4375
|
+
#line 3457 "informix.ec"
|
3526
4376
|
}
|
3527
|
-
|
3528
|
-
|
3529
|
-
currentdid = did;
|
3530
|
-
}
|
4377
|
+
if (SQLCODE < 0)
|
4378
|
+
return;
|
3531
4379
|
|
3532
4380
|
cid = c->cursor_id;
|
3533
4381
|
/*
|
3534
4382
|
* EXEC SQL close :cid;
|
3535
4383
|
*/
|
3536
|
-
#line
|
4384
|
+
#line 3462 "informix.ec"
|
3537
4385
|
{
|
3538
|
-
#line
|
4386
|
+
#line 3462 "informix.ec"
|
3539
4387
|
sqli_curs_close(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256));
|
3540
|
-
#line
|
4388
|
+
#line 3462 "informix.ec"
|
3541
4389
|
}
|
3542
4390
|
|
3543
4391
|
if (op == 2) {
|
@@ -3545,20 +4393,20 @@ cursor_close_or_free(cursor_t *c, short op)
|
|
3545
4393
|
/*
|
3546
4394
|
* EXEC SQL free :cid;
|
3547
4395
|
*/
|
3548
|
-
#line
|
4396
|
+
#line 3466 "informix.ec"
|
3549
4397
|
{
|
3550
|
-
#line
|
4398
|
+
#line 3466 "informix.ec"
|
3551
4399
|
sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 258));
|
3552
|
-
#line
|
4400
|
+
#line 3466 "informix.ec"
|
3553
4401
|
}
|
3554
4402
|
/*
|
3555
4403
|
* EXEC SQL free :sid;
|
3556
4404
|
*/
|
3557
|
-
#line
|
4405
|
+
#line 3466 "informix.ec"
|
3558
4406
|
{
|
3559
|
-
#line
|
4407
|
+
#line 3466 "informix.ec"
|
3560
4408
|
sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, sid, 258));
|
3561
|
-
#line
|
4409
|
+
#line 3466 "informix.ec"
|
3562
4410
|
}
|
3563
4411
|
}
|
3564
4412
|
}
|
@@ -3594,51 +4442,50 @@ cursor_alloc(VALUE klass)
|
|
3594
4442
|
|
3595
4443
|
/*
|
3596
4444
|
* call-seq:
|
3597
|
-
* Cursor.new(database, query, options) => cursor
|
4445
|
+
* Cursor.new(database, query, options = nil) => cursor
|
3598
4446
|
*
|
3599
4447
|
* Prepares <i>query</i> in the context of <i>database</i> with <i>options</i>
|
3600
4448
|
* and returns a <code>Cursor</code> object.
|
3601
4449
|
*
|
3602
|
-
* <i>options</i> can be nil or a
|
4450
|
+
* <i>options</i> can be nil or a Hash object with the following possible keys:
|
3603
4451
|
*
|
3604
4452
|
* :scroll => true or false
|
3605
|
-
* :hold
|
4453
|
+
* :hold => true or false
|
3606
4454
|
*/
|
3607
4455
|
static VALUE
|
3608
|
-
cursor_initialize(
|
4456
|
+
cursor_initialize(int argc, VALUE *argv, VALUE self)
|
3609
4457
|
{
|
4458
|
+
VALUE db, query, options;
|
3610
4459
|
VALUE scroll, hold;
|
3611
4460
|
struct sqlda *output;
|
3612
4461
|
cursor_t *c;
|
3613
4462
|
/*
|
3614
4463
|
* EXEC SQL begin declare section;
|
3615
4464
|
*/
|
3616
|
-
#line
|
3617
|
-
#line
|
4465
|
+
#line 3518 "informix.ec"
|
4466
|
+
#line 3519 "informix.ec"
|
3618
4467
|
char *c_query;
|
3619
4468
|
char *cid, *sid, *did;
|
3620
4469
|
/*
|
3621
4470
|
* EXEC SQL end declare section;
|
3622
4471
|
*/
|
3623
|
-
#line
|
4472
|
+
#line 3521 "informix.ec"
|
3624
4473
|
|
3625
4474
|
|
4475
|
+
rb_scan_args(argc, argv, "21", &db, &query, &options);
|
3626
4476
|
Data_Get_Struct(db, char, did);
|
3627
4477
|
|
3628
|
-
if (currentdid != did) {
|
3629
4478
|
/*
|
3630
|
-
*
|
4479
|
+
* EXEC SQL set connection :did;
|
3631
4480
|
*/
|
3632
|
-
#line
|
4481
|
+
#line 3526 "informix.ec"
|
3633
4482
|
{
|
3634
|
-
#line
|
4483
|
+
#line 3526 "informix.ec"
|
3635
4484
|
sqli_connect_set(0, did, 0);
|
3636
|
-
#line
|
4485
|
+
#line 3526 "informix.ec"
|
3637
4486
|
}
|
3638
|
-
|
3639
|
-
|
3640
|
-
currentdid = did;
|
3641
|
-
}
|
4487
|
+
if (SQLCODE < 0)
|
4488
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
3642
4489
|
|
3643
4490
|
Data_Get_Struct(self, cursor_t, c);
|
3644
4491
|
c->db = db;
|
@@ -3649,7 +4496,8 @@ cursor_initialize(VALUE self, VALUE db, VALUE query, VALUE options)
|
|
3649
4496
|
cid = c->cursor_id; sid = c->stmt_id;
|
3650
4497
|
c_query = StringValueCStr(query);
|
3651
4498
|
|
3652
|
-
if (
|
4499
|
+
if (!NIL_P(options)) {
|
4500
|
+
Check_Type(options, T_HASH);
|
3653
4501
|
scroll = rb_hash_aref(options, sym_scroll);
|
3654
4502
|
hold = rb_hash_aref(options, sym_hold);
|
3655
4503
|
}
|
@@ -3657,11 +4505,11 @@ cursor_initialize(VALUE self, VALUE db, VALUE query, VALUE options)
|
|
3657
4505
|
/*
|
3658
4506
|
* EXEC SQL prepare :sid from :c_query;
|
3659
4507
|
*/
|
3660
|
-
#line
|
4508
|
+
#line 3545 "informix.ec"
|
3661
4509
|
{
|
3662
|
-
#line
|
4510
|
+
#line 3545 "informix.ec"
|
3663
4511
|
sqli_prep(ESQLINTVERSION, sid, c_query,(ifx_literal_t *)0, (ifx_namelist_t *)0, -1, 0, 0 );
|
3664
|
-
#line
|
4512
|
+
#line 3545 "informix.ec"
|
3665
4513
|
}
|
3666
4514
|
if (SQLCODE < 0)
|
3667
4515
|
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
@@ -3670,41 +4518,41 @@ cursor_initialize(VALUE self, VALUE db, VALUE query, VALUE options)
|
|
3670
4518
|
/*
|
3671
4519
|
* EXEC SQL declare :cid scroll cursor with hold for :sid;
|
3672
4520
|
*/
|
3673
|
-
#line
|
4521
|
+
#line 3550 "informix.ec"
|
3674
4522
|
{
|
3675
|
-
#line
|
4523
|
+
#line 3550 "informix.ec"
|
3676
4524
|
sqli_curs_decl_dynm(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 0), cid, sqli_curs_locate(ESQLINTVERSION, sid, 1), 4128, 0);
|
3677
|
-
#line
|
4525
|
+
#line 3550 "informix.ec"
|
3678
4526
|
}
|
3679
4527
|
else if (RTEST(hold))
|
3680
4528
|
/*
|
3681
4529
|
* EXEC SQL declare :cid cursor with hold for :sid;
|
3682
4530
|
*/
|
3683
|
-
#line
|
4531
|
+
#line 3552 "informix.ec"
|
3684
4532
|
{
|
3685
|
-
#line
|
4533
|
+
#line 3552 "informix.ec"
|
3686
4534
|
sqli_curs_decl_dynm(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 0), cid, sqli_curs_locate(ESQLINTVERSION, sid, 1), 4096, 0);
|
3687
|
-
#line
|
4535
|
+
#line 3552 "informix.ec"
|
3688
4536
|
}
|
3689
4537
|
else if (RTEST(scroll))
|
3690
4538
|
/*
|
3691
4539
|
* EXEC SQL declare :cid scroll cursor for :sid;
|
3692
4540
|
*/
|
3693
|
-
#line
|
4541
|
+
#line 3554 "informix.ec"
|
3694
4542
|
{
|
3695
|
-
#line
|
4543
|
+
#line 3554 "informix.ec"
|
3696
4544
|
sqli_curs_decl_dynm(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 0), cid, sqli_curs_locate(ESQLINTVERSION, sid, 1), 32, 0);
|
3697
|
-
#line
|
4545
|
+
#line 3554 "informix.ec"
|
3698
4546
|
}
|
3699
4547
|
else
|
3700
4548
|
/*
|
3701
4549
|
* EXEC SQL declare :cid cursor for :sid;
|
3702
4550
|
*/
|
3703
|
-
#line
|
4551
|
+
#line 3556 "informix.ec"
|
3704
4552
|
{
|
3705
|
-
#line
|
4553
|
+
#line 3556 "informix.ec"
|
3706
4554
|
sqli_curs_decl_dynm(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 0), cid, sqli_curs_locate(ESQLINTVERSION, sid, 1), 0, 0);
|
3707
|
-
#line
|
4555
|
+
#line 3556 "informix.ec"
|
3708
4556
|
}
|
3709
4557
|
|
3710
4558
|
if (SQLCODE < 0)
|
@@ -3714,11 +4562,11 @@ cursor_initialize(VALUE self, VALUE db, VALUE query, VALUE options)
|
|
3714
4562
|
/*
|
3715
4563
|
* EXEC SQL describe :sid into output;
|
3716
4564
|
*/
|
3717
|
-
#line
|
4565
|
+
#line 3562 "informix.ec"
|
3718
4566
|
{
|
3719
|
-
#line
|
4567
|
+
#line 3562 "informix.ec"
|
3720
4568
|
sqli_describe_stmt(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, sid, 257), &output, 0);
|
3721
|
-
#line
|
4569
|
+
#line 3562 "informix.ec"
|
3722
4570
|
}
|
3723
4571
|
c->daOutput = output;
|
3724
4572
|
|
@@ -3738,6 +4586,53 @@ cursor_initialize(VALUE self, VALUE db, VALUE query, VALUE options)
|
|
3738
4586
|
return self;
|
3739
4587
|
}
|
3740
4588
|
|
4589
|
+
/*
|
4590
|
+
* call-seq:
|
4591
|
+
* Cursor.open(database, query, options) => cursor
|
4592
|
+
* Cursor.open(database, query, options) {|cursor| block } => obj
|
4593
|
+
*
|
4594
|
+
* Creates and opens a Cursor object based on <i>query</i> using <i>options</i>
|
4595
|
+
* in the context of <i>database</i>.
|
4596
|
+
* In the first form the Cursor object is returned.
|
4597
|
+
* In the second form the Cursor object is passed to the block and when it
|
4598
|
+
* terminates, the Cursor object is dropped, returning the value of the block.
|
4599
|
+
*
|
4600
|
+
* <i>options</i> can be nil or a Hash object with the following possible keys:
|
4601
|
+
*
|
4602
|
+
* :scroll => true or false
|
4603
|
+
* :hold => true or false
|
4604
|
+
* :params => input parameters as an Array or nil
|
4605
|
+
*/
|
4606
|
+
static VALUE cursor_open(int argc, VALUE *argv, VALUE self);
|
4607
|
+
static VALUE cursor_drop(VALUE self);
|
4608
|
+
static VALUE
|
4609
|
+
cursor_s_open(int argc, VALUE *argv, VALUE klass)
|
4610
|
+
{
|
4611
|
+
VALUE cursor, options, params;
|
4612
|
+
int open_argc;
|
4613
|
+
|
4614
|
+
rb_scan_args(argc, argv, "21", 0, 0, &options);
|
4615
|
+
open_argc = 0; params = Qnil;
|
4616
|
+
|
4617
|
+
if (!NIL_P(options)) {
|
4618
|
+
Check_Type(options, T_HASH);
|
4619
|
+
params = rb_hash_aref(options, sym_params);
|
4620
|
+
|
4621
|
+
if (TYPE(params) == T_ARRAY)
|
4622
|
+
open_argc = RARRAY(params)->len;
|
4623
|
+
else if (params != Qnil)
|
4624
|
+
rb_raise(rb_eRuntimeError, "Parameters must be supplied as an Array");
|
4625
|
+
}
|
4626
|
+
|
4627
|
+
cursor = rb_class_new_instance(argc, argv, klass);
|
4628
|
+
cursor_open(open_argc, ¶ms, cursor);
|
4629
|
+
|
4630
|
+
if (rb_block_given_p())
|
4631
|
+
return rb_ensure(rb_yield, cursor, cursor_drop, cursor);
|
4632
|
+
|
4633
|
+
return cursor;
|
4634
|
+
}
|
4635
|
+
|
3741
4636
|
/*
|
3742
4637
|
* call-seq:
|
3743
4638
|
* cursor.id => string
|
@@ -3770,13 +4665,13 @@ cursor_open(int argc, VALUE *argv, VALUE self)
|
|
3770
4665
|
/*
|
3771
4666
|
* EXEC SQL begin declare section;
|
3772
4667
|
*/
|
3773
|
-
#line
|
3774
|
-
#line
|
4668
|
+
#line 3657 "informix.ec"
|
4669
|
+
#line 3658 "informix.ec"
|
3775
4670
|
char *cid, *did;
|
3776
4671
|
/*
|
3777
4672
|
* EXEC SQL end declare section;
|
3778
4673
|
*/
|
3779
|
-
#line
|
4674
|
+
#line 3659 "informix.ec"
|
3780
4675
|
|
3781
4676
|
|
3782
4677
|
Data_Get_Struct(self, cursor_t, c);
|
@@ -3785,20 +4680,17 @@ cursor_open(int argc, VALUE *argv, VALUE self)
|
|
3785
4680
|
return self;
|
3786
4681
|
|
3787
4682
|
did = c->database_id;
|
3788
|
-
if (currentdid != did) {
|
3789
4683
|
/*
|
3790
|
-
*
|
4684
|
+
* EXEC SQL set connection :did;
|
3791
4685
|
*/
|
3792
|
-
#line
|
4686
|
+
#line 3667 "informix.ec"
|
3793
4687
|
{
|
3794
|
-
#line
|
4688
|
+
#line 3667 "informix.ec"
|
3795
4689
|
sqli_connect_set(0, did, 0);
|
3796
|
-
#line
|
4690
|
+
#line 3667 "informix.ec"
|
3797
4691
|
}
|
3798
|
-
|
3799
|
-
|
3800
|
-
currentdid = did;
|
3801
|
-
}
|
4692
|
+
if (SQLCODE < 0)
|
4693
|
+
rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
|
3802
4694
|
|
3803
4695
|
input = &c->daInput;
|
3804
4696
|
cid = c->cursor_id;
|
@@ -3814,11 +4706,11 @@ cursor_open(int argc, VALUE *argv, VALUE self)
|
|
3814
4706
|
* EXEC SQL open :cid using descriptor input
|
3815
4707
|
* with reoptimization;
|
3816
4708
|
*/
|
3817
|
-
#line
|
4709
|
+
#line 3681 "informix.ec"
|
3818
4710
|
{
|
3819
|
-
#line
|
4711
|
+
#line 3682 "informix.ec"
|
3820
4712
|
sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), input, (char *)0, (struct value *)0, 1, 1);
|
3821
|
-
#line
|
4713
|
+
#line 3682 "informix.ec"
|
3822
4714
|
}
|
3823
4715
|
clean_input_slots(c);
|
3824
4716
|
}
|
@@ -3826,22 +4718,22 @@ cursor_open(int argc, VALUE *argv, VALUE self)
|
|
3826
4718
|
/*
|
3827
4719
|
* EXEC SQL open :cid with reoptimization;
|
3828
4720
|
*/
|
3829
|
-
#line
|
4721
|
+
#line 3686 "informix.ec"
|
3830
4722
|
{
|
3831
|
-
#line
|
4723
|
+
#line 3686 "informix.ec"
|
3832
4724
|
sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 1);
|
3833
|
-
#line
|
4725
|
+
#line 3686 "informix.ec"
|
3834
4726
|
}
|
3835
4727
|
}
|
3836
4728
|
else
|
3837
4729
|
/*
|
3838
4730
|
* EXEC SQL open :cid;
|
3839
4731
|
*/
|
3840
|
-
#line
|
4732
|
+
#line 3689 "informix.ec"
|
3841
4733
|
{
|
3842
|
-
#line
|
4734
|
+
#line 3689 "informix.ec"
|
3843
4735
|
sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 0);
|
3844
|
-
#line
|
4736
|
+
#line 3689 "informix.ec"
|
3845
4737
|
}
|
3846
4738
|
|
3847
4739
|
if (SQLCODE < 0)
|
@@ -3898,20 +4790,44 @@ void Init_informix(void)
|
|
3898
4790
|
/* class Slob --------------------------------------------------------- */
|
3899
4791
|
rb_cSlob = rb_define_class_under(rb_mInformix, "Slob", rb_cObject);
|
3900
4792
|
rb_define_alloc_func(rb_cSlob, slob_alloc);
|
3901
|
-
rb_define_method(rb_cSlob, "initialize",
|
3902
|
-
|
3903
|
-
rb_define_method(rb_cSlob, "
|
3904
|
-
rb_define_method(rb_cSlob, "
|
3905
|
-
rb_define_method(rb_cSlob, "
|
3906
|
-
rb_define_method(rb_cSlob, "
|
3907
|
-
rb_define_method(rb_cSlob, "
|
3908
|
-
rb_define_method(rb_cSlob, "
|
4793
|
+
rb_define_method(rb_cSlob, "initialize", rb_slob_initialize, -1);
|
4794
|
+
rb_define_singleton_method(rb_cSlob, "new", rb_slob_s_new, -1);
|
4795
|
+
rb_define_method(rb_cSlob, "open", rb_slob_open, -1);
|
4796
|
+
rb_define_method(rb_cSlob, "close", rb_slob_close, 0);
|
4797
|
+
rb_define_method(rb_cSlob, "read", rb_slob_read, 1);
|
4798
|
+
rb_define_method(rb_cSlob, "write", rb_slob_write, 1);
|
4799
|
+
rb_define_method(rb_cSlob, "seek", rb_slob_seek, 2);
|
4800
|
+
rb_define_method(rb_cSlob, "tell", rb_slob_tell, 0);
|
4801
|
+
rb_define_alias(rb_cSlob, "pos", "tell");
|
4802
|
+
rb_define_method(rb_cSlob, "pos=", rb_slob_set_pos, 1);
|
4803
|
+
rb_define_method(rb_cSlob, "truncate", rb_slob_truncate, 1);
|
4804
|
+
rb_define_method(rb_cSlob, "stat", rb_slob_stat, 0);
|
4805
|
+
rb_define_method(rb_cSlob, "<<", rb_slob_addstr, 1);
|
4806
|
+
rb_define_method(rb_cSlob, "rewind", rb_slob_rewind, 0);
|
4807
|
+
rb_define_method(rb_cSlob, "lock", rb_slob_lock, 4);
|
4808
|
+
rb_define_method(rb_cSlob, "unlock", rb_slob_unlock, 3);
|
4809
|
+
|
4810
|
+
rb_define_method(rb_cSlob, "atime", rb_slob_atime, 0);
|
4811
|
+
rb_define_method(rb_cSlob, "ctime", rb_slob_ctime, 0);
|
4812
|
+
rb_define_method(rb_cSlob, "mtime", rb_slob_mtime, 0);
|
4813
|
+
rb_define_method(rb_cSlob, "refcnt", rb_slob_refcnt, 0);
|
4814
|
+
rb_define_method(rb_cSlob, "size", rb_slob_size, 0);
|
4815
|
+
|
4816
|
+
rb_define_method(rb_cSlob, "estbytes", rb_slob_estbytes, 0);
|
4817
|
+
rb_define_method(rb_cSlob, "extsz", rb_slob_extsz, 0);
|
4818
|
+
rb_define_method(rb_cSlob, "flags", rb_slob_flags, 0);
|
4819
|
+
rb_define_method(rb_cSlob, "maxbytes", rb_slob_maxbytes, 0);
|
4820
|
+
rb_define_method(rb_cSlob, "sbspace", rb_slob_sbspace, 0);
|
4821
|
+
|
4822
|
+
rb_define_method(rb_cSlob, "extsz=", rb_slob_set_extsz, 1);
|
4823
|
+
rb_define_method(rb_cSlob, "flags=", rb_slob_set_flags, 1);
|
3909
4824
|
|
3910
4825
|
rb_define_const(rb_cSlob, "CLOB", INT2FIX(XID_CLOB));
|
3911
4826
|
rb_define_const(rb_cSlob, "BLOB", INT2FIX(XID_BLOB));
|
3912
4827
|
|
3913
4828
|
#define DEF_SLOB_CONST(k) rb_define_const(rb_cSlob, #k, INT2FIX(LO_##k))
|
3914
4829
|
|
4830
|
+
/* Access modes */
|
3915
4831
|
DEF_SLOB_CONST(RDONLY);
|
3916
4832
|
DEF_SLOB_CONST(DIRTY_READ);
|
3917
4833
|
DEF_SLOB_CONST(WRONLY);
|
@@ -3925,25 +4841,58 @@ void Init_informix(void)
|
|
3925
4841
|
DEF_SLOB_CONST(SEEK_CUR);
|
3926
4842
|
DEF_SLOB_CONST(SEEK_END);
|
3927
4843
|
|
4844
|
+
/* Creation-time flags */
|
4845
|
+
DEF_SLOB_CONST(LOG);
|
4846
|
+
DEF_SLOB_CONST(NOLOG);
|
4847
|
+
DEF_SLOB_CONST(KEEP_LASTACCESS_TIME);
|
4848
|
+
DEF_SLOB_CONST(NOKEEP_LASTACCESS_TIME);
|
4849
|
+
|
4850
|
+
/* Ranges */
|
4851
|
+
DEF_SLOB_CONST(CURRENT_END);
|
4852
|
+
DEF_SLOB_CONST(MAX_END);
|
4853
|
+
|
4854
|
+
/* Lock modes */
|
4855
|
+
DEF_SLOB_CONST(SHARED_MODE);
|
4856
|
+
DEF_SLOB_CONST(EXCLUSIVE_MODE);
|
4857
|
+
|
4858
|
+
/* class Slob::Stat --------------------------------------------------- */
|
4859
|
+
|
4860
|
+
rb_cSlobStat = rb_define_class_under(rb_cSlob, "Stat", rb_cObject);
|
4861
|
+
rb_define_alloc_func(rb_cSlobStat, slobstat_alloc);
|
4862
|
+
rb_define_method(rb_cSlobStat, "initialize", rb_slobstat_initialize, 1);
|
4863
|
+
|
4864
|
+
rb_include_module(rb_cSlobStat, rb_mComparable);
|
4865
|
+
rb_define_method(rb_cSlobStat, "<=>", rb_slobstat_cmp, 1);
|
4866
|
+
|
4867
|
+
rb_define_method(rb_cSlobStat, "atime", rb_slobstat_atime, 0);
|
4868
|
+
rb_define_method(rb_cSlobStat, "ctime", rb_slobstat_ctime, 0);
|
4869
|
+
rb_define_method(rb_cSlobStat, "mtime", rb_slobstat_mtime, 0);
|
4870
|
+
rb_define_method(rb_cSlobStat, "refcnt", rb_slobstat_refcnt, 0);
|
4871
|
+
rb_define_method(rb_cSlobStat, "size", rb_slobstat_size, 0);
|
4872
|
+
|
3928
4873
|
/* class Database ----------------------------------------------------- */
|
3929
4874
|
rb_cDatabase = rb_define_class_under(rb_mInformix, "Database", rb_cObject);
|
3930
4875
|
rb_define_alloc_func(rb_cDatabase, database_alloc);
|
3931
|
-
rb_define_method(rb_cDatabase, "initialize",
|
3932
|
-
|
3933
|
-
|
3934
|
-
rb_define_method(rb_cDatabase, "
|
4876
|
+
rb_define_method(rb_cDatabase, "initialize", rb_database_initialize, -1);
|
4877
|
+
rb_define_singleton_method(rb_cDatabase, "open", rb_database_s_open, -1);
|
4878
|
+
rb_define_alias(rb_cDatabase, "new", "open");
|
4879
|
+
rb_define_method(rb_cDatabase, "close", rb_database_close, 0);
|
4880
|
+
rb_define_alias(rb_cDatabase, "disconnect", "close");
|
4881
|
+
rb_define_method(rb_cDatabase, "immediate", rb_database_immediate, 1);
|
3935
4882
|
rb_define_alias(rb_cDatabase, "do", "immediate");
|
3936
|
-
rb_define_method(rb_cDatabase, "rollback",
|
3937
|
-
rb_define_method(rb_cDatabase, "commit",
|
3938
|
-
rb_define_method(rb_cDatabase, "transaction",
|
3939
|
-
rb_define_method(rb_cDatabase, "prepare",
|
3940
|
-
rb_define_method(rb_cDatabase, "columns",
|
3941
|
-
rb_define_method(rb_cDatabase, "cursor",
|
4883
|
+
rb_define_method(rb_cDatabase, "rollback", rb_database_rollback, 0);
|
4884
|
+
rb_define_method(rb_cDatabase, "commit", rb_database_commit, 0);
|
4885
|
+
rb_define_method(rb_cDatabase, "transaction", rb_database_transaction, 0);
|
4886
|
+
rb_define_method(rb_cDatabase, "prepare", rb_database_prepare, 1);
|
4887
|
+
rb_define_method(rb_cDatabase, "columns", rb_database_columns, 1);
|
4888
|
+
rb_define_method(rb_cDatabase, "cursor", rb_database_cursor, -1);
|
4889
|
+
rb_define_method(rb_cDatabase, "slob", rb_database_slob, -1);
|
3942
4890
|
|
3943
4891
|
/* class Statement ---------------------------------------------------- */
|
3944
4892
|
rb_cStatement = rb_define_class_under(rb_mInformix, "Statement", rb_cObject);
|
3945
4893
|
rb_define_alloc_func(rb_cStatement, statement_alloc);
|
3946
4894
|
rb_define_method(rb_cStatement, "initialize", statement_initialize, 2);
|
4895
|
+
rb_define_singleton_method(rb_cStatement, "new", statement_s_new, -1);
|
3947
4896
|
rb_define_method(rb_cStatement, "[]", statement_call, -1);
|
3948
4897
|
rb_define_alias(rb_cStatement, "call", "[]");
|
3949
4898
|
rb_define_alias(rb_cStatement, "execute", "[]");
|
@@ -4000,7 +4949,8 @@ void Init_informix(void)
|
|
4000
4949
|
/* class Cursor ------------------------------------------------------- */
|
4001
4950
|
rb_cCursor = rb_define_class_under(rb_mInformix, "Cursor", rb_cObject);
|
4002
4951
|
rb_define_alloc_func(rb_cCursor, cursor_alloc);
|
4003
|
-
rb_define_method(rb_cCursor, "initialize", cursor_initialize,
|
4952
|
+
rb_define_method(rb_cCursor, "initialize", cursor_initialize, -1);
|
4953
|
+
rb_define_singleton_method(rb_cCursor, "open", cursor_s_open, -1);
|
4004
4954
|
rb_define_method(rb_cCursor, "id", cursor_id, 0);
|
4005
4955
|
rb_define_method(rb_cCursor, "open", cursor_open, -1);
|
4006
4956
|
rb_define_method(rb_cCursor, "close", cursor_close, 0);
|
@@ -4009,20 +4959,15 @@ void Init_informix(void)
|
|
4009
4959
|
/* Global constants --------------------------------------------------- */
|
4010
4960
|
rb_require("date");
|
4011
4961
|
rb_cDate = rb_const_get(rb_cObject, rb_intern("Date"));
|
4962
|
+
rb_require("bigdecimal");
|
4963
|
+
rb_cBigDecimal = rb_const_get(rb_cObject, rb_intern("BigDecimal"));
|
4012
4964
|
|
4013
4965
|
/* Global symbols ----------------------------------------------------- */
|
4014
|
-
|
4015
|
-
|
4016
|
-
|
4017
|
-
|
4018
|
-
|
4019
|
-
s_year = rb_intern("year");
|
4020
|
-
s_hour = rb_intern("hour");
|
4021
|
-
s_min = rb_intern("min");
|
4022
|
-
s_sec = rb_intern("sec");
|
4023
|
-
s_usec = rb_intern("usec");
|
4024
|
-
s_to_s = rb_intern("to_s");
|
4025
|
-
s_to_i = rb_intern("to_i");
|
4966
|
+
#define INTERN(sym) s_##sym = rb_intern(#sym)
|
4967
|
+
INTERN(read); INTERN(new);
|
4968
|
+
INTERN(utc); INTERN(day); INTERN(month); INTERN(year);
|
4969
|
+
INTERN(hour); INTERN(min); INTERN(sec); INTERN(usec);
|
4970
|
+
INTERN(to_s); INTERN(to_i);
|
4026
4971
|
|
4027
4972
|
sym_name = ID2SYM(rb_intern("name"));
|
4028
4973
|
sym_type = ID2SYM(rb_intern("type"));
|
@@ -4043,6 +4988,9 @@ void Init_informix(void)
|
|
4043
4988
|
sym_extsz = ID2SYM(rb_intern("extsz"));
|
4044
4989
|
sym_createflags = ID2SYM(rb_intern("createflags"));
|
4045
4990
|
sym_openflags = ID2SYM(rb_intern("openflags"));
|
4991
|
+
sym_maxbytes = ID2SYM(rb_intern("maxbytes"));
|
4992
|
+
|
4993
|
+
sym_params = ID2SYM(rb_intern("params"));
|
4046
4994
|
}
|
4047
4995
|
|
4048
|
-
#line
|
4996
|
+
#line 3946 "informix.ec"
|