ruby-odbc 0.99993 → 0.99994

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/ChangeLog +4 -0
  2. data/README +2 -2
  3. data/ext/odbc.c +44 -23
  4. data/ext/utf8/odbc.c +2 -2
  5. data/ruby-odbc.gemspec +1 -1
  6. metadata +13 -5
data/ChangeLog CHANGED
@@ -1,6 +1,10 @@
1
1
  ODBC binding for Ruby
2
2
  ---------------------
3
3
 
4
+ Sat Jan 15 2011 version 0.99994 released
5
+
6
+ * fixed column key caching, thanks Sean Noonan for bug report
7
+
4
8
  Fri Dec 24 2010 version 0.99993 released
5
9
 
6
10
  * fixed error reporting in Database.transaction method,
data/README CHANGED
@@ -1,6 +1,6 @@
1
- # $Id: README,v 1.40 2010/12/24 16:25:18 chw Exp chw $
1
+ # $Id: README,v 1.41 2011/01/15 08:03:22 chw Exp chw $
2
2
 
3
- ruby-odbc-0.99993
3
+ ruby-odbc-0.99994
4
4
 
5
5
  This is an ODBC binding for Ruby. So far it has been tested with
6
6
 
data/ext/odbc.c CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * ODBC-Ruby binding
3
- * Copyright (c) 2001-2010 Christian Werner <chw@ch-werner.de>
3
+ * Copyright (c) 2001-2011 Christian Werner <chw@ch-werner.de>
4
4
  * Portions copyright (c) 2004 Ryszard Niewisiewicz <micz@fibernet.pl>
5
5
  * Portions copyright (c) 2006 Carl Blakeley <cblakeley@openlinksw.co.uk>
6
6
  *
@@ -8,7 +8,7 @@
8
8
  * and redistribution of this file and for a
9
9
  * DISCLAIMER OF ALL WARRANTIES.
10
10
  *
11
- * $Id: odbc.c,v 1.71 2010/12/24 16:24:21 chw Exp chw $
11
+ * $Id: odbc.c,v 1.72 2011/01/15 08:02:55 chw Exp chw $
12
12
  */
13
13
 
14
14
  #undef ODBCVER
@@ -335,6 +335,14 @@ static VALUE stmt_each_hash(int argc, VALUE *argv, VALUE self);
335
335
  static VALUE stmt_close(VALUE self);
336
336
  static VALUE stmt_drop(VALUE self);
337
337
 
338
+ /*
339
+ * Column name buffers on statement.
340
+ */
341
+
342
+ static const char *colnamebuf[] = {
343
+ "@_c0", "@_c1", "@_c2", "@_c3"
344
+ };
345
+
338
346
  /*
339
347
  * Macro to align buffers.
340
348
  */
@@ -800,20 +808,22 @@ free_dbc(DBC *p)
800
808
  }
801
809
 
802
810
  static void
803
- free_stmt_sub(STMT *q)
811
+ free_stmt_sub(STMT *q, int withp)
804
812
  {
805
- if (q->paraminfo != NULL) {
806
- int i;
813
+ int i;
807
814
 
808
- for (i = 0; i < q->nump; i++) {
809
- if (q->paraminfo[i].outbuf != NULL) {
810
- xfree(q->paraminfo[i].outbuf);
815
+ if (withp) {
816
+ if (q->paraminfo != NULL) {
817
+ for (i = 0; i < q->nump; i++) {
818
+ if (q->paraminfo[i].outbuf != NULL) {
819
+ xfree(q->paraminfo[i].outbuf);
820
+ }
811
821
  }
822
+ xfree(q->paraminfo);
823
+ q->paraminfo = NULL;
812
824
  }
813
- xfree(q->paraminfo);
814
- q->paraminfo = NULL;
825
+ q->nump = 0;
815
826
  }
816
- q->nump = 0;
817
827
  q->ncols = 0;
818
828
  if (q->coltypes != NULL) {
819
829
  xfree(q->coltypes);
@@ -842,9 +852,11 @@ free_stmt_sub(STMT *q)
842
852
  if (v != Qnil) {
843
853
  rb_iv_set(q->self, "@_h", rb_hash_new());
844
854
  }
845
- v = rb_iv_get(q->self, "@_c");
846
- if (v != Qnil) {
847
- rb_iv_set(q->self, "@_c", rb_hash_new());
855
+ for (i = 0; i < 4; i++) {
856
+ v = rb_iv_get(q->self, colnamebuf[i]);
857
+ if (v != Qnil) {
858
+ rb_iv_set(q->self, colnamebuf[i], rb_hash_new());
859
+ }
848
860
  }
849
861
  }
850
862
  }
@@ -880,7 +892,7 @@ free_stmt(STMT *q)
880
892
  VALUE qself = q->self;
881
893
 
882
894
  q->self = q->dbc = Qnil;
883
- free_stmt_sub(q);
895
+ free_stmt_sub(q, 1);
884
896
  tracemsg(2, fprintf(stderr, "ObjFree: STMT %p\n", q););
885
897
  if (q->hstmt != SQL_NULL_HSTMT) {
886
898
  /* Issue warning message. */
@@ -3402,6 +3414,7 @@ wrap_stmt(VALUE dbc, DBC *p, SQLHSTMT hstmt, STMT **qp)
3402
3414
  {
3403
3415
  VALUE stmt = Qnil;
3404
3416
  STMT *q;
3417
+ int i;
3405
3418
 
3406
3419
  stmt = Data_Make_Struct(Cstmt, STMT, mark_stmt, free_stmt, q);
3407
3420
  tracemsg(2, fprintf(stderr, "ObjAlloc: STMT %p\n", q););
@@ -3419,7 +3432,9 @@ wrap_stmt(VALUE dbc, DBC *p, SQLHSTMT hstmt, STMT **qp)
3419
3432
  q->usef = 0;
3420
3433
  rb_iv_set(q->self, "@_a", rb_ary_new());
3421
3434
  rb_iv_set(q->self, "@_h", rb_hash_new());
3422
- rb_iv_set(q->self, "@_c", rb_hash_new());
3435
+ for (i = 0; i < 4; i++) {
3436
+ rb_iv_set(q->self, colnamebuf[i], rb_hash_new());
3437
+ }
3423
3438
  if (hstmt != SQL_NULL_HSTMT) {
3424
3439
  link_stmt(q, p);
3425
3440
  } else {
@@ -3479,7 +3494,7 @@ make_result(VALUE dbc, SQLHSTMT hstmt, VALUE result, int mode)
3479
3494
  } else {
3480
3495
  Data_Get_Struct(result, STMT, q);
3481
3496
  retain_paraminfo_override(q, nump, paraminfo);
3482
- free_stmt_sub(q);
3497
+ free_stmt_sub(q, 1);
3483
3498
  if (q->dbc != dbc) {
3484
3499
  unlink_stmt(q);
3485
3500
  q->dbc = dbc;
@@ -5407,7 +5422,7 @@ stmt_drop(VALUE self)
5407
5422
  q->hstmt = SQL_NULL_HSTMT;
5408
5423
  unlink_stmt(q);
5409
5424
  }
5410
- free_stmt_sub(q);
5425
+ free_stmt_sub(q, 1);
5411
5426
  return self;
5412
5427
  }
5413
5428
 
@@ -5421,7 +5436,7 @@ stmt_close(VALUE self)
5421
5436
  callsql(SQL_NULL_HENV, SQL_NULL_HDBC, q->hstmt,
5422
5437
  SQLFreeStmt(q->hstmt, SQL_CLOSE), "SQLFreeStmt(SQL_CLOSE)");
5423
5438
  }
5424
- free_stmt_sub(q);
5439
+ free_stmt_sub(q, 1);
5425
5440
  return self;
5426
5441
  }
5427
5442
 
@@ -6078,16 +6093,20 @@ do_fetch(STMT *q, int mode)
6078
6093
  q->colvals = ALLOC_N(VALUE, 4 * q->ncols);
6079
6094
  if (q->colvals != NULL) {
6080
6095
  VALUE cname;
6096
+ VALUE colbuf[4];
6081
6097
 
6082
6098
  for (i = 0; i < 4 * q->ncols; i++) {
6083
6099
  q->colvals[i] = Qnil;
6084
6100
  }
6085
- res = rb_iv_get(q->self, "@_c");
6086
- if (res == Qnil) {
6087
- res = rb_hash_new();
6088
- rb_iv_set(q->self, "@_c", res);
6101
+ for (i = 0; i < 4; i++) {
6102
+ colbuf[i] = rb_iv_get(q->self, colnamebuf[i]);
6103
+ if (colbuf[i] == Qnil) {
6104
+ res = rb_hash_new();
6105
+ rb_iv_set(q->self, colnamebuf[i], res);
6106
+ }
6089
6107
  }
6090
6108
  for (i = 0; i < 4 * q->ncols; i++) {
6109
+ res = colbuf[i / q->ncols];
6091
6110
  cname = rb_tainted_str_new2(q->colnames[i]);
6092
6111
  #ifdef USE_RB_ENC
6093
6112
  rb_enc_associate(cname, rb_enc);
@@ -6886,6 +6905,7 @@ stmt_more_results(VALUE self)
6886
6905
  return Qfalse;
6887
6906
  case SQL_SUCCESS:
6888
6907
  case SQL_SUCCESS_WITH_INFO:
6908
+ free_stmt_sub(q, 0);
6889
6909
  make_result(q->dbc, q->hstmt, self, 0);
6890
6910
  break;
6891
6911
  default:
@@ -6911,6 +6931,7 @@ stmt_prep_int(int argc, VALUE *argv, VALUE self, int mode)
6911
6931
 
6912
6932
  if (rb_obj_is_kind_of(self, Cstmt) == Qtrue) {
6913
6933
  Data_Get_Struct(self, STMT, q);
6934
+ free_stmt_sub(q, 0);
6914
6935
  if (q->hstmt == SQL_NULL_HSTMT) {
6915
6936
  if (!succeeded(SQL_NULL_HENV, p->hdbc, q->hstmt,
6916
6937
  SQLAllocStmt(p->hdbc, &q->hstmt),
@@ -1,12 +1,12 @@
1
1
  /*
2
2
  * ODBC-Ruby binding
3
- * Copyright (c) 2001-2010 Christian Werner <chw@ch-werner.de>
3
+ * Copyright (c) 2001-2011 Christian Werner <chw@ch-werner.de>
4
4
  *
5
5
  * See the file "COPYING" for information on usage
6
6
  * and redistribution of this file and for a
7
7
  * DISCLAIMER OF ALL WARRANTIES.
8
8
  *
9
- * $Id: odbc.c,v 1.5 2010/09/16 06:47:00 chw Exp chw $
9
+ * $Id: odbc.c,v 1.6 2011/01/15 08:02:55 chw Exp chw $
10
10
  */
11
11
 
12
12
  #undef UNICODE
@@ -1,7 +1,7 @@
1
1
  require 'date'
2
2
  spec = Gem::Specification.new do |s|
3
3
  s.name = "ruby-odbc"
4
- s.version = "0.99993"
4
+ s.version = "0.99994"
5
5
  s.date = Date.today.to_s
6
6
  s.author = "Christian Werner"
7
7
  s.email = "chw @nospam@ ch-werner.de"
metadata CHANGED
@@ -1,7 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-odbc
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.99993"
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 99994
8
+ version: "0.99994"
5
9
  platform: ruby
6
10
  authors:
7
11
  - Christian Werner
@@ -9,7 +13,7 @@ autorequire:
9
13
  bindir: bin
10
14
  cert_chain: []
11
15
 
12
- date: 2010-12-24 00:00:00 +01:00
16
+ date: 2011-01-15 00:00:00 +01:00
13
17
  default_executable:
14
18
  dependencies: []
15
19
 
@@ -61,21 +65,25 @@ require_paths:
61
65
  - lib
62
66
  - lib
63
67
  required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
64
69
  requirements:
65
70
  - - ">="
66
71
  - !ruby/object:Gem::Version
72
+ segments:
73
+ - 0
67
74
  version: "0"
68
- version:
69
75
  required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
70
77
  requirements:
71
78
  - - ">="
72
79
  - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
73
82
  version: "0"
74
- version:
75
83
  requirements: []
76
84
 
77
85
  rubyforge_project:
78
- rubygems_version: 1.3.5
86
+ rubygems_version: 1.3.7
79
87
  signing_key:
80
88
  specification_version: 3
81
89
  summary: ODBC binding for Ruby