ibm_db 2.5.18 → 2.5.25

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,5 +1,9 @@
1
1
  Change Log
2
2
  ==============
3
+ 2015/03/24 (IBM_DB adapter 2.5.25, driver 2.5.25)
4
+ - Support for Rails 4.2.x
5
+ - Support for Ruby 2.2.x
6
+
3
7
  2014/08/03 (IBM_DB adapter 2.5.18, driver 2.5.14) :
4
8
  - Support for Rails 4.1.x
5
9
  - Enhanced installation to pull IBM Data Server Driver automatically if not present
data/README CHANGED
@@ -1,5 +1,5 @@
1
1
  =====================================================================
2
- README for the IBM_DB Adapter (2.5.14) and Driver (2.5.14) (2014/02/11)
2
+ README for the IBM_DB Adapter (2.5.25) and Driver (2.5.25) (2015/03/24)
3
3
  For ActiveRecord Version >= 1.15.5 (and Rails >= 1.2.5)
4
4
  =====================================================================
5
5
 
@@ -5,6 +5,7 @@ require 'rubygems/package'
5
5
  require 'zlib'
6
6
  require 'fileutils'
7
7
 
8
+
8
9
  # +----------------------------------------------------------------------+
9
10
  # | Licensed Materials - Property of IBM |
10
11
  # | |
@@ -227,16 +228,32 @@ step 3: - Retry gem install
227
228
  EOL
228
229
  end
229
230
 
231
+ if(RUBY_VERSION =~ /2./)
232
+ require 'rbconfig'
233
+ end
234
+
230
235
  alias :libpathflag0 :libpathflag
231
236
  def libpathflag(libpath)
232
- ldflags = case Config::CONFIG["arch"]
233
- when /solaris2/
237
+ if(RUBY_VERSION =~ /2./)
238
+ ldflags = case RbConfig::CONFIG["arch"]
239
+ when /solaris2/
240
+ libpath[0..-2].map {|path| " -R#{path}"}.join
241
+ when /linux/
242
+ libpath[0..-2].map {|path| " -R#{path} "}.join
243
+ else
244
+ ""
245
+ end
246
+ else
247
+ ldflags = case Config::CONFIG["arch"]
248
+ when /solaris2/
234
249
  libpath[0..-2].map {|path| " -R#{path}"}.join
235
250
  when /linux/
236
251
  libpath[0..-2].map {|path| " -R#{path} "}.join
237
252
  else
238
253
  ""
239
254
  end
255
+ end
256
+
240
257
  #libpathflag0 + " '-Wl,-R$$ORIGIN/clidriver/lib #{ldflags}' "
241
258
  libpathflag0 + " '-Wl,-R$$ORIGIN/clidriver/lib' "
242
259
  end
@@ -2,17 +2,17 @@
2
2
  +----------------------------------------------------------------------+
3
3
  | Licensed Materials - Property of IBM |
4
4
  | |
5
- | (C) Copyright IBM Corporation 2006, 2007,2008, 2009, 2010 |
5
+ | (C) Copyright IBM Corporation 2006 - 2015 |
6
6
  +----------------------------------------------------------------------+
7
7
  | Authors: Sushant Koduru, Lynh Nguyen, Kanchana Padmanabhan, |
8
8
  | Dan Scott, Helmut Tessarek, Sam Ruby, Kellen Bombardier, |
9
9
  | Tony Cairns, Manas Dadarkar, Swetha Patel, Salvador Ledezma |
10
10
  | Mario Ds Briggs, Praveen Devarao, Ambrish Bhargava, |
11
- | Tarun Pasrija |
11
+ | Tarun Pasrija, Arvind Gupta |
12
12
  +----------------------------------------------------------------------+
13
13
  */
14
14
 
15
- #define MODULE_RELEASE "2.5.14"
15
+ #define MODULE_RELEASE "2.5.25"
16
16
 
17
17
  #ifdef HAVE_CONFIG_H
18
18
  #include "config.h"
@@ -28,6 +28,12 @@
28
28
  #include "ruby_ibm_db.h"
29
29
  #include <ctype.h>
30
30
 
31
+ #ifdef RUBY_THREAD_H
32
+ #include <ruby/thread.h>
33
+ #endif
34
+
35
+ #include <ruby/version.h>
36
+
31
37
  /* True global resources - no need for thread safety here */
32
38
  static VALUE le_conn_struct, le_stmt_struct, le_pconn_struct, le_row_struct;
33
39
  static VALUE le_client_info, le_server_info;
@@ -105,6 +111,9 @@ static VALUE id_id2name;
105
111
  #define RUBY_FALIAS(alias, function) \
106
112
  rb_define_singleton_method(mDB, #alias, ibm_db_##function, -1);
107
113
 
114
+
115
+
116
+
108
117
  #ifdef UNICODE_SUPPORT_VERSION
109
118
  const int _check_i = 1;
110
119
  #define arch_is_bigendian() ( (*(char*)&_check_i) == 0 ) /* returns 0 if the machine is of little endian architecture, 1 if the machine is of bigendian architecture*/
@@ -672,6 +681,25 @@ static void _ruby_ibm_db_mark_stmt_struct(stmt_handle *handle)
672
681
  {
673
682
  }
674
683
 
684
+
685
+ //VALUE ibm_Ruby_Thread_Call(void *(*func)(void *), void *data1, rb_unblock_function_t *ubf, void *data2)
686
+ VALUE ibm_Ruby_Thread_Call(rb_blocking_function_t *func, void *data1, rb_unblock_function_t *ubf, void *data2)
687
+ {
688
+ #ifdef RUBY_API_VERSION_MAJOR
689
+ if( RUBY_API_VERSION_MAJOR >=2 && RUBY_API_VERSION_MINOR >=2)
690
+ {
691
+ rb_thread_call_without_gvl(func, data1, ubf, data2);
692
+ }
693
+ else
694
+ {
695
+ return rb_thread_blocking_region(func, data1, ubf, data2);
696
+ }
697
+ #else
698
+ return rb_thread_blocking_region(func, data1, ubf, data2);
699
+ #endif
700
+ }
701
+
702
+
675
703
  /* */
676
704
 
677
705
  /* static _ruby_ibm_db_free_stmt_handle_and_resources */
@@ -988,7 +1016,8 @@ static void _ruby_ibm_db_check_sql_errors( void *conn_or_stmt, int resourceType,
988
1016
  if( release_gil == 1 ){
989
1017
 
990
1018
  #ifdef UNICODE_SUPPORT_VERSION
991
- return_code = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLGetDiagRec_helper, get_DiagRec_args,
1019
+ //return_code = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLGetDiagRec_helper, get_DiagRec_args,
1020
+ return_code = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLGetDiagRec_helper, get_DiagRec_args,
992
1021
  (void *)_ruby_ibm_db_Connection_level_UBF, NULL);
993
1022
  #else
994
1023
  return_code = _ruby_ibm_db_SQLGetDiagRec_helper( get_DiagRec_args );
@@ -2501,7 +2530,8 @@ static VALUE _ruby_ibm_db_connect_helper( int argc, VALUE *argv, int isPersisten
2501
2530
 
2502
2531
  /* Call the function where the actual logic is being run*/
2503
2532
  #ifdef UNICODE_SUPPORT_VERSION
2504
- return_value = rb_thread_blocking_region( (void *)_ruby_ibm_db_connect_helper2, helper_args,
2533
+ //return_value = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_connect_helper2, helper_args,
2534
+ return_value = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_connect_helper2, helper_args,
2505
2535
  (void *)_ruby_ibm_db_Connection_level_UBF, NULL);
2506
2536
  #else
2507
2537
  return_value = _ruby_ibm_db_connect_helper2( helper_args );
@@ -2919,7 +2949,8 @@ VALUE ruby_ibm_db_createDb_helper(VALUE connection, VALUE dbName, VALUE codeSet,
2919
2949
  _ruby_ibm_db_clear_conn_err_cache();
2920
2950
 
2921
2951
  #ifdef UNICODE_SUPPORT_VERSION
2922
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLCreateDB_helper, create_db_args,
2952
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLCreateDB_helper, create_db_args,
2953
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLCreateDB_helper, create_db_args,
2923
2954
  (void *)_ruby_ibm_db_Connection_level_UBF, NULL );
2924
2955
  #else
2925
2956
  rc = _ruby_ibm_db_SQLCreateDB_helper( create_db_args );
@@ -3048,7 +3079,8 @@ VALUE ruby_ibm_db_dropDb_helper(VALUE connection, VALUE dbName) {
3048
3079
  _ruby_ibm_db_clear_conn_err_cache();
3049
3080
 
3050
3081
  #ifdef UNICODE_SUPPORT_VERSION
3051
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLDropDB_helper, drop_db_args,
3082
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLDropDB_helper, drop_db_args,
3083
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLDropDB_helper, drop_db_args,
3052
3084
  (void *)_ruby_ibm_db_Connection_level_UBF, NULL );
3053
3085
  #else
3054
3086
  rc = _ruby_ibm_db_SQLDropDB_helper( drop_db_args );
@@ -3410,7 +3442,8 @@ VALUE ibm_db_bind_param_helper(int argc, char * varname, long varname_len ,long
3410
3442
  param_type = SQL_PARAM_INPUT;
3411
3443
 
3412
3444
  #ifdef UNICODE_SUPPORT_VERSION
3413
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLDescribeParam_helper, data,
3445
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLDescribeParam_helper, data,
3446
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLDescribeParam_helper, data,
3414
3447
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res);
3415
3448
  #else
3416
3449
  rc = _ruby_ibm_db_SQLDescribeParam_helper( data );
@@ -3430,7 +3463,8 @@ VALUE ibm_db_bind_param_helper(int argc, char * varname, long varname_len ,long
3430
3463
  case 4:
3431
3464
 
3432
3465
  #ifdef UNICODE_SUPPORT_VERSION
3433
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLDescribeParam_helper, data,
3466
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLDescribeParam_helper, data,
3467
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLDescribeParam_helper, data,
3434
3468
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res);
3435
3469
  #else
3436
3470
  rc = _ruby_ibm_db_SQLDescribeParam_helper( data );
@@ -3450,7 +3484,8 @@ VALUE ibm_db_bind_param_helper(int argc, char * varname, long varname_len ,long
3450
3484
  case 5:
3451
3485
 
3452
3486
  #ifdef UNICODE_SUPPORT_VERSION
3453
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLDescribeParam_helper, data,
3487
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLDescribeParam_helper, data,
3488
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLDescribeParam_helper, data,
3454
3489
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
3455
3490
  #else
3456
3491
  rc = _ruby_ibm_db_SQLDescribeParam_helper( data );
@@ -3471,7 +3506,8 @@ VALUE ibm_db_bind_param_helper(int argc, char * varname, long varname_len ,long
3471
3506
  case 6:
3472
3507
 
3473
3508
  #ifdef UNICODE_SUPPORT_VERSION
3474
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLDescribeParam_helper, data,
3509
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLDescribeParam_helper, data,
3510
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLDescribeParam_helper, data,
3475
3511
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
3476
3512
  #else
3477
3513
  rc = _ruby_ibm_db_SQLDescribeParam_helper( data );
@@ -3703,7 +3739,8 @@ VALUE ibm_db_close(int argc, VALUE *argv, VALUE self)
3703
3739
  end_X_args->completionType = SQL_ROLLBACK; /*Remeber you are rolling back the transaction*/
3704
3740
 
3705
3741
  #ifdef UNICODE_SUPPORT_VERSION
3706
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLEndTran, end_X_args,
3742
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLEndTran, end_X_args,
3743
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLEndTran, end_X_args,
3707
3744
  (void *)_ruby_ibm_db_Connection_level_UBF, NULL);
3708
3745
  #else
3709
3746
  rc = _ruby_ibm_db_SQLEndTran( end_X_args );
@@ -3721,7 +3758,8 @@ VALUE ibm_db_close(int argc, VALUE *argv, VALUE self)
3721
3758
  }
3722
3759
 
3723
3760
  #ifdef UNICODE_SUPPORT_VERSION
3724
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLDisconnect_helper, &(conn_res->hdbc),
3761
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLDisconnect_helper, &(conn_res->hdbc),
3762
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLDisconnect_helper, &(conn_res->hdbc),
3725
3763
  (void *)_ruby_ibm_db_Connection_level_UBF, NULL);
3726
3764
  #else
3727
3765
  rc = _ruby_ibm_db_SQLDisconnect_helper( &(conn_res->hdbc) );
@@ -3898,7 +3936,8 @@ VALUE ibm_db_column_privileges(int argc, VALUE *argv, VALUE self)
3898
3936
  col_privileges_args->stmt_res = stmt_res;
3899
3937
 
3900
3938
  #ifdef UNICODE_SUPPORT_VERSION
3901
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLColumnPrivileges_helper, col_privileges_args,
3939
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLColumnPrivileges_helper, col_privileges_args,
3940
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLColumnPrivileges_helper, col_privileges_args,
3902
3941
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
3903
3942
  #else
3904
3943
  rc = _ruby_ibm_db_SQLColumnPrivileges_helper( col_privileges_args );
@@ -4078,7 +4117,8 @@ VALUE ibm_db_columns(int argc, VALUE *argv, VALUE self)
4078
4117
  col_metadata_args->stmt_res = stmt_res;
4079
4118
 
4080
4119
  #ifdef UNICODE_SUPPORT_VERSION
4081
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLColumns_helper, col_metadata_args,
4120
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLColumns_helper, col_metadata_args,
4121
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLColumns_helper, col_metadata_args,
4082
4122
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
4083
4123
  #else
4084
4124
  rc = _ruby_ibm_db_SQLColumns_helper( col_metadata_args );
@@ -4244,7 +4284,8 @@ VALUE ibm_db_foreign_keys(int argc, VALUE *argv, VALUE self)
4244
4284
  col_metadata_args->stmt_res = stmt_res;
4245
4285
 
4246
4286
  #ifdef UNICODE_SUPPORT_VERSION
4247
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLForeignKeys_helper, col_metadata_args,
4287
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLForeignKeys_helper, col_metadata_args,
4288
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLForeignKeys_helper, col_metadata_args,
4248
4289
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
4249
4290
  #else
4250
4291
  rc = _ruby_ibm_db_SQLForeignKeys_helper( col_metadata_args );
@@ -4400,7 +4441,8 @@ VALUE ibm_db_primary_keys(int argc, VALUE *argv, VALUE self)
4400
4441
  col_metadata_args->stmt_res = stmt_res;
4401
4442
 
4402
4443
  #ifdef UNICODE_SUPPORT_VERSION
4403
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLPrimaryKeys_helper, col_metadata_args,
4444
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLPrimaryKeys_helper, col_metadata_args,
4445
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLPrimaryKeys_helper, col_metadata_args,
4404
4446
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
4405
4447
  #else
4406
4448
  rc = _ruby_ibm_db_SQLPrimaryKeys_helper( col_metadata_args );
@@ -4591,7 +4633,8 @@ VALUE ibm_db_procedure_columns(int argc, VALUE *argv, VALUE self)
4591
4633
  col_metadata_args->stmt_res = stmt_res;
4592
4634
 
4593
4635
  #ifdef UNICODE_SUPPORT_VERSION
4594
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLProcedureColumns_helper, col_metadata_args,
4636
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLProcedureColumns_helper, col_metadata_args,
4637
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLProcedureColumns_helper, col_metadata_args,
4595
4638
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res);
4596
4639
  #else
4597
4640
  rc = _ruby_ibm_db_SQLProcedureColumns_helper( col_metadata_args );
@@ -4748,7 +4791,8 @@ VALUE ibm_db_procedures(int argc, VALUE *argv, VALUE self)
4748
4791
  proc_metadata_args->stmt_res = stmt_res;
4749
4792
 
4750
4793
  #ifdef UNICODE_SUPPORT_VERSION
4751
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLProcedures_helper, proc_metadata_args,
4794
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLProcedures_helper, proc_metadata_args,
4795
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLProcedures_helper, proc_metadata_args,
4752
4796
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res);
4753
4797
  #else
4754
4798
  rc = _ruby_ibm_db_SQLProcedures_helper( proc_metadata_args );
@@ -4925,7 +4969,8 @@ VALUE ibm_db_special_columns(int argc, VALUE *argv, VALUE self)
4925
4969
  col_metadata_args->stmt_res = stmt_res;
4926
4970
 
4927
4971
  #ifdef UNICODE_SUPPORT_VERSION
4928
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLSpecialColumns_helper, col_metadata_args,
4972
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLSpecialColumns_helper, col_metadata_args,
4973
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLSpecialColumns_helper, col_metadata_args,
4929
4974
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res);
4930
4975
  #else
4931
4976
  rc = _ruby_ibm_db_SQLSpecialColumns_helper( col_metadata_args );
@@ -5120,7 +5165,8 @@ VALUE ibm_db_statistics(int argc, VALUE *argv, VALUE self)
5120
5165
  col_metadata_args->stmt_res = stmt_res;
5121
5166
 
5122
5167
  #ifdef UNICODE_SUPPORT_VERSION
5123
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLStatistics_helper, col_metadata_args,
5168
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLStatistics_helper, col_metadata_args,
5169
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLStatistics_helper, col_metadata_args,
5124
5170
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
5125
5171
  #else
5126
5172
  rc = _ruby_ibm_db_SQLStatistics_helper( col_metadata_args );
@@ -5279,7 +5325,8 @@ VALUE ibm_db_table_privileges(int argc, VALUE *argv, VALUE self)
5279
5325
  table_privileges_args->stmt_res = stmt_res;
5280
5326
 
5281
5327
  #ifdef UNICODE_SUPPORT_VERSION
5282
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLTablePrivileges_helper, table_privileges_args,
5328
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLTablePrivileges_helper, table_privileges_args,
5329
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLTablePrivileges_helper, table_privileges_args,
5283
5330
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
5284
5331
  #else
5285
5332
  rc = _ruby_ibm_db_SQLTablePrivileges_helper( table_privileges_args );
@@ -5453,7 +5500,8 @@ VALUE ibm_db_tables(int argc, VALUE *argv, VALUE self)
5453
5500
  table_metadata_args->stmt_res = stmt_res;
5454
5501
 
5455
5502
  #ifdef UNICODE_SUPPORT_VERSION
5456
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLTables_helper, table_metadata_args,
5503
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLTables_helper, table_metadata_args,
5504
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLTables_helper, table_metadata_args,
5457
5505
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
5458
5506
  #else
5459
5507
  rc = _ruby_ibm_db_SQLTables_helper( table_metadata_args );
@@ -5535,7 +5583,8 @@ VALUE ibm_db_commit(int argc, VALUE *argv, VALUE self)
5535
5583
  end_X_args->completionType = SQL_COMMIT; /*Remeber you are Commiting the transaction*/
5536
5584
 
5537
5585
  #ifdef UNICODE_SUPPORT_VERSION
5538
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLEndTran, end_X_args,
5586
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLEndTran, end_X_args,
5587
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLEndTran, end_X_args,
5539
5588
  (void *)_ruby_ibm_db_Connection_level_UBF, NULL);
5540
5589
  #else
5541
5590
  rc = _ruby_ibm_db_SQLEndTran( end_X_args );
@@ -5615,7 +5664,8 @@ static int _ruby_ibm_db_do_prepare(conn_handle *conn_res, VALUE stmt, stmt_handl
5615
5664
 
5616
5665
  /* Prepare the stmt. The cursor type requested has already been set in _ruby_ibm_db_assign_options */
5617
5666
  #ifdef UNICODE_SUPPORT_VERSION
5618
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLPrepare_helper, prepare_args,
5667
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLPrepare_helper, prepare_args,
5668
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLPrepare_helper, prepare_args,
5619
5669
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
5620
5670
  #else
5621
5671
  rc = _ruby_ibm_db_SQLPrepare_helper( prepare_args );
@@ -5753,7 +5803,8 @@ VALUE ibm_db_exec(int argc, VALUE *argv, VALUE self)
5753
5803
  exec_direct_args->stmt_res = stmt_res;
5754
5804
 
5755
5805
  #ifdef UNICODE_SUPPORT_VERSION
5756
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLExecDirect_helper, exec_direct_args,
5806
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLExecDirect_helper, exec_direct_args,
5807
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLExecDirect_helper, exec_direct_args,
5757
5808
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
5758
5809
  #else
5759
5810
  rc = _ruby_ibm_db_SQLExecDirect_helper( exec_direct_args );
@@ -5828,7 +5879,8 @@ VALUE ibm_db_free_result(int argc, VALUE *argv, VALUE self)
5828
5879
  freeStmt_args->option = SQL_CLOSE;
5829
5880
 
5830
5881
  #ifdef UNICODE_SUPPORT_VERSION
5831
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLFreeStmt_helper, freeStmt_args,
5882
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLFreeStmt_helper, freeStmt_args,
5883
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLFreeStmt_helper, freeStmt_args,
5832
5884
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
5833
5885
  #else
5834
5886
  rc = _ruby_ibm_db_SQLFreeStmt_helper( freeStmt_args );
@@ -6933,7 +6985,8 @@ VALUE ibm_db_execute(int argc, VALUE *argv, VALUE self)
6933
6985
  bind_array->error = &error;
6934
6986
 
6935
6987
  #ifdef UNICODE_SUPPORT_VERSION
6936
- ret_value = rb_thread_blocking_region( (void *)_ruby_ibm_db_execute_helper, bind_array,
6988
+ //ret_value = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_execute_helper, bind_array,
6989
+ ret_value = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_execute_helper, bind_array,
6937
6990
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
6938
6991
  #else
6939
6992
  ret_value = _ruby_ibm_db_execute_helper( bind_array );
@@ -7718,7 +7771,8 @@ VALUE ibm_db_next_result(int argc, VALUE *argv, VALUE self)
7718
7771
  nextresultparams->new_hstmt = &new_hstmt;
7719
7772
 
7720
7773
  #ifdef UNICODE_SUPPORT_VERSION
7721
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLNextResult_helper, nextresultparams,
7774
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLNextResult_helper, nextresultparams,
7775
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLNextResult_helper, nextresultparams,
7722
7776
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
7723
7777
  #else
7724
7778
  rc = _ruby_ibm_db_SQLNextResult_helper( nextresultparams );
@@ -7817,7 +7871,8 @@ VALUE ibm_db_num_fields(int argc, VALUE *argv, VALUE self)
7817
7871
  result_cols_args->count = 0;
7818
7872
 
7819
7873
  #ifdef UNICODE_SUPPORT_VERSION
7820
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLNumResultCols_helper, result_cols_args,
7874
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLNumResultCols_helper, result_cols_args,
7875
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLNumResultCols_helper, result_cols_args,
7821
7876
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
7822
7877
  #else
7823
7878
  rc = _ruby_ibm_db_SQLNumResultCols_helper( result_cols_args );
@@ -7910,7 +7965,8 @@ VALUE ibm_db_num_rows(int argc, VALUE *argv, VALUE self)
7910
7965
  row_count_args->count = 0;
7911
7966
 
7912
7967
  #ifdef UNICODE_SUPPORT_VERSION
7913
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLRowCount_helper, row_count_args,
7968
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLRowCount_helper, row_count_args,
7969
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLRowCount_helper, row_count_args,
7914
7970
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
7915
7971
  #else
7916
7972
  rc = _ruby_ibm_db_SQLRowCount_helper( row_count_args );
@@ -7966,7 +8022,8 @@ static int _ruby_ibm_db_get_column_by_name(stmt_handle *stmt_res, VALUE column,
7966
8022
  if ( release_gil == 1 ) {
7967
8023
 
7968
8024
  #ifdef UNICODE_SUPPORT_VERSION
7969
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_get_result_set_info, stmt_res,
8025
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_get_result_set_info, stmt_res,
8026
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_get_result_set_info, stmt_res,
7970
8027
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
7971
8028
  #else
7972
8029
  rc = _ruby_ibm_db_get_result_set_info( stmt_res );
@@ -8129,7 +8186,8 @@ VALUE ibm_db_field_display_size(int argc, VALUE *argv, VALUE self)
8129
8186
  colattr_args->FieldIdentifier = SQL_DESC_DISPLAY_SIZE;
8130
8187
 
8131
8188
  #ifdef UNICODE_SUPPORT_VERSION
8132
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLColAttributes_helper, colattr_args,
8189
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLColAttributes_helper, colattr_args,
8190
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLColAttributes_helper, colattr_args,
8133
8191
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
8134
8192
  #else
8135
8193
  rc = _ruby_ibm_db_SQLColAttributes_helper( colattr_args );
@@ -8449,7 +8507,8 @@ VALUE ibm_db_field_width(int argc, VALUE *argv, VALUE self)
8449
8507
  colattr_args->FieldIdentifier = SQL_DESC_LENGTH;
8450
8508
 
8451
8509
  #ifdef UNICODE_SUPPORT_VERSION
8452
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLColAttributes_helper, colattr_args,
8510
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLColAttributes_helper, colattr_args,
8511
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLColAttributes_helper, colattr_args,
8453
8512
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
8454
8513
  #else
8455
8514
  rc = _ruby_ibm_db_SQLColAttributes_helper( colattr_args );
@@ -8555,7 +8614,8 @@ VALUE ibm_db_rollback(int argc, VALUE *argv, VALUE self)
8555
8614
  end_X_args->completionType = SQL_ROLLBACK; /*Remeber you are Rollingback the transaction*/
8556
8615
 
8557
8616
  #ifdef UNICODE_SUPPORT_VERSION
8558
- rc = rb_thread_blocking_region( (void *)_ruby_ibm_db_SQLEndTran, end_X_args,
8617
+ //rc = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_SQLEndTran, end_X_args,
8618
+ rc = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_SQLEndTran, end_X_args,
8559
8619
  (void *)_ruby_ibm_db_Connection_level_UBF, NULL);
8560
8620
  #else
8561
8621
  rc = _ruby_ibm_db_SQLEndTran( end_X_args );
@@ -9144,7 +9204,8 @@ VALUE ibm_db_result(int argc, VALUE *argv, VALUE self)
9144
9204
  Data_Get_Struct(stmt, stmt_handle, result_args->stmt_res);
9145
9205
 
9146
9206
  #ifdef UNICODE_SUPPORT_VERSION
9147
- ret_val = rb_thread_blocking_region( (void *)_ruby_ibm_db_result_helper, result_args,
9207
+ //ret_val = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_result_helper, result_args,
9208
+ ret_val = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_result_helper, result_args,
9148
9209
  (void *)_ruby_ibm_db_Statement_level_UBF, result_args->stmt_res );
9149
9210
  #else
9150
9211
  ret_val = _ruby_ibm_db_result_helper( result_args );
@@ -9947,7 +10008,8 @@ VALUE ibm_db_fetch_row(int argc, VALUE *argv, VALUE self)
9947
10008
  helper_args->error = &error;
9948
10009
 
9949
10010
  #ifdef UNICODE_SUPPORT_VERSION
9950
- ret_val = rb_thread_blocking_region( (void *)_ruby_ibm_db_fetch_row_helper, helper_args,
10011
+ //ret_val = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_fetch_row_helper, helper_args,
10012
+ ret_val = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_fetch_row_helper, helper_args,
9951
10013
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
9952
10014
  #else
9953
10015
  ret_val = _ruby_ibm_db_fetch_row_helper( helper_args );
@@ -10115,7 +10177,8 @@ VALUE ibm_db_fetch_assoc(int argc, VALUE *argv, VALUE self) {
10115
10177
  helper_args->funcType = FETCH_ASSOC;
10116
10178
 
10117
10179
  #ifdef UNICODE_SUPPORT_VERSION
10118
- ret_val = rb_thread_blocking_region( (void *)_ruby_ibm_db_bind_fetch_helper, helper_args,
10180
+ //ret_val = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_bind_fetch_helper, helper_args,
10181
+ ret_val = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_bind_fetch_helper, helper_args,
10119
10182
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
10120
10183
  #else
10121
10184
  ret_val = _ruby_ibm_db_bind_fetch_helper( helper_args );
@@ -10202,7 +10265,8 @@ VALUE ibm_db_fetch_object(int argc, VALUE *argv, VALUE self)
10202
10265
  helper_args->funcType = FETCH_ASSOC;
10203
10266
 
10204
10267
  #ifdef UNICODE_SUPPORT_VERSION
10205
- row_res->hash = rb_thread_blocking_region( (void *)_ruby_ibm_db_bind_fetch_helper, helper_args,
10268
+ //row_res->hash = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_bind_fetch_helper, helper_args,
10269
+ row_res->hash = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_bind_fetch_helper, helper_args,
10206
10270
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
10207
10271
  #else
10208
10272
  row_res->hash = _ruby_ibm_db_bind_fetch_helper( helper_args );
@@ -10284,7 +10348,8 @@ VALUE ibm_db_fetch_array(int argc, VALUE *argv, VALUE self)
10284
10348
  helper_args->funcType = FETCH_INDEX;
10285
10349
 
10286
10350
  #ifdef UNICODE_SUPPORT_VERSION
10287
- ret_val = rb_thread_blocking_region( (void *)_ruby_ibm_db_bind_fetch_helper, helper_args,
10351
+ //ret_val = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_bind_fetch_helper, helper_args,
10352
+ ret_val = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_bind_fetch_helper, helper_args,
10288
10353
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
10289
10354
  #else
10290
10355
  ret_val = _ruby_ibm_db_bind_fetch_helper( helper_args );
@@ -10360,7 +10425,8 @@ VALUE ibm_db_fetch_both(int argc, VALUE *argv, VALUE self)
10360
10425
  helper_args->funcType = FETCH_BOTH;
10361
10426
 
10362
10427
  #ifdef UNICODE_SUPPORT_VERSION
10363
- ret_val = rb_thread_blocking_region( (void *)_ruby_ibm_db_bind_fetch_helper, helper_args,
10428
+ //ret_val = rb_thread_call_without_gvl ( (void *)_ruby_ibm_db_bind_fetch_helper, helper_args,
10429
+ ret_val = ibm_Ruby_Thread_Call ( (void *)_ruby_ibm_db_bind_fetch_helper, helper_args,
10364
10430
  (void *)_ruby_ibm_db_Statement_level_UBF, stmt_res );
10365
10431
  #else
10366
10432
  ret_val = _ruby_ibm_db_bind_fetch_helper( helper_args );
@@ -11111,7 +11177,8 @@ VALUE ibm_db_server_info(int argc, VALUE *argv, VALUE self)
11111
11177
  getInfo_args->buff_length = 0;
11112
11178
 
11113
11179
  #ifdef UNICODE_SUPPORT_VERSION
11114
- return_value = rb_thread_blocking_region( (void *)ibm_db_server_info_helper, getInfo_args,
11180
+ //return_value = rb_thread_call_without_gvl ( (void *)ibm_db_server_info_helper, getInfo_args,
11181
+ return_value = ibm_Ruby_Thread_Call ( (void *)ibm_db_server_info_helper, getInfo_args,
11115
11182
  (void *)_ruby_ibm_db_Connection_level_UBF, NULL);
11116
11183
  #else
11117
11184
  return_value = ibm_db_server_info_helper( getInfo_args );
@@ -11398,7 +11465,8 @@ VALUE ibm_db_client_info(int argc, VALUE *argv, VALUE self)
11398
11465
  getInfo_args->buff_length = 0;
11399
11466
 
11400
11467
  #ifdef UNICODE_SUPPORT_VERSION
11401
- return_value = rb_thread_blocking_region( (void *)ibm_db_client_info_helper, getInfo_args,
11468
+ //return_value = rb_thread_call_without_gvl ( (void *)ibm_db_client_info_helper, getInfo_args,
11469
+ return_value = ibm_Ruby_Thread_Call ( (void *)ibm_db_client_info_helper, getInfo_args,
11402
11470
  (void *)_ruby_ibm_db_Connection_level_UBF, NULL);
11403
11471
  #else
11404
11472
  return_value = ibm_db_client_info_helper( getInfo_args );
@@ -11706,6 +11774,7 @@ VALUE ibm_db_get_last_serial_value(int argc, VALUE *argv, VALUE self)
11706
11774
  rb_warn("Supplied statement handle is invalid");
11707
11775
  return Qfalse;
11708
11776
  }
11777
+
11709
11778
  }
11710
11779
 
11711
11780
 
@@ -1,11 +1,12 @@
1
1
  # +----------------------------------------------------------------------+
2
2
  # | Licensed Materials - Property of IBM |
3
3
  # | |
4
- # | (C) Copyright IBM Corporation 2006, 2007, 2008, 2009, 2010 |
4
+ # | (C) Copyright IBM Corporation 2006- 2015 |
5
5
  # +----------------------------------------------------------------------+
6
6
  # | Authors: Antonio Cangiano <cangiano@ca.ibm.com> |
7
7
  # | : Mario Ds Briggs <mario.briggs@in.ibm.com> |
8
8
  # | : Praveen Devarao <praveendrl@in.ibm.com> |
9
+ # | : Arvind Gupta <arvindgu@in.ibm.com> |
9
10
  # +----------------------------------------------------------------------+
10
11
 
11
12
  require 'active_record/connection_adapters/abstract_adapter'
@@ -725,17 +726,24 @@ module ActiveRecord
725
726
  def self.visitor_for(pool)
726
727
  Arel::Visitors::IBM_DB.new(pool)
727
728
  end
728
-
729
- def to_sql(arel, binds = [])
730
- if arel.respond_to?(:ast)
731
- visitor.accept(arel.ast) do
732
- quote(*binds.shift.reverse)
733
- end
734
- else
735
- arel
736
- end
729
+
730
+ #Check Arel version
731
+ begin
732
+ @arelVersion = Arel::VERSION.to_i
733
+ rescue
734
+ @arelVersion = 0
737
735
  end
738
-
736
+ if(@arelVersion < 6)
737
+ def to_sql(arel, binds = [])
738
+ if arel.respond_to?(:ast)
739
+ visitor.accept(arel.ast) do
740
+ quote(*binds.shift.reverse)
741
+ end
742
+ else
743
+ arel
744
+ end
745
+ end
746
+ end
739
747
  # This adapter supports migrations.
740
748
  # Current limitations:
741
749
  # +rename_column+ is not currently supported by the IBM data servers
@@ -1118,7 +1126,11 @@ module ActiveRecord
1118
1126
  end
1119
1127
 
1120
1128
  def insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, binds = [] )
1121
- sql, binds = [to_sql(arel),binds]
1129
+ if(@arelVersion < 6 )
1130
+ sql, binds = [to_sql(arel),binds]
1131
+ else
1132
+ sql, binds = sql_for_insert(to_sql(arel, binds), pk, id_value, sequence_name, binds) #[to_sql(arel),binds]
1133
+ end
1122
1134
 
1123
1135
  #unless IBM_DBAdapter.respond_to?(:exec_insert)
1124
1136
  if binds.nil? || binds.empty?
@@ -1278,7 +1290,11 @@ module ActiveRecord
1278
1290
  alias_method :prepared_delete, :prepared_update
1279
1291
 
1280
1292
  def update(arel, name = nil, binds = [])
1281
- sql = to_sql(arel)
1293
+ if(@arelVersion < 6 )
1294
+ sql = to_sql(arel)
1295
+ else
1296
+ sql = to_sql(arel,binds)
1297
+ end
1282
1298
 
1283
1299
  # Make sure the WHERE clause handles NULL's correctly
1284
1300
  sqlarray = sql.split(/\s*WHERE\s*/)
@@ -1335,6 +1351,13 @@ module ActiveRecord
1335
1351
  IBM_DB.autocommit @connection, IBM_DB::SQL_AUTOCOMMIT_ON
1336
1352
  end
1337
1353
 
1354
+ def get_limit_offset_clauses(limit,offset)
1355
+ if limit && limit == 0
1356
+ clauses = @servertype.get_limit_offset_clauses(limit,0)
1357
+ else
1358
+ clauses = @servertype.get_limit_offset_clauses(limit, offset)
1359
+ end
1360
+ end
1338
1361
 
1339
1362
  # Modifies a sql statement in order to implement a LIMIT and an OFFSET.
1340
1363
  # A LIMIT defines the number of rows that should be fetched, while
@@ -1459,7 +1482,7 @@ module ActiveRecord
1459
1482
  end
1460
1483
  elsif column && column.type.to_sym == :text
1461
1484
  unless caller[0] =~ /add_column_options/i
1462
- "'@@@IBMTEXT@@@'"
1485
+ "'<ibm>@@@IBMTEXT@@@</ibm>'"
1463
1486
  else
1464
1487
  @servertype.set_text_default(quote_string(value))
1465
1488
  end
@@ -1879,7 +1902,8 @@ module ActiveRecord
1879
1902
  if !(column_name =~ /db2_generated_rowid_for_lobs/i)
1880
1903
  # Pushes into the array the *IBM_DBColumn* object, created by passing to the initializer
1881
1904
  # +column_name+, +default_value+, +column_type+ and +column_nullable+.
1882
- columns << IBM_DBColumn.new(column_name, column_default_value, column_type, column_nullable)
1905
+ cast_type = lookup_cast_type(column_type)
1906
+ columns << IBM_DBColumn.new(column_name, column_default_value, cast_type, column_type, column_nullable)
1883
1907
  end
1884
1908
  end
1885
1909
  rescue StandardError => fetch_error # Handle driver fetch errors
@@ -2009,6 +2033,47 @@ module ActiveRecord
2009
2033
  def remove_index(table_name, options = {})
2010
2034
  execute("DROP INDEX #{index_name(table_name, options)}")
2011
2035
  end
2036
+
2037
+ protected
2038
+ def initialize_type_map(m) # :nodoc:
2039
+ register_class_with_limit m, %r(boolean)i, Type::Boolean
2040
+ register_class_with_limit m, %r(char)i, Type::String
2041
+ register_class_with_limit m, %r(binary)i, Type::Binary
2042
+ register_class_with_limit m, %r(text)i, Type::Text
2043
+ register_class_with_limit m, %r(date)i, Type::Date
2044
+ register_class_with_limit m, %r(time)i, Type::Time
2045
+ register_class_with_limit m, %r(datetime)i, Type::DateTime
2046
+ register_class_with_limit m, %r(float)i, Type::Float
2047
+ register_class_with_limit m, %r(int)i, Type::Integer
2048
+
2049
+ m.alias_type %r(blob)i, 'binary'
2050
+ m.alias_type %r(clob)i, 'text'
2051
+ m.alias_type %r(timestamp)i, 'datetime'
2052
+ m.alias_type %r(numeric)i, 'decimal'
2053
+ m.alias_type %r(number)i, 'decimal'
2054
+ m.alias_type %r(double)i, 'float'
2055
+
2056
+ m.register_type(%r(decimal)i) do |sql_type|
2057
+ scale = extract_scale(sql_type)
2058
+ precision = extract_precision(sql_type)
2059
+
2060
+ if scale == 0
2061
+ # FIXME: Remove this class as well
2062
+ Type::DecimalWithoutScale.new(precision: precision)
2063
+ else
2064
+ Type::Decimal.new(precision: precision, scale: scale)
2065
+ end
2066
+ end
2067
+
2068
+ m.alias_type %r(xml)i, 'text'
2069
+ m.alias_type %r(for bit data)i, 'binary'
2070
+ m.alias_type %r(smallint)i, 'boolean'
2071
+ m.alias_type %r(serial)i, 'int'
2072
+ m.alias_type %r(decfloat)i, 'decimal'
2073
+ m.alias_type %r(real)i, 'decimal'
2074
+ m.alias_type %r(graphic)i, 'binary'
2075
+ m.alias_type %r(rowid)i, 'int'
2076
+ end
2012
2077
  end # class IBM_DBAdapter
2013
2078
 
2014
2079
  # This class contains common code across DB's (DB2 LUW, zOS, i5 and IDS)
@@ -2145,6 +2210,9 @@ To remove the column, the table must be dropped and recreated without the #{colu
2145
2210
  def query_offset_limit(sql, offset, limit)
2146
2211
  end
2147
2212
 
2213
+ def get_limit_offset_clauses(limit, offset)
2214
+ end
2215
+
2148
2216
  def query_offset_limit!(sql, offset, limit, options)
2149
2217
  end
2150
2218
 
@@ -2507,6 +2575,30 @@ SET WITH DEFAULT #{@adapter.quote(default)}"
2507
2575
  end
2508
2576
  end
2509
2577
  =end
2578
+ def get_limit_offset_clauses(limit, offset)
2579
+ retHash = {"endSegment"=> "", "startSegment" => ""}
2580
+ if(offset.nil? && limit.nil?)
2581
+ return retHash
2582
+ end
2583
+
2584
+ if (offset.nil?)
2585
+ retHash["endSegment"] = " FETCH FIRST #{limit} ROWS ONLY"
2586
+ return retHash
2587
+ end
2588
+
2589
+ if(limit.nil?)
2590
+ retHash["startSegment"] = "SELECT O.* FROM (SELECT I.*, ROW_NUMBER() OVER () sys_row_num FROM ( SELECT "
2591
+ retHash["endSegment"] = " ) AS I) AS O WHERE sys_row_num > #{offset}"
2592
+ return retHash
2593
+ end
2594
+
2595
+ # Defines what will be the last record
2596
+ last_record = offset.to_i + limit.to_i
2597
+ retHash["startSegment"] = "SELECT O.* FROM (SELECT I.*, ROW_NUMBER() OVER () sys_row_num FROM ( SELECT "
2598
+ retHash["endSegment"] = " ) AS I) AS O WHERE sys_row_num BETWEEN #{offset+1} AND #{last_record}"
2599
+ return retHash
2600
+ end
2601
+
2510
2602
  def query_offset_limit(sql, offset, limit)
2511
2603
  if(offset.nil? && limit.nil?)
2512
2604
  return sql
@@ -2727,6 +2819,14 @@ SET WITH DEFAULT #{@adapter.quote(default)}"
2727
2819
  class IBM_DB2_ZOS_8 < IBM_DB2_ZOS
2728
2820
  include HostedDataServer
2729
2821
 
2822
+ def get_limit_offset_clauses(limit, offset)
2823
+ retHash = {"startSegment" => "", "endSegment" => ""}
2824
+ if (!limit.nil?)
2825
+ retHash["endSegment"] = " FETCH FIRST #{limit} ROWS ONLY"
2826
+ end
2827
+ return retHash
2828
+ end
2829
+
2730
2830
  def query_offset_limit(sql, offset, limit)
2731
2831
  if (!limit.nil?)
2732
2832
  sql << " FETCH FIRST #{limit} ROWS ONLY"
@@ -2889,6 +2989,22 @@ SET WITH DEFAULT #{@adapter.quote(default)}"
2889
2989
  return "double precision"
2890
2990
  end
2891
2991
 
2992
+ def get_limit_offset_clauses(limit, offset)
2993
+ retHash = {"startSegment" => "", "endSegment" => ""}
2994
+ if limit != 0
2995
+ if !offset.nil?
2996
+ # Modifying the SQL to utilize the skip and limit amounts
2997
+ retHash["startSegment"] = " SELECT SKIP #{offset} LIMIT #{limit} "
2998
+ else
2999
+ # Modifying the SQL to retrieve only the first #{limit} rows
3000
+ retHash["startSegment"] = " SELECT FIRST #{limit} "
3001
+ end
3002
+ else
3003
+ retHash["startSegment"] = " SELECT * FROM (SELECT "
3004
+ retHash["endSegment"] = " ) WHERE 0 = 1 "
3005
+ end
3006
+ end
3007
+
2892
3008
  # Handling offset/limit as per Informix requirements
2893
3009
  def query_offset_limit(sql, offset, limit)
2894
3010
  if limit != 0
@@ -2968,11 +3084,39 @@ SET WITH DEFAULT #{@adapter.quote(default)}"
2968
3084
  end # module ActiveRecord
2969
3085
 
2970
3086
  module Arel
3087
+ #Check Arel version
3088
+ begin
3089
+ arelVersion = Arel::VERSION.to_i
3090
+ rescue
3091
+ arelVersion = 0
3092
+ end
3093
+ if(arelVersion >= 6)
3094
+ module Collectors
3095
+ class Bind
3096
+ def changeFirstSegment(segment)
3097
+ @parts[0] = segment
3098
+ end
3099
+
3100
+ def changeEndSegment(segment)
3101
+ len = @parts.length
3102
+ @parts[len] = segment
3103
+ end
3104
+ end
3105
+ end
3106
+ end
3107
+
2971
3108
  module Visitors
2972
3109
  class Visitor #opening and closing the class to ensure backward compatibility
2973
3110
  end
2974
-
2975
- class ToSql < Arel::Visitors::Visitor #opening and closing the class to ensure backward compatibility
3111
+
3112
+ #Check Arel version
3113
+ begin
3114
+ arelVersion = Arel::VERSION.to_i
3115
+ rescue
3116
+ arelVersion = 0
3117
+ end
3118
+ if(arelVersion >= 6)
3119
+ class ToSql < Arel::Visitors::Reduce #opening and closing the class to ensure backward compatibility
2976
3120
  # In case when using Rails-2.3.x there is no arel used due to which the constructor has to be defined explicitly
2977
3121
  # to ensure the same code works on any version of Rails
2978
3122
 
@@ -2985,6 +3129,7 @@ module Arel
2985
3129
 
2986
3130
  if(@arelVersion >= 3)
2987
3131
  def initialize connection
3132
+ super()
2988
3133
  @connection = connection
2989
3134
  @schema_cache = connection.schema_cache if(connection.respond_to?(:schema_cache))
2990
3135
  @quoted_tables = {}
@@ -2993,18 +3138,52 @@ module Arel
2993
3138
  end
2994
3139
  end
2995
3140
  end
3141
+ else
3142
+ class ToSql < Arel::Visitors::Visitor #opening and closing the class to ensure backward compatibility
3143
+ # In case when using Rails-2.3.x there is no arel used due to which the constructor has to be defined explicitly
3144
+ # to ensure the same code works on any version of Rails
3145
+
3146
+ #Check Arel version
3147
+ begin
3148
+ @arelVersion = Arel::VERSION.to_i
3149
+ rescue
3150
+ @arelVersion = 0
3151
+ end
3152
+ if(@arelVersion >= 3)
3153
+ def initialize connection
3154
+ super()
3155
+ @connection = connection
3156
+ @schema_cache = connection.schema_cache if(connection.respond_to?(:schema_cache))
3157
+ @quoted_tables = {}
3158
+ @quoted_columns = {}
3159
+ @last_column = nil
3160
+ end
3161
+
3162
+ end
3163
+ end
3164
+
3165
+ end
3166
+
2996
3167
 
2997
3168
  class IBM_DB < Arel::Visitors::ToSql
2998
3169
  private
2999
3170
 
3000
- def visit_Arel_Nodes_Limit o, a=nil
3171
+
3172
+ #Check Arel version
3173
+ begin
3174
+ @arelVersion = Arel::VERSION.to_i
3175
+ rescue
3176
+ @arelVersion = 0
3177
+ end
3178
+ if(@arelVersion < 6)
3179
+
3180
+ def visit_Arel_Nodes_Limit o, a=nil
3001
3181
  visit o.expr
3002
3182
  end
3003
3183
 
3004
3184
  def visit_Arel_Nodes_Offset o, a=nil
3005
3185
  visit o.expr
3006
3186
  end
3007
-
3008
3187
  def visit_Arel_Nodes_SelectStatement o, a=nil
3009
3188
  #Interim fix for backward compatibility [Arel 4.0.0 and below]
3010
3189
  if self.method(:visit_Arel_Nodes_SelectCore).arity == 1
@@ -3036,7 +3215,71 @@ module Arel
3036
3215
  sql << " #{(visit(o.lock) if o.lock)}"
3037
3216
  return sql
3038
3217
  end
3218
+ else
3219
+ def visit_Arel_Nodes_Limit o,collector
3220
+ visit o.expr, collector
3221
+ end
3039
3222
 
3223
+ def visit_Arel_Nodes_Offset o,collector
3224
+ visit o.expr,collector
3225
+ end
3226
+
3227
+ def visit_Arel_Nodes_SelectStatement o, collector
3228
+
3229
+ if o.with
3230
+ collector = visit o.with, collector
3231
+ collector << SPACE
3232
+ end
3233
+
3234
+ collector = o.cores.inject(collector) { |c,x|
3235
+ visit_Arel_Nodes_SelectCore(x, c)
3236
+ }
3237
+
3238
+ unless o.orders.empty?
3239
+ collector << SPACE
3240
+ collector << ORDER_BY
3241
+ len = o.orders.length - 1
3242
+ o.orders.each_with_index { |x, i|
3243
+ collector = visit(x, collector)
3244
+ collector << COMMA unless len == i
3245
+ }
3246
+ end
3247
+
3248
+ if o.limit
3249
+ limcoll = Arel::Collectors::SQLString.new
3250
+ visit(o.limit,limcoll)
3251
+ limit = limcoll.value.to_i
3252
+ else
3253
+ limit = nil
3254
+ end
3255
+
3256
+ if o.offset
3257
+ offcoll = Arel::Collectors::SQLString.new
3258
+ visit(o.offset,offcoll)
3259
+ offset = offcoll.value.to_i
3260
+ else
3261
+ offset = nil
3262
+ end
3263
+
3264
+ limOffClause = @connection.get_limit_offset_clauses(limit,offset)
3265
+
3266
+ if( !limOffClause["startSegment"].empty? )
3267
+ collector.changeFirstSegment(limOffClause["startSegment"])
3268
+ end
3269
+
3270
+ if( !limOffClause["endSegment"].empty? )
3271
+ collector.changeEndSegment(limOffClause["endSegment"])
3272
+ end
3273
+
3274
+ #Initialize a new Collector and set its value to the sql string built so far with any limit and ofset modifications
3275
+ #collector.reset(sql)
3276
+
3277
+ collector = maybe_visit o.lock, collector
3278
+
3279
+ return collector
3280
+ end
3281
+ end
3282
+
3040
3283
  end
3041
3284
  end
3042
3285
  end
metadata CHANGED
@@ -1,27 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibm_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.18
4
+ version: 2.5.25
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - IBM
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-08-03 00:00:00.000000000 Z
12
+ date: 2015-03-26 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activerecord
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - ">="
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: 1.15.1
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - ">="
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: 1.15.1
27
30
  description:
@@ -34,78 +37,91 @@ extra_rdoc_files:
34
37
  - README
35
38
  - MANIFEST
36
39
  files:
37
- - CHANGES
38
- - LICENSE
39
- - MANIFEST
40
- - ParameterizedQueries README
41
40
  - README
42
- - ext/Makefile.nt32
43
- - ext/Makefile.nt32.191
44
- - ext/extconf.rb
45
- - ext/ibm_db.c
46
- - ext/ruby_ibm_db.h
47
- - ext/ruby_ibm_db_cli.c
48
- - ext/ruby_ibm_db_cli.h
49
- - init.rb
50
- - lib/IBM_DB.rb
41
+ - lib/active_record/connection_adapters/ibmdb_adapter.rb
51
42
  - lib/active_record/connection_adapters/ibm_db_adapter.rb
52
43
  - lib/active_record/connection_adapters/ibm_db_pstmt.rb
53
- - lib/active_record/connection_adapters/ibmdb_adapter.rb
54
44
  - lib/active_record/vendor/db2-i5-zOS.yaml
55
- - test/cases/adapter_test.rb
56
- - test/cases/associations/belongs_to_associations_test.rb
57
- - test/cases/associations/cascaded_eager_loading_test.rb
58
- - test/cases/associations/has_and_belongs_to_many_associations_test.rb
59
- - test/cases/associations/join_model_test.rb
45
+ - lib/IBM_DB.rb
46
+ - test/connections/native_ibm_db/connection.rb
47
+ - test/models/warehouse_thing.rb
60
48
  - test/cases/attribute_methods_test.rb
61
- - test/cases/base_test.rb
62
- - test/cases/calculations_test.rb
63
- - test/cases/migration_test.rb
64
- - test/cases/persistence_test.rb
65
- - test/cases/query_cache_test.rb
66
49
  - test/cases/relations_test.rb
67
50
  - test/cases/schema_dumper_test.rb
68
51
  - test/cases/transaction_callbacks_test.rb
69
- - test/cases/validations/uniqueness_validation_test.rb
70
52
  - test/cases/xml_serialization_test.rb
53
+ - test/cases/validations/uniqueness_validation_test.rb
54
+ - test/cases/persistence_test.rb
55
+ - test/cases/calculations_test.rb
56
+ - test/cases/query_cache_test.rb
57
+ - test/cases/migration_test.rb
58
+ - test/cases/base_test.rb
59
+ - test/cases/associations/belongs_to_associations_test.rb
60
+ - test/cases/associations/has_and_belongs_to_many_associations_test.rb
61
+ - test/cases/associations/cascaded_eager_loading_test.rb
62
+ - test/cases/associations/join_model_test.rb
63
+ - test/cases/adapter_test.rb
71
64
  - test/config.yml
72
- - test/connections/native_ibm_db/connection.rb
73
- - test/ibm_db_test.rb
74
- - test/models/warehouse_thing.rb
75
- - test/schema/i5/ibm_db_specific_schema.rb
65
+ - test/schema/zOS/ibm_db_specific_schema.rb
76
66
  - test/schema/ids/ibm_db_specific_schema.rb
77
- - test/schema/luw/ibm_db_specific_schema.rb
67
+ - test/schema/i5/ibm_db_specific_schema.rb
78
68
  - test/schema/schema.rb
79
- - test/schema/zOS/ibm_db_specific_schema.rb
69
+ - test/schema/luw/ibm_db_specific_schema.rb
70
+ - test/ibm_db_test.rb
71
+ - ParameterizedQueries README
72
+ - ext/ruby_ibm_db.h
73
+ - ext/Makefile.nt32
74
+ - ext/ruby_ibm_db_cli.c
75
+ - ext/ruby_ibm_db_cli.h
76
+ - ext/extconf.rb
77
+ - ext/ibm_db.c
78
+ - ext/Makefile.nt32.191
79
+ - LICENSE
80
+ - init.rb
81
+ - CHANGES
82
+ - MANIFEST
80
83
  homepage: https://github.com/ibmdb/ruby-ibmdb
81
84
  licenses: []
82
- metadata: {}
83
- post_install_message: |2+
85
+ post_install_message: ! '
84
86
 
85
87
  *****************************************************************************
86
- Successfully installed ibm_db, the Ruby gem for IBM DB2/Informix. The Ruby gem is licensed under the MIT License. The package also includes IBM ODBC and CLI Driver from IBM, which could have been automatically downloaded as the Ruby gem is installed on your system/device. The license agreement to the IBM driver is available in the folder "$GEM_HOME/ibm_db-*/lib/clidriver/license". Check for additional dependencies, which may come with their own license agreement(s). Your use of the components of the package and dependencies constitutes your acceptance of their respective license agreements. If you do not accept the terms of any license agreement(s), then delete the relevant component(s) from your system/device.
88
+
89
+ Successfully installed ibm_db, the Ruby gem for IBM DB2/Informix. The Ruby gem
90
+ is licensed under the MIT License. The package also includes IBM ODBC and CLI
91
+ Driver from IBM, which could have been automatically downloaded as the Ruby gem
92
+ is installed on your system/device. The license agreement to the IBM driver is
93
+ available in the folder "$GEM_HOME/ibm_db-*/lib/clidriver/license". Check for additional
94
+ dependencies, which may come with their own license agreement(s). Your use of the
95
+ components of the package and dependencies constitutes your acceptance of their
96
+ respective license agreements. If you do not accept the terms of any license agreement(s),
97
+ then delete the relevant component(s) from your system/device.
98
+
87
99
  *****************************************************************************
88
100
 
101
+
102
+ '
89
103
  rdoc_options: []
90
104
  require_paths:
91
105
  - lib
92
106
  required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
93
108
  requirements:
94
- - - ">="
109
+ - - ! '>='
95
110
  - !ruby/object:Gem::Version
96
111
  version: 1.8.6
97
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
98
114
  requirements:
99
- - - ">="
115
+ - - ! '>='
100
116
  - !ruby/object:Gem::Version
101
117
  version: '0'
102
118
  requirements:
103
119
  - ActiveRecord, at least 1.15.1
104
120
  rubyforge_project: rubyibm
105
- rubygems_version: 2.2.2
121
+ rubygems_version: 1.8.23.2
106
122
  signing_key:
107
- specification_version: 4
108
- summary: 'Rails Driver and Adapter for IBM Data Servers: {DB2 on Linux/Unix/Windows,
123
+ specification_version: 3
124
+ summary: ! 'Rails Driver and Adapter for IBM Data Servers: {DB2 on Linux/Unix/Windows,
109
125
  DB2 on zOS, DB2 on i5/OS, Informix (IDS)}'
110
126
  test_files:
111
127
  - test/ibm_db_test.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 91ff663db933ec69c03095b1a0a50347055fe634
4
- data.tar.gz: 22d1654982d6f4467ac8e9b107868d4533b5a825
5
- SHA512:
6
- metadata.gz: 8c97c793aef0305f16c530dd61055589382108468b3df1582dcca3e790197b52fa7810509cd086a3a6962bf9f2d7259af6038096293a2177c7b3d643af459aec
7
- data.tar.gz: da889c3f8cb89b64fea6f5de482e69ad108003e282d70282daece50100928b34571a64ae37b872d1cd70378e2339be7b95ca75977648967ebf9ae3a50b613d70