ibm_db 2.5.9-x86-mingw32 → 2.5.10-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +7 -0
- data/README +79 -141
- data/ext/extconf.rb +74 -13
- data/ext/ibm_db.c +20 -5
- data/lib/active_record/connection_adapters/ibm_db_adapter.rb +45 -8
- data/lib/mswin32/rb18x/ibm_db.so +0 -0
- data/lib/mswin32/rb19x/ibm_db.so +0 -0
- data/test/cases/adapter_test.rb +162 -160
- data/test/cases/associations/belongs_to_associations_test.rb +23 -0
- data/test/cases/associations/cascaded_eager_loading_test.rb +3 -7
- data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +40 -10
- data/test/cases/associations/join_model_test.rb +4 -4
- data/test/cases/attribute_methods_test.rb +169 -33
- data/test/cases/base_test.rb +302 -77
- data/test/cases/calculations_test.rb +37 -1
- data/test/cases/migration_test.rb +183 -115
- data/test/cases/persistence_test.rb +17 -11
- data/test/cases/query_cache_test.rb +18 -3
- data/test/cases/relations_test.rb +178 -15
- data/test/cases/schema_dumper_test.rb +5 -1
- data/test/cases/transaction_callbacks_test.rb +2 -2
- data/test/cases/xml_serialization_test.rb +133 -1
- data/test/schema/schema.rb +22 -3
- metadata +36 -55
data/CHANGES
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
Change Log
|
2
2
|
==============
|
3
|
+
2012/05/01 (IBM_DB adapter 2.5.10, driver 2.5.10) :
|
4
|
+
- Support for Rails-3.2
|
5
|
+
- Changes in installation process. Now user should set only one environment variable IBM_DB_HOME to DB2/IBM_Data_Server_Driver installation directory
|
6
|
+
- Fixed bug #29541 - Serialize data when corresponding field maps to CLOB type on Database
|
7
|
+
- Fixed bug #29561 - Fixed data truncation error when client and server codepages are different
|
8
|
+
- Updated IBM_DB specifics of AR test suite as per Rails-3.2.3
|
9
|
+
|
3
10
|
2012/01/03 (IBM_DB adapter 2.5.9, driver 2.5.9) :
|
4
11
|
- Support for Create and Drop database on DB2 LUW with DB2 client version V97fp4 and above
|
5
12
|
- Fixed bug #29482 - Fixed bigint being returned as string in the adapter
|
data/README
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
=====================================================================
|
2
|
-
README for the IBM_DB Adapter (2.5.
|
2
|
+
README for the IBM_DB Adapter (2.5.10) and Driver (2.5.10) (2012/04/30)
|
3
3
|
For ActiveRecord Version >= 1.15.5 (and Rails >= 1.2.5)
|
4
4
|
=====================================================================
|
5
5
|
|
@@ -14,11 +14,11 @@ Supported Operating Systems
|
|
14
14
|
|
15
15
|
Supported Databases
|
16
16
|
====================
|
17
|
-
- IBM DB2 Universal Database on Linux/Unix/Windows versions
|
17
|
+
- IBM DB2 Universal Database on Linux/Unix/Windows versions 9 Fixpak2 and above
|
18
18
|
- Remote connections to IBM DB2 Universal Database on i5/OS versions V5R3 and V5R4.
|
19
19
|
Please ensure PTF SI27358 (includes SI27250) is installed in i5/OS version 5R3 and
|
20
20
|
and PTF SI27256 is installed while using i5/OS version 5R4.
|
21
|
-
- Remote connections to IBM DB2 Universal Database on z/OS version 8 and
|
21
|
+
- Remote connections to IBM DB2 Universal Database on z/OS version 8, 9 and 10
|
22
22
|
- Informix Dynamic Server 11.10 and beyond.
|
23
23
|
Please ensure that the IBM DataServer Viper 2 client is installed.
|
24
24
|
|
@@ -37,32 +37,18 @@ Note : - 1) If using activerecord version below 2.0 then it requires that the ib
|
|
37
37
|
INSTALL (as Ruby gem)
|
38
38
|
To remove previous gem version (optionally):
|
39
39
|
D:\>gem uninstall ibm_db
|
40
|
-
Successfully uninstalled ibm_db version 0.
|
40
|
+
Successfully uninstalled ibm_db version 1.0.0
|
41
41
|
|
42
42
|
Example:
|
43
43
|
D:\>gem install ibm_db
|
44
|
-
|
45
|
-
|
46
|
-
1
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
Running gem install ibm_db you are presented with two choices for each release
|
52
|
-
(mswin32 or ruby)choose mswin32. This will install the IBM_DB gem containing
|
53
|
-
the pre-built binary file of the driver which is a C-extension of Ruby.
|
54
|
-
|
55
|
-
TEST (simple gem install verification)
|
56
|
-
Note: The manual step after install if using activerecord version below 2.0:
|
44
|
+
Fetching: ibm_db-2.5.9-x86-mingw32.gem (100%)
|
45
|
+
Successfully installed ibm_db-2.5.9-x86-mingw32
|
46
|
+
1 gem installed
|
47
|
+
Installing ri documentation for ibm_db-2.5.9-x86-mingw32...
|
48
|
+
Installing RDoc documentation for ibm_db-2.5.9-x86-mingw32...
|
49
|
+
|
50
|
+
Note: The manual step after install if using activerecord version below 2.0:
|
57
51
|
add ibm_db into GEM_HOME\1.8\gems\activerecord-1.15.3\lib\active_record.rb (Line 77)
|
58
|
-
D:\rails NewApp
|
59
|
-
D:\cd NewApp
|
60
|
-
D:\NewApp>irb
|
61
|
-
irb(main):001:0> gem 'ibm_db'
|
62
|
-
irb(main):002:0> require 'mswin32/ibm_db' // notice the [mswin32] in the library path
|
63
|
-
irb(main):003:0> IBM_DB.connect 'sample', 'db2admin', 'secret'
|
64
|
-
D:\NewApp>ruby script\console
|
65
|
-
|
66
52
|
|
67
53
|
2. Linux and Unix platforms:
|
68
54
|
============================
|
@@ -75,32 +61,13 @@ Note : - 1) If using activerecord version below 2.0 then it requires that the ib
|
|
75
61
|
Note: DB2 environment is required while using an arbitrary user account
|
76
62
|
(other than the DB2 install user account)
|
77
63
|
$ . /home/db2inst1/sqllib/db2profile
|
78
|
-
$ export
|
79
|
-
$ export IBM_DB_LIB=DB2HOME/lib (eg. /home/db2inst1/sqllib/lib or /opt/ibm/db2/V9.5/lib32)
|
64
|
+
$ export IBM_DB_DIR=DB2HOME (eg. /home/db2inst1/sqllib or /opt/ibm/db2/v9.5)
|
80
65
|
$ gem install ibm_db
|
81
|
-
Select which gem to install for your platform (i686-linux)
|
82
|
-
1. ibm_db 1.0.0 (mswin32)
|
83
|
-
2. ibm_db 1.0.0 (ruby)
|
84
|
-
3. ibm_db 0.10.0 (ruby)
|
85
|
-
4. ibm_db 0.10.0 (mswin32)
|
86
|
-
...
|
87
|
-
Running gem install ibm_db you are presented with two choices for each release
|
88
|
-
(mswin32 or ruby) choose ruby. This will build the native extension (ibm_db driver) and installs the ibm_db gem.
|
89
|
-
...
|
90
|
-
> 2
|
91
66
|
Building native extensions. This could take a while...
|
92
|
-
Successfully installed ibm_db-
|
93
|
-
|
94
|
-
Installing
|
95
|
-
|
96
|
-
TEST (simple gem install verification)
|
97
|
-
Note: The manual step after install, if using activerecord version below 2.0 is:
|
98
|
-
add ibm_db into GEM_HOME\1.8\gems\activerecord-1.15.3\lib\active_record.rb (Line 77)
|
99
|
-
$ irb
|
100
|
-
irb(main):001:0> gem 'ibm_db'
|
101
|
-
irb(main):002:0> require 'ibm_db' // notice the library path (different on win32, use require 'mswin32/ibm_db')
|
102
|
-
irb(main):003:0> IBM_DB.connect 'sample', 'db2admin', 'secret'
|
103
|
-
$
|
67
|
+
Successfully installed ibm_db-2.5.9
|
68
|
+
1 gem installed
|
69
|
+
Installing ri documentation for ibm_db-2.5.9...
|
70
|
+
Installing RDoc documentation for ibm_db-2.5.9...
|
104
71
|
|
105
72
|
BUILD (optionally) ibm_db gem from sources (ibm_db-x.x.x.tar.gz):
|
106
73
|
1. Download source from Rubyforge
|
@@ -109,80 +76,84 @@ Note : - 1) If using activerecord version below 2.0 then it requires that the ib
|
|
109
76
|
$ cd IBM_DB_Adapter/ibm_db
|
110
77
|
$ gem build IBM_DB.gemspec
|
111
78
|
|
79
|
+
Note: The manual step after install if using activerecord version below 2.0:
|
80
|
+
add ibm_db into GEM_HOME\1.8\gems\activerecord-1.15.3\lib\active_record.rb (Line 77)
|
112
81
|
|
82
|
+
TEST (simple gem install verification)
|
83
|
+
======================================
|
84
|
+
$ rails new myApp -d ibm_db
|
85
|
+
$ cd myApp
|
86
|
+
$ rails generate scaffold Wood name:string price:float
|
87
|
+
$ vi config/database.yml
|
88
|
+
$ rake db:migrate
|
89
|
+
$ rails console #rails server
|
90
|
+
|
113
91
|
Instructions for building and installing the IBM_DB driver from source
|
114
92
|
=======================================================================
|
115
93
|
Building the driver manually as described below is not required if the install
|
116
94
|
process above has been pursued. This manual procedure is in fact automated
|
117
95
|
on Linux and UNIX platforms by the IBM_DB gem install, but is presented
|
118
|
-
here only for reference
|
96
|
+
here only for reference.
|
119
97
|
|
120
98
|
Prerequisites:
|
121
99
|
Install Ruby from:
|
122
100
|
http://rubyforge.org
|
123
101
|
|
124
|
-
|
125
|
-
Note: commands may vary depending on the shell used
|
126
|
-
- To setup DB2 environment while using an arbitrary user account
|
127
|
-
(other than the DB2 install user account):
|
128
|
-
Example:
|
129
|
-
$ . /home/db2inst1/sqllib/db2profile
|
130
|
-
|
131
|
-
- To configure test database:
|
132
|
-
DB2 v9.x: some IBM_DB driver tests require a UTF-8 database:
|
133
|
-
$ db2 CREATE DATABASE testdrv USING CODESET UTF-8 \
|
134
|
-
TERRITORY US COLLATE USING SYSTEM PAGESIZE 32768
|
135
|
-
DB2 v8.x: driver tests 195 and 52949 requires XML functionality
|
136
|
-
only available in DB2 v9.x
|
137
|
-
|
138
|
-
- To configure database connection parameters edit config.yaml
|
139
|
-
Example:
|
140
|
-
database: testdrv
|
141
|
-
user: db2inst1
|
142
|
-
password: password
|
143
|
-
hostname: localhost
|
144
|
-
port: 50000
|
145
|
-
|
146
|
-
- To compile and link with DB2 client libraries:
|
147
|
-
$ export IBM_DB_INCLUDE=DB2HOME/include (eg. /home/db2inst1/sqllib/include or /opt/ibm/db2/v9.5/include)
|
148
|
-
$ export IBM_DB_LIB=DB2HOME/lib (eg. /home/db2inst1/sqllib/lib or /opt/ibm/db2/V9.5/lib32)
|
149
|
-
|
150
|
-
Windows platforms:
|
151
|
-
- Install Visual C++ 2005, Platform SDK (latest), .Net SDK (latest)
|
152
|
-
- Set environment:
|
153
|
-
CALL "C:\Program Files\Microsoft Platform SDK for Windows Server 2005\SetEnv.Cmd"
|
154
|
-
CALL "C:\Program Files\Microsoft Visual C++ Toolkit 2005\vcvars32.bat"
|
155
|
-
SET LIB=%LIB%;C:\Program Files\Microsoft Visual Studio .NET 2005\Vc8\lib
|
156
|
-
- To configure database connection parameters edit config.yml
|
102
|
+
Setup the environment
|
157
103
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
104
|
+
Linux and Unix platforms:
|
105
|
+
Note: commands may vary depending on the shell used
|
106
|
+
- To setup DB2 environment while using an arbitrary user account
|
107
|
+
(other than the DB2 install user account):
|
108
|
+
Example:
|
109
|
+
$ . /home/db2inst1/sqllib/db2profile
|
110
|
+
|
111
|
+
- To compile and link with DB2 client libraries:
|
112
|
+
$ export IBM_DB_DIR=DB2HOME (eg. /home/db2inst1/sqllib or /opt/ibm/db2/v9.5)
|
113
|
+
|
114
|
+
Windows platforms:
|
115
|
+
- Set ruby devkit environment:
|
116
|
+
- To compile and link with DB2 client libraries:
|
117
|
+
$ set IBM_DB_DIR=DB2HOME (eg. C:\Program Files\IBM\SQLLIB)
|
118
|
+
|
119
|
+
Build the driver:
|
120
|
+
- $ cd rubyibm_source/IBM_DB_Adapter/ibm_db/ext
|
121
|
+
- $ ruby extconf.rb
|
122
|
+
- $ make
|
123
|
+
|
124
|
+
Build the ibm_db gem
|
125
|
+
- $ cp rubyibm_source/IBM_DB_Adapter/ibm_db/ext/ibm_db.so rubyibm_source/IBM_DB_Adapter/ibm_db/lib
|
126
|
+
# Not on windows separate binaries are generated for 1.8 and 1.9 version of ruby
|
127
|
+
# and placed under rb18x and rb19x directories respectively. The file ibm_db_mswin32.rb is renamed to ibm_db.rb to ensure proper binary is loaded based on runtime
|
128
|
+
# You will need to similarly ensure that the generated binary is placed on rb18x or rb19x directory under lib based on ruby version being used
|
129
|
+
- $ cd rubyibm_source/IBM_DB_Adapter/ibm_db
|
130
|
+
- $ gem build IBM_DB.gemspec
|
131
|
+
|
132
|
+
Running tests
|
133
|
+
=============
|
134
|
+
Testing the IBM_DB Adapter
|
135
|
+
|
136
|
+
1) a) Copy the files under test directory of ibm_db gem to the test directory of Activerecord following the same directory structure.
|
137
|
+
These files contain modifications in some test files of AR suite to handle ibm_db specifics. Hence make sure these files are replaced in the AR test suite properly.
|
138
|
+
b) Rename warhouse-things.yml to warehouse_things.yml under fixtures directory
|
139
|
+
2) Edit the Rakefile to include ibm_db in list of adapters
|
140
|
+
%w( mysql mysql2 postgresql sqlite3 sqlite3_mem firebird db2 oracle sybase openbase ibm_db frontbase jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb )
|
141
|
+
3) Configure the connection information in test/config.yml for ibm_db
|
142
|
+
4) run the test suite - rake test_ibm_db
|
143
|
+
|
144
|
+
Running IBM_DB driver test suite
|
145
|
+
|
146
|
+
1) Copy over the test directory under source to lib directory of installed ibm_db under $GEM_HOME
|
147
|
+
2) Edit config.yml file to provide database connection information
|
148
|
+
3) Run the test suite
|
149
|
+
$ rake onlytests
|
150
|
+
4) To run single test
|
151
|
+
export SINGLE_RUBY_TEST=<test file name> #Eg: export SINGLE_RUBY_TEST=test_000_PrepareDb.rb
|
152
|
+
rake onlytests
|
168
153
|
|
169
154
|
Limitations and known problems
|
170
155
|
==============================
|
171
|
-
- ActiveRecord rename_column method is not supported for DB2 LUW, zOS and i5
|
172
156
|
- ActiveRecord remove_column method is not supported for DB2 zOS
|
173
|
-
- The following tests from the ActiveRecord 1.15.3 test suite with ibm_db gem < 0.9.5 are expected to fail
|
174
|
-
- test_limited_eager_with_multiple_order_columns
|
175
|
-
- test_limited_eager_with_order
|
176
|
-
- test_assign_ids_ignoring_blanks
|
177
|
-
- test_build_by_new_record
|
178
|
-
- test_get_ids
|
179
|
-
- test_select_limited_ids_list
|
180
|
-
- test_add_index
|
181
|
-
- The following tests from the driver test suite are expected to fail on DB2 version 8
|
182
|
-
on Linux/Unix/Windows and Informix Dynamic Server because of missing native XML support. If you want to
|
183
|
-
make use of the native XML features in DB2, please upgrade to version 9 or later
|
184
|
-
- test_195.rb
|
185
|
-
- test_52949.rb
|
186
157
|
- The driver returns an error when you try to insert a TIMESTAMP value into a DATE column.
|
187
158
|
To fix this, please ensure that the following configuration keyword PATCH2=58 is set
|
188
159
|
in the COMMON section of your DB2 CLI initialization file (db2cli.ini):
|
@@ -191,7 +162,7 @@ Limitations and known problems
|
|
191
162
|
Please refer to http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.apdv.cli.doc/doc/c0007882.htm
|
192
163
|
for more information.
|
193
164
|
- The behaviour of ActiveRecord::Base.find(:first) without an :order attribute can be unpredictable.
|
194
|
-
The first record (i.e. the record with the minimum id) may be not
|
165
|
+
The first record (i.e. the record with the minimum id) may be not retrieved. In a relational model,
|
195
166
|
the order of the rows returned is unpredictable and independent of the order of insertion.
|
196
167
|
This issue may be addressed in a future release.
|
197
168
|
- Rails applications on DB2 9 require the APPLHEAPSZ database configuration parameter to be
|
@@ -202,32 +173,17 @@ Limitations and known problems
|
|
202
173
|
To enable this parameter, you need to restart your DB2 instance.
|
203
174
|
- If you see connectivity issues with Informix Dynamic Server, please ensure that the server is configured to accept DRDA connections.
|
204
175
|
Please refer to http://publib.boulder.ibm.com/infocenter/idshelp/v111/index.jsp?topic=/com.ibm.admin.doc/admin154.htm for more information.
|
205
|
-
- The following tests from the ActiveRecord 1.15.3 test suite with ibm_db gem < 0.9.5 are expected to fail on Informix Dynamic Server
|
206
|
-
- test_quote
|
207
|
-
- test_to_xml
|
208
|
-
- test_should_calculate_grouped_by_function
|
209
|
-
- test_should_calculate_grouped_by_function_with_table_alias
|
210
|
-
- test_inserts_with_pre_and_suffix
|
211
|
-
- test_add_table_with_decimals
|
212
|
-
- test_no_limits_datatypes_IBM_DB
|
213
|
-
- test_instance_update_should_quote_pkey
|
214
|
-
- test_integer_columns
|
215
|
-
- test_arguments_line_up
|
216
|
-
- test_no_dump_errors
|
217
|
-
- test_schema_dump_includes_decimal_options
|
218
176
|
- IBM_DB is not supported on JRuby. As stated in the JRuby Wiki, "Basics of Getting JRuby Running":
|
219
177
|
'You may install other gems, but keep in mind that libraries with C extension dependencies
|
220
178
|
will not work in JRuby.' http://www.headius.com/jrubywiki/index.php/Getting_Started
|
221
179
|
The IBM_DB adapter relies on IBM_DB driver (C extension) and the IBM Driver for ODBC and
|
222
180
|
CLI to access databases on IBM data servers. Alternatively, you can either use the regular C
|
223
181
|
implementation of Ruby, or use ActiveRecord-JDBC adapter to access databases.
|
224
|
-
- Query caching feature of ActiveRecord-2.0 not supported
|
225
182
|
- When using ActiveRecord-2.1.0 it requires that ActiveRecord be patched, with the patch in the link below:
|
226
183
|
http://rails.lighthouseapp.com/attachments/26975/association_preloading.diff
|
227
184
|
The patch is required because, ActiveRecord 2.1.0 generates a non-standard SQL identifier,while preloading has_and_belongs_to_many associations,
|
228
185
|
which standard compliant databases like DB2 do not support. The bug report, against ActiveRecord, can be found in the link below
|
229
186
|
http://rails.lighthouseapp.com/projects/8994/tickets/394-patch-fixed-non-standard-sql-generated-by-preloading-has_and_belongs_to_many-associations
|
230
|
-
- ActiveRecord-2.1.0 test suite changes appropriate for DB2/IDS will be updated in the next release of the gem.(Updated in release 0.10.0)
|
231
187
|
- The following tests from the ActiveRecord 2.1.0 test suite with ibm_db gem 0.10.0 are expected to fail on DB2 LUW
|
232
188
|
- test_read_attributes_before_type_cast_on_datetime
|
233
189
|
- test_to_xml
|
@@ -241,24 +197,6 @@ Limitations and known problems
|
|
241
197
|
the complete suite. However they pass when run standalone.
|
242
198
|
2) Also there are two test cases (test_validate_uniqueness_with_non_standard_table_names, test_update_all_with_non_standard_table_name)which run against table with non-standard name. Given that DB2/IDS is standard compliant these test cases are expected to fail.
|
243
199
|
To have these test cases passing rename the fixtures file warehouse-things to warehouse_things.
|
244
|
-
- The following tests from the ActiveRecord 2.1.0 test suite with ibm_db gem 0.10.0 are expected to fail on Informix Dynamic Server
|
245
|
-
- test_attributes_on_dummy_time
|
246
|
-
- test_quote
|
247
|
-
- test_read_attributes_before_type_cast_on_datetime
|
248
|
-
- test_save_for_record_with_only_primary_key
|
249
|
-
- test_save_for_record_with_only_primary_key_that_is_provided
|
250
|
-
- test_to_xml
|
251
|
-
- test_utc_as_time_zone
|
252
|
-
- test_should_calculate_grouped_by_function
|
253
|
-
- test_should_calculate_grouped_by_function_with_table_alias
|
254
|
-
- test_include_query
|
255
|
-
- test_binary_in_fixtures
|
256
|
-
- test_inserts_with_pre_and_suffix
|
257
|
-
- test_create
|
258
|
-
- test_add_column_with_precision_and_scale
|
259
|
-
- test_add_table_with_decimals
|
260
|
-
- test_native_types
|
261
|
-
- test_schema_dump_includes_decimal_options
|
262
200
|
- Usage with Rails-3.0.3/Rails-3.0.4
|
263
201
|
- To use with Rails-3.0.3/4 patch latest Arel with the patch available at https://gist.github.com/814491
|
264
202
|
|
data/ext/extconf.rb
CHANGED
@@ -3,19 +3,81 @@
|
|
3
3
|
# +----------------------------------------------------------------------+
|
4
4
|
# | Licensed Materials - Property of IBM |
|
5
5
|
# | |
|
6
|
-
# | (C) Copyright IBM Corporation 2006
|
6
|
+
# | (C) Copyright IBM Corporation 2006 - 2012 |
|
7
7
|
# +----------------------------------------------------------------------+
|
8
8
|
|
9
|
-
require 'mkmf'
|
10
9
|
WIN = RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
|
11
10
|
|
12
|
-
# use ENV['
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
# use ENV['IBM_DB_HOME'] or latest db2 you can find
|
12
|
+
IBM_DB_HOME = ENV['IBM_DB_HOME']
|
13
|
+
|
14
|
+
machine_bits = ['ibm'].pack('p').size * 8
|
15
|
+
|
16
|
+
is64Bit = true
|
17
|
+
|
18
|
+
module Kernel
|
19
|
+
def suppress_warnings
|
20
|
+
origVerbosity = $VERBOSE
|
21
|
+
$VERBOSE = nil
|
22
|
+
result = yield
|
23
|
+
$VERBOSE = origVerbosity
|
24
|
+
return result
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
if machine_bits == 64
|
29
|
+
is64Bit = true
|
30
|
+
puts "Detected 64-bit Ruby\n "
|
31
|
+
else
|
32
|
+
is64Bit = false
|
33
|
+
puts "Detected 32-bit Ruby\n "
|
34
|
+
end
|
35
|
+
|
36
|
+
if(IBM_DB_HOME == nil || IBM_DB_HOME == '')
|
37
|
+
IBM_DB_INCLUDE = ENV['IBM_DB_INCLUDE']
|
38
|
+
IBM_DB_LIB = ENV['IBM_DB_LIB']
|
39
|
+
|
40
|
+
if( ( (IBM_DB_INCLUDE.nil?) || (IBM_DB_LIB.nil?) ) ||
|
41
|
+
( IBM_DB_INCLUDE == '' || IBM_DB_LIB == '' )
|
42
|
+
)
|
43
|
+
puts "Environment variable IBM_DB_HOME is not set. Set it to your DB2/IBM_Data_Server_Driver installation directory and retry gem install.\n "
|
44
|
+
exit 1
|
45
|
+
end
|
46
|
+
else
|
47
|
+
IBM_DB_INCLUDE = "#{IBM_DB_HOME}/include"
|
48
|
+
|
49
|
+
if(is64Bit)
|
50
|
+
IBM_DB_LIB="#{IBM_DB_HOME}/lib64"
|
51
|
+
else
|
52
|
+
IBM_DB_LIB="#{IBM_DB_HOME}/lib32"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
if( !(File.directory?(IBM_DB_LIB)) )
|
57
|
+
suppress_warnings{IBM_DB_LIB = "#{IBM_DB_HOME}/lib"}
|
58
|
+
if( !(File.directory?(IBM_DB_LIB)) )
|
59
|
+
puts "Cannot find #{IBM_DB_LIB} directory. Check if you have set the IBM_DB_HOME environment variable's value correctly\n "
|
60
|
+
exit 1
|
61
|
+
end
|
62
|
+
notifyString = "Detected usage of IBM Data Server Driver package. Ensure you have downloaded "
|
63
|
+
|
64
|
+
if(is64Bit)
|
65
|
+
notifyString = notifyString + "64-bit package "
|
66
|
+
else
|
67
|
+
notifyString = notifyString + "32-bit package "
|
68
|
+
end
|
69
|
+
notifyString = notifyString + "of IBM_Data_Server_Driver and retry the 'gem install ibm_db' command\n "
|
70
|
+
|
71
|
+
puts notifyString
|
72
|
+
end
|
73
|
+
|
74
|
+
if( !(File.directory?(IBM_DB_INCLUDE)) )
|
75
|
+
puts " #{IBM_DB_HOME}/include folder not found. Check if you have set the IBM_DB_HOME environment variable's value correctly\n "
|
76
|
+
exit 1
|
77
|
+
end
|
78
|
+
|
79
|
+
require 'mkmf'
|
80
|
+
|
19
81
|
dir_config('IBM_DB',IBM_DB_INCLUDE,IBM_DB_LIB)
|
20
82
|
|
21
83
|
def crash(str)
|
@@ -30,18 +92,17 @@ end
|
|
30
92
|
|
31
93
|
unless (have_library(WIN ? 'db2cli' : 'db2','SQLConnect') or find_library(WIN ? 'db2cli' : 'db2','SQLConnect', IBM_DB_LIB))
|
32
94
|
crash(<<EOL)
|
33
|
-
Unable to locate
|
95
|
+
Unable to locate libdb2.so/a under #{IBM_DB_LIB}
|
34
96
|
|
35
97
|
Follow the steps below and retry
|
36
98
|
|
37
99
|
Step 1: - Install IBM DB2 Universal Database Server/Client
|
38
100
|
|
39
|
-
step 2: - Set the environment
|
101
|
+
step 2: - Set the environment variable IBM_DB_HOME as below
|
40
102
|
|
41
103
|
(assuming bash shell)
|
42
104
|
|
43
|
-
export
|
44
|
-
export IBM_DB_LIB=DB2HOME/lib (eg. /home/db2inst1/sqllib/lib or /opt/ibm/db2/V9.5/lib32)
|
105
|
+
export IBM_DB_HOME=<DB2/IBM_Data_Server_Driver installation directory> #(Eg: export IBM_DB_HOME=/opt/ibm/db2/v10)
|
45
106
|
|
46
107
|
step 3: - Retry gem install
|
47
108
|
|
data/ext/ibm_db.c
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
+----------------------------------------------------------------------+
|
13
13
|
*/
|
14
14
|
|
15
|
-
#define MODULE_RELEASE "2.5.
|
15
|
+
#define MODULE_RELEASE "2.5.10"
|
16
16
|
|
17
17
|
#ifdef HAVE_CONFIG_H
|
18
18
|
#include "config.h"
|
@@ -1740,6 +1740,13 @@ static int _ruby_ibm_db_bind_column_helper(stmt_handle *stmt_res)
|
|
1740
1740
|
*/
|
1741
1741
|
bindCol_args->buff_length = bindCol_args->buff_length * 2;
|
1742
1742
|
}
|
1743
|
+
|
1744
|
+
if( column_type == SQL_CHAR || column_type == SQL_VARCHAR ) {
|
1745
|
+
/* Multiply the size by 4 to handle cases where client and server code pages are different.
|
1746
|
+
* 4 bytes should be able to cover any codeset character known*/
|
1747
|
+
bindCol_args->buff_length = bindCol_args->buff_length * 4;
|
1748
|
+
}
|
1749
|
+
|
1743
1750
|
row_data->str_val = ALLOC_N(char, bindCol_args->buff_length);
|
1744
1751
|
#endif
|
1745
1752
|
bindCol_args->TargetValuePtr = row_data->str_val;
|
@@ -8846,6 +8853,14 @@ static VALUE _ruby_ibm_db_result_helper(ibm_db_result_args *data) {
|
|
8846
8853
|
*/
|
8847
8854
|
in_length = in_length * 2;
|
8848
8855
|
}
|
8856
|
+
|
8857
|
+
if( column_type == SQL_CHAR || column_type == SQL_VARCHAR ) {
|
8858
|
+
/* Multiply size by 4 to handle different client and server codepages.
|
8859
|
+
* factor of 4 should suffice as known characters today well fit in 4 bytes.
|
8860
|
+
*/
|
8861
|
+
in_length = in_length * 4;
|
8862
|
+
}
|
8863
|
+
|
8849
8864
|
out_ptr = (SQLPOINTER)ALLOC_N(char,in_length);
|
8850
8865
|
memset(out_ptr, '\0', in_length);
|
8851
8866
|
#endif
|
@@ -8871,7 +8886,7 @@ static VALUE _ruby_ibm_db_result_helper(ibm_db_result_args *data) {
|
|
8871
8886
|
#ifdef UNICODE_SUPPORT_VERSION
|
8872
8887
|
return_value = _ruby_ibm_db_export_sqlwchar_to_utf8_rstr(out_ptr, out_length);
|
8873
8888
|
#else
|
8874
|
-
return_value =
|
8889
|
+
return_value = rb_str_new((char*)out_ptr, out_length);
|
8875
8890
|
#endif
|
8876
8891
|
ruby_xfree( out_ptr );
|
8877
8892
|
out_ptr = NULL;
|
@@ -9379,20 +9394,20 @@ static VALUE _ruby_ibm_db_bind_fetch_helper(ibm_db_fetch_helper_args *data)
|
|
9379
9394
|
#ifdef UNICODE_SUPPORT_VERSION
|
9380
9395
|
rb_hash_aset(return_value, colName, _ruby_ibm_db_export_sqlwchar_to_utf8_rstr(row_data->str_val, out_length ));
|
9381
9396
|
#else
|
9382
|
-
rb_hash_aset(return_value, colName,
|
9397
|
+
rb_hash_aset(return_value, colName, rb_str_new((char *)row_data->str_val, out_length));
|
9383
9398
|
#endif
|
9384
9399
|
}
|
9385
9400
|
if ( op == FETCH_INDEX ) {
|
9386
9401
|
#ifdef UNICODE_SUPPORT_VERSION
|
9387
9402
|
rb_ary_store(return_value, i, _ruby_ibm_db_export_sqlwchar_to_utf8_rstr(row_data->str_val, out_length ));
|
9388
9403
|
#else
|
9389
|
-
rb_ary_store(return_value, i,
|
9404
|
+
rb_ary_store(return_value, i, rb_str_new((char *)row_data->str_val, out_length));
|
9390
9405
|
#endif
|
9391
9406
|
} else if ( op == FETCH_BOTH ) {
|
9392
9407
|
#ifdef UNICODE_SUPPORT_VERSION
|
9393
9408
|
rb_hash_aset(return_value, INT2NUM(i), _ruby_ibm_db_export_sqlwchar_to_utf8_rstr(row_data->str_val, out_length ));
|
9394
9409
|
#else
|
9395
|
-
rb_hash_aset(return_value, INT2NUM(i),
|
9410
|
+
rb_hash_aset(return_value, INT2NUM(i), rb_str_new((char *)row_data->str_val, out_length));
|
9396
9411
|
#endif
|
9397
9412
|
}
|
9398
9413
|
break;
|