ruby-oci8 2.2.3 → 2.2.4

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.
@@ -245,9 +245,9 @@ static VALUE attr_get_common(int argc, VALUE *argv, VALUE self, enum datatype da
245
245
  *
246
246
  * Gets the value of an attribute as `ub1' datatype.
247
247
  *
248
- * @param [Fixnum] attr_type
248
+ * @param [Integer] attr_type
249
249
  * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
250
- * @return [Fixnum]
250
+ * @return [Integer]
251
251
  *
252
252
  * @since 2.0.4
253
253
  * @private
@@ -262,9 +262,9 @@ static VALUE attr_get_ub1(int argc, VALUE *argv, VALUE self)
262
262
  *
263
263
  * Gets the value of an attribute as `ub2' datatype.
264
264
  *
265
- * @param [Fixnum] attr_type
265
+ * @param [Integer] attr_type
266
266
  * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
267
- * @return [Fixnum]
267
+ * @return [Integer]
268
268
  *
269
269
  * @since 2.0.4
270
270
  * @private
@@ -279,7 +279,7 @@ static VALUE attr_get_ub2(int argc, VALUE *argv, VALUE self)
279
279
  *
280
280
  * Gets the value of an attribute as `ub4' datatype.
281
281
  *
282
- * @param [Fixnum] attr_type
282
+ * @param [Integer] attr_type
283
283
  * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
284
284
  * @return [Integer]
285
285
  *
@@ -296,7 +296,7 @@ static VALUE attr_get_ub4(int argc, VALUE *argv, VALUE self)
296
296
  *
297
297
  * Gets the value of an attribute as `ub8' datatype.
298
298
  *
299
- * @param [Fixnum] attr_type
299
+ * @param [Integer] attr_type
300
300
  * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
301
301
  * @return [Integer]
302
302
  *
@@ -313,9 +313,9 @@ static VALUE attr_get_ub8(int argc, VALUE *argv, VALUE self)
313
313
  *
314
314
  * Gets the value of an attribute as `sb1' datatype.
315
315
  *
316
- * @param [Fixnum] attr_type
316
+ * @param [Integer] attr_type
317
317
  * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
318
- * @return [Fixnum]
318
+ * @return [Integer]
319
319
  *
320
320
  * @since 2.0.4
321
321
  * @private
@@ -330,9 +330,9 @@ static VALUE attr_get_sb1(int argc, VALUE *argv, VALUE self)
330
330
  *
331
331
  * Gets the value of an attribute as `sb2' datatype.
332
332
  *
333
- * @param [Fixnum] attr_type
333
+ * @param [Integer] attr_type
334
334
  * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
335
- * @return [Fixnum]
335
+ * @return [Integer]
336
336
  *
337
337
  * @since 2.0.4
338
338
  * @private
@@ -347,7 +347,7 @@ static VALUE attr_get_sb2(int argc, VALUE *argv, VALUE self)
347
347
  *
348
348
  * Gets the value of an attribute as `sb4' datatype.
349
349
  *
350
- * @param [Fixnum] attr_type
350
+ * @param [Integer] attr_type
351
351
  * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
352
352
  * @return [Integer]
353
353
  *
@@ -364,7 +364,7 @@ static VALUE attr_get_sb4(int argc, VALUE *argv, VALUE self)
364
364
  *
365
365
  * Gets the value of an attribute as `sb8' datatype.
366
366
  *
367
- * @param [Fixnum] attr_type
367
+ * @param [Integer] attr_type
368
368
  * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
369
369
  * @return [Integer]
370
370
  *
@@ -381,7 +381,7 @@ static VALUE attr_get_sb8(int argc, VALUE *argv, VALUE self)
381
381
  *
382
382
  * Gets the value of an attribute as `boolean' datatype.
383
383
  *
384
- * @param [Fixnum] attr_type
384
+ * @param [Integer] attr_type
385
385
  * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
386
386
  * @return [true of false]
387
387
  *
@@ -403,7 +403,7 @@ static VALUE attr_get_boolean(int argc, VALUE *argv, VALUE self)
403
403
  * @note If the specified attr_type's datatype is not a
404
404
  * pointer type, it causes a segmentation fault.
405
405
  *
406
- * @param [Fixnum] attr_type
406
+ * @param [Integer] attr_type
407
407
  * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
408
408
  * @return [String]
409
409
  *
@@ -424,7 +424,7 @@ static VALUE attr_get_string(int argc, VALUE *argv, VALUE self)
424
424
  * @note If the specified attr_type's datatype is not a
425
425
  * pointer type, it causes a segmentation fault.
426
426
  *
427
- * @param [Fixnum] attr_type
427
+ * @param [Integer] attr_type
428
428
  * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
429
429
  * @return [String]
430
430
  *
@@ -445,9 +445,9 @@ static VALUE attr_get_binary(int argc, VALUE *argv, VALUE self)
445
445
  * @note If the specified attr_type's datatype is not a
446
446
  * pointer type, it causes a segmentation fault.
447
447
  *
448
- * @param [Fixnum] attr_type
448
+ * @param [Integer] attr_type
449
449
  * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
450
- * @return [Fixnum]
450
+ * @return [Integer]
451
451
  *
452
452
  * @since 2.0.4
453
453
  * @private
@@ -466,7 +466,7 @@ static VALUE attr_get_integer(int argc, VALUE *argv, VALUE self)
466
466
  * @note If the specified attr_type's datatype is not a
467
467
  * pointer type, it causes a segmentation fault.
468
468
  *
469
- * @param [Fixnum] attr_type
469
+ * @param [Integer] attr_type
470
470
  * @param [Boolean] strict If false, "ORA-24328: illegal attribute value" is ignored.
471
471
  * @return [OraDate]
472
472
  *
@@ -486,8 +486,8 @@ static VALUE attr_get_oradate(int argc, VALUE *argv, VALUE self)
486
486
  * @note If the specified attr_type's datatype is a
487
487
  * pointer type, it causes a segmentation fault.
488
488
  *
489
- * @param [Fixnum] attr_type
490
- * @param [Fixnum] attr_value
489
+ * @param [Integer] attr_type
490
+ * @param [Integer] attr_value
491
491
  * @return [self]
492
492
  *
493
493
  * @since 2.0.4
@@ -514,8 +514,8 @@ static VALUE attr_set_ub1(VALUE self, VALUE attr_type, VALUE val)
514
514
  * @note If the specified attr_type's datatype is a
515
515
  * pointer type, it causes a segmentation fault.
516
516
  *
517
- * @param [Fixnum] attr_type
518
- * @param [Fixnum] attr_value
517
+ * @param [Integer] attr_type
518
+ * @param [Integer] attr_value
519
519
  * @return [self]
520
520
  *
521
521
  * @since 2.0.4
@@ -542,7 +542,7 @@ static VALUE attr_set_ub2(VALUE self, VALUE attr_type, VALUE val)
542
542
  * @note If the specified attr_type's datatype is a
543
543
  * pointer type, it causes a segmentation fault.
544
544
  *
545
- * @param [Fixnum] attr_type
545
+ * @param [Integer] attr_type
546
546
  * @param [Integer] attr_value
547
547
  * @return [self]
548
548
  *
@@ -570,7 +570,7 @@ static VALUE attr_set_ub4(VALUE self, VALUE attr_type, VALUE val)
570
570
  * @note If the specified attr_type's datatype is a
571
571
  * pointer type, it causes a segmentation fault.
572
572
  *
573
- * @param [Fixnum] attr_type
573
+ * @param [Integer] attr_type
574
574
  * @param [Integer] attr_value
575
575
  * @return [self]
576
576
  *
@@ -598,8 +598,8 @@ static VALUE attr_set_ub8(VALUE self, VALUE attr_type, VALUE val)
598
598
  * @note If the specified attr_type's datatype is a
599
599
  * pointer type, it causes a segmentation fault.
600
600
  *
601
- * @param [Fixnum] attr_type
602
- * @param [Fixnum] attr_value
601
+ * @param [Integer] attr_type
602
+ * @param [Integer] attr_value
603
603
  * @return [self]
604
604
  *
605
605
  * @since 2.0.4
@@ -626,8 +626,8 @@ static VALUE attr_set_sb1(VALUE self, VALUE attr_type, VALUE val)
626
626
  * @note If the specified attr_type's datatype is a
627
627
  * pointer type, it causes a segmentation fault.
628
628
  *
629
- * @param [Fixnum] attr_type
630
- * @param [Fixnum] attr_value
629
+ * @param [Integer] attr_type
630
+ * @param [Integer] attr_value
631
631
  * @return [self]
632
632
  *
633
633
  * @since 2.0.4
@@ -654,7 +654,7 @@ static VALUE attr_set_sb2(VALUE self, VALUE attr_type, VALUE val)
654
654
  * @note If the specified attr_type's datatype is a
655
655
  * pointer type, it causes a segmentation fault.
656
656
  *
657
- * @param [Fixnum] attr_type
657
+ * @param [Integer] attr_type
658
658
  * @param [Integer] attr_value
659
659
  * @return [self]
660
660
  *
@@ -682,7 +682,7 @@ static VALUE attr_set_sb4(VALUE self, VALUE attr_type, VALUE val)
682
682
  * @note If the specified attr_type's datatype is a
683
683
  * pointer type, it causes a segmentation fault.
684
684
  *
685
- * @param [Fixnum] attr_type
685
+ * @param [Integer] attr_type
686
686
  * @param [Integer] attr_value
687
687
  * @return [self]
688
688
  *
@@ -710,7 +710,7 @@ static VALUE attr_set_sb8(VALUE self, VALUE attr_type, VALUE val)
710
710
  * @note If the specified attr_type's datatype is a
711
711
  * pointer type, it causes a segmentation fault.
712
712
  *
713
- * @param [Fixnum] attr_type
713
+ * @param [Integer] attr_type
714
714
  * @param [true or false] attr_value
715
715
  * @return [self]
716
716
  *
@@ -737,7 +737,7 @@ static VALUE attr_set_boolean(VALUE self, VALUE attr_type, VALUE val)
737
737
  * +attr_value+ is converted to {OCI8.encoding} before it is set
738
738
  * when the ruby version is 1.9.
739
739
  *
740
- * @param [Fixnum] attr_type
740
+ * @param [Integer] attr_type
741
741
  * @param [String] attr_value
742
742
  * @return [self]
743
743
  *
@@ -761,7 +761,7 @@ static VALUE attr_set_string(VALUE self, VALUE attr_type, VALUE val)
761
761
  *
762
762
  * Sets the value of an attribute as `ub1 *' datatype.
763
763
  *
764
- * @param [Fixnum] attr_type
764
+ * @param [Integer] attr_type
765
765
  * @param [String] attr_value
766
766
  * @return [self]
767
767
  *
@@ -787,7 +787,7 @@ static VALUE attr_set_binary(VALUE self, VALUE attr_type, VALUE val)
787
787
  * +number+ is converted to internal Oracle NUMBER format before
788
788
  * it is set.
789
789
  *
790
- * @param [Fixnum] attr_type
790
+ * @param [Integer] attr_type
791
791
  * @param [Numeric] number
792
792
  * @return [self]
793
793
  *
@@ -4,88 +4,37 @@ require 'mkmf'
4
4
  # compatibility for ruby-1.9
5
5
  RbConfig = Config unless defined? RbConfig
6
6
 
7
- module MiniRegistry
8
- class MiniRegistryError < StandardError
9
- attr_reader :api_name
10
- attr_reader :code
11
- def initialize(api_name, code)
12
- @api_name = api_name
13
- @code = code
14
- end
15
- end
16
- if RUBY_PLATFORM =~ /mswin32|mswin64|cygwin|mingw32|bccwin32/
17
- # Windows
18
- require 'Win32API' # raise LoadError when UNIX.
19
-
20
- # I looked in Win32Module by MoonWolf <URL:http://www.moonwolf.com/ruby/>,
21
- # copy the minimum code and reorganize it.
22
- ERROR_SUCCESS = 0
23
- ERROR_FILE_NOT_FOUND = 2
24
- ERROR_NO_MORE_ITEMS = 259
25
-
26
- HKEY_LOCAL_MACHINE = 0x80000002
27
- KEY_ENUMERATE_SUB_KEYS = 0x0008
28
- KEY_QUERY_VALUE = 0x0001
29
- RegOpenKeyExA = Win32API.new('advapi32', 'RegOpenKeyExA', 'LPLLP', 'L')
30
- RegEnumKeyExA = Win32API.new('advapi32', 'RegEnumKeyExA', 'LLPPPPPP', 'L')
31
- RegQueryValueExA = Win32API.new('advapi32','RegQueryValueExA','LPPPPP','L')
32
- RegCloseKey = Win32API.new('advapi32', 'RegCloseKey', 'L', 'L')
33
-
34
- def self.get_str_value(hKey, name)
35
- lpcbData = [0].pack('L')
36
- code = RegQueryValueExA.call(hKey, name, nil, nil, nil, lpcbData)
37
- if code == ERROR_FILE_NOT_FOUND
38
- return nil
39
- elsif code != ERROR_SUCCESS
40
- raise MiniRegistryError.new("Win32::RegQueryValueExA",code)
7
+ if RUBY_PLATFORM =~ /mswin32|mswin64|cygwin|mingw32|bccwin32/
8
+ # Windows
9
+ require 'win32/registry'
10
+ module Registry
11
+
12
+ class OracleHome
13
+ attr_reader :name
14
+ attr_reader :path
15
+ def initialize(name, path)
16
+ @name = name
17
+ @path = path
41
18
  end
42
- len = lpcbData.unpack('L')[0]
43
- lpType = [0].pack('L')
44
- lpData = "\0"*len
45
- lpcbData = [len].pack('L')
46
- code = RegQueryValueExA.call(hKey, name, nil, lpType, lpData, lpcbData)
47
- if code != ERROR_SUCCESS
48
- raise MiniRegistryError.new("Win32::RegQueryValueExA",code)
49
- end
50
- lpData.unpack('Z*')[0]
51
19
  end
52
20
 
53
- def self.enum_homes
54
- phkResult = [0].pack('L')
55
- code = RegOpenKeyExA.call(HKEY_LOCAL_MACHINE, 'SOFTWARE\ORACLE', 0, 0x20019, phkResult)
56
- if code != ERROR_SUCCESS
57
- raise MiniRegistryError.new("Win32::RegOpenKeyExA", code)
58
- end
59
- hKey = phkResult.unpack('L')[0]
60
- idx = 0
61
- maxkeylen = 256
62
- loop do
63
- lpName = "\0" * maxkeylen
64
- lpcName = [maxkeylen].pack('L')
65
- code = RegEnumKeyExA.call(hKey, idx, lpName, lpcName, nil, nil, nil, nil);
66
- break if code == ERROR_NO_MORE_ITEMS
67
- if code != ERROR_SUCCESS
68
- RegCloseKey.call(hKey)
69
- raise MiniRegistryError.new("Win32::RegEnumKeyEx", code)
70
- end
71
- code = RegOpenKeyExA.call(hKey, lpName, 0, KEY_QUERY_VALUE, phkResult)
72
- if code != ERROR_SUCCESS
73
- RegCloseKey.call(hKey)
74
- raise MiniRegistryError.new("Win32::RegEnumKeyEx", code)
21
+ def self.oracle_homes
22
+ homes = []
23
+ Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Oracle') do |key|
24
+ key.each_key do |subkey_name|
25
+ subkey = key.open(subkey_name)
26
+ begin
27
+ homes << OracleHome.new(subkey['ORACLE_HOME_NAME'], subkey['ORACLE_HOME'].chomp('\\'))
28
+ rescue Win32::Registry::Error
29
+ # ignore errors
30
+ end
75
31
  end
76
- hSubkey = phkResult.unpack('L')[0]
77
-
78
- name = get_str_value(hSubkey, 'ORACLE_HOME_NAME')
79
- path = get_str_value(hSubkey, 'ORACLE_HOME')
80
- yield name, path
81
- RegCloseKey.call(hSubkey)
82
- idx += 1
83
32
  end
84
- RegCloseKey.call(hKey)
33
+ homes
85
34
  end
86
35
 
87
36
  end
88
- end # module MiniRegistry
37
+ end
89
38
 
90
39
  # minimal implementation to read information of a shared object.
91
40
  class MiniSOReader
@@ -384,7 +333,7 @@ EOS
384
333
  [nil].pack('P').size
385
334
  rescue ArgumentError
386
335
  # Rubinius 1.2.3 doesn't support Array#pack('P').
387
- # Use Fixnum#size, which returns the size of long.
336
+ # Use Integer#size, which returns the size of long.
388
337
  1.size
389
338
  end
390
339
  is_32bit = size_of_pointer == 4
@@ -856,11 +805,8 @@ class OraConfFC < OraConf
856
805
  def get_home()
857
806
  oracle_home = ENV['ORACLE_HOME']
858
807
  if oracle_home.nil?
859
- struct = Struct.new("OracleHome", :name, :path)
860
- oracle_homes = []
861
- MiniRegistry.enum_homes do |name, path|
862
- path.chomp!("\\") if path
863
- oracle_homes << struct.new(name, path) if is_valid_home?(path)
808
+ oracle_homes = Registry::oracle_homes.select do |home|
809
+ is_valid_home?(home.path)
864
810
  end
865
811
  if oracle_homes.empty?
866
812
  raise <<EOS
@@ -116,12 +116,12 @@ static VALUE ora_date_s_allocate(VALUE klass)
116
116
  * OraDate.new(2012) # => 2012-01-01 00:00:00
117
117
  * OraDate.new(2012, 3, 4) # => 2012-03-04 00:00:00
118
118
  *
119
- * @param [Fixnum] year year
120
- * @param [Fixnum] month month
121
- * @param [Fixnum] day day of month
122
- * @param [Fixnum] hour hour
123
- * @param [Fixnum] min minute
124
- * @param [Fixnum] sec second
119
+ * @param [Integer] year year
120
+ * @param [Integer] month month
121
+ * @param [Integer] day day of month
122
+ * @param [Integer] hour hour
123
+ * @param [Integer] min minute
124
+ * @param [Integer] sec second
125
125
  */
126
126
  static VALUE ora_date_initialize(int argc, VALUE *argv, VALUE self)
127
127
  {
@@ -267,7 +267,7 @@ static VALUE ora_date_to_a(VALUE self)
267
267
  *
268
268
  * Returns the year field of <i>self</i>.
269
269
  *
270
- * @return [Fixnum]
270
+ * @return [Integer]
271
271
  */
272
272
  static VALUE ora_date_year(VALUE self)
273
273
  {
@@ -281,7 +281,7 @@ static VALUE ora_date_year(VALUE self)
281
281
  *
282
282
  * Assigns <i>num</i> to the year field of <i>self</i>.
283
283
  *
284
- * @param [Fixnum] num number between -4712 and 9999
284
+ * @param [Integer] num number between -4712 and 9999
285
285
  */
286
286
  static VALUE ora_date_set_year(VALUE self, VALUE val)
287
287
  {
@@ -299,7 +299,7 @@ static VALUE ora_date_set_year(VALUE self, VALUE val)
299
299
  * Returns the month field of <i>self</i>.
300
300
  * The month starts with one.
301
301
  *
302
- * @return [Fixnum]
302
+ * @return [Integer]
303
303
  */
304
304
  static VALUE ora_date_month(VALUE self)
305
305
  {
@@ -314,7 +314,7 @@ static VALUE ora_date_month(VALUE self)
314
314
  * Assigns <i>num</i> to the month field of <i>self</i>.
315
315
  * The month starts with one.
316
316
  *
317
- * @param [Fixnum] num number between 1 and 12
317
+ * @param [Integer] num number between 1 and 12
318
318
  */
319
319
  static VALUE ora_date_set_month(VALUE self, VALUE val)
320
320
  {
@@ -331,7 +331,7 @@ static VALUE ora_date_set_month(VALUE self, VALUE val)
331
331
  *
332
332
  * Returns the day of month field of <i>self</i>.
333
333
  *
334
- * @return [Fixnum]
334
+ * @return [Integer]
335
335
  */
336
336
  static VALUE ora_date_day(VALUE self)
337
337
  {
@@ -345,7 +345,7 @@ static VALUE ora_date_day(VALUE self)
345
345
  *
346
346
  * Assigns <i>num</i> to the day of month field of <i>self</i>.
347
347
  *
348
- * @param [Fixnum] num number between 1 and 31
348
+ * @param [Integer] num number between 1 and 31
349
349
  */
350
350
  static VALUE ora_date_set_day(VALUE self, VALUE val)
351
351
  {
@@ -362,7 +362,7 @@ static VALUE ora_date_set_day(VALUE self, VALUE val)
362
362
  *
363
363
  * Returns the hour field of <i>self</i>.
364
364
  *
365
- * @return [Fixnum]
365
+ * @return [Integer]
366
366
  */
367
367
  static VALUE ora_date_hour(VALUE self)
368
368
  {
@@ -376,7 +376,7 @@ static VALUE ora_date_hour(VALUE self)
376
376
  *
377
377
  * Assigns <i>num</i> to the hour field of <i>self</i>.
378
378
  *
379
- * @param [Fixnum] num number between 0 and 23
379
+ * @param [Integer] num number between 0 and 23
380
380
  */
381
381
  static VALUE ora_date_set_hour(VALUE self, VALUE val)
382
382
  {
@@ -393,7 +393,7 @@ static VALUE ora_date_set_hour(VALUE self, VALUE val)
393
393
  *
394
394
  * Returns the minute field of <i>self</i>.
395
395
  *
396
- * @return [Fixnum]
396
+ * @return [Integer]
397
397
  */
398
398
  static VALUE ora_date_minute(VALUE self)
399
399
  {
@@ -407,7 +407,7 @@ static VALUE ora_date_minute(VALUE self)
407
407
  *
408
408
  * Assigns <i>num</i> to the minute field of <i>self</i>.
409
409
  *
410
- * @param [Fixnum] num number between 0 and 59
410
+ * @param [Integer] num number between 0 and 59
411
411
  */
412
412
  static VALUE ora_date_set_minute(VALUE self, VALUE val)
413
413
  {
@@ -424,7 +424,7 @@ static VALUE ora_date_set_minute(VALUE self, VALUE val)
424
424
  *
425
425
  * Returns the second field of <i>self</i>.
426
426
  *
427
- * @return [Fixnum]
427
+ * @return [Integer]
428
428
  */
429
429
  static VALUE ora_date_second(VALUE self)
430
430
  {
@@ -438,7 +438,7 @@ static VALUE ora_date_second(VALUE self)
438
438
  *
439
439
  * Assigns <i>num</i> to the second field of <i>self</i>.
440
440
  *
441
- * @param [Fixnum] num number between 0 and 59
441
+ * @param [Integer] num number between 0 and 59
442
442
  */
443
443
  static VALUE ora_date_set_second(VALUE self, VALUE val)
444
444
  {