ibm_db 2.5.27-x86-mingw32 → 2.6.0-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +5 -0
  3. data/MANIFEST +14 -14
  4. data/README +225 -225
  5. data/ext/Makefile.nt32 +181 -181
  6. data/ext/Makefile.nt32.191 +212 -212
  7. data/ext/extconf.rb +264 -264
  8. data/ext/extconf_MacOS.rb +269 -0
  9. data/ext/ibm_db.c +1 -1
  10. data/ext/ruby_ibm_db.h +241 -241
  11. data/init.rb +41 -41
  12. data/lib/IBM_DB.rb +27 -3
  13. data/lib/active_record/connection_adapters/ibm_db_adapter.rb +3290 -3290
  14. data/lib/active_record/connection_adapters/ibmdb_adapter.rb +1 -1
  15. data/lib/active_record/vendor/db2-i5-zOS.yaml +328 -328
  16. data/lib/mswin32/ibm_db.rb +104 -20
  17. data/lib/mswin32/rb19x/ibm_db.so +0 -0
  18. data/lib/mswin32/rb21x/i386/ibm_db.so +0 -0
  19. data/lib/mswin32/rb22x/i386/ibm_db.so +0 -0
  20. data/lib/mswin32/rb2x/i386/ibm_db.so +0 -0
  21. data/test/cases/adapter_test.rb +207 -207
  22. data/test/cases/associations/belongs_to_associations_test.rb +711 -711
  23. data/test/cases/associations/cascaded_eager_loading_test.rb +181 -181
  24. data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +851 -851
  25. data/test/cases/associations/join_model_test.rb +743 -743
  26. data/test/cases/attribute_methods_test.rb +822 -822
  27. data/test/cases/base_test.rb +2133 -2133
  28. data/test/cases/calculations_test.rb +482 -482
  29. data/test/cases/migration_test.rb +2408 -2408
  30. data/test/cases/persistence_test.rb +642 -642
  31. data/test/cases/query_cache_test.rb +257 -257
  32. data/test/cases/relations_test.rb +1182 -1182
  33. data/test/cases/schema_dumper_test.rb +256 -256
  34. data/test/cases/transaction_callbacks_test.rb +300 -300
  35. data/test/cases/validations/uniqueness_validation_test.rb +299 -299
  36. data/test/cases/xml_serialization_test.rb +408 -408
  37. data/test/config.yml +154 -154
  38. data/test/connections/native_ibm_db/connection.rb +43 -43
  39. data/test/ibm_db_test.rb +24 -24
  40. data/test/models/warehouse_thing.rb +4 -4
  41. data/test/schema/schema.rb +751 -751
  42. metadata +31 -16
@@ -0,0 +1,269 @@
1
+ #!/usr/bin/env ruby
2
+ require 'net/http'
3
+ require 'open-uri'
4
+ require 'rubygems/package'
5
+ require 'zlib'
6
+ require 'fileutils'
7
+
8
+
9
+ # +----------------------------------------------------------------------+
10
+ # | Licensed Materials - Property of IBM |
11
+ # | |
12
+ # | (C) Copyright IBM Corporation 2006 - 2015 |
13
+ # +----------------------------------------------------------------------+
14
+
15
+ TAR_LONGLINK = '././@LongLink'
16
+
17
+ WIN = RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
18
+
19
+ # use ENV['IBM_DB_HOME'] or latest db2 you can find
20
+ IBM_DB_HOME = ENV['IBM_DB_HOME']
21
+
22
+ machine_bits = ['ibm'].pack('p').size * 8
23
+
24
+ is64Bit = true
25
+
26
+ if machine_bits == 64
27
+ is64Bit = true
28
+ puts "Detected 64-bit Ruby\n "
29
+ else
30
+ is64Bit = false
31
+ puts "Detected 32-bit Ruby\n "
32
+ end
33
+
34
+ module Kernel
35
+ def suppress_warnings
36
+ origVerbosity = $VERBOSE
37
+ $VERBOSE = nil
38
+ result = yield
39
+ $VERBOSE = origVerbosity
40
+ return result
41
+ end
42
+ end
43
+
44
+ DOWNLOADLINK = ''
45
+
46
+ if(RUBY_PLATFORM =~ /aix/i)
47
+ #AIX
48
+ if(is64Bit)
49
+ puts "Detected platform - aix 64"
50
+ DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/aix64_odbc_cli.tar.gz"
51
+ else
52
+ puts "Detected platform - aix 32"
53
+ DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/aix32_odbc_cli.tar.gz"
54
+ end
55
+ elsif (RUBY_PLATFORM =~ /powerpc/ || RUBY_PLATFORM =~ /ppc/)
56
+ #PPC
57
+ if(is64Bit)
58
+ puts "Detected platform - ppc linux 64"
59
+ DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ppc64_odbc_cli.tar.gz"
60
+ else
61
+ puts "Detected platform - ppc linux 64"
62
+ DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/ppc32_odbc_cli.tar.gz"
63
+ end
64
+ elsif (RUBY_PLATFORM =~ /linux/)
65
+ #x86
66
+ if(is64Bit)
67
+ puts "Detected platform - linux x86 64"
68
+ DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz"
69
+ else
70
+ puts "Detected platform - linux 32"
71
+ DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxia32_odbc_cli.tar.gz"
72
+ end
73
+ elsif (RUBY_PLATFORM =~ /sparc/i)
74
+ #Solaris
75
+ if(is64Bit)
76
+ puts "Detected platform - sun sparc64"
77
+ DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/sun64_odbc_cli.tar.gz"
78
+ else
79
+ puts "Detected platform - sun sparc32"
80
+ DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/sun32_odbc_cli.tar.gz"
81
+ end
82
+ elsif (RUBY_PLATFORM =~ /solaris/i)
83
+ if(is64Bit)
84
+ puts "Detected platform - sun amd64"
85
+ DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/sunamd64_odbc_cli.tar.gz"
86
+ else
87
+ puts "Detected platform - sun amd32"
88
+ DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/sunamd32_odbc_cli.tar.gz"
89
+ end
90
+ elsif (RUBY_PLATFORM =~ /darwin/i)
91
+ if(is64Bit)
92
+ puts "Detected platform - MacOS darwin64"
93
+ DOWNLOADLINK = "http://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/macos64_odbc_cli.tar.gz"
94
+ else
95
+ puts "Mac OS 32 bit not supported. Please use an x64 architecture."
96
+ end
97
+ end
98
+
99
+ def downloadCLIPackage(destination, link = nil)
100
+ if(link.nil?)
101
+ downloadLink = DOWNLOADLINK
102
+ else
103
+ downloadLink = link
104
+ end
105
+
106
+ uri = URI.parse(downloadLink)
107
+ filename = "#{destination}/clidriver.tar.gz"
108
+
109
+ headers = {
110
+ 'Accept-Encoding' => 'identity',
111
+ }
112
+
113
+ request = Net::HTTP::Get.new(uri.request_uri, headers)
114
+ http = Net::HTTP.new(uri.host, uri.port)
115
+ response = http.request(request)
116
+
117
+ f = open(filename, 'wb')
118
+ f.write(response.body)
119
+ f.close()
120
+
121
+ filename
122
+ end
123
+
124
+ def untarCLIPackage(archive,destination)
125
+ Gem::Package::TarReader.new( Zlib::GzipReader.open(archive) ) do |tar|
126
+ tar.each do |entry|
127
+ file = nil
128
+ if entry.full_name == $TAR_LONGLINK
129
+ file = File.join destination, entry.read.strip
130
+ next
131
+ end
132
+ file ||= File.join destination, entry.full_name
133
+ if entry.directory?
134
+ File.delete file if File.file? file
135
+ FileUtils.mkdir_p file, :mode => entry.header.mode, :verbose => false
136
+ elsif entry.file?
137
+ FileUtils.rm_rf file if File.directory? file
138
+ File.open file, "wb" do |f|
139
+ f.print entry.read
140
+ end
141
+ FileUtils.chmod entry.header.mode, file, :verbose => false
142
+ elsif entry.header.typeflag == '2' #Symlink!
143
+ File.symlink entry.header.linkname, file
144
+ end
145
+ end
146
+ end
147
+ end
148
+
149
+ if(IBM_DB_HOME == nil || IBM_DB_HOME == '')
150
+ IBM_DB_INCLUDE = ENV['IBM_DB_INCLUDE']
151
+ IBM_DB_LIB = ENV['IBM_DB_LIB']
152
+
153
+ if( ( (IBM_DB_INCLUDE.nil?) || (IBM_DB_LIB.nil?) ) ||
154
+ ( IBM_DB_INCLUDE == '' || IBM_DB_LIB == '' )
155
+ )
156
+ if(!DOWNLOADLINK.nil? && !DOWNLOADLINK.empty?)
157
+ puts "Environment variable IBM_DB_HOME is not set. Downloading and setting up the DB2 client driver\n"
158
+ destination = "#{File.expand_path(File.dirname(File.dirname(__FILE__)))}/../lib"
159
+
160
+ archive = downloadCLIPackage(destination)
161
+ untarCLIPackage(archive,destination)
162
+
163
+ IBM_DB_HOME="#{destination}/clidriver"
164
+
165
+ IBM_DB_INCLUDE = "#{IBM_DB_HOME}/include"
166
+ IBM_DB_LIB="#{IBM_DB_HOME}/lib"
167
+ else
168
+ 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 "
169
+ exit 1
170
+ end
171
+ end
172
+ else
173
+ IBM_DB_INCLUDE = "#{IBM_DB_HOME}/include"
174
+
175
+ if(is64Bit)
176
+ IBM_DB_LIB="#{IBM_DB_HOME}/lib64"
177
+ else
178
+ IBM_DB_LIB="#{IBM_DB_HOME}/lib32"
179
+ end
180
+ end
181
+
182
+ if( !(File.directory?(IBM_DB_LIB)) )
183
+ suppress_warnings{IBM_DB_LIB = "#{IBM_DB_HOME}/lib"}
184
+ if( !(File.directory?(IBM_DB_LIB)) )
185
+ puts "Cannot find #{IBM_DB_LIB} directory. Check if you have set the IBM_DB_HOME environment variable's value correctly\n "
186
+ exit 1
187
+ end
188
+ notifyString = "Detected usage of IBM Data Server Driver package. Ensure you have downloaded "
189
+
190
+ if(is64Bit)
191
+ notifyString = notifyString + "64-bit package "
192
+ else
193
+ notifyString = notifyString + "32-bit package "
194
+ end
195
+ notifyString = notifyString + "of IBM_Data_Server_Driver and retry the 'gem install ibm_db' command\n "
196
+
197
+ puts notifyString
198
+ end
199
+
200
+ if( !(File.directory?(IBM_DB_INCLUDE)) )
201
+ puts " #{IBM_DB_HOME}/include folder not found. Check if you have set the IBM_DB_HOME environment variable's value correctly\n "
202
+ exit 1
203
+ end
204
+
205
+ require 'mkmf'
206
+
207
+ dir_config('IBM_DB',IBM_DB_INCLUDE,IBM_DB_LIB)
208
+
209
+ def crash(str)
210
+ printf(" extconf failure: %s\n", str)
211
+ exit 1
212
+ end
213
+
214
+ if( RUBY_VERSION =~ /1.9/ || RUBY_VERSION =~ /2./)
215
+ create_header('gil_release_version')
216
+ create_header('unicode_support_version')
217
+ end
218
+
219
+ unless (have_library(WIN ? 'db2cli' : 'db2','SQLConnect') or find_library(WIN ? 'db2cli' : 'db2','SQLConnect', IBM_DB_LIB))
220
+ crash(<<EOL)
221
+ Unable to locate libdb2.so/a under #{IBM_DB_LIB}
222
+
223
+ Follow the steps below and retry
224
+
225
+ Step 1: - Install IBM DB2 Universal Database Server/Client
226
+
227
+ step 2: - Set the environment variable IBM_DB_HOME as below
228
+
229
+ (assuming bash shell)
230
+
231
+ export IBM_DB_HOME=<DB2/IBM_Data_Server_Driver installation directory> #(Eg: export IBM_DB_HOME=/opt/ibm/db2/v10)
232
+
233
+ step 3: - Retry gem install
234
+
235
+ EOL
236
+ end
237
+
238
+ if(RUBY_VERSION =~ /2./)
239
+ require 'rbconfig'
240
+ end
241
+
242
+ alias :libpathflag0 :libpathflag
243
+ def libpathflag(libpath)
244
+ if(RUBY_VERSION =~ /2./)
245
+ libpathflag0 + case RbConfig::CONFIG["arch"]
246
+ when /solaris2/
247
+ libpath[0..-2].map {|path| " -R#{path}"}.join
248
+ when /linux/
249
+ libpath[0..-2].map {|path| " -R#{path} "}.join
250
+ else
251
+ ""
252
+ end
253
+ else
254
+ libpathflag0 + case Config::CONFIG["arch"]
255
+ when /solaris2/
256
+ libpath[0..-2].map {|path| " -R#{path}"}.join
257
+ when /linux/
258
+ libpath[0..-2].map {|path| " -R#{path} "}.join
259
+ else
260
+ ""
261
+ end
262
+ end
263
+
264
+ end
265
+
266
+ have_header('gil_release_version')
267
+ have_header('unicode_support_version')
268
+
269
+ create_makefile('ibm_db')
data/ext/ibm_db.c CHANGED
@@ -12,7 +12,7 @@
12
12
  +----------------------------------------------------------------------+
13
13
  */
14
14
 
15
- #define MODULE_RELEASE "2.5.27"
15
+ #define MODULE_RELEASE "2.6.0"
16
16
 
17
17
  #ifdef HAVE_CONFIG_H
18
18
  #include "config.h"
data/ext/ruby_ibm_db.h CHANGED
@@ -1,241 +1,241 @@
1
- /*
2
- +----------------------------------------------------------------------+
3
- | Licensed Materials - Property of IBM |
4
- | |
5
- | (C) Copyright IBM Corporation 2006 - 2015 |
6
- +----------------------------------------------------------------------+
7
- | Authors: Sushant Koduru, Lynh Nguyen, Kanchana Padmanabhan, |
8
- | Dan Scott, Helmut Tessarek, Kellen Bombardier, Sam Ruby |
9
- | Ambrish Bhargava, Tarun Pasrija, Praveen Devarao, |
10
- | Arvind Gupta |
11
- +----------------------------------------------------------------------+
12
- */
13
-
14
- #ifndef RUBY_IBM_DB_H
15
- #define RUBY_IBM_DB_H
16
-
17
- #include <stdio.h>
18
- #include <string.h>
19
- #include <stdlib.h>
20
- #include <sqlcli1.h>
21
-
22
- #ifndef SQL_XML
23
- #define SQL_XML -370
24
- #endif
25
-
26
- /* Needed for Backward compatibility */
27
- #ifndef SQL_DECFLOAT
28
- #define SQL_DECFLOAT -360
29
- #endif
30
-
31
- /* needed for backward compatibility (SQL_ATTR_ROWCOUNT_PREFETCH not defined prior to DB2 9.5.0.3) */
32
- #ifndef SQL_ATTR_ROWCOUNT_PREFETCH
33
- #define SQL_ATTR_ROWCOUNT_PREFETCH 2592
34
- #define SQL_ROWCOUNT_PREFETCH_OFF 0
35
- #define SQL_ROWCOUNT_PREFETCH_ON 1
36
- #endif
37
-
38
- /* SQL_ATTR_USE_TRUSTED_CONTEXT,
39
- * SQL_ATTR_TRUSTED_CONTEXT_USERID and
40
- * SQL_ATTR_TRUSTED_CONTEXT_PASSWORD
41
- * not defined prior to DB2 v9 */
42
- #ifndef SQL_ATTR_USE_TRUSTED_CONTEXT
43
- #define SQL_ATTR_USE_TRUSTED_CONTEXT 2561
44
- #define SQL_ATTR_TRUSTED_CONTEXT_USERID 2562
45
- #define SQL_ATTR_TRUSTED_CONTEXT_PASSWORD 2563
46
- #endif
47
-
48
- #ifndef SQL_ATTR_REPLACE_QUOTED_LITERALS
49
- #define SQL_ATTR_REPLACE_QUOTED_LITERALS 2586
50
- #endif
51
-
52
- /* CLI v9.1 FP3 and below has a SQL_ATTR_REPLACE_QUOTED_LITERALS value of 116
53
- * We need to support both the new and old values for compatibility with older
54
- * versions of CLI. CLI v9.1 FP4 and beyond changed this value to 2586
55
- */
56
- #define SQL_ATTR_REPLACE_QUOTED_LITERALS_OLDVALUE 116
57
-
58
- /* If using a DB2 CLI version which doesn't support this functionality, explicitly
59
- * define this. We will rely on DB2 CLI to throw an error when SQLGetStmtAttr is
60
- * called.
61
- */
62
- #ifndef SQL_ATTR_GET_GENERATED_VALUE
63
- #define SQL_ATTR_GET_GENERATED_VALUE 2578
64
- #endif
65
-
66
- #ifdef _WIN32
67
- #define RUBY_IBM_DB_API __declspec(dllexport)
68
- #else
69
- #define RUBY_IBM_DB_API
70
- #endif
71
-
72
- /* strlen(" SQLCODE=") added in */
73
- #define DB2_MAX_ERR_MSG_LEN (SQL_MAX_MESSAGE_LENGTH + SQL_SQLSTATE_SIZE + 10)
74
-
75
- /*Used to find the type of resource and the error type required*/
76
- #define DB_ERRMSG 1
77
- #define DB_ERR_STATE 2
78
-
79
- #define DB_CONN 1
80
- #define DB_STMT 2
81
-
82
- #define CONN_ERROR 1
83
- #define STMT_ERROR 2
84
-
85
- /*Used to decide if LITERAL REPLACEMENT should be turned on or not*/
86
- #define SET_QUOTED_LITERAL_REPLACEMENT_ON 1
87
- #define SET_QUOTED_LITERAL_REPLACEMENT_OFF 0
88
-
89
- /* DB2 instance environment variable */
90
- #define DB2_VAR_INSTANCE "DB2INSTANCE="
91
-
92
- /******** Makes code compatible with the options used by the user */
93
- #define BINARY 1
94
- #define CONVERT 2
95
- #define PASSTHRU 3
96
- #define PARAM_FILE 11
97
-
98
- #ifdef PASE
99
- #define SQL_IS_INTEGER 0
100
- #define SQL_BEST_ROWID 0
101
- #define SQLLEN long
102
- #define SQLFLOAT double
103
- #endif
104
-
105
- /*fetch*/
106
- #define FETCH_INDEX 0x01
107
- #define FETCH_ASSOC 0x02
108
- #define FETCH_BOTH 0x03
109
-
110
- /* Change column case */
111
- #define ATTR_CASE 3271982
112
- #define CASE_NATURAL 0
113
- #define CASE_LOWER 1
114
- #define CASE_UPPER 2
115
-
116
- /* maximum sizes */
117
- #define USERID_LEN 16
118
- #define ACCTSTR_LEN 200
119
- #define APPLNAME_LEN 32
120
- #define WRKSTNNAME_LEN 18
121
-
122
- /*
123
- * Enum for Decfloat Rounding Modes
124
- * */
125
- enum
126
- {
127
- ROUND_HALF_EVEN = 0,
128
- ROUND_HALF_UP,
129
- ROUND_DOWN,
130
- ROUND_CEILING,
131
- ROUND_FLOOR
132
- }ROUNDING_MODE;
133
-
134
- void Init_ibm_db();
135
-
136
- /* Function Declarations */
137
-
138
- VALUE ibm_db_connect(int argc, VALUE *argv, VALUE self);
139
- VALUE ibm_db_createDB(int argc, VALUE *argv, VALUE self);
140
- VALUE ibm_db_dropDB(int argc, VALUE *argv, VALUE self);
141
- VALUE ibm_db_createDBNX(int argc, VALUE *argv, VALUE self);
142
- VALUE ibm_db_commit(int argc, VALUE *argv, VALUE self);
143
- VALUE ibm_db_pconnect(int argc, VALUE *argv, VALUE self);
144
- VALUE ibm_db_autocommit(int argc, VALUE *argv, VALUE self);
145
- VALUE ibm_db_bind_param(int argc, VALUE *argv, VALUE self);
146
- VALUE ibm_db_close(int argc, VALUE *argv, VALUE self);
147
- VALUE ibm_db_columnprivileges(int argc, VALUE *argv, VALUE self);
148
- VALUE ibm_db_column_privileges(int argc, VALUE *argv, VALUE self);
149
- VALUE ibm_db_columns(int argc, VALUE *argv, VALUE self);
150
- VALUE ibm_db_foreignkeys(int argc, VALUE *argv, VALUE self);
151
- VALUE ibm_db_foreign_keys(int argc, VALUE *argv, VALUE self);
152
- VALUE ibm_db_primarykeys(int argc, VALUE *argv, VALUE self);
153
- VALUE ibm_db_primary_keys(int argc, VALUE *argv, VALUE self);
154
- VALUE ibm_db_procedure_columns(int argc, VALUE *argv, VALUE self);
155
- VALUE ibm_db_procedures(int argc, VALUE *argv, VALUE self);
156
- VALUE ibm_db_specialcolumns(int argc, VALUE *argv, VALUE self);
157
- VALUE ibm_db_special_columns(int argc, VALUE *argv, VALUE self);
158
- VALUE ibm_db_statistics(int argc, VALUE *argv, VALUE self);
159
- VALUE ibm_db_tableprivileges(int argc, VALUE *argv, VALUE self);
160
- VALUE ibm_db_table_privileges(int argc, VALUE *argv, VALUE self);
161
- VALUE ibm_db_tables(int argc, VALUE *argv, VALUE self);
162
- VALUE ibm_db_commit(int argc, VALUE *argv, VALUE self);
163
- VALUE ibm_db_exec(int argc, VALUE *argv, VALUE self);
164
- VALUE ibm_db_prepare(int argc, VALUE *argv, VALUE self);
165
- VALUE ibm_db_execute(int argc, VALUE *argv, VALUE self);
166
- VALUE ibm_db_conn_errormsg(int argc, VALUE *argv, VALUE self);
167
- VALUE ibm_db_stmt_errormsg(int argc, VALUE *argv, VALUE self);
168
- VALUE ibm_db_getErrormsg(int argc, VALUE *argv, VALUE self);
169
- VALUE ibm_db_getErrorstate(int argc, VALUE *argv, VALUE self);
170
- VALUE ibm_db_conn_error(int argc, VALUE *argv, VALUE self);
171
- VALUE ibm_db_stmt_error(int argc, VALUE *argv, VALUE self);
172
- VALUE ibm_db_next_result(int argc, VALUE *argv, VALUE self);
173
- VALUE ibm_db_num_fields(int argc, VALUE *argv, VALUE self);
174
- VALUE ibm_db_num_rows(int argc, VALUE *argv, VALUE self);
175
- VALUE ibm_db_result_cols(int argc, VALUE *argv, VALUE self);
176
- VALUE ibm_db_field_name(int argc, VALUE *argv, VALUE self);
177
- VALUE ibm_db_field_display_size(int argc, VALUE *argv, VALUE self);
178
- VALUE ibm_db_field_num(int argc, VALUE *argv, VALUE self);
179
- VALUE ibm_db_field_precision(int argc, VALUE *argv, VALUE self);
180
- VALUE ibm_db_field_scale(int argc, VALUE *argv, VALUE self);
181
- VALUE ibm_db_field_type(int argc, VALUE *argv, VALUE self);
182
- VALUE ibm_db_field_width(int argc, VALUE *argv, VALUE self);
183
- VALUE ibm_db_cursor_type(int argc, VALUE *argv, VALUE self);
184
- VALUE ibm_db_rollback(int argc, VALUE *argv, VALUE self);
185
- VALUE ibm_db_free_stmt(int argc, VALUE *argv, VALUE self);
186
- VALUE ibm_db_result(int argc, VALUE *argv, VALUE self);
187
- VALUE ibm_db_fetch_row(int argc, VALUE *argv, VALUE self);
188
- VALUE ibm_db_fetch_assoc(int argc, VALUE *argv, VALUE self);
189
- VALUE ibm_db_fetch_array(int argc, VALUE *argv, VALUE self);
190
- VALUE ibm_db_fetch_both(int argc, VALUE *argv, VALUE self);
191
- VALUE ibm_db_result_all(int argc, VALUE *argv, VALUE self);
192
- VALUE ibm_db_free_result(int argc, VALUE *argv, VALUE self);
193
- VALUE ibm_db_set_option(int argc, VALUE *argv, VALUE self);
194
- VALUE ibm_db_setoption(int argc, VALUE *argv, VALUE self);
195
- VALUE ibm_db_get_option(int argc, VALUE *argv, VALUE self);
196
- VALUE ibm_db_get_last_serial_value(int argc, VALUE *argv, VALUE self);
197
- VALUE ibm_db_getoption(int argc, VALUE *argv, VALUE self);
198
- VALUE ibm_db_fetch_object(int argc, VALUE *argv, VALUE self);
199
- VALUE ibm_db_server_info(int argc, VALUE *argv, VALUE self);
200
- VALUE ibm_db_client_info(int argc, VALUE *argv, VALUE self);
201
- VALUE ibm_db_active(int argc, VALUE *argv, VALUE self);
202
-
203
- /*
204
- Declare any global variables you may need between the BEGIN
205
- and END macros here:
206
- */
207
- struct _ibm_db_globals {
208
- int bin_mode;
209
- #ifdef UNICODE_SUPPORT_VERSION
210
- SQLWCHAR __ruby_conn_err_msg[DB2_MAX_ERR_MSG_LEN];
211
- SQLWCHAR __ruby_stmt_err_msg[DB2_MAX_ERR_MSG_LEN];
212
- SQLWCHAR __ruby_conn_err_state[SQL_SQLSTATE_SIZE + 1];
213
- SQLWCHAR __ruby_stmt_err_state[SQL_SQLSTATE_SIZE + 1];
214
- #else
215
- char __ruby_conn_err_msg[DB2_MAX_ERR_MSG_LEN];
216
- char __ruby_stmt_err_msg[DB2_MAX_ERR_MSG_LEN];
217
- char __ruby_conn_err_state[SQL_SQLSTATE_SIZE + 1];
218
- char __ruby_stmt_err_state[SQL_SQLSTATE_SIZE + 1];
219
- #endif
220
-
221
- #ifdef PASE /* i5/OS ease of use turn off commit */
222
- long i5_allow_commit;
223
- #endif /* PASE */
224
- };
225
-
226
- /*
227
- TODO: make this threadsafe
228
- */
229
-
230
- #define IBM_DB_G(v) (ibm_db_globals->v)
231
-
232
- #endif /* RUBY_IBM_DB_H */
233
-
234
-
235
- /*
236
- * Local variables:
237
- * tab-width: 4
238
- * c-basic-offset: 4
239
- * indent-tabs-mode: t
240
- * End:
241
- */
1
+ /*
2
+ +----------------------------------------------------------------------+
3
+ | Licensed Materials - Property of IBM |
4
+ | |
5
+ | (C) Copyright IBM Corporation 2006 - 2015 |
6
+ +----------------------------------------------------------------------+
7
+ | Authors: Sushant Koduru, Lynh Nguyen, Kanchana Padmanabhan, |
8
+ | Dan Scott, Helmut Tessarek, Kellen Bombardier, Sam Ruby |
9
+ | Ambrish Bhargava, Tarun Pasrija, Praveen Devarao, |
10
+ | Arvind Gupta |
11
+ +----------------------------------------------------------------------+
12
+ */
13
+
14
+ #ifndef RUBY_IBM_DB_H
15
+ #define RUBY_IBM_DB_H
16
+
17
+ #include <stdio.h>
18
+ #include <string.h>
19
+ #include <stdlib.h>
20
+ #include <sqlcli1.h>
21
+
22
+ #ifndef SQL_XML
23
+ #define SQL_XML -370
24
+ #endif
25
+
26
+ /* Needed for Backward compatibility */
27
+ #ifndef SQL_DECFLOAT
28
+ #define SQL_DECFLOAT -360
29
+ #endif
30
+
31
+ /* needed for backward compatibility (SQL_ATTR_ROWCOUNT_PREFETCH not defined prior to DB2 9.5.0.3) */
32
+ #ifndef SQL_ATTR_ROWCOUNT_PREFETCH
33
+ #define SQL_ATTR_ROWCOUNT_PREFETCH 2592
34
+ #define SQL_ROWCOUNT_PREFETCH_OFF 0
35
+ #define SQL_ROWCOUNT_PREFETCH_ON 1
36
+ #endif
37
+
38
+ /* SQL_ATTR_USE_TRUSTED_CONTEXT,
39
+ * SQL_ATTR_TRUSTED_CONTEXT_USERID and
40
+ * SQL_ATTR_TRUSTED_CONTEXT_PASSWORD
41
+ * not defined prior to DB2 v9 */
42
+ #ifndef SQL_ATTR_USE_TRUSTED_CONTEXT
43
+ #define SQL_ATTR_USE_TRUSTED_CONTEXT 2561
44
+ #define SQL_ATTR_TRUSTED_CONTEXT_USERID 2562
45
+ #define SQL_ATTR_TRUSTED_CONTEXT_PASSWORD 2563
46
+ #endif
47
+
48
+ #ifndef SQL_ATTR_REPLACE_QUOTED_LITERALS
49
+ #define SQL_ATTR_REPLACE_QUOTED_LITERALS 2586
50
+ #endif
51
+
52
+ /* CLI v9.1 FP3 and below has a SQL_ATTR_REPLACE_QUOTED_LITERALS value of 116
53
+ * We need to support both the new and old values for compatibility with older
54
+ * versions of CLI. CLI v9.1 FP4 and beyond changed this value to 2586
55
+ */
56
+ #define SQL_ATTR_REPLACE_QUOTED_LITERALS_OLDVALUE 116
57
+
58
+ /* If using a DB2 CLI version which doesn't support this functionality, explicitly
59
+ * define this. We will rely on DB2 CLI to throw an error when SQLGetStmtAttr is
60
+ * called.
61
+ */
62
+ #ifndef SQL_ATTR_GET_GENERATED_VALUE
63
+ #define SQL_ATTR_GET_GENERATED_VALUE 2578
64
+ #endif
65
+
66
+ #ifdef _WIN32
67
+ #define RUBY_IBM_DB_API __declspec(dllexport)
68
+ #else
69
+ #define RUBY_IBM_DB_API
70
+ #endif
71
+
72
+ /* strlen(" SQLCODE=") added in */
73
+ #define DB2_MAX_ERR_MSG_LEN (SQL_MAX_MESSAGE_LENGTH + SQL_SQLSTATE_SIZE + 10)
74
+
75
+ /*Used to find the type of resource and the error type required*/
76
+ #define DB_ERRMSG 1
77
+ #define DB_ERR_STATE 2
78
+
79
+ #define DB_CONN 1
80
+ #define DB_STMT 2
81
+
82
+ #define CONN_ERROR 1
83
+ #define STMT_ERROR 2
84
+
85
+ /*Used to decide if LITERAL REPLACEMENT should be turned on or not*/
86
+ #define SET_QUOTED_LITERAL_REPLACEMENT_ON 1
87
+ #define SET_QUOTED_LITERAL_REPLACEMENT_OFF 0
88
+
89
+ /* DB2 instance environment variable */
90
+ #define DB2_VAR_INSTANCE "DB2INSTANCE="
91
+
92
+ /******** Makes code compatible with the options used by the user */
93
+ #define BINARY 1
94
+ #define CONVERT 2
95
+ #define PASSTHRU 3
96
+ #define PARAM_FILE 11
97
+
98
+ #ifdef PASE
99
+ #define SQL_IS_INTEGER 0
100
+ #define SQL_BEST_ROWID 0
101
+ #define SQLLEN long
102
+ #define SQLFLOAT double
103
+ #endif
104
+
105
+ /*fetch*/
106
+ #define FETCH_INDEX 0x01
107
+ #define FETCH_ASSOC 0x02
108
+ #define FETCH_BOTH 0x03
109
+
110
+ /* Change column case */
111
+ #define ATTR_CASE 3271982
112
+ #define CASE_NATURAL 0
113
+ #define CASE_LOWER 1
114
+ #define CASE_UPPER 2
115
+
116
+ /* maximum sizes */
117
+ #define USERID_LEN 16
118
+ #define ACCTSTR_LEN 200
119
+ #define APPLNAME_LEN 32
120
+ #define WRKSTNNAME_LEN 18
121
+
122
+ /*
123
+ * Enum for Decfloat Rounding Modes
124
+ * */
125
+ enum
126
+ {
127
+ ROUND_HALF_EVEN = 0,
128
+ ROUND_HALF_UP,
129
+ ROUND_DOWN,
130
+ ROUND_CEILING,
131
+ ROUND_FLOOR
132
+ }ROUNDING_MODE;
133
+
134
+ void Init_ibm_db();
135
+
136
+ /* Function Declarations */
137
+
138
+ VALUE ibm_db_connect(int argc, VALUE *argv, VALUE self);
139
+ VALUE ibm_db_createDB(int argc, VALUE *argv, VALUE self);
140
+ VALUE ibm_db_dropDB(int argc, VALUE *argv, VALUE self);
141
+ VALUE ibm_db_createDBNX(int argc, VALUE *argv, VALUE self);
142
+ VALUE ibm_db_commit(int argc, VALUE *argv, VALUE self);
143
+ VALUE ibm_db_pconnect(int argc, VALUE *argv, VALUE self);
144
+ VALUE ibm_db_autocommit(int argc, VALUE *argv, VALUE self);
145
+ VALUE ibm_db_bind_param(int argc, VALUE *argv, VALUE self);
146
+ VALUE ibm_db_close(int argc, VALUE *argv, VALUE self);
147
+ VALUE ibm_db_columnprivileges(int argc, VALUE *argv, VALUE self);
148
+ VALUE ibm_db_column_privileges(int argc, VALUE *argv, VALUE self);
149
+ VALUE ibm_db_columns(int argc, VALUE *argv, VALUE self);
150
+ VALUE ibm_db_foreignkeys(int argc, VALUE *argv, VALUE self);
151
+ VALUE ibm_db_foreign_keys(int argc, VALUE *argv, VALUE self);
152
+ VALUE ibm_db_primarykeys(int argc, VALUE *argv, VALUE self);
153
+ VALUE ibm_db_primary_keys(int argc, VALUE *argv, VALUE self);
154
+ VALUE ibm_db_procedure_columns(int argc, VALUE *argv, VALUE self);
155
+ VALUE ibm_db_procedures(int argc, VALUE *argv, VALUE self);
156
+ VALUE ibm_db_specialcolumns(int argc, VALUE *argv, VALUE self);
157
+ VALUE ibm_db_special_columns(int argc, VALUE *argv, VALUE self);
158
+ VALUE ibm_db_statistics(int argc, VALUE *argv, VALUE self);
159
+ VALUE ibm_db_tableprivileges(int argc, VALUE *argv, VALUE self);
160
+ VALUE ibm_db_table_privileges(int argc, VALUE *argv, VALUE self);
161
+ VALUE ibm_db_tables(int argc, VALUE *argv, VALUE self);
162
+ VALUE ibm_db_commit(int argc, VALUE *argv, VALUE self);
163
+ VALUE ibm_db_exec(int argc, VALUE *argv, VALUE self);
164
+ VALUE ibm_db_prepare(int argc, VALUE *argv, VALUE self);
165
+ VALUE ibm_db_execute(int argc, VALUE *argv, VALUE self);
166
+ VALUE ibm_db_conn_errormsg(int argc, VALUE *argv, VALUE self);
167
+ VALUE ibm_db_stmt_errormsg(int argc, VALUE *argv, VALUE self);
168
+ VALUE ibm_db_getErrormsg(int argc, VALUE *argv, VALUE self);
169
+ VALUE ibm_db_getErrorstate(int argc, VALUE *argv, VALUE self);
170
+ VALUE ibm_db_conn_error(int argc, VALUE *argv, VALUE self);
171
+ VALUE ibm_db_stmt_error(int argc, VALUE *argv, VALUE self);
172
+ VALUE ibm_db_next_result(int argc, VALUE *argv, VALUE self);
173
+ VALUE ibm_db_num_fields(int argc, VALUE *argv, VALUE self);
174
+ VALUE ibm_db_num_rows(int argc, VALUE *argv, VALUE self);
175
+ VALUE ibm_db_result_cols(int argc, VALUE *argv, VALUE self);
176
+ VALUE ibm_db_field_name(int argc, VALUE *argv, VALUE self);
177
+ VALUE ibm_db_field_display_size(int argc, VALUE *argv, VALUE self);
178
+ VALUE ibm_db_field_num(int argc, VALUE *argv, VALUE self);
179
+ VALUE ibm_db_field_precision(int argc, VALUE *argv, VALUE self);
180
+ VALUE ibm_db_field_scale(int argc, VALUE *argv, VALUE self);
181
+ VALUE ibm_db_field_type(int argc, VALUE *argv, VALUE self);
182
+ VALUE ibm_db_field_width(int argc, VALUE *argv, VALUE self);
183
+ VALUE ibm_db_cursor_type(int argc, VALUE *argv, VALUE self);
184
+ VALUE ibm_db_rollback(int argc, VALUE *argv, VALUE self);
185
+ VALUE ibm_db_free_stmt(int argc, VALUE *argv, VALUE self);
186
+ VALUE ibm_db_result(int argc, VALUE *argv, VALUE self);
187
+ VALUE ibm_db_fetch_row(int argc, VALUE *argv, VALUE self);
188
+ VALUE ibm_db_fetch_assoc(int argc, VALUE *argv, VALUE self);
189
+ VALUE ibm_db_fetch_array(int argc, VALUE *argv, VALUE self);
190
+ VALUE ibm_db_fetch_both(int argc, VALUE *argv, VALUE self);
191
+ VALUE ibm_db_result_all(int argc, VALUE *argv, VALUE self);
192
+ VALUE ibm_db_free_result(int argc, VALUE *argv, VALUE self);
193
+ VALUE ibm_db_set_option(int argc, VALUE *argv, VALUE self);
194
+ VALUE ibm_db_setoption(int argc, VALUE *argv, VALUE self);
195
+ VALUE ibm_db_get_option(int argc, VALUE *argv, VALUE self);
196
+ VALUE ibm_db_get_last_serial_value(int argc, VALUE *argv, VALUE self);
197
+ VALUE ibm_db_getoption(int argc, VALUE *argv, VALUE self);
198
+ VALUE ibm_db_fetch_object(int argc, VALUE *argv, VALUE self);
199
+ VALUE ibm_db_server_info(int argc, VALUE *argv, VALUE self);
200
+ VALUE ibm_db_client_info(int argc, VALUE *argv, VALUE self);
201
+ VALUE ibm_db_active(int argc, VALUE *argv, VALUE self);
202
+
203
+ /*
204
+ Declare any global variables you may need between the BEGIN
205
+ and END macros here:
206
+ */
207
+ struct _ibm_db_globals {
208
+ int bin_mode;
209
+ #ifdef UNICODE_SUPPORT_VERSION
210
+ SQLWCHAR __ruby_conn_err_msg[DB2_MAX_ERR_MSG_LEN];
211
+ SQLWCHAR __ruby_stmt_err_msg[DB2_MAX_ERR_MSG_LEN];
212
+ SQLWCHAR __ruby_conn_err_state[SQL_SQLSTATE_SIZE + 1];
213
+ SQLWCHAR __ruby_stmt_err_state[SQL_SQLSTATE_SIZE + 1];
214
+ #else
215
+ char __ruby_conn_err_msg[DB2_MAX_ERR_MSG_LEN];
216
+ char __ruby_stmt_err_msg[DB2_MAX_ERR_MSG_LEN];
217
+ char __ruby_conn_err_state[SQL_SQLSTATE_SIZE + 1];
218
+ char __ruby_stmt_err_state[SQL_SQLSTATE_SIZE + 1];
219
+ #endif
220
+
221
+ #ifdef PASE /* i5/OS ease of use turn off commit */
222
+ long i5_allow_commit;
223
+ #endif /* PASE */
224
+ };
225
+
226
+ /*
227
+ TODO: make this threadsafe
228
+ */
229
+
230
+ #define IBM_DB_G(v) (ibm_db_globals->v)
231
+
232
+ #endif /* RUBY_IBM_DB_H */
233
+
234
+
235
+ /*
236
+ * Local variables:
237
+ * tab-width: 4
238
+ * c-basic-offset: 4
239
+ * indent-tabs-mode: t
240
+ * End:
241
+ */