ibm_db 0.6.0 → 0.6.5

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.
data/CHANGES CHANGED
@@ -1,8 +1,16 @@
1
- CHANGE LOG
1
+ Change Log
2
2
  ==============
3
+ 2007/05/10 (IBM_DB adapter 0.6.5, driver 0.6.0):
4
+ - Driver code (ibm_db.c) remains at the same level: 0.6.0 (no changes)
5
+ - Fixed regression for reconnect after being inactive (connection recycle)
6
+ - Fixed rake db:schema:load failures on boolean data type [#10683]
7
+ - Fixed XML default option (:null => true for XML data type) [#10754]
8
+ - Fixed DB2 for zOS version 9 handling of column changes for DEFAULT NULL
9
+
3
10
  2007/04/30 (0.6.0):
4
11
  - Support for remote connections to DB2 Universal Database on z/OS version 9
5
- - Support for result set pagination via ActiveRecord add_limit_offset! method for DB2 Universal Database on z/OS and i5/OS
12
+ - Support for result set pagination via ActiveRecord add_limit_offset! method
13
+ for DB2 Universal Database on z/OS and i5/OS
6
14
  - Defect fixes
7
15
  - Improved documentation
8
16
 
@@ -36,4 +44,4 @@ CHANGE LOG
36
44
  - Fixed compatibility issue with other adapters
37
45
  - If a schema is omitted in database.yml, the username is now used as default schema
38
46
  - Introduced descriptive CLI error messages when a connection or an execute statement fails
39
- - Introduced check against schema in method 'indexes'
47
+ - Introduced check against schema in method 'indexes'
data/README CHANGED
@@ -1,231 +1,334 @@
1
- =====================================================================
2
- README for the IBM_DB Adapter and Driver Release 0.6.0 (2007/04/30)
3
- For ActiveRecord Version 1.15.3 (and Rails 1.2.3)
4
- =====================================================================
5
-
6
- Change Log
7
- ==============
8
-
9
- 2007/04/30 (0.6.0):
10
- - Support for remote connections to DB2 Universal Database on z/OS version 9
11
- - Support for result set pagination via ActiveRecord add_limit_offset! method for DB2 Universal Database on z/OS and i5/OS
12
- - Defect fixes
13
- - Improved documentation
14
-
15
- 2007/04/20 (0.4.6):
16
- - Fixed XML columns creation default value (NOT NULL)
17
- - Fixed border case for IS NULL in where clauses
18
- - Improved documentation (connection attributes)
19
-
20
- 2007/04/20 (0.4.5):
21
- - Fixed reconnect problems: driver (IBM_DB::active) and adapter (active)
22
- - Client connection attribute rename (app_user to replace user)
23
- - Improved support for ROWID data type (DB2 for zOS version 8 and 9)
24
-
25
- 2007/03/21 (0.4.0):
26
- - Support added for remote connectivity to DB2 zOS version 8
27
- - Support added for remote connectivity to DB2 i5 v5r3 and v5r4
28
- - Improved migration support (added change_column method)
29
- - Support for setting and retrieving values for client attributes (user,
30
- account, application, workstation)
31
-
32
- 2006/10/31 (0.2.0):
33
- - Significant performance improvements
34
- - Improved stored procedure support at driver level
35
- - Added support for Large Object data types (LOBs) greater than 32K (BLOB, CLOB, XML) in size
36
- - Added XML data type support for native storage of XML documents
37
- - Significant quality improvements, through many bug fixes in the driver and adapter
38
- - Improved migration support (added add_column and remove_column methods)
39
-
40
- 2006/06/07 (0.1.0):
41
-
42
- - Fixed compatibility issue with other adapters
43
- - If a schema is omitted in database.yml, the username is now used as default schema
44
- - Introduced descriptive CLI error messages when a connection or an execute statement fails
45
- - Introduced check against schema in method 'indexes'
46
-
47
- Supported Operating Systems
48
- ============================
49
- - Linux 32/64 bit
50
- - Microsoft Windows 32 bit
51
- - IBM AIX 32/64 bit
52
- - HP-UX 32/64 bit
53
- - Sun Solaris 32/64 bit
54
-
55
-
56
- Supported Databases
57
- ====================
58
- - IBM DB2 Universal Database on Linux/Unix/Windows versions 8 and 9
59
- - Remote connections to IBM DB2 Universal Database on i5/OS versions V5R3 and V5R4. Please ensure that PTFs SI27250 and SI27256 are installed for i5/OS version V5R4 and PTF SI27358 is installed for /OS version V5R3
60
- - Remote connections to IBM DB2 Universal Database on z/OS version 8
61
- - Remote connections to IBM DB2 Universal Database on z/OS version 9
62
-
63
-
64
- There are two alternatives for installing the IBM_DB adapter and driver:
65
- A. Installing as a Ruby gem in the Ruby runtime
66
- B. Installing as a Rails plugin in a specific Rails application runtime
67
- Note: The IBM_DB driver can also be built separately (from source)
68
-
69
- A. Installing the IBM_DB adapter and driver as a Ruby Gem
70
- =======================================================
71
-
72
- 1. Windows platforms:
73
- BUILD (or download from Rubyforge http://rubyforge.org/frs/?group_id=2361&release_id=8337)
74
- D:\IBM_DB_Adapter\ibm_db>gem build IBM_DB.gemspec
75
-
76
- INSTALL
77
- D:\IBM_DB_Adapter\ibm_db>gem install ibm_db
78
-
79
- TEST
80
- Note: IBM_DB Gem requires a manual step after install:
81
- add ibm_db into gems\1.8\gems\activerecord-1.15.3\lib\active_record.rb (Line 77)
82
- D:\NewApp>dir vendor\plugins
83
- D:\NewApp>irb
84
- irb(main):001:0> gem 'ibm_db'
85
- irb(main):002:0> require 'mswin32/ibm_db'
86
- irb(main):003:0> IBM_DB::connect 'sample', 'db2admin', 'secret'
87
- D:\NewApp>ruby script\console
88
-
89
- 2. Linux and Unix platforms:
90
- BUILD
91
- $ gem build IBM_DB.gemspec
92
-
93
- INSTALL
94
- Note: DB2 environment is required while using an arbitrary user account
95
- (other than the DB2 install user account)
96
- $ . /home/db2inst1/sqllib/db2profile
97
- $ export IBM_DB_DIR=/opt/ibm/db2/V9.1
98
- $ export IBM_DB_LIB=/opt/ibm/db2/V9.1/lib32
99
- $ gem install ibm_db
100
-
101
- TEST
102
- Note: IBM_DB Gem requires a manual step after install:
103
- add ibm_db into /gems/activerecord-1.15.3/lib/active_record.rb (Line 77)
104
- $ ls -al vendor/plugins/
105
- $ irb
106
- irb(main):001:0> gem 'ibm_db'
107
- irb(main):002:0> require 'ibm_db'
108
- irb(main):003:0> IBM_DB::connect 'sample', 'db2admin', 'secret'
109
- $ ./script/console
110
-
111
-
112
- B. Installing the IBM_DB adapter and driver as a Rails plugin
113
- ==========================================================
114
- 1. Linux and Unix platforms:
115
- Register Repository and Query
116
- $ ./script/plugin source svn://rubyforge.org/var/svn/rubyibm/trunk/IBM_DB_Adapter/ibm_db/
117
- $ ./script/plugin list
118
-
119
- INSTALL
120
- $ ./script/plugin install ibm_db
121
-
122
- TEST
123
- Note: Make sure there's no ibm_db in /gems/activerecord-1.15.3/lib/active_record.rb (Line 77)
124
- $ ./script/console
125
-
126
- 2. Windows platforms:
127
- REGISTER REPOSITORY and QUERY (not enabled yet @rubyibm.rubyforge.org)
128
- D:\NewApp>ruby script\plugin source http://rubyibm.rubyforge.org/IBM_DB_Adapter/ibm_db/
129
- D:\NewApp>ruby script\plugin list
130
-
131
- INSTALL
132
- D:\NewApp>ruby script\plugin install ibm_db
133
-
134
- TEST
135
- Note: Make sure there's no ibm_db in gems\1.8\gems\activerecord-1.15.3\lib\active_record.rb (Line 77)
136
- D:\NewApp>ruby script\console
137
-
138
-
139
- Instructions for building and installing the IBM_DB driver from source
140
- =======================================================================
141
-
142
- Prerequisites:
143
- Install Ruby from:
144
- http://rubyforge.org
145
-
146
- Linux and Unix platforms:
147
- Note: commands may vary depending on the shell used
148
- - To setup DB2 environment while using an arbitrary user account
149
- (other than the DB2 install user account):
150
- Example:
151
- $ . /home/db2inst1/sqllib/db2profile
152
-
153
- - To configure test database:
154
- DB2 v9.x: some IBM_DB driver tests require a UTF-8 database:
155
- $ db2 CREATE DATABASE testdrv USING CODESET UTF-8 TERRITORY US
156
- DB2 v8.x: driver tests 195 and 52949 requires XML functionality
157
- only available in DB2 v9.x
158
-
159
- - To configure database connection parameters edit config.yaml
160
- Example:
161
- database: sample
162
- user: db2inst1
163
- password: password
164
- hostname: localhost
165
- port: 50000
166
-
167
- - To compile and link with DB2 client libraries:
168
- $ export IBM_DB_DIR=/opt/ibm/db2/V9.1
169
- $ export IBM_DB_LIB=/opt/ibm/db2/V9.1/lib32
170
-
171
- Windows platforms:
172
- - Install Visual C++ 2003, Platform SDK (latest), .Net SDK Version 1.1 from:
173
- http://wiki.tcl.tk/11431
174
- - Set environment:
175
- CALL "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\SetEnv.Cmd"
176
- CALL "C:\Program Files\Microsoft Visual C++ Toolkit 2003\vcvars32.bat"
177
- SET LIB=%LIB%;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib
178
- - To configure database connection parameters edit config.yaml
179
-
180
- Build and Execution:
181
- rake
182
-
183
- Execution of tests without compilation (must have .so in ibm_db source directory):
184
- rake onlytests
185
-
186
- Execution of a single test inside the tests directory can be done by the following:
187
- export SINGLE_RUBY_TEST=test_001.rb
188
- rake
189
-
190
-
191
- Limitations and known problems
192
- ==============================
193
- - ActiveRecord add_limit_offset! method is not supported for DB2 zOS and i5.
194
- - ActiveRecord rename_column method is not supported for DB2 LUW, zOS and i5
195
- - ActiveRecord remove_column method is not supported for DB2 zOS
196
- - The following tests from the ActiveRecord 1.15.3 test suite are expected to fail
197
- - test_limited_eager_with_multiple_order_columns
198
- - test_limited_eager_with_order
199
- - test_assign_ids_ignoring_blanks
200
- - test_build_by_new_record
201
- - test_get_ids
202
- - test_select_limited_ids_list
203
- - test_add_index
204
- - The following tests from the driver test suite are expected to fail on DB2 version 8
205
- on Linux/Unix/Windows because of missing native XML support. If you want to
206
- make use of the native XML features in DB2, please upgrade to version 9
207
- - test_195.rb
208
- - test_52949.rb
209
- - The driver returns an error when you try to insert a TIMESTAMP value into a DATE column.
210
- To fix this, please ensure that the following configuration keyword PATCH2=58 is set
211
- in the COMMON section of your DB2 CLI initialization file (db2cli.ini). Please refer to
212
- http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.apdv.cli.doc/doc/c0007882.htm
213
- for more information.
214
- - The behavior of ActiveRecord::Base.find(:first), without an :order attribute, may be unpredictable.
215
- The first record, ie. the record with the minimum id may be not be retrieved. In a relational model,
216
- the order of the rows returned is unpredictable and independent of the order of insertion.
217
- This issue may be addressed in a future release.
218
-
219
- To Do
220
- ====
221
- - Support Informix Dynamic Server 11.10
222
- - Support ActiveRecord rename_column method for DB2 zOS version 9
223
-
224
-
225
- Feedback
226
- ========
227
- Your feedback is very much appreciated and expected through Rubyforge:
228
- - rubyibm project: http://rubyforge.org/projects/rubyibm/
229
- - rubyibm forum: http://rubyforge.org/forum/?group_id=2361
230
- - rubyibm bug reports: http://rubyforge.org/tracker/?group_id=2361
1
+ =====================================================================
2
+ README for the IBM_DB Adapter 0.6.5 and Driver 0.6.0 (2007/04/30)
3
+ For ActiveRecord Version 1.15.3 (and Rails 1.2.3)
4
+ =====================================================================
5
+
6
+ Change Log
7
+ ==============
8
+ 2007/05/10 (IBM_DB adapter 0.6.5, driver 0.6.0):
9
+ - Driver code (ibm_db.c) remains at the same level: 0.6.0 (no changes)
10
+ - Fixed regression for reconnect after being inactive (connection recycle)
11
+ - Fixed rake db:schema:load failures on boolean data type [#10683]
12
+ - Fixed XML default option (:null => true for XML data type) [#10754]
13
+ - Fixed DB2 for zOS version 9 handling of column changes for DEFAULT NULL
14
+
15
+ 2007/04/30 (0.6.0):
16
+ - Support for remote connections to DB2 Universal Database on z/OS version 9
17
+ - Support for result set pagination via ActiveRecord add_limit_offset! method
18
+ for DB2 Universal Database on z/OS and i5/OS
19
+ - Defect fixes
20
+ - Improved documentation
21
+
22
+ 2007/04/20 (0.4.6):
23
+ - Fixed XML columns creation default value (NOT NULL)
24
+ - Fixed border case for IS NULL in where clauses
25
+ - Improved documentation (connection attributes)
26
+
27
+ 2007/04/20 (0.4.5):
28
+ - Fixed reconnect problems: driver (IBM_DB::active) and adapter (active)
29
+ - Client connection attribute rename (app_user to replace user)
30
+ - Improved support for ROWID data type (DB2 for zOS version 8 and 9)
31
+
32
+ 2007/03/21 (0.4.0):
33
+ - Support added for remote connectivity to DB2 zOS version 8
34
+ - Support added for remote connectivity to DB2 i5 v5r3 and v5r4
35
+ - Improved migration support (added change_column method)
36
+ - Support for setting and retrieving values for client attributes (user,
37
+ account, application, workstation)
38
+
39
+ 2006/10/31 (0.2.0):
40
+ - Significant performance improvements
41
+ - Improved stored procedure support at driver level
42
+ - Added support for Large Object data types (LOBs) greater than 32K (BLOB, CLOB, XML) in size
43
+ - Added XML data type support for native storage of XML documents
44
+ - Significant quality improvements, through many bug fixes in the driver and adapter
45
+ - Improved migration support (added add_column and remove_column methods)
46
+
47
+ 2006/06/07 (0.1.0):
48
+
49
+ - Fixed compatibility issue with other adapters
50
+ - If a schema is omitted in database.yml, the username is now used as default schema
51
+ - Introduced descriptive CLI error messages when a connection or an execute statement fails
52
+ - Introduced check against schema in method 'indexes'
53
+
54
+ Supported Operating Systems
55
+ ============================
56
+ - Linux 32/64 bit
57
+ - Microsoft Windows 32 bit
58
+ - IBM AIX 32/64 bit
59
+ - HP-UX 32/64 bit
60
+ - Sun Solaris 32/64 bit
61
+
62
+
63
+ Supported Databases
64
+ ====================
65
+ - IBM DB2 Universal Database on Linux/Unix/Windows versions 8 and 9
66
+ - Remote connections to IBM DB2 Universal Database on i5/OS versions V5R3 and V5R4.
67
+ Please ensure PTF SI27358 (includes SI27250) is installed in i5/OS version 5R3 and
68
+ and PTF SI27256 is installed while using i5/OS version 5R4.
69
+ - Remote connections to IBM DB2 Universal Database on z/OS version 8 and 9
70
+
71
+
72
+ There are two alternatives for installing the IBM_DB adapter and driver:
73
+ A. Installing as a Ruby gem in the Ruby runtime
74
+ B. Installing as a Rails plugin in a specific Rails application runtime
75
+ Note: The IBM_DB driver can also be built separately (from source) and used in direct API calls.
76
+
77
+ A. Installing the IBM_DB adapter and driver as a Ruby gem
78
+ =======================================================
79
+ The IBM_DB gem is an ActiveRecord adapter and requires the abstract adapter to register it
80
+ in the list of RAILS_CONNECTION_ADAPTERS (active_record.rb) before it can be utilized in
81
+ the Rails framework. Once registered, the IBM_DB adapter and its dependencies (ibm_db Ruby
82
+ driver and the IBM Driver for ODBC and CLI) are loaded. This enables any application in the
83
+ Ruby environment, including Rails, to interact with IBM data servers.
84
+
85
+ 1. Windows platforms:
86
+ =====================
87
+ INSTALL (as Ruby gem)
88
+ To remove previous gem version (optionally):
89
+ D:\>gem uninstall ibm_db
90
+ Successfully uninstalled ibm_db version 0.6.0
91
+
92
+ Example:
93
+ D:\>gem install ibm_db
94
+ Bulk updating gem source index for: http://gems.rubyforge.org
95
+ Select which gem to install for your platform (i386-mswin32)
96
+ 1. ibm_db 0.6.5 (mswin32)
97
+ 2. ibm_db 0.6.5 (ruby)
98
+ 3. ibm_db 0.6.0 (mswin32)
99
+ 4. ibm_db 0.6.0 (ruby)
100
+
101
+ Running �gem install ibm_db� you are presented with two choices for each release
102
+ (mswin32 or ruby). Choose �mswin32� and the native extension (�ibm_db� driver)
103
+ binary file for Windows is installed.
104
+
105
+ TEST (simple gem install verification)
106
+ Note: IBM_DB gem requires a manual step after install:
107
+ add �ibm_db� into gems\1.8\gems\activerecord-1.15.3\lib\active_record.rb (Line 77)
108
+ D:\NewApp>dir vendor\plugins
109
+ D:\NewApp>irb
110
+ irb(main):001:0> gem 'ibm_db'
111
+ irb(main):002:0> require 'mswin32/ibm_db' // notice the [mswin32] in the library path
112
+ irb(main):003:0> IBM_DB::connect 'sample', 'db2admin', 'secret'
113
+ D:\NewApp>ruby script\console
114
+
115
+ BUILD (optionally) �ibm_db� gem from sources (ibm_db-x.x.x.tar.gz):
116
+ 1. Download source from Rubyforge
117
+ http://rubyforge.org/frs/?group_id=2361
118
+ 2. Build gem from specification (IBM_DB.gemspec)
119
+ D:\IBM_DB_Adapter\ibm_db>gem build IBM_DB.gemspec
120
+
121
+
122
+ 2. Linux and Unix platforms:
123
+ ============================
124
+
125
+ INSTALL (as Ruby gem)
126
+ To remove previous gem version (optionally):
127
+ $ gem uninstall ibm_db
128
+ Successfully uninstalled ibm_db version 0.6.0
129
+
130
+ Note: DB2 environment is required while using an arbitrary user account
131
+ (other than the DB2 install user account)
132
+ $ . /home/db2inst1/sqllib/db2profile
133
+ $ export IBM_DB_DIR=/opt/ibm/db2/V9.1
134
+ $ export IBM_DB_LIB=/opt/ibm/db2/V9.1/lib32
135
+ $ gem install ibm_db
136
+ Select which gem to install for your platform (i686-linux)
137
+ 1. ibm_db 0.6.5 (mswin32)
138
+ 2. ibm_db 0.6.5 (ruby)
139
+ 3. ibm_db 0.6.0 (ruby)
140
+ 4. ibm_db 0.6.0 (mswin32)
141
+ ...
142
+ Running �gem install ibm_db� you are presented with two choices for each release
143
+ (mswin32 or ruby). Choose �ruby� and the native extension (�ibm_db� driver) is built.
144
+ ...
145
+ > 2
146
+ Building native extensions. This could take a while...
147
+ Successfully installed ibm_db-0.6.5
148
+ Installing ri documentation for ibm_db-0.6.5...
149
+ Installing RDoc documentation for ibm_db-0.6.5...
150
+
151
+ TEST (simple gem install verification)
152
+ Note: IBM_DB gem requires a manual step after install:
153
+ add �ibm_db� into /gems/activerecord-1.15.3/lib/active_record.rb (Line 77)
154
+ $ ls -al vendor/plugins/
155
+ $ irb
156
+ irb(main):001:0> gem 'ibm_db'
157
+ irb(main):002:0> require 'ibm_db' // notice the library path (different on win32)
158
+ irb(main):003:0> IBM_DB::connect 'sample', 'db2admin', 'secret'
159
+ $ ./script/console
160
+
161
+ BUILD (optionally) �ibm_db� gem from sources (ibm_db-x.x.x.tar.gz):
162
+ 1. Download source from Rubyforge
163
+ http://rubyforge.org/frs/?group_id=2361
164
+ 2. Build gem from specification (IBM_DB.gemspec)
165
+ $ cd IBM_DB_Adapter/ibm_db
166
+ $ gem build IBM_DB.gemspec
167
+
168
+
169
+ B. Installing the IBM_DB adapter and driver as a Rails plugin
170
+ =============================================================
171
+ IBM_DB adapter and driver install as plugin provides support for IBM data servers
172
+ within the scope of a specific and individual Rails application. Rails plugins do
173
+ not offer the version management specific to Ruby gems, but does provide an
174
+ initialization mechanism which allows the IBM_DB plugin to self-insert into the
175
+ ActiveRecord's list of supported adapters: RAILS_CONNECTION_ADAPTERS. Therefore,
176
+ after installing IBM_DB as plugin in your Rails application, no manual step is required
177
+ for the Rails framework to load it.
178
+
179
+ 1. Windows platforms
180
+ =====================
181
+ Register Repository and Query:
182
+
183
+ A. Download and install Subversion (SVN) client from:
184
+ http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91
185
+ Register rubyibm project as plugin source
186
+ D:\NewApp>ruby script\plugin source svn://rubyforge.org/var/svn/rubyibm/trunk/IBM_DB_Adapter/
187
+
188
+ B. Accessing RubyForge repository through HTTP (no SVN client required) is NOT YET ENABLED
189
+ D:\NewApp>ruby script\plugin source http://rubyibm.rubyforge.org/IBM_DB_Adapter/
190
+
191
+ LIST plugin
192
+ D:\NewApp>ruby script\plugin list
193
+
194
+ INSTALL (as Rails plugin)
195
+ D:\NewApp>ruby script\plugin install ibm_db
196
+
197
+ TEST (simple plugin install verification)
198
+ Note: Make sure there's no ibm_db in gems\1.8\gems\activerecord-1.15.3\lib\active_record.rb (Line 77)
199
+ D:\NewApp>ruby script\console
200
+
201
+ 2. Linux and Unix platforms
202
+ ===========================
203
+ Register Repository and Query:
204
+
205
+ A. Ensure Subversion (SVN) client is installed or download from:
206
+ http://subversion.tigris.org/project_packages.html
207
+ Register rubyibm project as plugin source
208
+ $ ./script/plugin source svn://rubyforge.org/var/svn/rubyibm/trunk/IBM_DB_Adapter/
209
+
210
+ B. Accessing RubyForge repository through HTTP (no SVN client required) is NOT YET ENABLED
211
+ $ ./script/plugin source http://rubyibm.rubyforge.org/IBM_DB_Adapter/
212
+
213
+ LIST plugin
214
+ $ ./script/plugin list
215
+
216
+ INSTALL (as Rails plugin)
217
+ $ ./script/plugin install ibm_db
218
+
219
+ TEST (simple plugin install verification)
220
+ Note: Make sure there's no ibm_db in /gems/activerecord-1.15.3/lib/active_record.rb (Line 77)
221
+ $ ./script/console
222
+
223
+
224
+ Instructions for building and installing the IBM_DB driver from source
225
+ =======================================================================
226
+ Building the driver manually as described below is not required if any the install
227
+ alternatives above have been pursued. This manual procedure is in fact automated
228
+ on Linux and UNIX platforms by the IBM_DB gem and plugin install, but is presented
229
+ here only for reference, and also involves running the unit tests.
230
+
231
+ Prerequisites:
232
+ Install Ruby from:
233
+ http://rubyforge.org
234
+
235
+ Linux and Unix platforms:
236
+ Note: commands may vary depending on the shell used
237
+ - To setup DB2 environment while using an arbitrary user account
238
+ (other than the DB2 install user account):
239
+ Example:
240
+ $ . /home/db2inst1/sqllib/db2profile
241
+
242
+ - To configure test database:
243
+ DB2 v9.x: some IBM_DB driver tests require a UTF-8 database:
244
+ $ db2 CREATE DATABASE testdrv USING CODESET UTF-8 \
245
+ TERRITORY US COLLATE USING SYSTEM PAGESIZE 32768
246
+ DB2 v8.x: driver tests 195 and 52949 requires XML functionality
247
+ only available in DB2 v9.x
248
+
249
+ - To configure database connection parameters edit config.yaml
250
+ Example:
251
+ database: testdrv
252
+ user: db2inst1
253
+ password: password
254
+ hostname: localhost
255
+ port: 50000
256
+
257
+ - To compile and link with DB2 client libraries:
258
+ $ export IBM_DB_DIR=/opt/ibm/db2/V9.1
259
+ $ export IBM_DB_LIB=/opt/ibm/db2/V9.1/lib32
260
+
261
+ Windows platforms:
262
+ - Install Visual C++ 2003, Platform SDK (latest), .Net SDK Version 1.1 from:
263
+ http://wiki.tcl.tk/11431
264
+ - Set environment:
265
+ CALL "C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\SetEnv.Cmd"
266
+ CALL "C:\Program Files\Microsoft Visual C++ Toolkit 2003\vcvars32.bat"
267
+ SET LIB=%LIB%;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib
268
+ - To configure database connection parameters edit config.yaml
269
+
270
+ Build and Execution:
271
+ rake
272
+
273
+ Execution of tests without compilation (must have .so in ibm_db source directory):
274
+ rake onlytests
275
+
276
+ Execution of a single test inside the tests directory can be done by the following:
277
+ export SINGLE_RUBY_TEST=test_001.rb
278
+ rake
279
+
280
+
281
+ Limitations and known problems
282
+ ==============================
283
+ - ActiveRecord rename_column method is not supported for DB2 LUW, zOS and i5
284
+ - ActiveRecord remove_column method is not supported for DB2 zOS
285
+ - The following tests from the ActiveRecord 1.15.3 test suite are expected to fail
286
+ - test_limited_eager_with_multiple_order_columns
287
+ - test_limited_eager_with_order
288
+ - test_assign_ids_ignoring_blanks
289
+ - test_build_by_new_record
290
+ - test_get_ids
291
+ - test_select_limited_ids_list
292
+ - test_add_index
293
+ - The following tests from the driver test suite are expected to fail on DB2 version 8
294
+ on Linux/Unix/Windows because of missing native XML support. If you want to
295
+ make use of the native XML features in DB2, please upgrade to version 9
296
+ - test_195.rb
297
+ - test_52949.rb
298
+ - The driver returns an error when you try to insert a TIMESTAMP value into a DATE column.
299
+ To fix this, please ensure that the following configuration keyword PATCH2=58 is set
300
+ in the COMMON section of your DB2 CLI initialization file (db2cli.ini):
301
+ - set: db2 UPDATE CLI CFG FOR SECTION COMMON USING PATCH2 58
302
+ - verify: db2 GET CLI CFG FOR SECTION COMMON
303
+ Please refer to http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.apdv.cli.doc/doc/c0007882.htm
304
+ for more information.
305
+ - The behaviour of ActiveRecord::Base.find(:first) without an :order attribute can be unpredictable.
306
+ The first record (i.e. the record with the minimum id) may be not be retrieved. In a relational model,
307
+ the order of the rows returned is unpredictable and independent of the order of insertion.
308
+ This issue may be addressed in a future release.
309
+ - Rails applications on DB2 9 require the APPLHEAPSZ database configuration parameter to be
310
+ set to or above 1024. You will need to set this parameter for each database for which you will be
311
+ running DB2 on Rails applications. Following is the command syntax for updating the
312
+ applheapsz parameter:
313
+ > db2 update db cfg for <database_name> using APPLHEAPSZ 1024
314
+ To enable this parameter, you need to restart your DB2 instance.
315
+ - IBM_DB is not supported on JRuby. As stated in the JRuby Wiki, "Basics of Getting JRuby Running":
316
+ 'You may install other gems, but keep in mind that libraries with C extension dependencies
317
+ will not work in JRuby.' http://www.headius.com/jrubywiki/index.php/Getting_Started
318
+ The IBM_DB adapter relies on IBM_DB driver (C extension) and the IBM Driver for ODBC and
319
+ CLI to access databases on IBM data servers. Alternatively, you can either use the regular C
320
+ implementation of Ruby, or use ActiveRecord-JDBC adapter to access databases.
321
+
322
+ To Do
323
+ ====
324
+ - Support Informix Dynamic Server 11.10
325
+ - Support ActiveRecord remove_column method for DB2 zOS version 9
326
+
327
+
328
+ Feedback
329
+ ========
330
+ Your feedback is very much appreciated and expected through Rubyforge:
331
+ - rubyibm project: http://rubyforge.org/projects/rubyibm/
332
+ - rubyibm forum: http://rubyforge.org/forum/?group_id=2361
333
+ - rubyibm bug reports: http://rubyforge.org/tracker/?group_id=2361
231
334
  - IBM_DB developers: rubyibm-developers@rubyforge.org
@@ -10,20 +10,25 @@ require 'active_record/connection_adapters/abstract_adapter'
10
10
 
11
11
  module ActiveRecord
12
12
  class Base
13
- # Method required to handle LOBs and XML fields. An after save callback checks if a marker
14
- # has been inserted by the calling insert or update method, and if so it proceeds to update that record
15
- # with the real large object through query binding.
13
+ # Method required to handle LOBs and XML fields.
14
+ # An after save callback checks if a marker has been inserted through
15
+ # the insert or update, and then proceeds to update that record with
16
+ # the actual large object through a prepared statement (param binding).
16
17
  after_save :handle_lobs
17
18
  def handle_lobs()
18
19
  if connection.kind_of?(ConnectionAdapters::IBM_DBAdapter)
19
20
  # Checks that the insert or update had at least a BLOB, CLOB or XML field
20
- if connection.sql =~ /BLOB\('(.*)'\)/i || connection.sql =~ /@@@IBMTEXT@@@/i || connection.sql =~ /@@@IBMXML@@@/i
21
+ if connection.sql =~ /BLOB\('(.*)'\)/i ||
22
+ connection.sql =~ /@@@IBMTEXT@@@/i ||
23
+ connection.sql =~ /@@@IBMXML@@@/i
21
24
  update_query = "UPDATE #{self.class.table_name} SET ("
22
25
  counter = 0
23
26
  values = []
24
27
  params = []
25
28
  # Selects only binary, text and xml columns
26
- self.class.columns.select{|col| col.type == :binary || col.type == :text || col.type == :xml}.each do |col|
29
+ self.class.columns.select{|col| col.type == :binary ||
30
+ col.type == :text ||
31
+ col.type == :xml}.each do |col|
27
32
  # Adds the selected columns to the query
28
33
  if counter == 0
29
34
  update_query << "#{col.name}"
@@ -31,8 +36,11 @@ module ActiveRecord
31
36
  update_query << ",#{col.name}"
32
37
  end
33
38
 
34
- # Add a '?' for the parameter or a NULL if the value is nil or empty (except for a CLOB field where '' can be a value)
35
- if self[col.name].nil? || self[col.name] == {} || (self[col.name] == '' && col.type != :text)
39
+ # Add a '?' for the parameter or a NULL if the value is nil or empty
40
+ # (except for a CLOB field where '' can be a value)
41
+ if self[col.name].nil? ||
42
+ self[col.name] == {} ||
43
+ (self[col.name] == '' && col.type != :text)
36
44
  params << 'NULL'
37
45
  else
38
46
  values << self[col.name]
@@ -90,7 +98,8 @@ module ActiveRecord
90
98
  # Retrieves database user credentials from the +config+ hash
91
99
  # or raises ArgumentError in case of failure.
92
100
  if !config.has_key?(:username) || !config.has_key?(:password)
93
- raise ArgumentError, "Missing argument(s): Database configuration #{config} requires credentials: username and password"
101
+ raise ArgumentError, "Missing argument(s): Database configuration #{config} \
102
+ requires credentials: username and password"
94
103
  else
95
104
  username = config[:username].to_s
96
105
  password = config[:password].to_s
@@ -121,9 +130,13 @@ module ActiveRecord
121
130
  # A net address connection requires a port. If no port has been specified, 50000 is used by default
122
131
  port = config[:port] || 50000
123
132
  # Connects to the database using the database, host, port, username and password specified
124
- connection = IBM_DB::connect "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=#{database};HOSTNAME=#{host};\
125
- PORT=#{port};PROTOCOL=TCPIP;UID=#{username};PWD=#{password};", '', '', conn_options
126
-
133
+ connection = IBM_DB::connect "DRIVER={IBM DB2 ODBC DRIVER};\
134
+ DATABASE=#{database};\
135
+ HOSTNAME=#{host};\
136
+ PORT=#{port};\
137
+ PROTOCOL=TCPIP;\
138
+ UID=#{username};\
139
+ PWD=#{password};", '', '', conn_options
127
140
  else
128
141
  # No host implies a local catalog-based connection: +database+ represents catalog alias
129
142
  connection = IBM_DB::connect( database, username, password, conn_options )
@@ -195,6 +208,40 @@ module ActiveRecord
195
208
  end # method simplified_type
196
209
  end #class IBM_DBColumn
197
210
 
211
+ class TableDefinition
212
+ # Overrides the abstract adapter in order to handle
213
+ # the DEFAULT option for the native XML datat type
214
+ def column(name, type, options ={})
215
+ # construct a column definition where @base is adaptor instance
216
+ column = ColumnDefinition.new(@base, name, type)
217
+ column.null = options[:null] # if options[:null]
218
+
219
+ # DB2 does not accept DEFAULT NULL option for XML in table create
220
+ unless type.to_s == 'xml'
221
+ column.default = options[:default] # if options[:default]
222
+ else
223
+ unless options[:default]
224
+ # override column object method to not append DEFAULT NULL
225
+ def column.to_s
226
+ "#{base.quote_column_name(name)} #{type}"
227
+ end
228
+ end
229
+ end
230
+ column.scale = options[:scale] if options[:scale]
231
+ column.precision = options[:precision] if options[:precision]
232
+ # append column's limit option and yield native limits
233
+ if options[:limit]
234
+ column.limit = options[:limit]
235
+ elsif @base.native_database_types[type.to_sym]
236
+ column.limit = @base.native_database_types[type.to_sym][:limit]
237
+ end
238
+
239
+ unless @columns.include? column
240
+ @columns << column
241
+ end
242
+ return self
243
+ end
244
+ end
198
245
 
199
246
  # The IBM_DB Adapter requires the native Ruby driver (ibm_db)
200
247
  # for IBM data servers (ibm_db.so).
@@ -252,23 +299,19 @@ module ActiveRecord
252
299
  if @connection
253
300
  server_info = IBM_DB::server_info( @connection )
254
301
  case server_info.DBMS_NAME
255
- # DB2 on Linux, Unix and Windows (LUW)
256
- when /DB2\//i
257
- @servertype = IBM_DB2_LUW.new(@connection, self)
258
- # DB2 on zOS
259
- #
260
- when /DB2/i
302
+ when /DB2\//i # DB2 for Linux, Unix and Windows (LUW)
303
+ @servertype = IBM_DB2_LUW.new(self)
304
+ when /DB2/i # DB2 for zOS
261
305
  case server_info.DBMS_VER
262
- when /09/
263
- @servertype = IBM_DB2_ZOS.new(@connection, self)
264
- when /08/
265
- @servertype = IBM_DB2_ZOS_8.new(@connection, self)
266
- else
306
+ when /09/ # DB2 for zOS version 9
307
+ @servertype = IBM_DB2_ZOS.new(self)
308
+ when /08/ # DB2 for zOS version 8
309
+ @servertype = IBM_DB2_ZOS_8.new(self)
310
+ else # DB2 for zOS version 7
267
311
  raise "Only DB2 z/OS version 8 and above are currently supported"
268
312
  end
269
- # DB2 on i5
270
- when /AS/i
271
- @servertype = IBM_DB2_I5.new(@connection, self)
313
+ when /AS/i # DB2 for i5 (iSeries)
314
+ @servertype = IBM_DB2_I5.new(self)
272
315
  end
273
316
  end
274
317
  # Executes the +set schema+ statement using the schema identifier provided
@@ -354,12 +397,17 @@ module ActiveRecord
354
397
  # If the type of connection is net based
355
398
  if @host
356
399
  # Connects and assigns the resulting IBM_DB::Connection to the +@connection+ instance variable
357
- @connection = IBM_DB::connect "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=#{@database};HOSTNAME=#{@host};\
358
- PORT=#{@port};PROTOCOL=TCPIP;UID=#{@username};PWD=#{@password};", '', '', @conn_options
400
+ @connection = IBM_DB::connect("DRIVER={IBM DB2 ODBC DRIVER};\
401
+ DATABASE=#{@database};\
402
+ HOSTNAME=#{@host};\
403
+ PORT=#{@port};\
404
+ PROTOCOL=TCPIP;\
405
+ UID=#{@username};\
406
+ PWD=#{@password};", '', '', @conn_options)
359
407
  else
360
408
  # Connects to the database using the local alias (@database)
361
409
  # and assigns the connection object (IBM_DB::Connection) to @connection
362
- @connection = IBM_DB::connect @database, @username, @password, @conn_options
410
+ @connection = IBM_DB::connect(@database, @username, @password, @conn_options)
363
411
  end
364
412
  # Sets the schema if different from default (username)
365
413
  if @schema && @schema != @username
@@ -390,18 +438,19 @@ module ActiveRecord
390
438
  def create_table(name, options = {})
391
439
  @servertype.setup_for_lob_table
392
440
  super
393
- @servertype.create_index_after_table(name, self)
441
+ @servertype.create_index_after_table(name)
394
442
  end
395
443
 
396
444
  # Returns an array of hashes with the column names as keys and
397
- # column values as values. +sql+ is the select query, and +name+ is an optional description for logging
445
+ # column values as values. +sql+ is the select query,
446
+ # and +name+ is an optional description for logging
398
447
  def select_all(sql, name = nil)
399
448
  # Replaces {"= NULL" with " IS NULL"} OR {"IN (NULL)" with " IS NULL"}
400
449
  sql.gsub!( /(=\s*NULL|IN\s*\(NULL\))/i, " IS NULL" )
401
450
 
402
451
  results = []
403
- # Invokes the method +execute+ in order to log and execute the sql instructions
404
- # and get a IBM_DB::Statement from which is possible to fetch the results
452
+ # Invokes the method +execute+ in order to log and execute the SQL
453
+ # IBM_DB::Statement is returned from which results can be fetched
405
454
  if stmt = execute(sql, name)
406
455
  begin
407
456
  @servertype.select_all(sql, name, stmt, results)
@@ -440,7 +489,6 @@ module ActiveRecord
440
489
  # Executes and logs +sql+ commands and
441
490
  # returns a +IBM_DB::Statement+ object.
442
491
  def execute(sql, name = nil)
443
- sql.gsub!( /(\s*xml DEFAULT NULL)/i, " xml NOT NULL" )
444
492
  # Logs and execute the sql instructions.
445
493
  # The +log+ method is defined in the parent class +AbstractAdapter+
446
494
  log(sql, name) do
@@ -525,8 +573,10 @@ module ActiveRecord
525
573
  # If there is a non-zero limit
526
574
  else
527
575
  offset = options[:offset]
528
- # If an offset is specified builds the query with offset and limit, oterwise retrieves only the first +limit+ rows
529
- offset ? sql = query_offset_limit(sql, offset, limit) : sql << " FETCH FIRST #{limit} ROWS ONLY"
576
+ # If an offset is specified builds the query with offset and limit,
577
+ # otherwise retrieves only the first +limit+ rows
578
+ offset ? sql = query_offset_limit(sql, offset, limit) \
579
+ : sql << " FETCH FIRST #{limit} ROWS ONLY"
530
580
  end
531
581
  end
532
582
  # Returns the sql query in any case
@@ -658,6 +708,8 @@ module ActiveRecord
658
708
  # strip off limits on data types not supporting them
659
709
  if [:integer, :double, :date, :time, :timestamp, :xml].include? type
660
710
  return type.to_s
711
+ elsif type.to_sym == :boolean
712
+ return "smallint"
661
713
  else
662
714
  return super
663
715
  end
@@ -747,12 +799,20 @@ module ActiveRecord
747
799
  # Assigns the field length (size) for the column
748
800
  column_length = col["column_size"]
749
801
  column_scale = col["decimal_digits"]
750
- # The initializer of the class Column, requires the +column_length+ to be declared between brackets after
751
- # the datatype(e.g VARCHAR(50)) for :string and :text types. If it's a "for bit data" field it does a subsitution in place, if not
802
+ # The initializer of the class Column, requires the +column_length+ to be declared
803
+ # between brackets after the datatype(e.g VARCHAR(50)) for :string and :text types.
804
+ # If it's a "for bit data" field it does a subsitution in place, if not
752
805
  # it appends the (column_length) string on the supported data types
753
- unless column_length.nil? || column_length == '' || column_type.sub!(/ \(\) for bit data/i,"(#{column_length}) FOR BIT DATA") || !column_type =~ /char|lob|graphic/i
806
+ unless column_length.nil? ||
807
+ column_length == '' ||
808
+ column_type.sub!(/ \(\) for bit data/i,"(#{column_length}) FOR BIT DATA") ||
809
+ !column_type =~ /char|lob|graphic/i
754
810
  if column_type =~ /decimal/i
755
811
  column_type << "(#{column_length},#{column_scale})"
812
+ elsif column_type =~ /smallint/i
813
+ column_type << "" # override the native column size limit [5]
814
+ elsif column_type =~ /xml/i
815
+ column_type << "" # override the native column size limit [0]
756
816
  else
757
817
  column_type << "(#{column_length})"
758
818
  end
@@ -823,12 +883,7 @@ module ActiveRecord
823
883
  # change_column_default(:accounts, :authorized, 1)
824
884
  # Method overriden to satisfy IBM data servers syntax.
825
885
  def change_column_default(table_name, column_name, default)
826
- # SQL statement which alters column's default value
827
- change_column_sql = "ALTER TABLE #{table_name} ALTER COLUMN #{column_name} SET WITH DEFAULT #{quote(default)}"
828
- stmt = execute(change_column_sql)
829
- # Ensures to free the resources associated with the statement
830
- ensure
831
- IBM_DB::free_result stmt if stmt
886
+ @servertype.change_column_default(table_name, column_name, default)
832
887
  end
833
888
 
834
889
  # Adds a new index to the table. +column_name+ can be a single Symbol, or
@@ -906,15 +961,14 @@ module ActiveRecord
906
961
 
907
962
  # This class contains common code across DB's (DB2 LUW, zOS and i5)
908
963
  class IBM_DataServer
909
- def initialize(connection, caller)
910
- @connection = connection
911
- @caller = caller
964
+ def initialize(adapter)
965
+ @adapter = adapter
912
966
  end
913
967
 
914
968
  def last_generated_id
915
969
  end
916
970
 
917
- def create_index_after_table (table_name, caller)
971
+ def create_index_after_table (table_name)
918
972
  end
919
973
 
920
974
  def setup_for_lob_table ()
@@ -931,12 +985,14 @@ module ActiveRecord
931
985
  # and by the DB2 for i5 data servers
932
986
  def remove_column(table_name, column_name)
933
987
  begin
934
- @caller.execute "ALTER TABLE #{table_name} DROP #{column_name}"
988
+ @adapter.execute "ALTER TABLE #{table_name} DROP #{column_name}"
935
989
  reorg_table(table_name)
936
990
  rescue StandardError => exec_err
937
991
  # Provide details on the current XML columns support
938
992
  if exec_err.message.include?('SQLCODE=-1242') && exec_err.message.include?('42997')
939
- raise StatementInvalid, "A column that is part of a table containing an XML column cannot be dropped. To remove the column, the table must be dropped and recreated without the #{column_name} column: #{exec_err}"
993
+ raise StatementInvalid,
994
+ "A column that is part of a table containing an XML column cannot be dropped. \
995
+ To remove the column, the table must be dropped and recreated without the #{column_name} column: #{exec_err}"
940
996
  else
941
997
  raise
942
998
  end
@@ -944,15 +1000,12 @@ module ActiveRecord
944
1000
  end
945
1001
 
946
1002
  def set_schema(schema)
947
- @caller.execute("SET SCHEMA #{schema}")
1003
+ @adapter.execute("SET SCHEMA #{schema}")
948
1004
  end
949
1005
 
950
1006
  def select_all(sql, name, stmt, results)
951
1007
  end
952
1008
 
953
- def execute(sql, name)
954
- end
955
-
956
1009
  def query_offset_limit(sql, offset, limit)
957
1010
  end
958
1011
 
@@ -970,13 +1023,12 @@ module ActiveRecord
970
1023
  return "INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 100) PRIMARY KEY"
971
1024
  end
972
1025
 
973
- # Method that returns the last automatically generated ID
974
- # on the given +@connection+. This method is required by the +insert+
975
- # method
1026
+ # Returns the last automatically generated ID.
1027
+ # This method is required by the +insert+ method
976
1028
  def last_generated_id
977
1029
  # Queries the db to obtain the last ID that was automatically generated
978
1030
  sql = "SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1"
979
- stmt = IBM_DB::exec(@connection, sql)
1031
+ stmt = IBM_DB::exec(@adapter.connection, sql)
980
1032
  # Fetches the only record available (containing the last id)
981
1033
  IBM_DB::fetch_row(stmt)
982
1034
  # Retrieves and returns the result of the query with the last id.
@@ -984,22 +1036,33 @@ module ActiveRecord
984
1036
  end
985
1037
 
986
1038
  def change_column(table_name, column_name, type, options)
987
- data_type = @caller.type_to_sql(type, options[:limit], options[:precision], options[:scale])
1039
+ data_type = @adapter.type_to_sql(type, options[:limit], options[:precision], options[:scale])
988
1040
  begin
989
- @caller.execute "ALTER TABLE #{table_name} ALTER #{column_name} SET DATA TYPE #{data_type}"
1041
+ execute "ALTER TABLE #{table_name} ALTER #{column_name} SET DATA TYPE #{data_type}"
990
1042
  rescue StandardError => exec_err
991
1043
  if exec_err.message.include?('SQLCODE=-190')
992
- raise StatementInvalid, "Please consult documentation for compatible data types while changing column datatype. The column datatype change to [#{data_type}] is not supported by this data server: #{exec_err}"
1044
+ raise StatementInvalid,
1045
+ "Please consult documentation for compatible data types while changing column datatype. \
1046
+ The column datatype change to [#{data_type}] is not supported by this data server: #{exec_err}"
993
1047
  else
994
1048
  raise
995
1049
  end
996
1050
  end
997
1051
  reorg_table(table_name)
998
1052
  if !options[:default].nil?
999
- @caller.change_column_default(table_name, column_name, options[:default])
1053
+ change_column_default(table_name, column_name, options[:default])
1000
1054
  end
1001
1055
  end
1002
1056
 
1057
+ def change_column_default(table_name, column_name, default)
1058
+ # SQL statement which alters column's default value
1059
+ change_column_sql = "ALTER TABLE #{table_name} ALTER COLUMN #{column_name} \
1060
+ SET WITH DEFAULT #{@adapter.quote(default)}"
1061
+ stmt = execute(change_column_sql)
1062
+ ensure
1063
+ IBM_DB::free_result stmt if stmt
1064
+ end
1065
+
1003
1066
  # Fetches all the results available. IBM_DB::fetch_assoc(stmt) returns
1004
1067
  # an hash for each single record.
1005
1068
  # The loop stops when there aren't any more valid records to fetch
@@ -1057,13 +1120,14 @@ module ActiveRecord
1057
1120
  @limit = nil
1058
1121
  end
1059
1122
 
1060
- def execute(sql, name)
1123
+ def execute(sql, name = nil)
1061
1124
  # Check if there is a limit and/or an offset
1062
1125
  # If so then make sure and use a static cursor type
1063
1126
  if (!@offset.nil? && @offset >= 0) || (!@limit.nil? && @limit > 0)
1064
1127
  begin
1065
1128
  # Set the cursor type to static so we can later utilize the offset and limit correctly
1066
- if stmt = IBM_DB::exec(@connection, sql, {IBM_DB::SQL_ATTR_CURSOR_TYPE => IBM_DB::SQL_CURSOR_STATIC})
1129
+ if stmt = IBM_DB::exec(@adapter.connection, sql,
1130
+ {IBM_DB::SQL_ATTR_CURSOR_TYPE => IBM_DB::SQL_CURSOR_STATIC})
1067
1131
  stmt # Return the statement object
1068
1132
  else
1069
1133
  raise StatementInvalid, IBM_DB::stmt_errormsg
@@ -1078,7 +1142,7 @@ module ActiveRecord
1078
1142
  end
1079
1143
  else
1080
1144
  begin
1081
- if stmt = IBM_DB::exec(@connection, sql)
1145
+ if stmt = IBM_DB::exec(@adapter.connection, sql)
1082
1146
  stmt # Return the statement object
1083
1147
  else
1084
1148
  raise StatementInvalid, IBM_DB::stmt_errormsg
@@ -1103,7 +1167,7 @@ module ActiveRecord
1103
1167
  class IBM_DB2_LUW < IBM_DB2
1104
1168
  # Reorganizes the table for column changes
1105
1169
  def reorg_table(table_name)
1106
- @caller.execute("CALL ADMIN_CMD('REORG TABLE #{table_name}')")
1170
+ execute("CALL ADMIN_CMD('REORG TABLE #{table_name}')")
1107
1171
  end
1108
1172
 
1109
1173
  def select_all(sql, name, stmt, results)
@@ -1116,9 +1180,9 @@ module ActiveRecord
1116
1180
  end
1117
1181
  end
1118
1182
 
1119
- def execute(sql, name)
1183
+ def execute(sql, name = nil)
1120
1184
  begin
1121
- if stmt = IBM_DB::exec(@connection, sql)
1185
+ if stmt = IBM_DB::exec(@adapter.connection, sql)
1122
1186
  stmt # Return the statement object
1123
1187
  else
1124
1188
  raise StatementInvalid, IBM_DB::stmt_errormsg
@@ -1167,21 +1231,29 @@ module ActiveRecord
1167
1231
 
1168
1232
  class IBM_DB2_ZOS < IBM_DB2
1169
1233
  # since v9 doesn't need, suggest putting it in HostedDataServer?
1170
- def create_index_after_table(table_name, caller)
1171
- caller.add_index(table_name, "id", :unique => true)
1234
+ def create_index_after_table(table_name)
1235
+ @adapter.add_index(table_name, "id", :unique => true)
1172
1236
  end
1173
1237
 
1174
1238
  def remove_column(table_name, column_name)
1175
- raise NotImplementedError, "remove_column is not supported by the DB2 for zOS data server"
1239
+ raise NotImplementedError,
1240
+ "remove_column is not supported by the DB2 for zOS data server"
1176
1241
  end
1177
-
1178
- # DB2 z/OS only allows a "null" or an empty binary string
1179
- # as a default for a BLOB column
1180
- # if value is not empty or equivalent to the string "null",
1181
- # the server will complain
1242
+
1243
+ # DB2 z/OS only allows NULL or "" (empty) string as DEFAULT value for a BLOB column.
1244
+ # For non-empty string and non-NULL values, the server returns error
1182
1245
  def set_blob_default(value)
1183
1246
  "#{value}"
1184
1247
  end
1248
+
1249
+ def change_column_default(table_name, column_name, default)
1250
+ unless default
1251
+ raise NotImplementedError,
1252
+ "DB2 for zOS data server version 9 does not support changing the column default to NULL"
1253
+ else
1254
+ super
1255
+ end
1256
+ end
1185
1257
  end # class IBM_DB2_ZOS
1186
1258
 
1187
1259
  class IBM_DB2_ZOS_8 < IBM_DB2_ZOS
@@ -1189,7 +1261,7 @@ module ActiveRecord
1189
1261
  # Setting the SQLID on z/OS will also update the CURRENT SCHEMA
1190
1262
  # special register, but not vice versa
1191
1263
  def set_schema(schema)
1192
- @caller.execute("SET CURRENT SQLID ='#{schema.upcase}'")
1264
+ execute("SET CURRENT SQLID ='#{schema.upcase}'")
1193
1265
  end
1194
1266
 
1195
1267
  # This call is needed on DB2 z/OS v8 for the creation of tables
@@ -1197,7 +1269,12 @@ module ActiveRecord
1197
1269
  # DB2 creates LOB table spaces, auxiliary tables, and indexes on auxiliary
1198
1270
  # tables for LOB columns.
1199
1271
  def setup_for_lob_table()
1200
- @caller.execute "SET CURRENT RULES = 'STD'"
1272
+ execute "SET CURRENT RULES = 'STD'"
1273
+ end
1274
+
1275
+ def change_column_default(table_name, column_name, default)
1276
+ raise NotImplementedError,
1277
+ "DB2 for zOS data server version 8 does not support changing the column default"
1201
1278
  end
1202
1279
  end # class IBM_DB2_ZOS_8
1203
1280
 
@@ -185,10 +185,10 @@ CREATE TABLE binaries (
185
185
  );
186
186
  CREATE UNIQUE INDEX binaries_id_idx ON
187
187
  binaries (id);
188
- --CREATE LOB TABLESPACE datalob;
189
- --CREATE AUXILIARY TABLE data_aux IN datalob
190
- --STORES binaries COLUMN data;
191
- --CREATE UNIQUE INDEX lob_data_idx ON data_aux;
188
+ CREATE LOB TABLESPACE datalob;
189
+ CREATE AUXILIARY TABLE data_aux IN datalob
190
+ STORES binaries COLUMN data;
191
+ CREATE UNIQUE INDEX lob_data_idx ON data_aux;
192
192
 
193
193
  CREATE TABLE computers (
194
194
  id INT GENERATED BY DEFAULT AS IDENTITY (START WITH 100),
@@ -140,6 +140,7 @@ if ActiveRecord::Base.connection.supports_migrations?
140
140
  clasz.connection.create_table clasz.table_name do |t|
141
141
  t.column "test_varchar", :string, :limit => 10
142
142
  t.column "test_integer", :integer, :limit => 5
143
+ t.column "test_boolean", :boolean, :limit => 5
143
144
  t.column "test_double", :double, :limit => 10
144
145
  t.column "test_date", :date, :limit => 10
145
146
  t.column "test_time", :time, :limit => 10
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: ibm_db
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.6.0
7
- date: 2007-04-30 00:00:00 -04:00
6
+ version: 0.6.5
7
+ date: 2007-05-14 00:00:00 -04:00
8
8
  summary: "Rails Driver and Adapter for IBM Data Servers: {LUW, zOS, i5, IDS}"
9
9
  require_paths:
10
10
  - lib
@@ -31,9 +31,10 @@ authors:
31
31
  files:
32
32
  - CHANGES
33
33
  - ext
34
- - ext/ruby_ibm_db.h
35
34
  - ext/extconf.rb
36
35
  - ext/ibm_db.c
36
+ - ext/ruby_ibm_db.h
37
+ - init.rb
37
38
  - lib
38
39
  - lib/active_record
39
40
  - lib/active_record/connection_adapters
@@ -46,12 +47,15 @@ files:
46
47
  - LICENSE
47
48
  - MANIFEST
48
49
  - README
49
- - init.rb
50
50
  - test
51
+ - test/adapter_test.rb
52
+ - test/associations
53
+ - test/associations/eager_test.rb
54
+ - test/associations_test.rb
55
+ - test/base_test.rb
51
56
  - test/connections
52
57
  - test/connections/native_ibm_db
53
58
  - test/connections/native_ibm_db/connection.rb
54
- - test/base_test.rb
55
59
  - test/fixtures
56
60
  - test/fixtures/db_definitions
57
61
  - test/fixtures/db_definitions/i5
@@ -70,13 +74,9 @@ files:
70
74
  - test/fixtures/db_definitions/zOS/ibm_db.sql
71
75
  - test/fixtures/db_definitions/zOS/ibm_db2.drop.sql
72
76
  - test/fixtures/db_definitions/zOS/ibm_db2.sql
73
- - test/migration_test.rb
74
77
  - test/ibm_db_test.rb
75
78
  - test/locking_test.rb
76
- - test/associations
77
- - test/associations/eager_test.rb
78
- - test/adapter_test.rb
79
- - test/associations_test.rb
79
+ - test/migration_test.rb
80
80
  test_files:
81
81
  - test/ibm_db_test.rb
82
82
  rdoc_options: []