ruby-informix 0.7.1 → 0.7.2

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.
@@ -1,4 +1,3 @@
1
- /* $Id: informixc.ec,v 1.29 2008/04/03 00:50:20 santana Exp $ */
2
1
  /*
3
2
  * Copyright (c) 2006-2008, Gerardo Santana Gomez Garrido <gerardo.santana@gmail.com>
4
3
  * All rights reserved.
@@ -28,8 +27,6 @@
28
27
  * POSSIBILITY OF SUCH DAMAGE.
29
28
  */
30
29
 
31
- static const char rcsid[] = "$Id: informixc.ec,v 1.29 2008/04/03 00:50:20 santana Exp $";
32
-
33
30
  #include "ruby.h"
34
31
 
35
32
  #include <sqlstype.h>
@@ -49,8 +46,6 @@ static VALUE rb_cStatement, rb_cCursorBase;
49
46
  static VALUE rb_cSequentialCursor, rb_cScrollCursor, rb_cInsertCursor;
50
47
  static VALUE rb_cIfxVersion;
51
48
 
52
- static VALUE rb_cArray;
53
-
54
49
  /* Exceptions */
55
50
  static VALUE rb_eError, rb_eWarning, rb_eInternalError;
56
51
  static VALUE rb_eProgrammingError, rb_eOperationalError, rb_eDatabaseError;
@@ -180,82 +175,74 @@ rbifx_ext_exception(VALUE exception_class)
180
175
  mint i;
181
176
  EXEC SQL END DECLARE SECTION;
182
177
 
183
- new_instance = rb_class_new_instance(0, 0, exception_class);
184
-
185
- /* Check that instance of exception_class is derived from
186
- * Informix::Error
187
- */
188
- if (!rb_obj_is_kind_of(new_instance, rb_eError) &&
189
- !rb_obj_is_kind_of(new_instance, rb_eWarning)) {
190
- rb_raise(rb_eRuntimeError,
191
- "Can't instantiate exception from %s, only from %s or %s or their children",
192
- rb_class2name(exception_class),
193
- rb_class2name(rb_eWarning),
194
- rb_class2name(rb_eError));
195
- }
196
-
197
- EXEC SQL GET DIAGNOSTICS :exc_count = NUMBER;
198
-
199
- if (exc_count == 0) { /* Something went wrong */
200
- char message[128];
201
- snprintf(message,
202
- sizeof(message),
203
- "SQL ERROR: SQLCODE %d (sorry, no GET DIAGNOSTICS information available)",
204
- SQLCODE);
205
-
206
- {
207
- VALUE argv[] = { rb_str_new2(message) };
208
- return rb_class_new_instance(NUM_ELEMS(argv), argv, rb_eOperationalError);
209
- }
210
- }
211
-
212
- for (i = 0; i < exc_count; ++i) {
213
- sql_exception_number = i + 1;
214
-
215
- EXEC SQL GET DIAGNOSTICS EXCEPTION :sql_exception_number
216
- :sql_code = INFORMIX_SQLCODE,
217
- :sql_state = RETURNED_SQLSTATE,
218
- :class_origin_val = CLASS_ORIGIN,
219
- :subclass_origin_val = SUBCLASS_ORIGIN,
220
- :message = MESSAGE_TEXT,
221
- :message_len = MESSAGE_LENGTH,
222
- :server_name = SERVER_NAME,
223
- :connection_name = CONNECTION_NAME
224
- ;
225
-
226
- TRIM_BLANKS(class_origin_val);
227
- TRIM_BLANKS(subclass_origin_val);
228
- TRIM_BLANKS(server_name);
229
- TRIM_BLANKS(connection_name);
230
- message[message_len - 1] = '\0';
231
- TRIM_BLANKS(message);
232
-
233
- {
234
- VALUE sprintf_args[] = { rb_str_new2(message), rb_str_new2(sqlca.sqlerrm) };
235
- VALUE argv[] = {
236
- INT2FIX(sql_code),
237
- rb_str_new2(sql_state),
238
- rb_str_new2(class_origin_val),
239
- rb_str_new2(subclass_origin_val),
240
- rb_f_sprintf(NUM_ELEMS(sprintf_args), sprintf_args),
241
- rb_str_new2(server_name),
242
- rb_str_new2(connection_name)
243
- };
244
-
245
- rb_funcall(new_instance, s_add_info, 1, rb_ary_new4(7, argv));
246
- }
247
- }
178
+ new_instance = rb_class_new_instance(0, 0, exception_class);
179
+
180
+ /* Check that instance of exception_class is derived from Informix::Error */
181
+ if (!rb_obj_is_kind_of(new_instance, rb_eError) &&
182
+ !rb_obj_is_kind_of(new_instance, rb_eWarning)) {
183
+ rb_raise(rb_eRuntimeError, "Can't instantiate exception from %s, "
184
+ "only from %s or %s or their children",
185
+ rb_class2name(exception_class),
186
+ rb_class2name(rb_eWarning),
187
+ rb_class2name(rb_eError));
188
+ }
248
189
 
249
- return new_instance;
190
+ EXEC SQL GET DIAGNOSTICS :exc_count = NUMBER;
191
+
192
+ if (exc_count == 0) { /* Something went wrong */
193
+ char message[128];
194
+ snprintf(message, sizeof(message), "SQL ERROR: SQLCODE %d "
195
+ "(sorry, no GET DIAGNOSTICS information available)", SQLCODE);
196
+ {
197
+ VALUE argv[] = { rb_str_new2(message) };
198
+ return rb_class_new_instance(NUM_ELEMS(argv),argv,rb_eOperationalError);
199
+ }
200
+ }
201
+
202
+ for (i = 0; i < exc_count; ++i) {
203
+ sql_exception_number = i + 1;
204
+
205
+ EXEC SQL GET DIAGNOSTICS EXCEPTION :sql_exception_number
206
+ :sql_code = INFORMIX_SQLCODE,
207
+ :sql_state = RETURNED_SQLSTATE,
208
+ :class_origin_val = CLASS_ORIGIN,
209
+ :subclass_origin_val = SUBCLASS_ORIGIN,
210
+ :message = MESSAGE_TEXT,
211
+ :message_len = MESSAGE_LENGTH,
212
+ :server_name = SERVER_NAME,
213
+ :connection_name = CONNECTION_NAME
214
+ ;
215
+
216
+ TRIM_BLANKS(class_origin_val);
217
+ TRIM_BLANKS(subclass_origin_val);
218
+ TRIM_BLANKS(server_name);
219
+ TRIM_BLANKS(connection_name);
220
+ message[message_len - 1] = '\0';
221
+ TRIM_BLANKS(message);
222
+
223
+ {
224
+ VALUE sprintf_args[] = { rb_str_new2(message), rb_str_new2(sqlca.sqlerrm) };
225
+ VALUE argv[] = {
226
+ INT2FIX(sql_code),
227
+ rb_str_new2(sql_state),
228
+ rb_str_new2(class_origin_val),
229
+ rb_str_new2(subclass_origin_val),
230
+ rb_f_sprintf(NUM_ELEMS(sprintf_args), sprintf_args),
231
+ rb_str_new2(server_name),
232
+ rb_str_new2(connection_name)
233
+ };
234
+
235
+ rb_funcall(new_instance, s_add_info, 1, rb_ary_new4(7, argv));
236
+ }
237
+ }
238
+
239
+ return new_instance;
250
240
  }
251
241
 
252
- /*
253
- * C helper functions (see ifx_except.h for documentation)
254
- */
255
242
  static void
256
243
  raise_ifx_extended(void)
257
244
  {
258
- rb_exc_raise(rbifx_ext_exception(rb_eDatabaseError));
245
+ rb_exc_raise(rbifx_ext_exception(rb_eDatabaseError));
259
246
  }
260
247
  /*
261
248
  *****************************************************************************
@@ -1511,7 +1498,7 @@ free_output_slots(cursor_t *c)
1511
1498
  {
1512
1499
  if (c->daOutput != NULL) {
1513
1500
  struct sqlvar_struct *var = c->daOutput->sqlvar;
1514
- if (var) {
1501
+ if (var != NULL) {
1515
1502
  register int i;
1516
1503
  for (i = 0; i < c->daOutput->sqld; i++, var++) {
1517
1504
  if (ISBLOBTYPE(var->sqltype)) {
@@ -1522,6 +1509,7 @@ free_output_slots(cursor_t *c)
1522
1509
  if (ISSMARTBLOB(var->sqltype, var->sqlxid))
1523
1510
  xfree(var->sqldata);
1524
1511
  }
1512
+ c->daOutput->sqlvar = NULL;
1525
1513
  }
1526
1514
  xfree(c->daOutput);
1527
1515
  c->daOutput = NULL;
@@ -2925,7 +2913,7 @@ static void
2925
2913
  cursorbase_close_or_free(cursor_t *c, short op)
2926
2914
  {
2927
2915
  EXEC SQL begin declare section;
2928
- char *cid, *sid, *did;
2916
+ char *cid, *did;
2929
2917
  EXEC SQL end declare section;
2930
2918
 
2931
2919
  if (op == 1 && !c->is_open)
@@ -3381,8 +3369,6 @@ void Init_informixc(void)
3381
3369
  rb_define_singleton_method(rb_mCursor, "new0", rb_cursor_s_new0, -1);
3382
3370
 
3383
3371
  /* Global constants --------------------------------------------------- */
3384
- rb_cArray = rb_const_get(rb_cObject, rb_intern("Array"));
3385
-
3386
3372
  rb_require("date");
3387
3373
  rb_cDate = rb_const_get(rb_cObject, rb_intern("Date"));
3388
3374
 
@@ -1,5 +1,4 @@
1
- # $Id: informix.rb,v 1.13 2008/04/01 01:17:21 santana Exp $
2
- #
1
+ #--
3
2
  # Copyright (c) 2008, Gerardo Santana Gomez Garrido <gerardo.santana@gmail.com>
4
3
  # All rights reserved.
5
4
  #
@@ -26,13 +25,14 @@
26
25
  # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27
26
  # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
27
  # POSSIBILITY OF SUCH DAMAGE.
28
+ #++
29
29
 
30
30
  require 'informixc'
31
31
  require 'informix/seqcursor'
32
32
  require 'informix/scrollcursor'
33
33
 
34
34
  module Informix
35
- VERSION = "0.7.0"
35
+ VERSION = "0.7.2"
36
36
  VERSION.freeze
37
37
 
38
38
  # Shortcut to create a +Database+ object connected to +dbname+ as
@@ -195,35 +195,39 @@ module Informix
195
195
  # Examples:
196
196
  #
197
197
  # Iterating over a table:
198
- # db.each('select * from customer') do |cust|
198
+ # db.foreach('select * from customer') do |cust|
199
199
  # # do something with cust
200
200
  # puts "#{cust[0] cust[1]}"
201
201
  # end
202
202
  # Same thing, using input parameters:
203
203
  # query = 'select * from orders where order_date = ?'
204
- # db.each(query, :params => [Date.today]) do |order|
204
+ # db.foreach(query, :params => [Date.today]) do |order|
205
205
  # # do something with order
206
206
  # end
207
- def each(query, options = nil, &block)
207
+ def foreach(query, options = nil, &block)
208
208
  Cursor.open(self, query, options) {|cur| cur.each(&block)}
209
209
  self
210
210
  end
211
+
212
+ alias each foreach
211
213
 
212
- # Similar to +Database#each+, except that retrieves records as hashes
214
+ # Similar to +Database#foreach+, except that retrieves records as hashes
213
215
  # instead of arrays.
214
216
  #
215
217
  # Examples:
216
218
  #
217
219
  # Iterating over a table:
218
- # db.each_hash('select * from customer') do |cust|
220
+ # db.foreach_hash('select * from customer') do |cust|
219
221
  # # do something with cust
220
222
  # puts "#{cust['fname'] cust['lname']}"
221
223
  # end
222
- def each_hash(query, options = nil, &block)
224
+ def foreach_hash(query, options = nil, &block)
223
225
  Cursor.open(self, query, options) {|cur| cur.each_hash(&block)}
224
226
  self
225
227
  end
226
228
 
229
+ alias each_hash foreach_hash
230
+
227
231
  # Shortcut to create a +Slob+ object.
228
232
  #
229
233
  # The +Slob+ object is passed to the block if it's given, and
@@ -1,5 +1,4 @@
1
- # $Id: exceptions.rb,v 1.2 2008/03/29 01:38:35 santana Exp $
2
- #
1
+ #--
3
2
  # Copyright (c) 2008, Gerardo Santana Gomez Garrido <gerardo.santana@gmail.com>
4
3
  # All rights reserved.
5
4
  #
@@ -26,6 +25,7 @@
26
25
  # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27
26
  # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
27
  # POSSIBILITY OF SUCH DAMAGE.
28
+ #++
29
29
 
30
30
  #--
31
31
  # The following code is a translation of the original C code written
@@ -1,5 +1,4 @@
1
- # $Id: interval.rb,v 1.3 2008/03/29 20:32:57 santana Exp $
2
- #
1
+ #--
3
2
  # Copyright (c) 2008, Gerardo Santana Gomez Garrido <gerardo.santana@gmail.com>
4
3
  # All rights reserved.
5
4
  #
@@ -26,6 +25,7 @@
26
25
  # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27
26
  # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
27
  # POSSIBILITY OF SUCH DAMAGE.
28
+ #++
29
29
 
30
30
  module Informix
31
31
  # The +IntervalBase+ class is used for sending and retrieving INTERVAL
@@ -1,5 +1,4 @@
1
- # $Id: scrollcursor.rb,v 1.4 2008/03/29 07:35:03 santana Exp $
2
- #
1
+ #--
3
2
  # Copyright (c) 2008, Gerardo Santana Gomez Garrido <gerardo.santana@gmail.com>
4
3
  # All rights reserved.
5
4
  #
@@ -26,6 +25,7 @@
26
25
  # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27
26
  # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
27
  # POSSIBILITY OF SUCH DAMAGE.
28
+ #++
29
29
 
30
30
  require 'informixc'
31
31
 
@@ -1,5 +1,4 @@
1
- # $Id: seqcursor.rb,v 1.3 2008/03/29 07:35:03 santana Exp $
2
- #
1
+ #--
3
2
  # Copyright (c) 2008, Gerardo Santana Gomez Garrido <gerardo.santana@gmail.com>
4
3
  # All rights reserved.
5
4
  #
@@ -26,6 +25,7 @@
26
25
  # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27
26
  # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
27
  # POSSIBILITY OF SUCH DAMAGE.
28
+ #++
29
29
 
30
30
  require 'informixc'
31
31
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,42 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: ruby-informix
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.7.1
7
- date: 2008-04-02 00:00:00 -06:00
8
- summary: Ruby library for IBM Informix
9
- require_paths:
10
- - lib
11
- email: gerardo.santana@gmail.com
12
- homepage: http://santanatechnotes.blogspot.com
13
- rubyforge_project: ruby-informix
14
- description: Ruby library for connecting to IBM Informix 7 and above
15
- autorequire: informix
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.7.2
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Gerardo Santana Gomez Garrido
8
+ autorequire: informix
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-21 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Ruby library for connecting to IBM Informix 7 and above
17
+ email: gerardo.santana@gmail.com
18
+ executables: []
19
+
20
+ extensions:
21
+ - ext/extconf.rb
22
+ extra_rdoc_files:
23
+ - README
24
+ - ext/informixc.c
31
25
  files:
32
26
  - ext/informixc.ec
33
27
  - lib/informix.rb
28
+ - lib/informix/exceptions.rb
34
29
  - lib/informix/interval.rb
35
30
  - lib/informix/scrollcursor.rb
36
31
  - lib/informix/seqcursor.rb
37
- - lib/informix/CVS
38
- - lib/informix/exceptions.rb
39
- - test/testcase.rb
40
32
  - test/ifx_all.rb
41
33
  - test/ifx_test_create_table.rb
42
34
  - test/ifx_test_errinfo.rb
@@ -44,12 +36,14 @@ files:
44
36
  - test/ifx_test_fetch_n_each.rb
45
37
  - test/ifx_test_insert.rb
46
38
  - test/ifx_test_select.rb
39
+ - test/testcase.rb
47
40
  - COPYRIGHT
48
41
  - Changelog
49
42
  - README
50
43
  - ext/informixc.c
51
- test_files: []
52
-
44
+ has_rdoc: true
45
+ homepage: http://santanatechnotes.blogspot.com
46
+ post_install_message:
53
47
  rdoc_options:
54
48
  - --title
55
49
  - Ruby/Informix -- Ruby library for IBM Informix
@@ -61,14 +55,26 @@ rdoc_options:
61
55
  - --line-numbers
62
56
  - --main
63
57
  - README
64
- extra_rdoc_files:
65
- - README
66
- - ext/informixc.c
67
- executables: []
68
-
69
- extensions:
70
- - ext/extconf.rb
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: "0"
71
+ version:
71
72
  requirements: []
72
73
 
73
- dependencies: []
74
+ rubyforge_project: ruby-informix
75
+ rubygems_version: 1.2.0
76
+ signing_key:
77
+ specification_version: 2
78
+ summary: Ruby library for IBM Informix
79
+ test_files: []
74
80