ruby-informix 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (10) hide show
  1. data/Changelog +47 -0
  2. data/README +8 -5
  3. data/extconf.rb +1 -1
  4. data/ifx_assert.h +45 -0
  5. data/ifx_except.c +523 -0
  6. data/ifx_except.ec +467 -0
  7. data/ifx_except.h +82 -0
  8. data/informix.c +555 -541
  9. data/informix.ec +173 -159
  10. metadata +9 -3
@@ -0,0 +1,82 @@
1
+ /* $Id: ifx_except.h,v 1.1 2007/01/31 02:16:32 santana Exp $ */
2
+ /*
3
+ * Copyright (c) 2006, 2007 Edwin M. Fine <efine@finecomputerconsultants.com>
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions
8
+ * are met:
9
+ *
10
+ * 1. Redistributions of source code must retain the above copyright
11
+ * notice, this list of conditions and the following disclaimer.
12
+ * 2. Redistributions in binary form must reproduce the above copyright
13
+ * notice, this list of conditions and the following disclaimer in the
14
+ * documentation and/or other materials provided with the distribution.
15
+ * 3. The name of the author may not be used to endorse or promote products
16
+ * derived from this software without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
22
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+ * POSSIBILITY OF SUCH DAMAGE.
29
+ */
30
+
31
+ #if !defined(IFX_EXCEPT_H_INCLUDED)
32
+ #define IFX_EXCEPT_H_INCLUDED
33
+
34
+ #include <ruby.h>
35
+
36
+ typedef struct ifx_except_symbols_t {
37
+ VALUE mInformix;
38
+ VALUE sExcInfo;
39
+
40
+ VALUE eError;
41
+ VALUE eInterfaceError;
42
+ VALUE eDatabaseError;
43
+ VALUE eDataError;
44
+ VALUE eOperationalError;
45
+ VALUE eIntegrityError;
46
+ VALUE eInternalError;
47
+ VALUE eProgrammingError;
48
+ VALUE eNotSupportedError;
49
+ VALUE eWarning;
50
+
51
+ VALUE lib_eAssertion;
52
+
53
+ /* Symbols for the ErrorInfo struct */
54
+ ID id_sql_code;
55
+ ID id_sql_state;
56
+ ID id_class_origin;
57
+ ID id_subclass_origin;
58
+ ID id_message;
59
+ ID id_server_name;
60
+ ID id_connection_name;
61
+ } ifx_except_symbols_t;
62
+
63
+ /**
64
+ * Initializes this module. MUST be called from within
65
+ * Informix_init(). If syms is not null, the struct it points
66
+ * to will be set to the value of the corresponding symbols.
67
+ */
68
+ void rbifx_except_init(VALUE mInformix, ifx_except_symbols_t *syms);
69
+
70
+ /**
71
+ * Creates and returns an instance of any class derived from
72
+ * Informix::Error or Informix::Warning, using extended data from
73
+ * the SQL GET DIAGNOSTICS statement.
74
+ */
75
+ VALUE rbifx_ext_exception(VALUE exception_class);
76
+
77
+ /**
78
+ * Raises an error with extended GET DIAGNOSTICS information
79
+ */
80
+ void raise_ifx_extended(void); /* Raises Informix::DatabaseError */
81
+
82
+ #endif
data/informix.c CHANGED
@@ -1,7 +1,7 @@
1
1
  #include <sqlhdr.h>
2
2
  #include <sqliapi.h>
3
3
  #line 1 "informix.ec"
4
- /* $Id: informix.ec,v 1.81.2.2 2007/08/10 17:48:47 santana Exp $ */
4
+ /* $Id: informix.ec,v 1.10 2007/08/23 02:32:56 santana Exp $ */
5
5
  /*
6
6
  * Copyright (c) 2006-2007, Gerardo Santana Gomez Garrido <gerardo.santana@gmail.com>
7
7
  * All rights reserved.
@@ -31,7 +31,10 @@
31
31
  * POSSIBILITY OF SUCH DAMAGE.
32
32
  */
33
33
 
34
+ static const char rcsid[] = "$Id: informix.ec,v 1.10 2007/08/23 02:32:56 santana Exp $";
35
+
34
36
  #include "ruby.h"
37
+ #include "ifx_except.h"
35
38
 
36
39
  #include <sqlstype.h>
37
40
  #include <sqltypes.h>
@@ -58,6 +61,9 @@ static VALUE sym_col_info, sym_sbspace, sym_estbytes, sym_extsz;
58
61
  static VALUE sym_createflags, sym_openflags, sym_maxbytes;
59
62
  static VALUE sym_params;
60
63
 
64
+ /* Symbols from ifx_except module */
65
+ static ifx_except_symbols_t esyms;
66
+
61
67
  #define IDSIZE 30
62
68
 
63
69
  typedef struct {
@@ -85,20 +91,22 @@ typedef struct {
85
91
  ifx_int8_t size;
86
92
  } slobstat_t;
87
93
 
88
- #define NUM2INT8(num, int8addr) do { \
94
+ #define NUM2INT8(num, int8addr) \
95
+ do { \
89
96
  VALUE str = rb_funcall(num, s_to_s, 0); \
90
97
  char *c_str = StringValueCStr(str); \
91
98
  mint ret = ifx_int8cvasc(c_str, strlen(c_str), (int8addr)); \
92
99
  if (ret < 0) \
93
- rb_raise(rb_eRuntimeError, "Could not convert %s to int8", c_str); \
94
- }while(0)
100
+ rb_raise(esyms.eOperationalError, "Could not convert %s to int8", c_str); \
101
+ } while(0)
95
102
 
96
- #define INT82NUM(int8addr, num) do { \
103
+ #define INT82NUM(int8addr, num) \
104
+ do { \
97
105
  char str[21]; \
98
106
  ifx_int8toasc((int8addr), str, sizeof(str) - 1); \
99
107
  str[sizeof(str) - 1] = 0; \
100
108
  num = rb_cstr2inum(str, 10); \
101
- }while(0)
109
+ } while(0)
102
110
 
103
111
  /* class Slob::Stat ------------------------------------------------------ */
104
112
 
@@ -134,39 +142,39 @@ rb_slobstat_initialize(VALUE self, VALUE slob)
134
142
  /*
135
143
  * EXEC SQL begin declare section;
136
144
  */
137
- #line 131 "informix.ec"
138
- #line 132 "informix.ec"
145
+ #line 139 "informix.ec"
146
+ #line 140 "informix.ec"
139
147
  char *did;
140
148
  /*
141
149
  * EXEC SQL end declare section;
142
150
  */
143
- #line 133 "informix.ec"
151
+ #line 141 "informix.ec"
144
152
 
145
153
 
146
154
  Data_Get_Struct(slob, slob_t, sb);
147
155
  Data_Get_Struct(self, slobstat_t, stat);
148
156
 
149
157
  if (sb->fd == -1)
150
- rb_raise(rb_eRuntimeError,
158
+ rb_raise(esyms.eProgrammingError,
151
159
  "Open the Slob object before getting its status");
152
160
 
153
161
  did = sb->database_id;
154
162
  /*
155
163
  * EXEC SQL set connection :did;
156
164
  */
157
- #line 143 "informix.ec"
165
+ #line 151 "informix.ec"
158
166
  {
159
- #line 143 "informix.ec"
167
+ #line 151 "informix.ec"
160
168
  sqli_connect_set(0, did, 0);
161
- #line 143 "informix.ec"
169
+ #line 151 "informix.ec"
162
170
  }
163
171
  if (SQLCODE < 0)
164
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
172
+ raise_ifx_extended();
165
173
 
166
174
  ret = ifx_lo_stat(sb->fd, &st);
167
175
 
168
176
  if (ret < 0)
169
- rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
177
+ raise_ifx_extended();
170
178
 
171
179
  stat->atime = ifx_lo_stat_atime(st);
172
180
  stat->ctime = ifx_lo_stat_ctime(st);
@@ -178,7 +186,7 @@ rb_slobstat_initialize(VALUE self, VALUE slob)
178
186
 
179
187
  if (stat->atime == -1 || stat->ctime == -1 || stat->mtime == -1 ||
180
188
  stat->refcnt == -1 || ret == -1) {
181
- rb_raise(rb_eRuntimeError, "Unable to get status");
189
+ rb_raise(esyms.eOperationalError, "Unable to get status");
182
190
  }
183
191
 
184
192
  return self;
@@ -305,24 +313,24 @@ slob_free(slob_t *slob)
305
313
  /*
306
314
  * EXEC SQL begin declare section;
307
315
  */
308
- #line 286 "informix.ec"
309
- #line 287 "informix.ec"
316
+ #line 294 "informix.ec"
317
+ #line 295 "informix.ec"
310
318
  char *did;
311
319
  /*
312
320
  * EXEC SQL end declare section;
313
321
  */
314
- #line 288 "informix.ec"
322
+ #line 296 "informix.ec"
315
323
 
316
324
 
317
325
  did = slob->database_id;
318
326
  /*
319
327
  * EXEC SQL set connection :did;
320
328
  */
321
- #line 291 "informix.ec"
329
+ #line 299 "informix.ec"
322
330
  {
323
- #line 291 "informix.ec"
331
+ #line 299 "informix.ec"
324
332
  sqli_connect_set(0, did, 0);
325
- #line 291 "informix.ec"
333
+ #line 299 "informix.ec"
326
334
  }
327
335
  if (SQLCODE >= 0)
328
336
  ifx_lo_close(slob->fd);
@@ -349,27 +357,6 @@ slob_alloc(VALUE klass)
349
357
  return Data_Wrap_Struct(klass, slob_mark, slob_free, slob);
350
358
  }
351
359
 
352
- /*
353
- * call-seq:
354
- * Slob.new(database, type = Slob::CLOB, options = nil) => slob
355
- * Slob.new(database, type = Slob::CLOB, options = nil) {|slob| block } => obj
356
- *
357
- * Creates a Smart Large Object of type <i>type</i> in <i>database</i>.
358
- * Returns a <code>Slob</code> object pointing to it.
359
- *
360
- * <i>type</i> can be Slob::BLOB or Slob::CLOB
361
- *
362
- * <i>options</i> must be a hash with the following possible keys:
363
- *
364
- * :sbspace => Sbspace name
365
- * :estbytes => Estimated size, in bytes
366
- * :extsz => Allocation extent size
367
- * :createflags => Create-time flags
368
- * :openflags => Access mode
369
- * :maxbytes => Maximum size
370
- * :col_info => Get the previous values from the column-level storage
371
- * characteristics for the specified database column
372
- */
373
360
  static VALUE
374
361
  rb_slob_initialize(int argc, VALUE *argv, VALUE self)
375
362
  {
@@ -380,13 +367,13 @@ rb_slob_initialize(int argc, VALUE *argv, VALUE self)
380
367
  /*
381
368
  * EXEC SQL begin declare section;
382
369
  */
383
- #line 345 "informix.ec"
384
- #line 346 "informix.ec"
370
+ #line 332 "informix.ec"
371
+ #line 333 "informix.ec"
385
372
  char *did;
386
373
  /*
387
374
  * EXEC SQL end declare section;
388
375
  */
389
- #line 347 "informix.ec"
376
+ #line 334 "informix.ec"
390
377
 
391
378
 
392
379
  rb_scan_args(argc, argv, "12", &db, &type, &options);
@@ -395,14 +382,14 @@ rb_slob_initialize(int argc, VALUE *argv, VALUE self)
395
382
  /*
396
383
  * EXEC SQL set connection :did;
397
384
  */
398
- #line 352 "informix.ec"
385
+ #line 339 "informix.ec"
399
386
  {
400
- #line 352 "informix.ec"
387
+ #line 339 "informix.ec"
401
388
  sqli_connect_set(0, did, 0);
402
- #line 352 "informix.ec"
389
+ #line 339 "informix.ec"
403
390
  }
404
391
  if (SQLCODE < 0)
405
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
392
+ raise_ifx_extended();
406
393
 
407
394
  Data_Get_Struct(self, slob_t, slob);
408
395
  slob->db = db;
@@ -411,7 +398,7 @@ rb_slob_initialize(int argc, VALUE *argv, VALUE self)
411
398
  if (!NIL_P(type)) {
412
399
  int t = FIX2INT(type);
413
400
  if (t != XID_CLOB && t != XID_BLOB)
414
- rb_raise(rb_eRuntimeError, "Invalid type %d for an SLOB", t);
401
+ rb_raise(esyms.eInternalError, "Invalid type %d for an SLOB", t);
415
402
  slob->type = t;
416
403
  }
417
404
 
@@ -430,19 +417,19 @@ rb_slob_initialize(int argc, VALUE *argv, VALUE self)
430
417
 
431
418
  ret = ifx_lo_def_create_spec(&slob->spec);
432
419
  if (ret < 0)
433
- rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
420
+ raise_ifx_extended();
434
421
 
435
422
  if (!NIL_P(col_info)) {
436
423
  ret = ifx_lo_col_info(StringValueCStr(col_info), slob->spec);
437
424
 
438
425
  if (ret < 0)
439
- rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
426
+ raise_ifx_extended();
440
427
  }
441
428
  if (!NIL_P(sbspace)) {
442
429
  char *c_sbspace = StringValueCStr(sbspace);
443
430
  ret = ifx_lo_specset_sbspace(slob->spec, c_sbspace);
444
431
  if (ret == -1)
445
- rb_raise(rb_eRuntimeError, "Could not set sbspace name to %s", c_sbspace);
432
+ rb_raise(esyms.eOperationalError, "Could not set sbspace name to %s", c_sbspace);
446
433
  }
447
434
  if (!NIL_P(estbytes)) {
448
435
  ifx_int8_t estbytes8;
@@ -450,17 +437,17 @@ rb_slob_initialize(int argc, VALUE *argv, VALUE self)
450
437
  NUM2INT8(estbytes, &estbytes8);
451
438
  ret = ifx_lo_specset_estbytes(slob->spec, &estbytes8);
452
439
  if (ret == -1)
453
- rb_raise(rb_eRuntimeError, "Could not set estbytes");
440
+ rb_raise(esyms.eOperationalError, "Could not set estbytes");
454
441
  }
455
442
  if (!NIL_P(extsz)) {
456
443
  ret = ifx_lo_specset_extsz(slob->spec, FIX2LONG(extsz));
457
444
  if (ret == -1)
458
- rb_raise(rb_eRuntimeError, "Could not set extsz to %d", FIX2LONG(extsz));
445
+ rb_raise(esyms.eOperationalError, "Could not set extsz to %d", FIX2LONG(extsz));
459
446
  }
460
447
  if (!NIL_P(createflags)) {
461
448
  ret = ifx_lo_specset_flags(slob->spec, FIX2LONG(createflags));
462
449
  if (ret == -1)
463
- rb_raise(rb_eRuntimeError, "Could not set crate-time flags to 0x%X", FIX2LONG(createflags));
450
+ rb_raise(esyms.eOperationalError, "Could not set crate-time flags to 0x%X", FIX2LONG(createflags));
464
451
  }
465
452
  if (!NIL_P(maxbytes)) {
466
453
  ifx_int8_t maxbytes8;
@@ -468,16 +455,17 @@ rb_slob_initialize(int argc, VALUE *argv, VALUE self)
468
455
  NUM2INT8(maxbytes, (&maxbytes8));
469
456
  ret = ifx_lo_specset_maxbytes(slob->spec, &maxbytes8);
470
457
  if (ret == -1)
471
- rb_raise(rb_eRuntimeError, "Could not set maxbytes");
458
+ rb_raise(esyms.eOperationalError, "Could not set maxbytes");
472
459
  }
473
460
 
474
461
  slob->fd = ifx_lo_create(slob->spec, RTEST(openflags)? FIX2LONG(openflags): LO_RDWR, &slob->lo, &error);
475
462
  if (slob->fd == -1)
476
- rb_raise(rb_eRuntimeError, "Informix Error: %d\n", error);
463
+ raise_ifx_extended();
477
464
 
478
465
  return self;
479
466
  }
480
467
 
468
+ static VALUE rb_slob_close(VALUE self);
481
469
  /*
482
470
  * call-seq:
483
471
  * Slob.new(database, type = Slob::CLOB, options = nil) => slob
@@ -499,7 +487,6 @@ rb_slob_initialize(int argc, VALUE *argv, VALUE self)
499
487
  * :col_info => Get the previous values from the column-level storage
500
488
  * characteristics for the specified database column
501
489
  */
502
- static VALUE rb_slob_close(VALUE self);
503
490
  static VALUE
504
491
  rb_slob_s_new(int argc, VALUE *argv, VALUE klass)
505
492
  {
@@ -542,13 +529,13 @@ rb_slob_open(int argc, VALUE *argv, VALUE self)
542
529
  /*
543
530
  * EXEC SQL begin declare section;
544
531
  */
545
- #line 491 "informix.ec"
546
- #line 492 "informix.ec"
532
+ #line 478 "informix.ec"
533
+ #line 479 "informix.ec"
547
534
  char *did;
548
535
  /*
549
536
  * EXEC SQL end declare section;
550
537
  */
551
- #line 493 "informix.ec"
538
+ #line 480 "informix.ec"
552
539
 
553
540
 
554
541
  Data_Get_Struct(self, slob_t, slob);
@@ -560,21 +547,21 @@ rb_slob_open(int argc, VALUE *argv, VALUE self)
560
547
  /*
561
548
  * EXEC SQL set connection :did;
562
549
  */
563
- #line 501 "informix.ec"
550
+ #line 488 "informix.ec"
564
551
  {
565
- #line 501 "informix.ec"
552
+ #line 488 "informix.ec"
566
553
  sqli_connect_set(0, did, 0);
567
- #line 501 "informix.ec"
554
+ #line 488 "informix.ec"
568
555
  }
569
556
  if (SQLCODE < 0)
570
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
557
+ raise_ifx_extended();
571
558
 
572
559
  rb_scan_args(argc, argv, "01", &access);
573
560
 
574
561
  slob->fd = ifx_lo_open(&slob->lo, NIL_P(access)? LO_RDONLY: FIX2INT(access), &error);
575
562
 
576
563
  if (slob->fd == -1)
577
- rb_raise(rb_eRuntimeError, "Informix Error: %d", error);
564
+ raise_ifx_extended();
578
565
 
579
566
  return self;
580
567
  }
@@ -595,24 +582,24 @@ rb_slob_close(VALUE self)
595
582
  /*
596
583
  * EXEC SQL begin declare section;
597
584
  */
598
- #line 528 "informix.ec"
599
- #line 529 "informix.ec"
585
+ #line 515 "informix.ec"
586
+ #line 516 "informix.ec"
600
587
  char *did;
601
588
  /*
602
589
  * EXEC SQL end declare section;
603
590
  */
604
- #line 530 "informix.ec"
591
+ #line 517 "informix.ec"
605
592
 
606
593
 
607
594
  did = slob->database_id;
608
595
  /*
609
596
  * EXEC SQL set connection :did;
610
597
  */
611
- #line 533 "informix.ec"
598
+ #line 520 "informix.ec"
612
599
  {
613
- #line 533 "informix.ec"
600
+ #line 520 "informix.ec"
614
601
  sqli_connect_set(0, did, 0);
615
- #line 533 "informix.ec"
602
+ #line 520 "informix.ec"
616
603
  }
617
604
  if (SQLCODE < 0)
618
605
  return self;
@@ -643,33 +630,33 @@ rb_slob_read(VALUE self, VALUE nbytes)
643
630
  /*
644
631
  * EXEC SQL begin declare section;
645
632
  */
646
- #line 560 "informix.ec"
647
- #line 561 "informix.ec"
633
+ #line 547 "informix.ec"
634
+ #line 548 "informix.ec"
648
635
  char *did;
649
636
  /*
650
637
  * EXEC SQL end declare section;
651
638
  */
652
- #line 562 "informix.ec"
639
+ #line 549 "informix.ec"
653
640
 
654
641
 
655
642
 
656
643
  Data_Get_Struct(self, slob_t, slob);
657
644
 
658
645
  if (slob->fd == -1)
659
- rb_raise(rb_eRuntimeError, "Open the Slob object before reading");
646
+ rb_raise(esyms.eProgrammingError, "Open the Slob object before reading");
660
647
 
661
648
  did = slob->database_id;
662
649
  /*
663
650
  * EXEC SQL set connection :did;
664
651
  */
665
- #line 571 "informix.ec"
652
+ #line 558 "informix.ec"
666
653
  {
667
- #line 571 "informix.ec"
654
+ #line 558 "informix.ec"
668
655
  sqli_connect_set(0, did, 0);
669
- #line 571 "informix.ec"
656
+ #line 558 "informix.ec"
670
657
  }
671
658
  if (SQLCODE < 0)
672
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
659
+ raise_ifx_extended();
673
660
 
674
661
  c_nbytes = FIX2LONG(nbytes);
675
662
  buffer = ALLOC_N(char, c_nbytes);
@@ -677,7 +664,7 @@ rb_slob_read(VALUE self, VALUE nbytes)
677
664
 
678
665
  if (ret == -1) {
679
666
  xfree(buffer);
680
- rb_raise(rb_eRuntimeError, "Informix Error: %d\n", error);
667
+ raise_ifx_extended();
681
668
  }
682
669
 
683
670
  str = rb_str_new(buffer, ret);
@@ -706,32 +693,32 @@ rb_slob_write(VALUE self, VALUE data)
706
693
  /*
707
694
  * EXEC SQL begin declare section;
708
695
  */
709
- #line 607 "informix.ec"
710
- #line 608 "informix.ec"
696
+ #line 594 "informix.ec"
697
+ #line 595 "informix.ec"
711
698
  char *did;
712
699
  /*
713
700
  * EXEC SQL end declare section;
714
701
  */
715
- #line 609 "informix.ec"
702
+ #line 596 "informix.ec"
716
703
 
717
704
 
718
705
  Data_Get_Struct(self, slob_t, slob);
719
706
 
720
707
  if (slob->fd == -1)
721
- rb_raise(rb_eRuntimeError, "Open the Slob object before writing");
708
+ rb_raise(esyms.eProgrammingError, "Open the Slob object before writing");
722
709
 
723
710
  did = slob->database_id;
724
711
  /*
725
712
  * EXEC SQL set connection :did;
726
713
  */
727
- #line 617 "informix.ec"
714
+ #line 604 "informix.ec"
728
715
  {
729
- #line 617 "informix.ec"
716
+ #line 604 "informix.ec"
730
717
  sqli_connect_set(0, did, 0);
731
- #line 617 "informix.ec"
718
+ #line 604 "informix.ec"
732
719
  }
733
720
  if (SQLCODE < 0)
734
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
721
+ raise_ifx_extended();
735
722
 
736
723
  str = rb_obj_as_string(data);
737
724
  buffer = RSTRING(str)->ptr;
@@ -740,7 +727,7 @@ rb_slob_write(VALUE self, VALUE data)
740
727
  ret = ifx_lo_write(slob->fd, buffer, nbytes, &error);
741
728
 
742
729
  if (ret == -1)
743
- rb_raise(rb_eRuntimeError, "Informix Error: %d", error);
730
+ raise_ifx_extended();
744
731
 
745
732
  return LONG2NUM(ret);
746
733
  }
@@ -790,37 +777,37 @@ rb_slob_seek(VALUE self, VALUE offset, VALUE whence)
790
777
  /*
791
778
  * EXEC SQL begin declare section;
792
779
  */
793
- #line 675 "informix.ec"
794
- #line 676 "informix.ec"
780
+ #line 662 "informix.ec"
781
+ #line 663 "informix.ec"
795
782
  char *did;
796
783
  /*
797
784
  * EXEC SQL end declare section;
798
785
  */
799
- #line 677 "informix.ec"
786
+ #line 664 "informix.ec"
800
787
 
801
788
 
802
789
  Data_Get_Struct(self, slob_t, slob);
803
790
 
804
791
  if (slob->fd == -1)
805
- rb_raise(rb_eRuntimeError, "Open the Slob object first");
792
+ rb_raise(esyms.eProgrammingError, "Open the Slob object first");
806
793
 
807
794
  did = slob->database_id;
808
795
  /*
809
796
  * EXEC SQL set connection :did;
810
797
  */
811
- #line 685 "informix.ec"
798
+ #line 672 "informix.ec"
812
799
  {
813
- #line 685 "informix.ec"
800
+ #line 672 "informix.ec"
814
801
  sqli_connect_set(0, did, 0);
815
- #line 685 "informix.ec"
802
+ #line 672 "informix.ec"
816
803
  }
817
804
  if (SQLCODE < 0)
818
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
805
+ raise_ifx_extended();
819
806
 
820
807
  NUM2INT8(offset, &offset8);
821
808
  ret = ifx_lo_seek(slob->fd, &offset8, FIX2INT(whence), &seek_pos8);
822
809
  if (ret < 0)
823
- rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
810
+ raise_ifx_extended();
824
811
 
825
812
  INT82NUM(&seek_pos8, seek_pos);
826
813
 
@@ -868,36 +855,36 @@ rb_slob_tell(VALUE self)
868
855
  /*
869
856
  * EXEC SQL begin declare section;
870
857
  */
871
- #line 737 "informix.ec"
872
- #line 738 "informix.ec"
858
+ #line 724 "informix.ec"
859
+ #line 725 "informix.ec"
873
860
  char *did;
874
861
  /*
875
862
  * EXEC SQL end declare section;
876
863
  */
877
- #line 739 "informix.ec"
864
+ #line 726 "informix.ec"
878
865
 
879
866
 
880
867
  Data_Get_Struct(self, slob_t, slob);
881
868
 
882
869
  if (slob->fd == -1)
883
- rb_raise(rb_eRuntimeError, "Open the Slob object first");
870
+ rb_raise(esyms.eProgrammingError, "Open the Slob object first");
884
871
 
885
872
  did = slob->database_id;
886
873
  /*
887
874
  * EXEC SQL set connection :did;
888
875
  */
889
- #line 747 "informix.ec"
876
+ #line 734 "informix.ec"
890
877
  {
891
- #line 747 "informix.ec"
878
+ #line 734 "informix.ec"
892
879
  sqli_connect_set(0, did, 0);
893
- #line 747 "informix.ec"
880
+ #line 734 "informix.ec"
894
881
  }
895
882
  if (SQLCODE < 0)
896
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
883
+ raise_ifx_extended();
897
884
 
898
885
  ret = ifx_lo_tell(slob->fd, &seek_pos8);
899
886
  if (ret < 0)
900
- rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
887
+ raise_ifx_extended();
901
888
 
902
889
  INT82NUM(&seek_pos8, seek_pos);
903
890
 
@@ -921,37 +908,37 @@ rb_slob_truncate(VALUE self, VALUE offset)
921
908
  /*
922
909
  * EXEC SQL begin declare section;
923
910
  */
924
- #line 774 "informix.ec"
925
- #line 775 "informix.ec"
911
+ #line 761 "informix.ec"
912
+ #line 762 "informix.ec"
926
913
  char *did;
927
914
  /*
928
915
  * EXEC SQL end declare section;
929
916
  */
930
- #line 776 "informix.ec"
917
+ #line 763 "informix.ec"
931
918
 
932
919
 
933
920
  Data_Get_Struct(self, slob_t, slob);
934
921
 
935
922
  if (slob->fd == -1)
936
- rb_raise(rb_eRuntimeError, "Open the Slob object first");
923
+ rb_raise(esyms.eProgrammingError, "Open the Slob object first");
937
924
 
938
925
  did = slob->database_id;
939
926
  /*
940
927
  * EXEC SQL set connection :did;
941
928
  */
942
- #line 784 "informix.ec"
929
+ #line 771 "informix.ec"
943
930
  {
944
- #line 784 "informix.ec"
931
+ #line 771 "informix.ec"
945
932
  sqli_connect_set(0, did, 0);
946
- #line 784 "informix.ec"
933
+ #line 771 "informix.ec"
947
934
  }
948
935
  if (SQLCODE < 0)
949
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
936
+ raise_ifx_extended();
950
937
 
951
938
  NUM2INT8(offset, &offset8);
952
939
  ret = ifx_lo_truncate(slob->fd, &offset8);
953
940
  if (ret < 0)
954
- rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
941
+ raise_ifx_extended();
955
942
 
956
943
  return self;
957
944
  }
@@ -993,38 +980,38 @@ rb_slob_lock(VALUE self, VALUE offset, VALUE whence, VALUE range, VALUE mode)
993
980
  /*
994
981
  * EXEC SQL begin declare section;
995
982
  */
996
- #line 830 "informix.ec"
997
- #line 831 "informix.ec"
983
+ #line 817 "informix.ec"
984
+ #line 818 "informix.ec"
998
985
  char *did;
999
986
  /*
1000
987
  * EXEC SQL end declare section;
1001
988
  */
1002
- #line 832 "informix.ec"
989
+ #line 819 "informix.ec"
1003
990
 
1004
991
 
1005
992
  Data_Get_Struct(self, slob_t, slob);
1006
993
 
1007
994
  if (slob->fd == -1)
1008
- rb_raise(rb_eRuntimeError, "Open the Slob object first");
995
+ rb_raise(esyms.eProgrammingError, "Open the Slob object first");
1009
996
 
1010
997
  did = slob->database_id;
1011
998
  /*
1012
999
  * EXEC SQL set connection :did;
1013
1000
  */
1014
- #line 840 "informix.ec"
1001
+ #line 827 "informix.ec"
1015
1002
  {
1016
- #line 840 "informix.ec"
1003
+ #line 827 "informix.ec"
1017
1004
  sqli_connect_set(0, did, 0);
1018
- #line 840 "informix.ec"
1005
+ #line 827 "informix.ec"
1019
1006
  }
1020
1007
  if (SQLCODE < 0)
1021
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
1008
+ raise_ifx_extended();
1022
1009
 
1023
1010
  NUM2INT8(offset, &offset8);
1024
1011
  NUM2INT8(range, &range8);
1025
1012
  ret = ifx_lo_lock(slob->fd, &offset8, FIX2INT(whence), &range8, FIX2INT(mode));
1026
1013
  if (ret < 0)
1027
- rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
1014
+ raise_ifx_extended();
1028
1015
 
1029
1016
  return self;
1030
1017
  }
@@ -1053,38 +1040,38 @@ rb_slob_unlock(VALUE self, VALUE offset, VALUE whence, VALUE range)
1053
1040
  /*
1054
1041
  * EXEC SQL begin declare section;
1055
1042
  */
1056
- #line 874 "informix.ec"
1057
- #line 875 "informix.ec"
1043
+ #line 861 "informix.ec"
1044
+ #line 862 "informix.ec"
1058
1045
  char *did;
1059
1046
  /*
1060
1047
  * EXEC SQL end declare section;
1061
1048
  */
1062
- #line 876 "informix.ec"
1049
+ #line 863 "informix.ec"
1063
1050
 
1064
1051
 
1065
1052
  Data_Get_Struct(self, slob_t, slob);
1066
1053
 
1067
1054
  if (slob->fd == -1)
1068
- rb_raise(rb_eRuntimeError, "Open the Slob object first");
1055
+ rb_raise(esyms.eProgrammingError, "Open the Slob object first");
1069
1056
 
1070
1057
  did = slob->database_id;
1071
1058
  /*
1072
1059
  * EXEC SQL set connection :did;
1073
1060
  */
1074
- #line 884 "informix.ec"
1061
+ #line 871 "informix.ec"
1075
1062
  {
1076
- #line 884 "informix.ec"
1063
+ #line 871 "informix.ec"
1077
1064
  sqli_connect_set(0, did, 0);
1078
- #line 884 "informix.ec"
1065
+ #line 871 "informix.ec"
1079
1066
  }
1080
1067
  if (SQLCODE < 0)
1081
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
1068
+ raise_ifx_extended();
1082
1069
 
1083
1070
  NUM2INT8(offset, &offset8);
1084
1071
  NUM2INT8(range, &range8);
1085
1072
  ret = ifx_lo_unlock(slob->fd, &offset8, FIX2INT(whence), &range8);
1086
1073
  if (ret < 0)
1087
- rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
1074
+ raise_ifx_extended();
1088
1075
 
1089
1076
  return self;
1090
1077
  }
@@ -1110,41 +1097,41 @@ slob_specget(VALUE self, slob_option_t option)
1110
1097
  /*
1111
1098
  * EXEC SQL begin declare section;
1112
1099
  */
1113
- #line 915 "informix.ec"
1114
- #line 916 "informix.ec"
1100
+ #line 902 "informix.ec"
1101
+ #line 903 "informix.ec"
1115
1102
  char *did;
1116
1103
  /*
1117
1104
  * EXEC SQL end declare section;
1118
1105
  */
1119
- #line 917 "informix.ec"
1106
+ #line 904 "informix.ec"
1120
1107
 
1121
1108
 
1122
1109
  Data_Get_Struct(self, slob_t, slob);
1123
1110
 
1124
1111
  if (slob->fd == -1)
1125
- rb_raise(rb_eRuntimeError, "Open the Slob object first");
1112
+ rb_raise(esyms.eProgrammingError, "Open the Slob object first");
1126
1113
 
1127
1114
  did = slob->database_id;
1128
1115
  /*
1129
1116
  * EXEC SQL set connection :did;
1130
1117
  */
1131
- #line 925 "informix.ec"
1118
+ #line 912 "informix.ec"
1132
1119
  {
1133
- #line 925 "informix.ec"
1120
+ #line 912 "informix.ec"
1134
1121
  sqli_connect_set(0, did, 0);
1135
- #line 925 "informix.ec"
1122
+ #line 912 "informix.ec"
1136
1123
  }
1137
1124
  if (SQLCODE < 0)
1138
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
1125
+ raise_ifx_extended();
1139
1126
 
1140
1127
  ret = ifx_lo_stat(slob->fd, &stat);
1141
1128
  if (ret < 0)
1142
- rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
1129
+ raise_ifx_extended();
1143
1130
 
1144
1131
  spec = ifx_lo_stat_cspec(stat);
1145
1132
  if (spec == NULL) {
1146
1133
  ifx_lo_stat_free(stat);
1147
- rb_raise(rb_eRuntimeError, "Unable to get storage characteristics");
1134
+ rb_raise(esyms.eOperationalError, "Unable to get storage characteristics");
1148
1135
  }
1149
1136
 
1150
1137
  switch(option) {
@@ -1166,7 +1153,7 @@ slob_specget(VALUE self, slob_option_t option)
1166
1153
 
1167
1154
  ifx_lo_stat_free(stat);
1168
1155
  if (ret == -1)
1169
- rb_raise(rb_eRuntimeError, "Unable to get information for %s", str_slob_options[option]);
1156
+ rb_raise(esyms.eOperationalError, "Unable to get information for %s", str_slob_options[option]);
1170
1157
 
1171
1158
  switch(option) {
1172
1159
  case slob_estbytes:
@@ -1196,41 +1183,41 @@ slob_specset(VALUE self, slob_option_t option, VALUE value)
1196
1183
  /*
1197
1184
  * EXEC SQL begin declare section;
1198
1185
  */
1199
- #line 985 "informix.ec"
1200
- #line 986 "informix.ec"
1186
+ #line 972 "informix.ec"
1187
+ #line 973 "informix.ec"
1201
1188
  char *did;
1202
1189
  /*
1203
1190
  * EXEC SQL end declare section;
1204
1191
  */
1205
- #line 987 "informix.ec"
1192
+ #line 974 "informix.ec"
1206
1193
 
1207
1194
 
1208
1195
  Data_Get_Struct(self, slob_t, slob);
1209
1196
 
1210
1197
  if (slob->fd == -1)
1211
- rb_raise(rb_eRuntimeError, "Open the Slob object first");
1198
+ rb_raise(esyms.eProgrammingError, "Open the Slob object first");
1212
1199
 
1213
1200
  did = slob->database_id;
1214
1201
  /*
1215
1202
  * EXEC SQL set connection :did;
1216
1203
  */
1217
- #line 995 "informix.ec"
1204
+ #line 982 "informix.ec"
1218
1205
  {
1219
- #line 995 "informix.ec"
1206
+ #line 982 "informix.ec"
1220
1207
  sqli_connect_set(0, did, 0);
1221
- #line 995 "informix.ec"
1208
+ #line 982 "informix.ec"
1222
1209
  }
1223
1210
  if (SQLCODE < 0)
1224
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
1211
+ raise_ifx_extended();
1225
1212
 
1226
1213
  ret = ifx_lo_stat(slob->fd, &stat);
1227
1214
  if (ret < 0)
1228
- rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
1215
+ raise_ifx_extended();
1229
1216
 
1230
1217
  spec = ifx_lo_stat_cspec(stat);
1231
1218
  if (spec == NULL) {
1232
1219
  ifx_lo_stat_free(stat);
1233
- rb_raise(rb_eRuntimeError, "Unable to get storage characteristics");
1220
+ rb_raise(esyms.eOperationalError, "Unable to get storage characteristics");
1234
1221
  }
1235
1222
 
1236
1223
  switch(option) {
@@ -1246,7 +1233,7 @@ slob_specset(VALUE self, slob_option_t option, VALUE value)
1246
1233
 
1247
1234
  ifx_lo_stat_free(stat);
1248
1235
  if (ret == -1)
1249
- rb_raise(rb_eRuntimeError, "Unable to set information for %s", str_slob_options[option]);
1236
+ rb_raise(esyms.eOperationalError, "Unable to set information for %s", str_slob_options[option]);
1250
1237
 
1251
1238
  return value;
1252
1239
  }
@@ -1354,38 +1341,38 @@ slob_stat(VALUE self, slob_stat_t stat)
1354
1341
  /*
1355
1342
  * EXEC SQL begin declare section;
1356
1343
  */
1357
- #line 1127 "informix.ec"
1358
- #line 1128 "informix.ec"
1344
+ #line 1114 "informix.ec"
1345
+ #line 1115 "informix.ec"
1359
1346
  char *did;
1360
1347
  /*
1361
1348
  * EXEC SQL end declare section;
1362
1349
  */
1363
- #line 1129 "informix.ec"
1350
+ #line 1116 "informix.ec"
1364
1351
 
1365
1352
 
1366
1353
  Data_Get_Struct(self, slob_t, slob);
1367
1354
 
1368
1355
  if (slob->fd == -1)
1369
- rb_raise(rb_eRuntimeError,
1356
+ rb_raise(esyms.eProgrammingError,
1370
1357
  "Open the Slob object before getting its status");
1371
1358
 
1372
1359
  did = slob->database_id;
1373
1360
  /*
1374
1361
  * EXEC SQL set connection :did;
1375
1362
  */
1376
- #line 1138 "informix.ec"
1363
+ #line 1125 "informix.ec"
1377
1364
  {
1378
- #line 1138 "informix.ec"
1365
+ #line 1125 "informix.ec"
1379
1366
  sqli_connect_set(0, did, 0);
1380
- #line 1138 "informix.ec"
1367
+ #line 1125 "informix.ec"
1381
1368
  }
1382
1369
  if (SQLCODE < 0)
1383
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
1370
+ raise_ifx_extended();
1384
1371
 
1385
1372
  ret = ifx_lo_stat(slob->fd, &st);
1386
1373
 
1387
1374
  if (ret < 0)
1388
- rb_raise(rb_eRuntimeError, "Informix Error: %d", ret);
1375
+ raise_ifx_extended();
1389
1376
 
1390
1377
  switch(stat) {
1391
1378
  case slob_atime:
@@ -1407,7 +1394,7 @@ slob_stat(VALUE self, slob_stat_t stat)
1407
1394
  ifx_lo_stat_free(st);
1408
1395
 
1409
1396
  if (ret == -1)
1410
- rb_raise(rb_eRuntimeError, "Unable to get value of %s", str_slob_stats[stat]);
1397
+ rb_raise(esyms.eOperationalError, "Unable to get value of %s", str_slob_stats[stat]);
1411
1398
 
1412
1399
  switch(stat) {
1413
1400
  case slob_atime:
@@ -1943,7 +1930,7 @@ make_result(cursor_t *c, VALUE record)
1943
1930
  ret = dectoasc((dec_t *)var->sqldata, buffer,
1944
1931
  sizeof(buffer) - 1, -1);
1945
1932
  if (ret)
1946
- rb_raise(rb_eRuntimeError,
1933
+ rb_raise(esyms.eOperationalError,
1947
1934
  "Unable to convert DECIMAL to BigDecimal");
1948
1935
 
1949
1936
  buffer[sizeof(buffer) - 1] = 0;
@@ -2002,6 +1989,7 @@ make_result(cursor_t *c, VALUE record)
2002
1989
 
2003
1990
  /* module Informix -------------------------------------------------------- */
2004
1991
 
1992
+ static VALUE rb_database_s_open(int argc, VALUE *argv, VALUE klass);
2005
1993
  /*
2006
1994
  * call-seq:
2007
1995
  * Informix.connect(dbname, user=nil, password=nil) => database
@@ -2015,13 +2003,29 @@ make_result(cursor_t *c, VALUE record)
2015
2003
  * closes the connection when the block terminates, returning the value of
2016
2004
  * the block.
2017
2005
  */
2018
- static VALUE rb_database_s_open(int argc, VALUE *argv, VALUE klass);
2019
2006
  static VALUE
2020
- informix_connect(int argc, VALUE *argv, VALUE self)
2007
+ rb_informix_connect(int argc, VALUE *argv, VALUE self)
2021
2008
  {
2022
2009
  return rb_database_s_open(argc, argv, rb_cDatabase);
2023
2010
  }
2024
2011
 
2012
+ /*
2013
+ * call-seq:
2014
+ * Informix.version => string
2015
+ *
2016
+ * Returns the version of this Ruby/Informix driver.
2017
+ * Note that this is NOT the Informix database version.
2018
+ */
2019
+ static VALUE rb_informix_version(void)
2020
+ {
2021
+ static const char * const ver = "0.6.0";
2022
+ static VALUE driver_version;
2023
+
2024
+ if (driver_version == 0)
2025
+ driver_version = rb_str_freeze(rb_str_new2(ver));
2026
+
2027
+ return driver_version;
2028
+ }
2025
2029
 
2026
2030
  /* class Database --------------------------------------------------------- */
2027
2031
 
@@ -2031,24 +2035,24 @@ database_free(void *p)
2031
2035
  /*
2032
2036
  * EXEC SQL begin declare section;
2033
2037
  */
2034
- #line 1788 "informix.ec"
2035
- #line 1789 "informix.ec"
2038
+ #line 1792 "informix.ec"
2039
+ #line 1793 "informix.ec"
2036
2040
  char *did;
2037
2041
  /*
2038
2042
  * EXEC SQL end declare section;
2039
2043
  */
2040
- #line 1790 "informix.ec"
2044
+ #line 1794 "informix.ec"
2041
2045
 
2042
2046
 
2043
2047
  did = p;
2044
2048
  /*
2045
2049
  * EXEC SQL disconnect :did;
2046
2050
  */
2047
- #line 1793 "informix.ec"
2051
+ #line 1797 "informix.ec"
2048
2052
  {
2049
- #line 1793 "informix.ec"
2053
+ #line 1797 "informix.ec"
2050
2054
  sqli_connect_close(0, did, 0, 0);
2051
- #line 1793 "informix.ec"
2055
+ #line 1797 "informix.ec"
2052
2056
  }
2053
2057
  xfree(p);
2054
2058
  }
@@ -2071,19 +2075,19 @@ rb_database_initialize(int argc, VALUE *argv, VALUE self)
2071
2075
  /*
2072
2076
  * EXEC SQL begin declare section;
2073
2077
  */
2074
- #line 1812 "informix.ec"
2075
- #line 1813 "informix.ec"
2078
+ #line 1816 "informix.ec"
2079
+ #line 1817 "informix.ec"
2076
2080
  char *dbname, *user = NULL, *pass = NULL, *did;
2077
2081
  /*
2078
2082
  * EXEC SQL end declare section;
2079
2083
  */
2080
- #line 1814 "informix.ec"
2084
+ #line 1818 "informix.ec"
2081
2085
 
2082
2086
 
2083
2087
  rb_scan_args(argc, argv, "12", &arg[0], &arg[1], &arg[2]);
2084
2088
 
2085
2089
  if (NIL_P(arg[0]))
2086
- rb_raise(rb_eRuntimeError, "A database name must be specified");
2090
+ rb_raise(esyms.eProgrammingError, "A database name must be specified");
2087
2091
 
2088
2092
  Data_Get_Struct(self, char, did);
2089
2093
 
@@ -2101,28 +2105,28 @@ rb_database_initialize(int argc, VALUE *argv, VALUE self)
2101
2105
  * EXEC SQL connect to :dbname as :did user :user
2102
2106
  * using :pass with concurrent transaction;
2103
2107
  */
2104
- #line 1833 "informix.ec"
2108
+ #line 1837 "informix.ec"
2105
2109
  {
2106
- #line 1834 "informix.ec"
2110
+ #line 1838 "informix.ec"
2107
2111
  ifx_conn_t *_sqiconn;
2108
2112
  _sqiconn = (ifx_conn_t *)ifx_alloc_conn_user(user, pass);
2109
2113
  sqli_connect_open(ESQLINTVERSION, 0, dbname, did, _sqiconn, 1);
2110
2114
  ifx_free_conn_user(&_sqiconn);
2111
- #line 1834 "informix.ec"
2115
+ #line 1838 "informix.ec"
2112
2116
  }
2113
2117
  else
2114
2118
  /*
2115
2119
  * EXEC SQL connect to :dbname as :did with concurrent transaction;
2116
2120
  */
2117
- #line 1836 "informix.ec"
2121
+ #line 1840 "informix.ec"
2118
2122
  {
2119
- #line 1836 "informix.ec"
2123
+ #line 1840 "informix.ec"
2120
2124
  sqli_connect_open(ESQLINTVERSION, 0, dbname, did, (ifx_conn_t *)0, 1);
2121
- #line 1836 "informix.ec"
2125
+ #line 1840 "informix.ec"
2122
2126
  }
2123
2127
 
2124
2128
  if (SQLCODE < 0)
2125
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
2129
+ raise_ifx_extended();
2126
2130
 
2127
2131
  return self;
2128
2132
  }
@@ -2168,13 +2172,13 @@ rb_database_close(VALUE self)
2168
2172
  /*
2169
2173
  * EXEC SQL begin declare section;
2170
2174
  */
2171
- #line 1882 "informix.ec"
2172
- #line 1883 "informix.ec"
2175
+ #line 1886 "informix.ec"
2176
+ #line 1887 "informix.ec"
2173
2177
  char *did;
2174
2178
  /*
2175
2179
  * EXEC SQL end declare section;
2176
2180
  */
2177
- #line 1884 "informix.ec"
2181
+ #line 1888 "informix.ec"
2178
2182
 
2179
2183
 
2180
2184
  Data_Get_Struct(self, char, did);
@@ -2183,21 +2187,21 @@ rb_database_close(VALUE self)
2183
2187
  /*
2184
2188
  * EXEC SQL free :did;
2185
2189
  */
2186
- #line 1889 "informix.ec"
2190
+ #line 1893 "informix.ec"
2187
2191
  {
2188
- #line 1889 "informix.ec"
2192
+ #line 1893 "informix.ec"
2189
2193
  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, did, 258));
2190
- #line 1889 "informix.ec"
2194
+ #line 1893 "informix.ec"
2191
2195
  }
2192
2196
  did -= IDSIZE;
2193
2197
  /*
2194
2198
  * EXEC SQL disconnect :did;
2195
2199
  */
2196
- #line 1891 "informix.ec"
2200
+ #line 1895 "informix.ec"
2197
2201
  {
2198
- #line 1891 "informix.ec"
2202
+ #line 1895 "informix.ec"
2199
2203
  sqli_connect_close(0, did, 0, 0);
2200
- #line 1891 "informix.ec"
2204
+ #line 1895 "informix.ec"
2201
2205
  }
2202
2206
 
2203
2207
  return self;
@@ -2206,6 +2210,7 @@ rb_database_close(VALUE self)
2206
2210
  /*
2207
2211
  * call-seq:
2208
2212
  * db.immediate(query) => fixnum
2213
+ * db.execute(query) => fixnum
2209
2214
  *
2210
2215
  * Executes <i>query</i> and returns the number of rows affected.
2211
2216
  * <i>query</i> must not return rows. Executes efficiently any
@@ -2218,13 +2223,13 @@ rb_database_immediate(VALUE self, VALUE arg)
2218
2223
  /*
2219
2224
  * EXEC SQL begin declare section;
2220
2225
  */
2221
- #line 1908 "informix.ec"
2222
- #line 1909 "informix.ec"
2226
+ #line 1913 "informix.ec"
2227
+ #line 1914 "informix.ec"
2223
2228
  char *query, *did;
2224
2229
  /*
2225
2230
  * EXEC SQL end declare section;
2226
2231
  */
2227
- #line 1910 "informix.ec"
2232
+ #line 1915 "informix.ec"
2228
2233
 
2229
2234
 
2230
2235
  Data_Get_Struct(self, char, did);
@@ -2232,27 +2237,27 @@ rb_database_immediate(VALUE self, VALUE arg)
2232
2237
  /*
2233
2238
  * EXEC SQL set connection :did;
2234
2239
  */
2235
- #line 1914 "informix.ec"
2240
+ #line 1919 "informix.ec"
2236
2241
  {
2237
- #line 1914 "informix.ec"
2242
+ #line 1919 "informix.ec"
2238
2243
  sqli_connect_set(0, did, 0);
2239
- #line 1914 "informix.ec"
2244
+ #line 1919 "informix.ec"
2240
2245
  }
2241
2246
  if (SQLCODE < 0)
2242
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
2247
+ raise_ifx_extended();
2243
2248
 
2244
2249
  query = StringValueCStr(arg);
2245
2250
  /*
2246
2251
  * EXEC SQL execute immediate :query;
2247
2252
  */
2248
- #line 1919 "informix.ec"
2253
+ #line 1924 "informix.ec"
2249
2254
  {
2250
- #line 1919 "informix.ec"
2255
+ #line 1924 "informix.ec"
2251
2256
  sqli_exec_immed(query);
2252
- #line 1919 "informix.ec"
2257
+ #line 1924 "informix.ec"
2253
2258
  }
2254
2259
  if (SQLCODE < 0)
2255
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
2260
+ raise_ifx_extended();
2256
2261
 
2257
2262
  return INT2FIX(sqlca.sqlerrd[2]);
2258
2263
  }
@@ -2269,13 +2274,13 @@ rb_database_rollback(VALUE self)
2269
2274
  /*
2270
2275
  * EXEC SQL begin declare section;
2271
2276
  */
2272
- #line 1935 "informix.ec"
2273
- #line 1936 "informix.ec"
2277
+ #line 1940 "informix.ec"
2278
+ #line 1941 "informix.ec"
2274
2279
  char *did;
2275
2280
  /*
2276
2281
  * EXEC SQL end declare section;
2277
2282
  */
2278
- #line 1937 "informix.ec"
2283
+ #line 1942 "informix.ec"
2279
2284
 
2280
2285
 
2281
2286
  Data_Get_Struct(self, char, did);
@@ -2283,23 +2288,23 @@ rb_database_rollback(VALUE self)
2283
2288
  /*
2284
2289
  * EXEC SQL set connection :did;
2285
2290
  */
2286
- #line 1941 "informix.ec"
2291
+ #line 1946 "informix.ec"
2287
2292
  {
2288
- #line 1941 "informix.ec"
2293
+ #line 1946 "informix.ec"
2289
2294
  sqli_connect_set(0, did, 0);
2290
- #line 1941 "informix.ec"
2295
+ #line 1946 "informix.ec"
2291
2296
  }
2292
2297
  if (SQLCODE < 0)
2293
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
2298
+ raise_ifx_extended();
2294
2299
 
2295
2300
  /*
2296
2301
  * EXEC SQL rollback;
2297
2302
  */
2298
- #line 1945 "informix.ec"
2303
+ #line 1950 "informix.ec"
2299
2304
  {
2300
- #line 1945 "informix.ec"
2305
+ #line 1950 "informix.ec"
2301
2306
  sqli_trans_rollback();
2302
- #line 1945 "informix.ec"
2307
+ #line 1950 "informix.ec"
2303
2308
  }
2304
2309
  return self;
2305
2310
  }
@@ -2316,13 +2321,13 @@ rb_database_commit(VALUE self)
2316
2321
  /*
2317
2322
  * EXEC SQL begin declare section;
2318
2323
  */
2319
- #line 1958 "informix.ec"
2320
- #line 1959 "informix.ec"
2324
+ #line 1963 "informix.ec"
2325
+ #line 1964 "informix.ec"
2321
2326
  char *did;
2322
2327
  /*
2323
2328
  * EXEC SQL end declare section;
2324
2329
  */
2325
- #line 1960 "informix.ec"
2330
+ #line 1965 "informix.ec"
2326
2331
 
2327
2332
 
2328
2333
  Data_Get_Struct(self, char, did);
@@ -2330,23 +2335,23 @@ rb_database_commit(VALUE self)
2330
2335
  /*
2331
2336
  * EXEC SQL set connection :did;
2332
2337
  */
2333
- #line 1964 "informix.ec"
2338
+ #line 1969 "informix.ec"
2334
2339
  {
2335
- #line 1964 "informix.ec"
2340
+ #line 1969 "informix.ec"
2336
2341
  sqli_connect_set(0, did, 0);
2337
- #line 1964 "informix.ec"
2342
+ #line 1969 "informix.ec"
2338
2343
  }
2339
2344
  if (SQLCODE < 0)
2340
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
2345
+ raise_ifx_extended();
2341
2346
 
2342
2347
  /*
2343
2348
  * EXEC SQL commit;
2344
2349
  */
2345
- #line 1968 "informix.ec"
2350
+ #line 1973 "informix.ec"
2346
2351
  {
2347
- #line 1968 "informix.ec"
2352
+ #line 1973 "informix.ec"
2348
2353
  sqli_trans_commit();
2349
- #line 1968 "informix.ec"
2354
+ #line 1973 "informix.ec"
2350
2355
  }
2351
2356
  return self;
2352
2357
  }
@@ -2375,13 +2380,13 @@ rb_database_transaction(VALUE self)
2375
2380
  /*
2376
2381
  * EXEC SQL begin declare section;
2377
2382
  */
2378
- #line 1993 "informix.ec"
2379
- #line 1994 "informix.ec"
2383
+ #line 1998 "informix.ec"
2384
+ #line 1999 "informix.ec"
2380
2385
  char *did;
2381
2386
  /*
2382
2387
  * EXEC SQL end declare section;
2383
2388
  */
2384
- #line 1995 "informix.ec"
2389
+ #line 2000 "informix.ec"
2385
2390
 
2386
2391
 
2387
2392
  Data_Get_Struct(self, char, did);
@@ -2389,49 +2394,50 @@ rb_database_transaction(VALUE self)
2389
2394
  /*
2390
2395
  * EXEC SQL set connection :did;
2391
2396
  */
2392
- #line 1999 "informix.ec"
2397
+ #line 2004 "informix.ec"
2393
2398
  {
2394
- #line 1999 "informix.ec"
2399
+ #line 2004 "informix.ec"
2395
2400
  sqli_connect_set(0, did, 0);
2396
- #line 1999 "informix.ec"
2401
+ #line 2004 "informix.ec"
2397
2402
  }
2398
2403
  if (SQLCODE < 0)
2399
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
2404
+ raise_ifx_extended();
2400
2405
 
2401
2406
  /*
2402
2407
  * EXEC SQL commit;
2403
2408
  */
2404
- #line 2003 "informix.ec"
2409
+ #line 2008 "informix.ec"
2405
2410
  {
2406
- #line 2003 "informix.ec"
2411
+ #line 2008 "informix.ec"
2407
2412
  sqli_trans_commit();
2408
- #line 2003 "informix.ec"
2413
+ #line 2008 "informix.ec"
2409
2414
  }
2410
2415
 
2411
2416
  /*
2412
2417
  * EXEC SQL begin work;
2413
2418
  */
2414
- #line 2005 "informix.ec"
2419
+ #line 2010 "informix.ec"
2415
2420
  {
2416
- #line 2005 "informix.ec"
2421
+ #line 2010 "informix.ec"
2417
2422
  sqli_trans_begin2((mint)1);
2418
- #line 2005 "informix.ec"
2423
+ #line 2010 "informix.ec"
2419
2424
  }
2420
2425
  ret = rb_rescue(rb_yield, self, database_transfail, self);
2421
2426
  if (ret == Qundef)
2422
- rb_raise(rb_eRuntimeError, "Transaction rolled back");
2427
+ rb_raise(esyms.eOperationalError, "Transaction rolled back");
2423
2428
  /*
2424
2429
  * EXEC SQL commit;
2425
2430
  */
2426
- #line 2009 "informix.ec"
2431
+ #line 2014 "informix.ec"
2427
2432
  {
2428
- #line 2009 "informix.ec"
2433
+ #line 2014 "informix.ec"
2429
2434
  sqli_trans_commit();
2430
- #line 2009 "informix.ec"
2435
+ #line 2014 "informix.ec"
2431
2436
  }
2432
2437
  return self;
2433
2438
  }
2434
2439
 
2440
+ static VALUE statement_s_new(int, VALUE *, VALUE);
2435
2441
  /*
2436
2442
  * call-seq:
2437
2443
  * db.prepare(query) => statement
@@ -2447,7 +2453,6 @@ rb_database_transaction(VALUE self)
2447
2453
  * it must not be a query returning more than one row
2448
2454
  * (use <code>Database#cursor</code> instead.)
2449
2455
  */
2450
- static VALUE statement_s_new(int, VALUE *, VALUE);
2451
2456
  static VALUE
2452
2457
  rb_database_prepare(VALUE self, VALUE query)
2453
2458
  {
@@ -2457,6 +2462,7 @@ rb_database_prepare(VALUE self, VALUE query)
2457
2462
  return statement_s_new(2, argv, rb_cStatement);
2458
2463
  }
2459
2464
 
2465
+ static VALUE rb_cursor_s_new(int argc, VALUE *argv, VALUE klass);
2460
2466
  /*
2461
2467
  * call-seq:
2462
2468
  * db.cursor(query, options = nil) => cursor
@@ -2477,7 +2483,7 @@ rb_database_cursor(int argc, VALUE *argv, VALUE self)
2477
2483
 
2478
2484
  arg[0] = self;
2479
2485
  rb_scan_args(argc, argv, "11", &arg[1], &arg[2]);
2480
- return rb_class_new_instance(3, arg, rb_cCursor);
2486
+ return rb_cursor_s_new(3, arg, rb_cCursor);
2481
2487
  }
2482
2488
 
2483
2489
  /*
@@ -2537,8 +2543,8 @@ rb_database_columns(VALUE self, VALUE tablename)
2537
2543
  /*
2538
2544
  * EXEC SQL begin declare section;
2539
2545
  */
2540
- #line 2115 "informix.ec"
2541
- #line 2116 "informix.ec"
2546
+ #line 2121 "informix.ec"
2547
+ #line 2122 "informix.ec"
2542
2548
  char *did, *cid;
2543
2549
  char *tabname;
2544
2550
  int tabid, xid;
@@ -2549,7 +2555,7 @@ short coltype, collength;
2549
2555
  /*
2550
2556
  * EXEC SQL end declare section;
2551
2557
  */
2552
- #line 2123 "informix.ec"
2558
+ #line 2129 "informix.ec"
2553
2559
 
2554
2560
 
2555
2561
  Data_Get_Struct(self, char, did);
@@ -2557,53 +2563,53 @@ short coltype, collength;
2557
2563
  /*
2558
2564
  * EXEC SQL set connection :did;
2559
2565
  */
2560
- #line 2127 "informix.ec"
2566
+ #line 2133 "informix.ec"
2561
2567
  {
2562
- #line 2127 "informix.ec"
2568
+ #line 2133 "informix.ec"
2563
2569
  sqli_connect_set(0, did, 0);
2564
- #line 2127 "informix.ec"
2570
+ #line 2133 "informix.ec"
2565
2571
  }
2566
2572
  if (SQLCODE < 0)
2567
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
2573
+ raise_ifx_extended();
2568
2574
 
2569
2575
  tabname = StringValueCStr(tablename);
2570
2576
 
2571
2577
  /*
2572
2578
  * EXEC SQL select tabid into :tabid from systables where tabname = :tabname;
2573
2579
  */
2574
- #line 2133 "informix.ec"
2580
+ #line 2139 "informix.ec"
2575
2581
  {
2576
- #line 2133 "informix.ec"
2582
+ #line 2139 "informix.ec"
2577
2583
  static const char *sqlcmdtxt[] =
2578
- #line 2133 "informix.ec"
2584
+ #line 2139 "informix.ec"
2579
2585
  {
2580
- #line 2133 "informix.ec"
2586
+ #line 2139 "informix.ec"
2581
2587
  "select tabid from systables where tabname = ?",
2582
2588
  0
2583
2589
  };
2584
- #line 2133 "informix.ec"
2590
+ #line 2139 "informix.ec"
2585
2591
  static ifx_cursor_t _SQ0 = {0};
2586
2592
  static ifx_sqlvar_t _sqibind[] =
2587
2593
  {
2588
2594
  { 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
2589
- #line 2133 "informix.ec"
2595
+ #line 2139 "informix.ec"
2590
2596
  };
2591
2597
  static ifx_sqlvar_t _sqobind[] =
2592
2598
  {
2593
2599
  { 102, sizeof(tabid), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
2594
- #line 2133 "informix.ec"
2600
+ #line 2139 "informix.ec"
2595
2601
  };
2596
- #line 2133 "informix.ec"
2602
+ #line 2139 "informix.ec"
2597
2603
  _sqibind[0].sqldata = tabname;
2598
- #line 2133 "informix.ec"
2604
+ #line 2139 "informix.ec"
2599
2605
  _sqobind[0].sqldata = (char *) &tabid;
2600
- #line 2133 "informix.ec"
2606
+ #line 2139 "informix.ec"
2601
2607
  sqli_slct(ESQLINTVERSION, &_SQ0,sqlcmdtxt,1,_sqibind,1,_sqobind,0,(ifx_literal_t *)0,(ifx_namelist_t *)0,0);
2602
- #line 2133 "informix.ec"
2608
+ #line 2139 "informix.ec"
2603
2609
  }
2604
2610
 
2605
2611
  if (SQLCODE == SQLNOTFOUND)
2606
- rb_raise(rb_eRuntimeError, "Table '%s' doesn't exist", tabname);
2612
+ rb_raise(esyms.eProgrammingError, "Table '%s' doesn't exist", tabname);
2607
2613
 
2608
2614
  result = rb_ary_new();
2609
2615
 
@@ -2619,55 +2625,55 @@ static ifx_cursor_t _SQ0 = {0};
2619
2625
  * and c.colno = d.colno
2620
2626
  * order by c.colno;
2621
2627
  */
2622
- #line 2143 "informix.ec"
2623
- {
2624
2628
  #line 2149 "informix.ec"
2629
+ {
2630
+ #line 2155 "informix.ec"
2625
2631
  static const char *sqlcmdtxt[] =
2626
- #line 2149 "informix.ec"
2632
+ #line 2155 "informix.ec"
2627
2633
  {
2628
- #line 2149 "informix.ec"
2634
+ #line 2155 "informix.ec"
2629
2635
  "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",
2630
2636
  0
2631
2637
  };
2632
- #line 2149 "informix.ec"
2638
+ #line 2155 "informix.ec"
2633
2639
  static ifx_sqlvar_t _sqibind[] =
2634
2640
  {
2635
2641
  { 102, sizeof(tabid), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
2636
- #line 2149 "informix.ec"
2642
+ #line 2155 "informix.ec"
2637
2643
  };
2638
2644
  static ifx_sqlda_t _SD0 = { 1, _sqibind, {0}, 1, 0 };
2639
- #line 2149 "informix.ec"
2645
+ #line 2155 "informix.ec"
2640
2646
  _sqibind[0].sqldata = (char *) &tabid;
2641
- #line 2149 "informix.ec"
2647
+ #line 2155 "informix.ec"
2642
2648
  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);
2643
- #line 2149 "informix.ec"
2649
+ #line 2155 "informix.ec"
2644
2650
  }
2645
2651
  if (SQLCODE < 0) {
2646
2652
  cid[0] = 0;
2647
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
2653
+ raise_ifx_extended();
2648
2654
  }
2649
2655
  }
2650
2656
 
2651
2657
  /*
2652
2658
  * EXEC SQL open :cid;
2653
2659
  */
2654
- #line 2156 "informix.ec"
2660
+ #line 2162 "informix.ec"
2655
2661
  {
2656
- #line 2156 "informix.ec"
2662
+ #line 2162 "informix.ec"
2657
2663
  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 0);
2658
- #line 2156 "informix.ec"
2664
+ #line 2162 "informix.ec"
2659
2665
  }
2660
2666
  if (SQLCODE < 0)
2661
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
2667
+ raise_ifx_extended();
2662
2668
 
2663
2669
  for(;;) {
2664
2670
  /*
2665
2671
  * EXEC SQL fetch :cid into :colname, :coltype, :collength, :xid,
2666
2672
  * :deftype, :defvalue;
2667
2673
  */
2668
- #line 2161 "informix.ec"
2674
+ #line 2167 "informix.ec"
2669
2675
  {
2670
- #line 2162 "informix.ec"
2676
+ #line 2168 "informix.ec"
2671
2677
  static ifx_sqlvar_t _sqobind[] =
2672
2678
  {
2673
2679
  { 114, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
@@ -2676,27 +2682,27 @@ sqli_curs_decl_stat(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 0), ci
2676
2682
  { 102, sizeof(xid), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
2677
2683
  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
2678
2684
  { 114, 257, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
2679
- #line 2162 "informix.ec"
2685
+ #line 2168 "informix.ec"
2680
2686
  };
2681
2687
  static ifx_sqlda_t _SD0 = { 6, _sqobind, {0}, 6, 0 };
2682
2688
  static _FetchSpec _FS1 = { 0, 1, 0 };
2683
- #line 2162 "informix.ec"
2689
+ #line 2168 "informix.ec"
2684
2690
  _sqobind[0].sqldata = colname;
2685
- #line 2162 "informix.ec"
2691
+ #line 2168 "informix.ec"
2686
2692
  _sqobind[1].sqldata = (char *) &coltype;
2687
- #line 2162 "informix.ec"
2693
+ #line 2168 "informix.ec"
2688
2694
  _sqobind[2].sqldata = (char *) &collength;
2689
- #line 2162 "informix.ec"
2695
+ #line 2168 "informix.ec"
2690
2696
  _sqobind[3].sqldata = (char *) &xid;
2691
- #line 2162 "informix.ec"
2697
+ #line 2168 "informix.ec"
2692
2698
  _sqobind[4].sqldata = deftype;
2693
- #line 2162 "informix.ec"
2699
+ #line 2168 "informix.ec"
2694
2700
  _sqobind[5].sqldata = defvalue;
2695
2701
  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, &_SD0, (char *)0, &_FS1);
2696
- #line 2162 "informix.ec"
2702
+ #line 2168 "informix.ec"
2697
2703
  }
2698
2704
  if (SQLCODE < 0)
2699
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
2705
+ raise_ifx_extended();
2700
2706
 
2701
2707
  if (SQLCODE == SQLNOTFOUND)
2702
2708
  break;
@@ -2791,11 +2797,11 @@ sqli_curs_decl_stat(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 0), ci
2791
2797
  /*
2792
2798
  * EXEC SQL close :cid;
2793
2799
  */
2794
- #line 2256 "informix.ec"
2800
+ #line 2262 "informix.ec"
2795
2801
  {
2796
- #line 2256 "informix.ec"
2802
+ #line 2262 "informix.ec"
2797
2803
  sqli_curs_close(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256));
2798
- #line 2256 "informix.ec"
2804
+ #line 2262 "informix.ec"
2799
2805
  }
2800
2806
 
2801
2807
  return result;
@@ -2821,13 +2827,13 @@ statement_free(void *p)
2821
2827
  /*
2822
2828
  * EXEC SQL begin declare section;
2823
2829
  */
2824
- #line 2278 "informix.ec"
2825
- #line 2279 "informix.ec"
2830
+ #line 2284 "informix.ec"
2831
+ #line 2285 "informix.ec"
2826
2832
  char *sid, *did;
2827
2833
  /*
2828
2834
  * EXEC SQL end declare section;
2829
2835
  */
2830
- #line 2280 "informix.ec"
2836
+ #line 2286 "informix.ec"
2831
2837
 
2832
2838
 
2833
2839
  free_input_slots(p);
@@ -2837,22 +2843,22 @@ statement_free(void *p)
2837
2843
  /*
2838
2844
  * EXEC SQL set connection :did;
2839
2845
  */
2840
- #line 2286 "informix.ec"
2846
+ #line 2292 "informix.ec"
2841
2847
  {
2842
- #line 2286 "informix.ec"
2848
+ #line 2292 "informix.ec"
2843
2849
  sqli_connect_set(0, did, 0);
2844
- #line 2286 "informix.ec"
2850
+ #line 2292 "informix.ec"
2845
2851
  }
2846
2852
  if (SQLCODE >= 0) {
2847
2853
  sid = ((cursor_t *)p)->stmt_id;
2848
2854
  /*
2849
2855
  * EXEC SQL free :sid;
2850
2856
  */
2851
- #line 2289 "informix.ec"
2857
+ #line 2295 "informix.ec"
2852
2858
  {
2853
- #line 2289 "informix.ec"
2859
+ #line 2295 "informix.ec"
2854
2860
  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, sid, 258));
2855
- #line 2289 "informix.ec"
2861
+ #line 2295 "informix.ec"
2856
2862
  }
2857
2863
  }
2858
2864
 
@@ -2869,22 +2875,6 @@ statement_alloc(VALUE klass)
2869
2875
  return Data_Wrap_Struct(klass, statement_mark, statement_free, c);
2870
2876
  }
2871
2877
 
2872
- /*
2873
- * call-seq:
2874
- * Statement.new(database, query) => statement
2875
- * Statement.new(database, query) {|stmt| block } => obj
2876
- *
2877
- * Creates a <code>Statement</code> object based on <i>query</i> in the
2878
- * context of <i>database</i>.
2879
- * In the first form the <code>Statement</code> object is returned.
2880
- * In the second form the Statement object is passed to the block and when it
2881
- * terminates, the Statement object is dropped, returning the value of the
2882
- * block.
2883
- *
2884
- * <i>query</i> may contain '?' placeholders for input parameters;
2885
- * it must not be a query returning more than one row
2886
- * (use <code>Cursor</code> instead.)
2887
- */
2888
2878
  static VALUE
2889
2879
  statement_initialize(VALUE self, VALUE db, VALUE query)
2890
2880
  {
@@ -2893,27 +2883,27 @@ statement_initialize(VALUE self, VALUE db, VALUE query)
2893
2883
  /*
2894
2884
  * EXEC SQL begin declare section;
2895
2885
  */
2896
- #line 2326 "informix.ec"
2897
- #line 2327 "informix.ec"
2886
+ #line 2316 "informix.ec"
2887
+ #line 2317 "informix.ec"
2898
2888
  char *c_query, *sid, *did;
2899
2889
  /*
2900
2890
  * EXEC SQL end declare section;
2901
2891
  */
2902
- #line 2328 "informix.ec"
2892
+ #line 2318 "informix.ec"
2903
2893
 
2904
2894
 
2905
2895
  Data_Get_Struct(db, char, did);
2906
2896
  /*
2907
2897
  * EXEC SQL set connection :did;
2908
2898
  */
2909
- #line 2331 "informix.ec"
2899
+ #line 2321 "informix.ec"
2910
2900
  {
2911
- #line 2331 "informix.ec"
2901
+ #line 2321 "informix.ec"
2912
2902
  sqli_connect_set(0, did, 0);
2913
- #line 2331 "informix.ec"
2903
+ #line 2321 "informix.ec"
2914
2904
  }
2915
2905
  if (SQLCODE < 0)
2916
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
2906
+ raise_ifx_extended();
2917
2907
 
2918
2908
  Data_Get_Struct(self, cursor_t, c);
2919
2909
  c->db = db;
@@ -2926,24 +2916,24 @@ statement_initialize(VALUE self, VALUE db, VALUE query)
2926
2916
  /*
2927
2917
  * EXEC SQL prepare :sid from :c_query;
2928
2918
  */
2929
- #line 2343 "informix.ec"
2919
+ #line 2333 "informix.ec"
2930
2920
  {
2931
- #line 2343 "informix.ec"
2921
+ #line 2333 "informix.ec"
2932
2922
  sqli_prep(ESQLINTVERSION, sid, c_query,(ifx_literal_t *)0, (ifx_namelist_t *)0, -1, 0, 0 );
2933
- #line 2343 "informix.ec"
2923
+ #line 2333 "informix.ec"
2934
2924
  }
2935
2925
  if (SQLCODE < 0)
2936
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
2926
+ raise_ifx_extended();
2937
2927
 
2938
2928
  alloc_input_slots(c, c_query);
2939
2929
  /*
2940
2930
  * EXEC SQL describe :sid into output;
2941
2931
  */
2942
- #line 2348 "informix.ec"
2932
+ #line 2338 "informix.ec"
2943
2933
  {
2944
- #line 2348 "informix.ec"
2934
+ #line 2338 "informix.ec"
2945
2935
  sqli_describe_stmt(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, sid, 257), &output, 0);
2946
- #line 2348 "informix.ec"
2936
+ #line 2338 "informix.ec"
2947
2937
  }
2948
2938
  c->daOutput = output;
2949
2939
 
@@ -2959,6 +2949,7 @@ statement_initialize(VALUE self, VALUE db, VALUE query)
2959
2949
  return self;
2960
2950
  }
2961
2951
 
2952
+ static VALUE statement_drop(VALUE);
2962
2953
  /*
2963
2954
  * call-seq:
2964
2955
  * Statement.new(database, query) => statement
@@ -2975,7 +2966,6 @@ statement_initialize(VALUE self, VALUE db, VALUE query)
2975
2966
  * it must not be a query returning more than one row
2976
2967
  * (use <code>Cursor</code> instead.)
2977
2968
  */
2978
- static VALUE statement_drop(VALUE);
2979
2969
  static VALUE
2980
2970
  statement_s_new(int argc, VALUE *argv, VALUE klass)
2981
2971
  {
@@ -3007,13 +2997,13 @@ statement_call(int argc, VALUE *argv, VALUE self)
3007
2997
  /*
3008
2998
  * EXEC SQL begin declare section;
3009
2999
  */
3010
- #line 2408 "informix.ec"
3011
- #line 2409 "informix.ec"
3000
+ #line 2398 "informix.ec"
3001
+ #line 2399 "informix.ec"
3012
3002
  char *sid, *did;
3013
3003
  /*
3014
3004
  * EXEC SQL end declare section;
3015
3005
  */
3016
- #line 2410 "informix.ec"
3006
+ #line 2400 "informix.ec"
3017
3007
 
3018
3008
 
3019
3009
  Data_Get_Struct(self, cursor_t, c);
@@ -3022,14 +3012,14 @@ statement_call(int argc, VALUE *argv, VALUE self)
3022
3012
  /*
3023
3013
  * EXEC SQL set connection :did;
3024
3014
  */
3025
- #line 2415 "informix.ec"
3015
+ #line 2405 "informix.ec"
3026
3016
  {
3027
- #line 2415 "informix.ec"
3017
+ #line 2405 "informix.ec"
3028
3018
  sqli_connect_set(0, did, 0);
3029
- #line 2415 "informix.ec"
3019
+ #line 2405 "informix.ec"
3030
3020
  }
3031
3021
  if (SQLCODE < 0)
3032
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
3022
+ raise_ifx_extended();
3033
3023
 
3034
3024
  output = c->daOutput;
3035
3025
  input = &c->daInput;
@@ -3046,11 +3036,11 @@ statement_call(int argc, VALUE *argv, VALUE self)
3046
3036
  * EXEC SQL execute :sid into descriptor output
3047
3037
  * using descriptor input;
3048
3038
  */
3049
- #line 2430 "informix.ec"
3039
+ #line 2420 "informix.ec"
3050
3040
  {
3051
- #line 2431 "informix.ec"
3041
+ #line 2421 "informix.ec"
3052
3042
  sqli_exec(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, sid, 257), input, (char *)0, (struct value *)0, output, (char *)0, (struct value *)0, 0);
3053
- #line 2431 "informix.ec"
3043
+ #line 2421 "informix.ec"
3054
3044
  }
3055
3045
  clean_input_slots(c);
3056
3046
  }
@@ -3058,15 +3048,15 @@ statement_call(int argc, VALUE *argv, VALUE self)
3058
3048
  /*
3059
3049
  * EXEC SQL execute :sid into descriptor output;
3060
3050
  */
3061
- #line 2435 "informix.ec"
3051
+ #line 2425 "informix.ec"
3062
3052
  {
3063
- #line 2435 "informix.ec"
3053
+ #line 2425 "informix.ec"
3064
3054
  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);
3065
- #line 2435 "informix.ec"
3055
+ #line 2425 "informix.ec"
3066
3056
  }
3067
3057
 
3068
3058
  if (SQLCODE < 0)
3069
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
3059
+ raise_ifx_extended();
3070
3060
 
3071
3061
  if (SQLCODE == SQLNOTFOUND)
3072
3062
  return Qnil;
@@ -3078,11 +3068,11 @@ statement_call(int argc, VALUE *argv, VALUE self)
3078
3068
  /*
3079
3069
  * EXEC SQL execute :sid using descriptor input;
3080
3070
  */
3081
- #line 2447 "informix.ec"
3071
+ #line 2437 "informix.ec"
3082
3072
  {
3083
- #line 2447 "informix.ec"
3073
+ #line 2437 "informix.ec"
3084
3074
  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);
3085
- #line 2447 "informix.ec"
3075
+ #line 2437 "informix.ec"
3086
3076
  }
3087
3077
  clean_input_slots(c);
3088
3078
  }
@@ -3090,15 +3080,15 @@ statement_call(int argc, VALUE *argv, VALUE self)
3090
3080
  /*
3091
3081
  * EXEC SQL execute :sid;
3092
3082
  */
3093
- #line 2451 "informix.ec"
3083
+ #line 2441 "informix.ec"
3094
3084
  {
3095
- #line 2451 "informix.ec"
3085
+ #line 2441 "informix.ec"
3096
3086
  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);
3097
- #line 2451 "informix.ec"
3087
+ #line 2441 "informix.ec"
3098
3088
  }
3099
3089
  }
3100
3090
  if (SQLCODE < 0)
3101
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
3091
+ raise_ifx_extended();
3102
3092
 
3103
3093
  return INT2FIX(sqlca.sqlerrd[2]);
3104
3094
  }
@@ -3116,13 +3106,13 @@ statement_drop(VALUE self)
3116
3106
  /*
3117
3107
  * EXEC SQL begin declare section;
3118
3108
  */
3119
- #line 2469 "informix.ec"
3120
- #line 2470 "informix.ec"
3109
+ #line 2459 "informix.ec"
3110
+ #line 2460 "informix.ec"
3121
3111
  char *sid, *did;
3122
3112
  /*
3123
3113
  * EXEC SQL end declare section;
3124
3114
  */
3125
- #line 2471 "informix.ec"
3115
+ #line 2461 "informix.ec"
3126
3116
 
3127
3117
 
3128
3118
  Data_Get_Struct(self, cursor_t, c);
@@ -3133,11 +3123,11 @@ statement_drop(VALUE self)
3133
3123
  /*
3134
3124
  * EXEC SQL set connection :did;
3135
3125
  */
3136
- #line 2478 "informix.ec"
3126
+ #line 2468 "informix.ec"
3137
3127
  {
3138
- #line 2478 "informix.ec"
3128
+ #line 2468 "informix.ec"
3139
3129
  sqli_connect_set(0, did, 0);
3140
- #line 2478 "informix.ec"
3130
+ #line 2468 "informix.ec"
3141
3131
  }
3142
3132
  if (SQLCODE < 0)
3143
3133
  return Qnil;
@@ -3145,11 +3135,11 @@ statement_drop(VALUE self)
3145
3135
  /*
3146
3136
  * EXEC SQL free :sid;
3147
3137
  */
3148
- #line 2482 "informix.ec"
3138
+ #line 2472 "informix.ec"
3149
3139
  {
3150
- #line 2482 "informix.ec"
3140
+ #line 2472 "informix.ec"
3151
3141
  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, sid, 258));
3152
- #line 2482 "informix.ec"
3142
+ #line 2472 "informix.ec"
3153
3143
  }
3154
3144
 
3155
3145
  return Qnil;
@@ -3160,7 +3150,8 @@ statement_drop(VALUE self)
3160
3150
  /* Decides whether to use an Array or a Hash, and instantiate a new
3161
3151
  * object or reuse an existing one.
3162
3152
  */
3163
- #define RECORD(c, type, bang, record) do {\
3153
+ #define RECORD(c, type, bang, record) \
3154
+ do {\
3164
3155
  if (type == T_ARRAY) {\
3165
3156
  if (bang) {\
3166
3157
  if (!c->array)\
@@ -3190,13 +3181,13 @@ fetch(VALUE self, VALUE type, int bang)
3190
3181
  /*
3191
3182
  * EXEC SQL begin declare section;
3192
3183
  */
3193
- #line 2519 "informix.ec"
3194
- #line 2520 "informix.ec"
3184
+ #line 2510 "informix.ec"
3185
+ #line 2511 "informix.ec"
3195
3186
  char *cid, *did;
3196
3187
  /*
3197
3188
  * EXEC SQL end declare section;
3198
3189
  */
3199
- #line 2521 "informix.ec"
3190
+ #line 2512 "informix.ec"
3200
3191
 
3201
3192
  cursor_t *c;
3202
3193
  struct sqlda *output;
@@ -3204,20 +3195,20 @@ fetch(VALUE self, VALUE type, int bang)
3204
3195
 
3205
3196
  Data_Get_Struct(self, cursor_t, c);
3206
3197
  if (!c->is_open)
3207
- rb_raise(rb_eRuntimeError, "Open the cursor object first");
3198
+ rb_raise(esyms.eProgrammingError, "Open the cursor object first");
3208
3199
 
3209
3200
  did = c->database_id;
3210
3201
  /*
3211
3202
  * EXEC SQL set connection :did;
3212
3203
  */
3213
- #line 2531 "informix.ec"
3204
+ #line 2522 "informix.ec"
3214
3205
  {
3215
- #line 2531 "informix.ec"
3206
+ #line 2522 "informix.ec"
3216
3207
  sqli_connect_set(0, did, 0);
3217
- #line 2531 "informix.ec"
3208
+ #line 2522 "informix.ec"
3218
3209
  }
3219
3210
  if (SQLCODE < 0)
3220
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
3211
+ raise_ifx_extended();
3221
3212
 
3222
3213
  output = c->daOutput;
3223
3214
  cid = c->cursor_id;
@@ -3225,15 +3216,15 @@ fetch(VALUE self, VALUE type, int bang)
3225
3216
  /*
3226
3217
  * EXEC SQL fetch :cid using descriptor output;
3227
3218
  */
3228
- #line 2538 "informix.ec"
3219
+ #line 2529 "informix.ec"
3229
3220
  {
3230
- #line 2538 "informix.ec"
3221
+ #line 2529 "informix.ec"
3231
3222
  static _FetchSpec _FS0 = { 0, 1, 0 };
3232
3223
  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, output, (char *)0, &_FS0);
3233
- #line 2538 "informix.ec"
3224
+ #line 2529 "informix.ec"
3234
3225
  }
3235
3226
  if (SQLCODE < 0)
3236
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
3227
+ raise_ifx_extended();
3237
3228
 
3238
3229
  if (SQLCODE == SQLNOTFOUND)
3239
3230
  return Qnil;
@@ -3313,13 +3304,13 @@ fetch_many(VALUE self, VALUE n, VALUE type)
3313
3304
  /*
3314
3305
  * EXEC SQL begin declare section;
3315
3306
  */
3316
- #line 2617 "informix.ec"
3317
- #line 2618 "informix.ec"
3307
+ #line 2608 "informix.ec"
3308
+ #line 2609 "informix.ec"
3318
3309
  char *cid, *did;
3319
3310
  /*
3320
3311
  * EXEC SQL end declare section;
3321
3312
  */
3322
- #line 2619 "informix.ec"
3313
+ #line 2610 "informix.ec"
3323
3314
 
3324
3315
  cursor_t *c;
3325
3316
  struct sqlda *output;
@@ -3329,20 +3320,20 @@ fetch_many(VALUE self, VALUE n, VALUE type)
3329
3320
 
3330
3321
  Data_Get_Struct(self, cursor_t, c);
3331
3322
  if (!c->is_open)
3332
- rb_raise(rb_eRuntimeError, "Open the cursor object first");
3323
+ rb_raise(esyms.eProgrammingError, "Open the cursor object first");
3333
3324
 
3334
3325
  did = c->database_id;
3335
3326
  /*
3336
3327
  * EXEC SQL set connection :did;
3337
3328
  */
3338
- #line 2631 "informix.ec"
3329
+ #line 2622 "informix.ec"
3339
3330
  {
3340
- #line 2631 "informix.ec"
3331
+ #line 2622 "informix.ec"
3341
3332
  sqli_connect_set(0, did, 0);
3342
- #line 2631 "informix.ec"
3333
+ #line 2622 "informix.ec"
3343
3334
  }
3344
3335
  if (SQLCODE < 0)
3345
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
3336
+ raise_ifx_extended();
3346
3337
 
3347
3338
  output = c->daOutput;
3348
3339
  cid = c->cursor_id;
@@ -3359,15 +3350,15 @@ fetch_many(VALUE self, VALUE n, VALUE type)
3359
3350
  /*
3360
3351
  * EXEC SQL fetch :cid using descriptor output;
3361
3352
  */
3362
- #line 2647 "informix.ec"
3353
+ #line 2638 "informix.ec"
3363
3354
  {
3364
- #line 2647 "informix.ec"
3355
+ #line 2638 "informix.ec"
3365
3356
  static _FetchSpec _FS0 = { 0, 1, 0 };
3366
3357
  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, output, (char *)0, &_FS0);
3367
- #line 2647 "informix.ec"
3358
+ #line 2638 "informix.ec"
3368
3359
  }
3369
3360
  if (SQLCODE < 0)
3370
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
3361
+ raise_ifx_extended();
3371
3362
 
3372
3363
  if (SQLCODE == SQLNOTFOUND)
3373
3364
  break;
@@ -3443,33 +3434,33 @@ each(VALUE self, VALUE type, int bang)
3443
3434
  /*
3444
3435
  * EXEC SQL begin declare section;
3445
3436
  */
3446
- #line 2722 "informix.ec"
3447
- #line 2723 "informix.ec"
3437
+ #line 2713 "informix.ec"
3438
+ #line 2714 "informix.ec"
3448
3439
  char *cid, *did;
3449
3440
  /*
3450
3441
  * EXEC SQL end declare section;
3451
3442
  */
3452
- #line 2724 "informix.ec"
3443
+ #line 2715 "informix.ec"
3453
3444
 
3454
3445
  struct sqlda *output;
3455
3446
  VALUE record;
3456
3447
 
3457
3448
  Data_Get_Struct(self, cursor_t, c);
3458
3449
  if (!c->is_open)
3459
- rb_raise(rb_eRuntimeError, "Open the cursor object first");
3450
+ rb_raise(esyms.eProgrammingError, "Open the cursor object first");
3460
3451
 
3461
3452
  did = c->database_id;
3462
3453
  /*
3463
3454
  * EXEC SQL set connection :did;
3464
3455
  */
3465
- #line 2733 "informix.ec"
3456
+ #line 2724 "informix.ec"
3466
3457
  {
3467
- #line 2733 "informix.ec"
3458
+ #line 2724 "informix.ec"
3468
3459
  sqli_connect_set(0, did, 0);
3469
- #line 2733 "informix.ec"
3460
+ #line 2724 "informix.ec"
3470
3461
  }
3471
3462
  if (SQLCODE < 0)
3472
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
3463
+ raise_ifx_extended();
3473
3464
 
3474
3465
  output = c->daOutput;
3475
3466
  cid = c->cursor_id;
@@ -3478,15 +3469,15 @@ each(VALUE self, VALUE type, int bang)
3478
3469
  /*
3479
3470
  * EXEC SQL fetch :cid using descriptor output;
3480
3471
  */
3481
- #line 2741 "informix.ec"
3472
+ #line 2732 "informix.ec"
3482
3473
  {
3483
- #line 2741 "informix.ec"
3474
+ #line 2732 "informix.ec"
3484
3475
  static _FetchSpec _FS0 = { 0, 1, 0 };
3485
3476
  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, output, (char *)0, &_FS0);
3486
- #line 2741 "informix.ec"
3477
+ #line 2732 "informix.ec"
3487
3478
  }
3488
3479
  if (SQLCODE < 0)
3489
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
3480
+ raise_ifx_extended();
3490
3481
 
3491
3482
  if (SQLCODE == SQLNOTFOUND)
3492
3483
  return self;
@@ -3622,31 +3613,31 @@ inscur_put(int argc, VALUE *argv, VALUE self)
3622
3613
  /*
3623
3614
  * EXEC SQL begin declare section;
3624
3615
  */
3625
- #line 2876 "informix.ec"
3626
- #line 2877 "informix.ec"
3616
+ #line 2867 "informix.ec"
3617
+ #line 2868 "informix.ec"
3627
3618
  char *cid, *did;
3628
3619
  /*
3629
3620
  * EXEC SQL end declare section;
3630
3621
  */
3631
- #line 2878 "informix.ec"
3622
+ #line 2869 "informix.ec"
3632
3623
 
3633
3624
 
3634
3625
  Data_Get_Struct(self, cursor_t, c);
3635
3626
  if (!c->is_open)
3636
- rb_raise(rb_eRuntimeError, "Open the cursor object first");
3627
+ rb_raise(esyms.eProgrammingError, "Open the cursor object first");
3637
3628
 
3638
3629
  did = c->database_id;
3639
3630
  /*
3640
3631
  * EXEC SQL set connection :did;
3641
3632
  */
3642
- #line 2885 "informix.ec"
3633
+ #line 2876 "informix.ec"
3643
3634
  {
3644
- #line 2885 "informix.ec"
3635
+ #line 2876 "informix.ec"
3645
3636
  sqli_connect_set(0, did, 0);
3646
- #line 2885 "informix.ec"
3637
+ #line 2876 "informix.ec"
3647
3638
  }
3648
3639
  if (SQLCODE < 0)
3649
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
3640
+ raise_ifx_extended();
3650
3641
 
3651
3642
  input = &c->daInput;
3652
3643
  cid = c->cursor_id;
@@ -3659,15 +3650,15 @@ inscur_put(int argc, VALUE *argv, VALUE self)
3659
3650
  /*
3660
3651
  * EXEC SQL put :cid using descriptor input;
3661
3652
  */
3662
- #line 2897 "informix.ec"
3653
+ #line 2888 "informix.ec"
3663
3654
  {
3664
- #line 2897 "informix.ec"
3655
+ #line 2888 "informix.ec"
3665
3656
  sqli_curs_put(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), input, (char *)0);
3666
- #line 2897 "informix.ec"
3657
+ #line 2888 "informix.ec"
3667
3658
  }
3668
3659
  clean_input_slots(c);
3669
3660
  if (SQLCODE < 0)
3670
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
3661
+ raise_ifx_extended();
3671
3662
 
3672
3663
  /* XXX 2-448, Guide to SQL: Sytax*/
3673
3664
  return INT2FIX(sqlca.sqlerrd[2]);
@@ -3688,41 +3679,41 @@ inscur_flush(VALUE self)
3688
3679
  /*
3689
3680
  * EXEC SQL begin declare section;
3690
3681
  */
3691
- #line 2918 "informix.ec"
3692
- #line 2919 "informix.ec"
3682
+ #line 2909 "informix.ec"
3683
+ #line 2910 "informix.ec"
3693
3684
  char *cid, *did;
3694
3685
  /*
3695
3686
  * EXEC SQL end declare section;
3696
3687
  */
3697
- #line 2920 "informix.ec"
3688
+ #line 2911 "informix.ec"
3698
3689
 
3699
3690
 
3700
3691
  Data_Get_Struct(self, cursor_t, c);
3701
3692
  if (!c->is_open)
3702
- rb_raise(rb_eRuntimeError, "Open the cursor object first");
3693
+ rb_raise(esyms.eProgrammingError, "Open the cursor object first");
3703
3694
 
3704
3695
  did = c->database_id;
3705
3696
  /*
3706
3697
  * EXEC SQL set connection :did;
3707
3698
  */
3708
- #line 2927 "informix.ec"
3699
+ #line 2918 "informix.ec"
3709
3700
  {
3710
- #line 2927 "informix.ec"
3701
+ #line 2918 "informix.ec"
3711
3702
  sqli_connect_set(0, did, 0);
3712
- #line 2927 "informix.ec"
3703
+ #line 2918 "informix.ec"
3713
3704
  }
3714
3705
  if (SQLCODE < 0)
3715
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
3706
+ raise_ifx_extended();
3716
3707
 
3717
3708
  cid = c->cursor_id;
3718
3709
  /*
3719
3710
  * EXEC SQL flush :cid;
3720
3711
  */
3721
- #line 2932 "informix.ec"
3712
+ #line 2923 "informix.ec"
3722
3713
  {
3723
- #line 2932 "informix.ec"
3714
+ #line 2923 "informix.ec"
3724
3715
  sqli_curs_flush(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256));
3725
- #line 2932 "informix.ec"
3716
+ #line 2923 "informix.ec"
3726
3717
  }
3727
3718
  return self;
3728
3719
  }
@@ -3742,29 +3733,29 @@ scrollcur_entry(VALUE self, VALUE index, VALUE type, int bang)
3742
3733
  /*
3743
3734
  * EXEC SQL begin declare section;
3744
3735
  */
3745
- #line 2948 "informix.ec"
3746
- #line 2949 "informix.ec"
3736
+ #line 2939 "informix.ec"
3737
+ #line 2940 "informix.ec"
3747
3738
  char *cid, *did;
3748
3739
  long pos;
3749
3740
  /*
3750
3741
  * EXEC SQL end declare section;
3751
3742
  */
3752
- #line 2951 "informix.ec"
3743
+ #line 2942 "informix.ec"
3753
3744
 
3754
3745
 
3755
3746
  Data_Get_Struct(self, cursor_t, c);
3756
3747
  if (!c->is_open)
3757
- rb_raise(rb_eRuntimeError, "Open the cursor object first");
3748
+ rb_raise(esyms.eProgrammingError, "Open the cursor object first");
3758
3749
 
3759
3750
  did = c->database_id;
3760
3751
  /*
3761
3752
  * EXEC SQL set connection :did;
3762
3753
  */
3763
- #line 2958 "informix.ec"
3754
+ #line 2949 "informix.ec"
3764
3755
  {
3765
- #line 2958 "informix.ec"
3756
+ #line 2949 "informix.ec"
3766
3757
  sqli_connect_set(0, did, 0);
3767
- #line 2958 "informix.ec"
3758
+ #line 2949 "informix.ec"
3768
3759
  }
3769
3760
  if (SQLCODE < 0)
3770
3761
  return Qnil;
@@ -3776,60 +3767,60 @@ long pos;
3776
3767
  /*
3777
3768
  * EXEC SQL fetch current :cid using descriptor output;
3778
3769
  */
3779
- #line 2966 "informix.ec"
3770
+ #line 2957 "informix.ec"
3780
3771
  {
3781
- #line 2966 "informix.ec"
3772
+ #line 2957 "informix.ec"
3782
3773
  static _FetchSpec _FS0 = { 0, 5, 0 };
3783
3774
  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, output, (char *)0, &_FS0);
3784
- #line 2966 "informix.ec"
3775
+ #line 2957 "informix.ec"
3785
3776
  }
3786
3777
  else if ((pos = NUM2LONG(index) + 1) > 0)
3787
3778
  /*
3788
3779
  * EXEC SQL fetch absolute :pos :cid using descriptor output;
3789
3780
  */
3790
- #line 2968 "informix.ec"
3781
+ #line 2959 "informix.ec"
3791
3782
  {
3792
- #line 2968 "informix.ec"
3783
+ #line 2959 "informix.ec"
3793
3784
  static ifx_sqlvar_t _sqibind[] =
3794
3785
  {
3795
3786
  { 103, sizeof(pos), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
3796
- #line 2968 "informix.ec"
3787
+ #line 2959 "informix.ec"
3797
3788
  };
3798
3789
  static ifx_sqlda_t _SD0 = { 1, _sqibind, {0}, 1, 0 };
3799
3790
  static _FetchSpec _FS1 = { 0, 6, 0 };
3800
- #line 2968 "informix.ec"
3791
+ #line 2959 "informix.ec"
3801
3792
  _sqibind[0].sqldata = (char *) &pos;
3802
3793
  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), &_SD0, output, (char *)0, &_FS1);
3803
- #line 2968 "informix.ec"
3794
+ #line 2959 "informix.ec"
3804
3795
  }
3805
3796
  else {
3806
3797
  /*
3807
3798
  * EXEC SQL fetch last :cid;
3808
3799
  */
3809
- #line 2970 "informix.ec"
3800
+ #line 2961 "informix.ec"
3810
3801
  {
3811
- #line 2970 "informix.ec"
3802
+ #line 2961 "informix.ec"
3812
3803
  static _FetchSpec _FS0 = { 0, 4, 0 };
3813
3804
  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, (ifx_sqlda_t *)0, (char *)0, &_FS0);
3814
- #line 2970 "informix.ec"
3805
+ #line 2961 "informix.ec"
3815
3806
  }
3816
3807
  /*
3817
3808
  * EXEC SQL fetch relative :pos :cid using descriptor output;
3818
3809
  */
3819
- #line 2971 "informix.ec"
3810
+ #line 2962 "informix.ec"
3820
3811
  {
3821
- #line 2971 "informix.ec"
3812
+ #line 2962 "informix.ec"
3822
3813
  static ifx_sqlvar_t _sqibind[] =
3823
3814
  {
3824
3815
  { 103, sizeof(pos), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
3825
- #line 2971 "informix.ec"
3816
+ #line 2962 "informix.ec"
3826
3817
  };
3827
3818
  static ifx_sqlda_t _SD0 = { 1, _sqibind, {0}, 1, 0 };
3828
3819
  static _FetchSpec _FS1 = { 0, 7, 0 };
3829
- #line 2971 "informix.ec"
3820
+ #line 2962 "informix.ec"
3830
3821
  _sqibind[0].sqldata = (char *) &pos;
3831
3822
  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), &_SD0, output, (char *)0, &_FS1);
3832
- #line 2971 "informix.ec"
3823
+ #line 2962 "informix.ec"
3833
3824
  }
3834
3825
  }
3835
3826
 
@@ -3837,7 +3828,7 @@ long pos;
3837
3828
  return Qnil;
3838
3829
 
3839
3830
  if (SQLCODE < 0)
3840
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
3831
+ raise_ifx_extended();
3841
3832
 
3842
3833
  RECORD(c, type, bang, record);
3843
3834
  return make_result(c, record);
@@ -3854,13 +3845,13 @@ scrollcur_subseq(VALUE self, VALUE start, VALUE length, VALUE type)
3854
3845
  /*
3855
3846
  * EXEC SQL begin declare section;
3856
3847
  */
3857
- #line 2992 "informix.ec"
3858
- #line 2993 "informix.ec"
3848
+ #line 2983 "informix.ec"
3849
+ #line 2984 "informix.ec"
3859
3850
  long pos;
3860
3851
  /*
3861
3852
  * EXEC SQL end declare section;
3862
3853
  */
3863
- #line 2994 "informix.ec"
3854
+ #line 2985 "informix.ec"
3864
3855
 
3865
3856
 
3866
3857
  first = scrollcur_entry(self, start, type, 0);
@@ -3992,29 +3983,29 @@ scrollcur_rel(int argc, VALUE *argv, VALUE self, int dir, VALUE type, int bang)
3992
3983
  /*
3993
3984
  * EXEC SQL begin declare section;
3994
3985
  */
3995
- #line 3122 "informix.ec"
3996
- #line 3123 "informix.ec"
3986
+ #line 3113 "informix.ec"
3987
+ #line 3114 "informix.ec"
3997
3988
  char *cid, *did;
3998
3989
  long pos;
3999
3990
  /*
4000
3991
  * EXEC SQL end declare section;
4001
3992
  */
4002
- #line 3125 "informix.ec"
3993
+ #line 3116 "informix.ec"
4003
3994
 
4004
3995
 
4005
3996
  Data_Get_Struct(self, cursor_t, c);
4006
3997
  if (!c->is_open)
4007
- rb_raise(rb_eRuntimeError, "Open the cursor object first");
3998
+ rb_raise(esyms.eProgrammingError, "Open the cursor object first");
4008
3999
 
4009
4000
  did = c->database_id;
4010
4001
  /*
4011
4002
  * EXEC SQL set connection :did;
4012
4003
  */
4013
- #line 3132 "informix.ec"
4004
+ #line 3123 "informix.ec"
4014
4005
  {
4015
- #line 3132 "informix.ec"
4006
+ #line 3123 "informix.ec"
4016
4007
  sqli_connect_set(0, did, 0);
4017
- #line 3132 "informix.ec"
4008
+ #line 3123 "informix.ec"
4018
4009
  }
4019
4010
  if (SQLCODE < 0)
4020
4011
  return Qnil;
@@ -4027,27 +4018,27 @@ long pos;
4027
4018
  /*
4028
4019
  * EXEC SQL fetch relative :pos :cid using descriptor output;
4029
4020
  */
4030
- #line 3141 "informix.ec"
4021
+ #line 3132 "informix.ec"
4031
4022
  {
4032
- #line 3141 "informix.ec"
4023
+ #line 3132 "informix.ec"
4033
4024
  static ifx_sqlvar_t _sqibind[] =
4034
4025
  {
4035
4026
  { 103, sizeof(pos), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
4036
- #line 3141 "informix.ec"
4027
+ #line 3132 "informix.ec"
4037
4028
  };
4038
4029
  static ifx_sqlda_t _SD0 = { 1, _sqibind, {0}, 1, 0 };
4039
4030
  static _FetchSpec _FS1 = { 0, 7, 0 };
4040
- #line 3141 "informix.ec"
4031
+ #line 3132 "informix.ec"
4041
4032
  _sqibind[0].sqldata = (char *) &pos;
4042
4033
  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), &_SD0, output, (char *)0, &_FS1);
4043
- #line 3141 "informix.ec"
4034
+ #line 3132 "informix.ec"
4044
4035
  }
4045
4036
 
4046
4037
  if (SQLCODE == SQLNOTFOUND)
4047
4038
  return Qnil;
4048
4039
 
4049
4040
  if (SQLCODE < 0)
4050
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
4041
+ raise_ifx_extended();
4051
4042
 
4052
4043
  RECORD(c, type, bang, record);
4053
4044
  return make_result(c, record);
@@ -4340,13 +4331,13 @@ cursor_close_or_free(cursor_t *c, short op)
4340
4331
  /*
4341
4332
  * EXEC SQL begin declare section;
4342
4333
  */
4343
- #line 3437 "informix.ec"
4344
- #line 3438 "informix.ec"
4334
+ #line 3428 "informix.ec"
4335
+ #line 3429 "informix.ec"
4345
4336
  char *cid, *sid, *did;
4346
4337
  /*
4347
4338
  * EXEC SQL end declare section;
4348
4339
  */
4349
- #line 3439 "informix.ec"
4340
+ #line 3430 "informix.ec"
4350
4341
 
4351
4342
 
4352
4343
  if (op == 1 && !c->is_open)
@@ -4364,11 +4355,11 @@ cursor_close_or_free(cursor_t *c, short op)
4364
4355
  /*
4365
4356
  * EXEC SQL set connection :did;
4366
4357
  */
4367
- #line 3453 "informix.ec"
4358
+ #line 3444 "informix.ec"
4368
4359
  {
4369
- #line 3453 "informix.ec"
4360
+ #line 3444 "informix.ec"
4370
4361
  sqli_connect_set(0, did, 0);
4371
- #line 3453 "informix.ec"
4362
+ #line 3444 "informix.ec"
4372
4363
  }
4373
4364
  if (SQLCODE < 0)
4374
4365
  return;
@@ -4377,11 +4368,11 @@ cursor_close_or_free(cursor_t *c, short op)
4377
4368
  /*
4378
4369
  * EXEC SQL close :cid;
4379
4370
  */
4380
- #line 3458 "informix.ec"
4371
+ #line 3449 "informix.ec"
4381
4372
  {
4382
- #line 3458 "informix.ec"
4373
+ #line 3449 "informix.ec"
4383
4374
  sqli_curs_close(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256));
4384
- #line 3458 "informix.ec"
4375
+ #line 3449 "informix.ec"
4385
4376
  }
4386
4377
 
4387
4378
  if (op == 2) {
@@ -4389,20 +4380,20 @@ cursor_close_or_free(cursor_t *c, short op)
4389
4380
  /*
4390
4381
  * EXEC SQL free :cid;
4391
4382
  */
4392
- #line 3462 "informix.ec"
4383
+ #line 3453 "informix.ec"
4393
4384
  {
4394
- #line 3462 "informix.ec"
4385
+ #line 3453 "informix.ec"
4395
4386
  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 258));
4396
- #line 3462 "informix.ec"
4387
+ #line 3453 "informix.ec"
4397
4388
  }
4398
4389
  /*
4399
4390
  * EXEC SQL free :sid;
4400
4391
  */
4401
- #line 3462 "informix.ec"
4392
+ #line 3453 "informix.ec"
4402
4393
  {
4403
- #line 3462 "informix.ec"
4394
+ #line 3453 "informix.ec"
4404
4395
  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, sid, 258));
4405
- #line 3462 "informix.ec"
4396
+ #line 3453 "informix.ec"
4406
4397
  }
4407
4398
  }
4408
4399
  }
@@ -4436,18 +4427,6 @@ cursor_alloc(VALUE klass)
4436
4427
  return Data_Wrap_Struct(klass, cursor_mark, cursor_free, c);
4437
4428
  }
4438
4429
 
4439
- /*
4440
- * call-seq:
4441
- * Cursor.new(database, query, options = nil) => cursor
4442
- *
4443
- * Prepares <i>query</i> in the context of <i>database</i> with <i>options</i>
4444
- * and returns a <code>Cursor</code> object.
4445
- *
4446
- * <i>options</i> can be nil or a Hash object with the following possible keys:
4447
- *
4448
- * :scroll => true or false
4449
- * :hold => true or false
4450
- */
4451
4430
  static VALUE
4452
4431
  cursor_initialize(int argc, VALUE *argv, VALUE self)
4453
4432
  {
@@ -4458,14 +4437,14 @@ cursor_initialize(int argc, VALUE *argv, VALUE self)
4458
4437
  /*
4459
4438
  * EXEC SQL begin declare section;
4460
4439
  */
4461
- #line 3514 "informix.ec"
4462
- #line 3515 "informix.ec"
4440
+ #line 3493 "informix.ec"
4441
+ #line 3494 "informix.ec"
4463
4442
  char *c_query;
4464
4443
  char *cid, *sid, *did;
4465
4444
  /*
4466
4445
  * EXEC SQL end declare section;
4467
4446
  */
4468
- #line 3517 "informix.ec"
4447
+ #line 3496 "informix.ec"
4469
4448
 
4470
4449
 
4471
4450
  rb_scan_args(argc, argv, "21", &db, &query, &options);
@@ -4474,14 +4453,14 @@ cursor_initialize(int argc, VALUE *argv, VALUE self)
4474
4453
  /*
4475
4454
  * EXEC SQL set connection :did;
4476
4455
  */
4477
- #line 3522 "informix.ec"
4456
+ #line 3501 "informix.ec"
4478
4457
  {
4479
- #line 3522 "informix.ec"
4458
+ #line 3501 "informix.ec"
4480
4459
  sqli_connect_set(0, did, 0);
4481
- #line 3522 "informix.ec"
4460
+ #line 3501 "informix.ec"
4482
4461
  }
4483
4462
  if (SQLCODE < 0)
4484
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
4463
+ raise_ifx_extended();
4485
4464
 
4486
4465
  Data_Get_Struct(self, cursor_t, c);
4487
4466
  c->db = db;
@@ -4501,68 +4480,68 @@ cursor_initialize(int argc, VALUE *argv, VALUE self)
4501
4480
  /*
4502
4481
  * EXEC SQL prepare :sid from :c_query;
4503
4482
  */
4504
- #line 3541 "informix.ec"
4483
+ #line 3520 "informix.ec"
4505
4484
  {
4506
- #line 3541 "informix.ec"
4485
+ #line 3520 "informix.ec"
4507
4486
  sqli_prep(ESQLINTVERSION, sid, c_query,(ifx_literal_t *)0, (ifx_namelist_t *)0, -1, 0, 0 );
4508
- #line 3541 "informix.ec"
4487
+ #line 3520 "informix.ec"
4509
4488
  }
4510
4489
  if (SQLCODE < 0)
4511
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
4490
+ raise_ifx_extended();
4512
4491
 
4513
4492
  if (RTEST(scroll) && RTEST(hold))
4514
4493
  /*
4515
4494
  * EXEC SQL declare :cid scroll cursor with hold for :sid;
4516
4495
  */
4517
- #line 3546 "informix.ec"
4496
+ #line 3525 "informix.ec"
4518
4497
  {
4519
- #line 3546 "informix.ec"
4498
+ #line 3525 "informix.ec"
4520
4499
  sqli_curs_decl_dynm(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 0), cid, sqli_curs_locate(ESQLINTVERSION, sid, 1), 4128, 0);
4521
- #line 3546 "informix.ec"
4500
+ #line 3525 "informix.ec"
4522
4501
  }
4523
4502
  else if (RTEST(hold))
4524
4503
  /*
4525
4504
  * EXEC SQL declare :cid cursor with hold for :sid;
4526
4505
  */
4527
- #line 3548 "informix.ec"
4506
+ #line 3527 "informix.ec"
4528
4507
  {
4529
- #line 3548 "informix.ec"
4508
+ #line 3527 "informix.ec"
4530
4509
  sqli_curs_decl_dynm(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 0), cid, sqli_curs_locate(ESQLINTVERSION, sid, 1), 4096, 0);
4531
- #line 3548 "informix.ec"
4510
+ #line 3527 "informix.ec"
4532
4511
  }
4533
4512
  else if (RTEST(scroll))
4534
4513
  /*
4535
4514
  * EXEC SQL declare :cid scroll cursor for :sid;
4536
4515
  */
4537
- #line 3550 "informix.ec"
4516
+ #line 3529 "informix.ec"
4538
4517
  {
4539
- #line 3550 "informix.ec"
4518
+ #line 3529 "informix.ec"
4540
4519
  sqli_curs_decl_dynm(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 0), cid, sqli_curs_locate(ESQLINTVERSION, sid, 1), 32, 0);
4541
- #line 3550 "informix.ec"
4520
+ #line 3529 "informix.ec"
4542
4521
  }
4543
4522
  else
4544
4523
  /*
4545
4524
  * EXEC SQL declare :cid cursor for :sid;
4546
4525
  */
4547
- #line 3552 "informix.ec"
4526
+ #line 3531 "informix.ec"
4548
4527
  {
4549
- #line 3552 "informix.ec"
4528
+ #line 3531 "informix.ec"
4550
4529
  sqli_curs_decl_dynm(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 0), cid, sqli_curs_locate(ESQLINTVERSION, sid, 1), 0, 0);
4551
- #line 3552 "informix.ec"
4530
+ #line 3531 "informix.ec"
4552
4531
  }
4553
4532
 
4554
4533
  if (SQLCODE < 0)
4555
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
4534
+ raise_ifx_extended();
4556
4535
 
4557
4536
  alloc_input_slots(c, c_query);
4558
4537
  /*
4559
4538
  * EXEC SQL describe :sid into output;
4560
4539
  */
4561
- #line 3558 "informix.ec"
4540
+ #line 3537 "informix.ec"
4562
4541
  {
4563
- #line 3558 "informix.ec"
4542
+ #line 3537 "informix.ec"
4564
4543
  sqli_describe_stmt(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, sid, 257), &output, 0);
4565
- #line 3558 "informix.ec"
4544
+ #line 3537 "informix.ec"
4566
4545
  }
4567
4546
  c->daOutput = output;
4568
4547
 
@@ -4582,6 +4561,37 @@ cursor_initialize(int argc, VALUE *argv, VALUE self)
4582
4561
  return self;
4583
4562
  }
4584
4563
 
4564
+ static VALUE cursor_drop(VALUE self);
4565
+ /*
4566
+ * call-seq:
4567
+ * Cursor.new(database, query, options) => cursor
4568
+ * Cursor.new(database, query, options) {|cursor| block } => obj
4569
+ *
4570
+ * Creates a Cursor object based on <i>query</i> using <i>options</i>
4571
+ * in the context of <i>database</i> but does not open it.
4572
+ * In the first form the Cursor object is returned.
4573
+ * In the second form the Cursor object is passed to the block and when it
4574
+ * terminates, the Cursor object is dropped, returning the value of the block.
4575
+ *
4576
+ * <i>options</i> can be nil or a Hash object with the following possible keys:
4577
+ *
4578
+ * :scroll => true or false
4579
+ * :hold => true or false
4580
+ */
4581
+ static VALUE
4582
+ rb_cursor_s_new(int argc, VALUE *argv, VALUE klass)
4583
+ {
4584
+ VALUE cursor;
4585
+
4586
+ cursor = rb_class_new_instance(argc, argv, klass);
4587
+
4588
+ if (rb_block_given_p())
4589
+ return rb_ensure(rb_yield, cursor, cursor_drop, cursor);
4590
+
4591
+ return cursor;
4592
+ }
4593
+
4594
+ static VALUE cursor_open(int argc, VALUE *argv, VALUE self);
4585
4595
  /*
4586
4596
  * call-seq:
4587
4597
  * Cursor.open(database, query, options) => cursor
@@ -4599,8 +4609,6 @@ cursor_initialize(int argc, VALUE *argv, VALUE self)
4599
4609
  * :hold => true or false
4600
4610
  * :params => input parameters as an Array or nil
4601
4611
  */
4602
- static VALUE cursor_open(int argc, VALUE *argv, VALUE self);
4603
- static VALUE cursor_drop(VALUE self);
4604
4612
  static VALUE
4605
4613
  cursor_s_open(int argc, VALUE *argv, VALUE klass)
4606
4614
  {
@@ -4617,7 +4625,7 @@ cursor_s_open(int argc, VALUE *argv, VALUE klass)
4617
4625
  if (TYPE(params) == T_ARRAY)
4618
4626
  open_argc = RARRAY(params)->len;
4619
4627
  else if (params != Qnil)
4620
- rb_raise(rb_eRuntimeError, "Parameters must be supplied as an Array");
4628
+ rb_raise(rb_eArgError, "Parameters must be supplied as an Array");
4621
4629
  }
4622
4630
 
4623
4631
  cursor = rb_class_new_instance(argc, argv, klass);
@@ -4661,13 +4669,13 @@ cursor_open(int argc, VALUE *argv, VALUE self)
4661
4669
  /*
4662
4670
  * EXEC SQL begin declare section;
4663
4671
  */
4664
- #line 3653 "informix.ec"
4665
- #line 3654 "informix.ec"
4672
+ #line 3661 "informix.ec"
4673
+ #line 3662 "informix.ec"
4666
4674
  char *cid, *did;
4667
4675
  /*
4668
4676
  * EXEC SQL end declare section;
4669
4677
  */
4670
- #line 3655 "informix.ec"
4678
+ #line 3663 "informix.ec"
4671
4679
 
4672
4680
 
4673
4681
  Data_Get_Struct(self, cursor_t, c);
@@ -4679,14 +4687,14 @@ cursor_open(int argc, VALUE *argv, VALUE self)
4679
4687
  /*
4680
4688
  * EXEC SQL set connection :did;
4681
4689
  */
4682
- #line 3663 "informix.ec"
4690
+ #line 3671 "informix.ec"
4683
4691
  {
4684
- #line 3663 "informix.ec"
4692
+ #line 3671 "informix.ec"
4685
4693
  sqli_connect_set(0, did, 0);
4686
- #line 3663 "informix.ec"
4694
+ #line 3671 "informix.ec"
4687
4695
  }
4688
4696
  if (SQLCODE < 0)
4689
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
4697
+ raise_ifx_extended();
4690
4698
 
4691
4699
  input = &c->daInput;
4692
4700
  cid = c->cursor_id;
@@ -4702,11 +4710,11 @@ cursor_open(int argc, VALUE *argv, VALUE self)
4702
4710
  * EXEC SQL open :cid using descriptor input
4703
4711
  * with reoptimization;
4704
4712
  */
4705
- #line 3677 "informix.ec"
4713
+ #line 3685 "informix.ec"
4706
4714
  {
4707
- #line 3678 "informix.ec"
4715
+ #line 3686 "informix.ec"
4708
4716
  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), input, (char *)0, (struct value *)0, 1, 1);
4709
- #line 3678 "informix.ec"
4717
+ #line 3686 "informix.ec"
4710
4718
  }
4711
4719
  clean_input_slots(c);
4712
4720
  }
@@ -4714,26 +4722,26 @@ cursor_open(int argc, VALUE *argv, VALUE self)
4714
4722
  /*
4715
4723
  * EXEC SQL open :cid with reoptimization;
4716
4724
  */
4717
- #line 3682 "informix.ec"
4725
+ #line 3690 "informix.ec"
4718
4726
  {
4719
- #line 3682 "informix.ec"
4727
+ #line 3690 "informix.ec"
4720
4728
  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 1);
4721
- #line 3682 "informix.ec"
4729
+ #line 3690 "informix.ec"
4722
4730
  }
4723
4731
  }
4724
4732
  else
4725
4733
  /*
4726
4734
  * EXEC SQL open :cid;
4727
4735
  */
4728
- #line 3685 "informix.ec"
4736
+ #line 3693 "informix.ec"
4729
4737
  {
4730
- #line 3685 "informix.ec"
4738
+ #line 3693 "informix.ec"
4731
4739
  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, cid, 256), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 0);
4732
- #line 3685 "informix.ec"
4740
+ #line 3693 "informix.ec"
4733
4741
  }
4734
4742
 
4735
4743
  if (SQLCODE < 0)
4736
- rb_raise(rb_eRuntimeError, "Informix Error: %d", SQLCODE);
4744
+ raise_ifx_extended();
4737
4745
 
4738
4746
  c->is_open = 1;
4739
4747
  return self;
@@ -4781,7 +4789,8 @@ void Init_informix(void)
4781
4789
  rb_mInformix = rb_define_module("Informix");
4782
4790
  rb_mScrollCursor = rb_define_module_under(rb_mInformix, "ScrollCursor");
4783
4791
  rb_mInsertCursor = rb_define_module_under(rb_mInformix, "InsertCursor");
4784
- rb_define_module_function(rb_mInformix, "connect", informix_connect, -1);
4792
+ rb_define_module_function(rb_mInformix, "connect", rb_informix_connect, -1);
4793
+ rb_define_module_function(rb_mInformix, "version", rb_informix_version, 0);
4785
4794
 
4786
4795
  /* class Slob --------------------------------------------------------- */
4787
4796
  rb_cSlob = rb_define_class_under(rb_mInformix, "Slob", rb_cObject);
@@ -4876,6 +4885,7 @@ void Init_informix(void)
4876
4885
  rb_define_alias(rb_cDatabase, "disconnect", "close");
4877
4886
  rb_define_method(rb_cDatabase, "immediate", rb_database_immediate, 1);
4878
4887
  rb_define_alias(rb_cDatabase, "do", "immediate");
4888
+ rb_define_alias(rb_cDatabase, "execute", "immediate");
4879
4889
  rb_define_method(rb_cDatabase, "rollback", rb_database_rollback, 0);
4880
4890
  rb_define_method(rb_cDatabase, "commit", rb_database_commit, 0);
4881
4891
  rb_define_method(rb_cDatabase, "transaction", rb_database_transaction, 0);
@@ -4946,6 +4956,7 @@ void Init_informix(void)
4946
4956
  rb_cCursor = rb_define_class_under(rb_mInformix, "Cursor", rb_cObject);
4947
4957
  rb_define_alloc_func(rb_cCursor, cursor_alloc);
4948
4958
  rb_define_method(rb_cCursor, "initialize", cursor_initialize, -1);
4959
+ rb_define_singleton_method(rb_cCursor, "new", rb_cursor_s_new, -1);
4949
4960
  rb_define_singleton_method(rb_cCursor, "open", cursor_s_open, -1);
4950
4961
  rb_define_method(rb_cCursor, "id", cursor_id, 0);
4951
4962
  rb_define_method(rb_cCursor, "open", cursor_open, -1);
@@ -4987,6 +4998,9 @@ void Init_informix(void)
4987
4998
  sym_maxbytes = ID2SYM(rb_intern("maxbytes"));
4988
4999
 
4989
5000
  sym_params = ID2SYM(rb_intern("params"));
5001
+
5002
+ /* Initialize ifx_except module */
5003
+ rbifx_except_init(rb_mInformix, &esyms);
4990
5004
  }
4991
5005
 
4992
- #line 3942 "informix.ec"
5006
+ #line 3956 "informix.ec"