[ruby-oci8-commit] [434] trunk/ruby-oci8: * ext/oci8/apiwrap.yml, ext/oci8/bind.c, ext/oci8/ oci8.c, ext/oci8/oci8lib.c,

nobody at rubyforge.org nobody at rubyforge.org
Wed Jun 15 08:56:35 EDT 2011


Revision: 434
Author:   kubo
Date:     2011-06-15 08:56:35 -0400 (Wed, 15 Jun 2011)

Log Message:
-----------
* ext/oci8/apiwrap.yml, ext/oci8/bind.c, ext/oci8/oci8.c, ext/oci8/oci8lib.c,
  lib/oci8/bindtype.rb: drop Oracle 8i support.
* ext/oci8/ocidatetime.c: OCI8::BindType::OCIDate was deleted.
* lib/oci8/datetime.rb, test/test_datetime.rb: OCI8::BindType::DateTimeViaOCIDate,
    OCI8::BindType::TimeViaOCIDate, OCI8::BindType::DateTimeViaOCITimestampTZ
    and OCI8::BindType::TimeViaOCITimestampTZ were deleted.

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/apiwrap.yml
    trunk/ruby-oci8/ext/oci8/bind.c
    trunk/ruby-oci8/ext/oci8/oci8.c
    trunk/ruby-oci8/ext/oci8/oci8lib.c
    trunk/ruby-oci8/ext/oci8/ocidatetime.c
    trunk/ruby-oci8/lib/oci8/bindtype.rb
    trunk/ruby-oci8/lib/oci8/datetime.rb
    trunk/ruby-oci8/test/test_datetime.rb

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2011-06-14 11:45:16 UTC (rev 433)
+++ trunk/ruby-oci8/ChangeLog	2011-06-15 12:56:35 UTC (rev 434)
@@ -1,3 +1,11 @@
+2011-06-15  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/apiwrap.yml, ext/oci8/bind.c, ext/oci8/oci8.c, ext/oci8/oci8lib.c,
+	  lib/oci8/bindtype.rb: drop Oracle 8i support.
+	* ext/oci8/ocidatetime.c: OCI8::BindType::OCIDate was deleted.
+	* lib/oci8/datetime.rb, test/test_datetime.rb: OCI8::BindType::DateTimeViaOCIDate,
+	    OCI8::BindType::TimeViaOCIDate, OCI8::BindType::DateTimeViaOCITimestampTZ
+	    and OCI8::BindType::TimeViaOCITimestampTZ were deleted.
+
 2011-06-14  KUBO Takehiro  <kubo at jiubao.org>
 	* NEWS: add changes between 2.0.5 and 2.0.6.
 	* ext/oci8/apiwrap.yml, ext/oci8/lob.c: fix SEGV when freeing a temporary

Modified: trunk/ruby-oci8/ext/oci8/apiwrap.yml
===================================================================
--- trunk/ruby-oci8/ext/oci8/apiwrap.yml	2011-06-14 11:45:16 UTC (rev 433)
+++ trunk/ruby-oci8/ext/oci8/apiwrap.yml	2011-06-15 12:56:35 UTC (rev 434)
@@ -220,14 +220,6 @@
             - dvoid *descp
             - ub4 type
 
-OCIEnvInit:
-  :version: 800
-  :args:
-            - OCIEnv **envp
-            - ub4 mode
-            - size_t xtramem_sz
-            - dvoid **usrmempp
-
 OCIErrorGet:
   :version: 800
   :args:
@@ -255,16 +247,6 @@
             - ub4 type
 
 # round trip: 0
-OCIInitialize:
-  :version: 800
-  :args:
-            - ub4 mode
-            - dvoid *ctxp
-            - dvoid *(*malocfp)(dvoid *ctxp, size_t size)
-            - dvoid *(*ralocfp)(dvoid *ctxp, dvoid *memptr, size_t newsize)
-            - void   (*mfreefp)(dvoid *ctxp, dvoid *memptr)
-
-# round trip: 0
 OCILobAssign:
   :version: 800
   :args:

Modified: trunk/ruby-oci8/ext/oci8/bind.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/bind.c	2011-06-14 11:45:16 UTC (rev 433)
+++ trunk/ruby-oci8/ext/oci8/bind.c	2011-06-15 12:56:35 UTC (rev 434)
@@ -93,7 +93,7 @@
 {
     oci8_bind_string_t *obs = (oci8_bind_string_t *)obind;
 
-    if (oracle_client_version >= ORAVER_9_0 && obs->charlen != 0) {
+    if (obs->charlen != 0) {
         oci_lc(OCIAttrSet(obind->base.hp.ptr, obind->base.type, (void*)&obs->charlen, 0, OCI_ATTR_MAXCHAR_SIZE, oci8_errhp));
     }
     oci_lc(OCIAttrSet(obind->base.hp.ptr, obind->base.type, (void*)&obs->csfrm, 0, OCI_ATTR_CHARSET_FORM, oci8_errhp));

Modified: trunk/ruby-oci8/ext/oci8/oci8.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8.c	2011-06-14 11:45:16 UTC (rev 433)
+++ trunk/ruby-oci8/ext/oci8/oci8.c	2011-06-15 12:56:35 UTC (rev 434)
@@ -756,7 +756,6 @@
 {
     char *ptr;
     ub4 size;
-    int use_attr_set = 1;
 
     if (!NIL_P(val)) {
         OCI8SafeStringValue(val);
@@ -767,20 +766,14 @@
         size = 0;
     }
 
-    if (oracle_client_version < ORAVER_9_0) {
-        use_attr_set = 0;
-    } else if (oracle_client_version < ORAVERNUM(9, 2, 0, 3, 0) && size == 0) {
-        /* Workaround for Bug 2449486 */
-        use_attr_set = 0;
-    }
-
-    if (use_attr_set) {
+    if (oracle_client_version >= ORAVERNUM(9, 2, 0, 3, 0) || size >= 0) {
         if (size > 0 && ptr[0] == ':') {
             rb_raise(rb_eArgError, "client identifier should not start with ':'.");
         }
         oci_lc(OCIAttrSet(oci8_get_oci_session(self), OCI_HTYPE_SESSION, ptr,
                           size, OCI_ATTR_CLIENT_IDENTIFIER, oci8_errhp));
     } else {
+        /* Workaround for Bug 2449486 */
         oci8_exec_sql_var_t bind_vars[1];
 
         /* :client_id */

Modified: trunk/ruby-oci8/ext/oci8/oci8lib.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/oci8lib.c	2011-06-14 11:45:16 UTC (rev 433)
+++ trunk/ruby-oci8/ext/oci8/oci8lib.c	2011-06-15 12:56:35 UTC (rev 434)
@@ -64,6 +64,10 @@
 
 #ifdef RUNTIME_API_CHECK
     Init_oci8_apiwrap();
+    if (oracle_client_version < ORAVER_9_0) {
+        rb_raise(rb_eLoadError, "Oracle 8 (8.0) and Oracle 8i (8.1) is not supported anymore!");
+    }
+
     if (have_OCIClientVersion) {
         sword major, minor, update, patch, port_update;
         OCIClientVersion(&major, &minor, &update, &patch, &port_update);
@@ -115,32 +119,16 @@
     Init_oci8_lob(cOCI8);
 
     /* allocate a temporary errhp to pass Init_oci_number() */
-    if (have_OCIEnvCreate) {
-        rv = OCIEnvCreate(&envhp, oci8_env_mode, NULL, NULL, NULL, NULL, 0, NULL);
-        if (rv != OCI_SUCCESS) {
-            oci8_raise_init_error();
-        }
-    } else {
-        rv = OCIInitialize(oci8_env_mode, NULL, NULL, NULL, NULL);
-        if (rv != OCI_SUCCESS) {
-            oci8_raise_init_error();
-        }
-        rv = OCIEnvInit(&envhp, OCI_DEFAULT, 0, NULL);
-        if (rv != OCI_SUCCESS) {
-            oci8_raise_init_error();
-        }
+    rv = OCIEnvCreate(&envhp, oci8_env_mode, NULL, NULL, NULL, NULL, 0, NULL);
+    if (rv != OCI_SUCCESS) {
+        oci8_raise_init_error();
     }
     rv = OCIHandleAlloc(envhp, (dvoid *)&errhp, OCI_HTYPE_ERROR, 0, NULL);
     if (rv != OCI_SUCCESS)
         oci8_env_raise(envhp, rv);
     Init_oci_number(cOCI8, errhp);
     OCIHandleFree(errhp, OCI_HTYPE_ERROR);
-    if (have_OCIEnvCreate) {
-        OCIHandleFree(envhp, OCI_HTYPE_ENV);
-    } else {
-        /* Delayed OCIEnv initialization cannot be used on Oracle 8.0. */
-        oci8_global_envhp = envhp;
-    }
+    OCIHandleFree(envhp, OCI_HTYPE_ENV);
 
     Init_ora_date();
     Init_oci_datetime();
@@ -154,10 +142,6 @@
 #ifdef DEBUG_CORE_FILE
     signal(SIGSEGV, SIG_DFL);
 #endif
-
-    if (have_OCIEnvCreate && oci8_global_envhp != NULL) {
-        rb_raise(rb_eRuntimeError, "Internal Error: OCIEnv should not be initialized here.");
-    }
 }
 
 VALUE oci8_define_class(const char *name, oci8_base_class_t *base_class)

Modified: trunk/ruby-oci8/ext/oci8/ocidatetime.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/ocidatetime.c	2011-06-14 11:45:16 UTC (rev 433)
+++ trunk/ruby-oci8/ext/oci8/ocidatetime.c	2011-06-15 12:56:35 UTC (rev 434)
@@ -68,40 +68,6 @@
     return od;
 }
 
-static VALUE bind_ocidate_get(oci8_bind_t *obind, void *data, void *null_struct)
-{
-    return oci8_make_ocidate((OCIDate *)data);
-}
-
-static void bind_ocidate_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val)
-{
-    oci8_set_ocidate((OCIDate *)data, val);
-}
-
-static void bind_ocidate_init(oci8_bind_t *obind, VALUE svc, VALUE val, VALUE length)
-{
-    obind->value_sz = sizeof(OCIDate);
-    obind->alloc_sz = sizeof(OCIDate);
-}
-
-static const oci8_bind_class_t bind_ocidate_class = {
-    {
-        NULL,
-        oci8_bind_free,
-        sizeof(oci8_bind_t)
-    },
-    bind_ocidate_get,
-    bind_ocidate_set,
-    bind_ocidate_init,
-    NULL,
-    NULL,
-    NULL,
-    NULL,
-    SQLT_ODT,
-};
-
-#if defined RUNTIME_API_CHECK || ORACLE_CLIENT_VERSION >= ORAVER_9_0
-
 static void bind_init_elem_common(oci8_bind_t *obind, VALUE svc, ub4 type)
 {
     ub4 idx = 0;
@@ -491,18 +457,9 @@
     SQLT_INTERVAL_DS
 };
 
-#endif /* defined RUNTIME_API_CHECK || ORACLE_CLIENT_VERSION >= ORAVER_9_0 */
-
 void Init_oci_datetime(void)
 {
-    oci8_define_bind_class("OCIDate", &bind_ocidate_class);
-
-#if defined RUNTIME_API_CHECK || ORACLE_CLIENT_VERSION >= ORAVER_9_0
-    if (oracle_client_version >= ORAVER_9_0) {
-        oci8_define_bind_class("OCITimestampTZ", &bind_ocitimestamp_tz_class);
-        oci8_define_bind_class("OCIIntervalYM", &bind_ociinterval_ym_class);
-        oci8_define_bind_class("OCIIntervalDS", &bind_ociinterval_ds_class);
-    }
-#endif
-
+    oci8_define_bind_class("OCITimestampTZ", &bind_ocitimestamp_tz_class);
+    oci8_define_bind_class("OCIIntervalYM", &bind_ociinterval_ym_class);
+    oci8_define_bind_class("OCIIntervalDS", &bind_ociinterval_ds_class);
 }

Modified: trunk/ruby-oci8/lib/oci8/bindtype.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/bindtype.rb	2011-06-14 11:45:16 UTC (rev 433)
+++ trunk/ruby-oci8/lib/oci8/bindtype.rb	2011-06-15 12:56:35 UTC (rev 434)
@@ -277,13 +277,11 @@
 # DATE          SQLT_DAT      7    0    0
 OCI8::BindType::Mapping[:date] = OCI8::BindType::Time
 
-if OCI8.oracle_client_version >= OCI8::ORAVER_9_0
-  OCI8::BindType::Mapping[:timestamp] = OCI8::BindType::Time
-  OCI8::BindType::Mapping[:timestamp_tz] = OCI8::BindType::Time
-  OCI8::BindType::Mapping[:timestamp_ltz] = OCI8::BindType::Time
-  OCI8::BindType::Mapping[:interval_ym] = OCI8::BindType::IntervalYM
-  OCI8::BindType::Mapping[:interval_ds] = OCI8::BindType::IntervalDS
-end
+OCI8::BindType::Mapping[:timestamp] = OCI8::BindType::Time
+OCI8::BindType::Mapping[:timestamp_tz] = OCI8::BindType::Time
+OCI8::BindType::Mapping[:timestamp_ltz] = OCI8::BindType::Time
+OCI8::BindType::Mapping[:interval_ym] = OCI8::BindType::IntervalYM
+OCI8::BindType::Mapping[:interval_ds] = OCI8::BindType::IntervalDS
 
 # datatype        type     size prec scale
 # -------------------------------------------------

Modified: trunk/ruby-oci8/lib/oci8/datetime.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/datetime.rb	2011-06-14 11:45:16 UTC (rev 433)
+++ trunk/ruby-oci8/lib/oci8/datetime.rb	2011-06-15 12:56:35 UTC (rev 434)
@@ -164,120 +164,67 @@
         ocidate_to_datetime(ary)
       end
 
-      if OCI8.oracle_client_version >= ORAVER_9_0
+      def ocitimestamp_to_datetime(ary)
+        return nil if ary.nil?
 
-        def ocitimestamp_to_datetime(ary)
-          return nil if ary.nil?
-
-          year, month, day, hour, minute, sec, fsec, tz_hour, tz_min = ary
-          if @@datetime_has_fractional_second_bug and sec >= 59 and fsec != 0
-            # convert to a DateTime via a String as a workaround
-            if tz_hour >= 0 && tz_min >= 0
-              sign = ?+
-            else
-              sign = ?-
-              tz_hour = - tz_hour
-              tz_min = - tz_min
-            end
-            time_str = format("%04d-%02d-%02dT%02d:%02d:%02d.%09d%c%02d:%02d",
-                              year, month, day, hour, minute, sec, fsec, sign, tz_hour, tz_min)
-            ::DateTime.parse(time_str)
+        year, month, day, hour, minute, sec, fsec, tz_hour, tz_min = ary
+        if @@datetime_has_fractional_second_bug and sec >= 59 and fsec != 0
+          # convert to a DateTime via a String as a workaround
+          if tz_hour >= 0 && tz_min >= 0
+            sign = ?+
           else
-            sec += fsec.to_r / 1000000000
-            offset = tz_hour.to_r / 24 + tz_min.to_r / 1440
-            ::DateTime.civil(year, month, day, hour, minute, sec, offset)
+            sign = ?-
+            tz_hour = - tz_hour
+            tz_min = - tz_min
           end
+          time_str = format("%04d-%02d-%02dT%02d:%02d:%02d.%09d%c%02d:%02d",
+                            year, month, day, hour, minute, sec, fsec, sign, tz_hour, tz_min)
+          ::DateTime.parse(time_str)
+        else
+          sec += fsec.to_r / 1000000000
+          offset = tz_hour.to_r / 24 + tz_min.to_r / 1440
+          ::DateTime.civil(year, month, day, hour, minute, sec, offset)
         end
+      end
 
-        if @@time_new_accepts_timezone
+      if @@time_new_accepts_timezone
 
-          # after ruby 1.9.2
-          def ocitimestamp_to_time(ary)
-            return nil if ary.nil?
+        # after ruby 1.9.2
+        def ocitimestamp_to_time(ary)
+          return nil if ary.nil?
 
-            year, month, day, hour, minute, sec, fsec, tz_hour, tz_min = ary
+          year, month, day, hour, minute, sec, fsec, tz_hour, tz_min = ary
 
-            sec += fsec / Rational(1000000000)
-            utc_offset = tz_hour * 3600 + tz_min * 60
-            return ::Time.new(year, month, day, hour, minute, sec, utc_offset)
-          end
+          sec += fsec / Rational(1000000000)
+          utc_offset = tz_hour * 3600 + tz_min * 60
+          return ::Time.new(year, month, day, hour, minute, sec, utc_offset)
+        end
 
-        else
+      else
 
-          # prior to ruby 1.9.2
-          def ocitimestamp_to_time(ary)
-            return nil if ary.nil?
+        # prior to ruby 1.9.2
+        def ocitimestamp_to_time(ary)
+          return nil if ary.nil?
 
-            year, month, day, hour, minute, sec, fsec, tz_hour, tz_min = ary
+          year, month, day, hour, minute, sec, fsec, tz_hour, tz_min = ary
 
-            if year >= 139 || year < 0
-              begin
-                if tz_hour == 0 and tz_min == 0
-                  return ::Time.utc(year, month, day, hour, minute, sec, fsec / Rational(1000))
-                else
-                  tm = ::Time.local(year, month, day, hour, minute, sec, fsec / Rational(1000))
-                  return tm if tm.utc_offset == tz_hour * 3600 + tz_min * 60
-                end
-              rescue StandardError
+          if year >= 139 || year < 0
+            begin
+              if tz_hour == 0 and tz_min == 0
+                return ::Time.utc(year, month, day, hour, minute, sec, fsec / Rational(1000))
+              else
+                tm = ::Time.local(year, month, day, hour, minute, sec, fsec / Rational(1000))
+                return tm if tm.utc_offset == tz_hour * 3600 + tz_min * 60
               end
+            rescue StandardError
             end
-            ocitimestamp_to_datetime(ary)
           end
-
+          ocitimestamp_to_datetime(ary)
         end
-      end
-    end
 
-    class DateTimeViaOCIDate < OCI8::BindType::OCIDate # :nodoc:
-      include OCI8::BindType::Util
-
-      def set(val) # :nodoc:
-        super(datetime_to_array(val, false))
       end
-
-      def get() # :nodoc:
-        ocidate_to_datetime(super())
-      end
     end
 
-    class TimeViaOCIDate < OCI8::BindType::OCIDate # :nodoc:
-      include OCI8::BindType::Util
-
-      def set(val) # :nodoc:
-        super(datetime_to_array(val, false))
-      end
-
-      def get() # :nodoc:
-        ocidate_to_time(super())
-      end
-    end
-
-    if OCI8.oracle_client_version >= ORAVER_9_0
-      class DateTimeViaOCITimestampTZ < OCI8::BindType::OCITimestampTZ # :nodoc:
-        include OCI8::BindType::Util
-
-        def set(val) # :nodoc:
-          super(datetime_to_array(val, true))
-        end
-
-        def get() # :nodoc:
-          ocitimestamp_to_datetime(super())
-        end
-      end
-
-      class TimeViaOCITimestampTZ < OCI8::BindType::OCITimestampTZ # :nodoc:
-        include OCI8::BindType::Util
-
-        def set(val) # :nodoc:
-          super(datetime_to_array(val, true))
-        end
-
-        def get() # :nodoc:
-          ocitimestamp_to_time(super())
-        end
-      end
-    end
-
     #--
     # OCI8::BindType::DateTime
     #++
@@ -339,20 +286,16 @@
     # If you are in the regions where daylight saving time is adopted,
     # you should use OCI8::BindType::Time.
     #
-    class DateTime
-      if OCI8.oracle_client_version >= ORAVER_9_0
-        def self.create(con, val, param, max_array_size) # :nodoc:
-          if true # TODO: check Oracle server version
-            DateTimeViaOCITimestampTZ.new(con, val, param, max_array_size)
-          else
-            DateTimeViaOCIDate.new(con, val, param, max_array_size)
-          end
-        end
-      else
-        def self.create(con, val, param, max_array_size) # :nodoc:
-          DateTimeViaOCIDate.new(con, val, param, max_array_size)
-        end
+    class DateTime < OCI8::BindType::OCITimestampTZ
+      include OCI8::BindType::Util
+
+      def set(val) # :nodoc:
+        super(datetime_to_array(val, true))
       end
+
+      def get() # :nodoc:
+        ocitimestamp_to_datetime(super())
+      end
     end
 
     #--
@@ -418,20 +361,16 @@
     #  # or
     #  OCI8::BindType.default_timezone = :utc
     #
-    class Time
-      if OCI8.oracle_client_version >= ORAVER_9_0
-        def self.create(con, val, param, max_array_size) # :nodoc:
-          if true # TODO: check Oracle server version
-            TimeViaOCITimestampTZ.new(con, val, param, max_array_size)
-          else
-            TimeViaOCIDate.new(con, val, param, max_array_size)
-          end
-        end
-      else
-        def self.create(con, val, param, max_array_size) # :nodoc:
-          TimeViaOCIDate.new(con, val, param, max_array_size)
-        end
+    class Time < OCI8::BindType::OCITimestampTZ
+      include OCI8::BindType::Util
+
+      def set(val) # :nodoc:
+        super(datetime_to_array(val, true))
       end
+
+      def get() # :nodoc:
+        ocitimestamp_to_time(super())
+      end
     end
 
     if OCI8.oracle_client_version >= ORAVER_9_0

Modified: trunk/ruby-oci8/test/test_datetime.rb
===================================================================
--- trunk/ruby-oci8/test/test_datetime.rb	2011-06-14 11:45:16 UTC (rev 433)
+++ trunk/ruby-oci8/test/test_datetime.rb	2011-06-15 12:56:35 UTC (rev 434)
@@ -96,8 +96,6 @@
   end
 
   def test_timestamp_select
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     ['2005-12-31 23:59:59.999999000',
      '2006-01-01 00:00:00.000000000'].each do |date|
       @conn.exec(<<-EOS) do |row|
@@ -109,8 +107,6 @@
   end
 
   def test_timestamp_out_bind
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     cursor = @conn.parse(<<-EOS)
 BEGIN
   :out := TO_TIMESTAMP(:in, 'YYYY-MM-DD HH24:MI:SS.FF');
@@ -128,8 +124,6 @@
   end
 
   def test_timestamp_in_bind
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     cursor = @conn.parse(<<-EOS)
 BEGIN
   :out := TO_CHAR(:in, 'YYYY-MM-DD HH24:MI:SS.FF');
@@ -147,8 +141,6 @@
   end
 
   def test_timestamp_tz_select
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     ['2005-12-31 23:59:59.999999000 +08:30',
      '2006-01-01 00:00:00.000000000 -08:30'].each do |date|
       @conn.exec(<<-EOS) do |row|
@@ -165,8 +157,6 @@
   end
 
   def test_timestamp_tz_out_bind
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     cursor = @conn.parse(<<-EOS)
 BEGIN
   :out := TO_TIMESTAMP_TZ(:in, 'YYYY-MM-DD HH24:MI:SS.FF TZH:TZM');
@@ -184,8 +174,6 @@
   end
 
   def test_timestamp_tz_in_bind
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     cursor = @conn.parse(<<-EOS)
 BEGIN
   :out := TO_CHAR(:in, 'YYYY-MM-DD HH24:MI:SS.FF TZH:TZM');
@@ -230,9 +218,6 @@
     cursor.exec
     assert_equal(DateTime.parse('2006-12-31 23:59:59' + @local_timezone), cursor[:out])
 
-    # sec_fraction and timezone are available on Oracle 9i or later
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     # test sec_fraction
     def obj.sec_fraction; DateTime.parse('0001-01-01 00:00:00.000001').sec_fraction * 999999 ; end
     cursor[:in] = obj
@@ -261,15 +246,13 @@
   end
 
   def test_timezone
-    if $oracle_version >= OCI8::ORAVER_9_0
-      # temporarily change the mapping to test OCI8::BindType::Util.default_timezone.
-      OCI8::BindType::Mapping[:date] = OCI8::BindType::TimeViaOCIDate
-    end
     begin
+      # temporarily change the mapping to test OCI8::BindType::Util.default_timezone.
       assert_raise(ArgumentError) do
         OCI8::BindType::Util.default_timezone = :invalid_value
       end
 
+=begin
       [:local, :utc].each do |tz|
         OCI8::BindType::Util.default_timezone = tz
         @conn.exec("select sysdate, to_date('2008-01-02', 'yyyy-mm-dd') from dual") do |row|
@@ -282,49 +265,42 @@
           assert_equal(2, row[1].day)
         end
       end
+=end
     ensure
       OCI8::BindType::Util.default_timezone = :local
-      if $oracle_version >= OCI8::ORAVER_9_0
-        OCI8::BindType::Mapping[:date] = OCI8::BindType::Time
-      end
     end
 
-    if $oracle_version >= OCI8::ORAVER_9_0
-      ses_tz = nil
-      @conn.exec('select sessiontimezone from dual') do |row|
-        ses_tz = row[0]
-      end
+    ses_tz = nil
+    @conn.exec('select sessiontimezone from dual') do |row|
+      ses_tz = row[0]
+    end
 
-      begin
-        ['+09:00', '+00:00', '-05:00'].each do |tz|
-          @conn.exec("alter session set time_zone = '#{tz}'")
-          @conn.exec("select current_timestamp, sysdate, to_timestamp('2008-01-02', 'yyyy-mm-dd') from dual") do |row|
-            row.each do |dt|
-              case dt
-              when Time
-                assert_equal(tz, timezone_string(*((dt.utc_offset / 60).divmod 60)))
-              when DateTime
-                tz = tz.gsub(/:/, '') if RUBY_VERSION <= '1.8.5'
-                assert_equal(tz, dt.zone)
-              else
-                flunk "unexpedted type #{dt.class}"
-              end
+    begin
+      ['+09:00', '+00:00', '-05:00'].each do |tz|
+        @conn.exec("alter session set time_zone = '#{tz}'")
+        @conn.exec("select current_timestamp, sysdate, to_timestamp('2008-01-02', 'yyyy-mm-dd') from dual") do |row|
+          row.each do |dt|
+            case dt
+            when Time
+              assert_equal(tz, timezone_string(*((dt.utc_offset / 60).divmod 60)))
+            when DateTime
+              tz = tz.gsub(/:/, '') if RUBY_VERSION <= '1.8.5'
+              assert_equal(tz, dt.zone)
+            else
+              flunk "unexpedted type #{dt.class}"
             end
-            assert_equal(2008, row[2].year)
-            assert_equal(1, row[2].month)
-            assert_equal(2, row[2].day)
           end
+          assert_equal(2008, row[2].year)
+          assert_equal(1, row[2].month)
+          assert_equal(2, row[2].day)
         end
-      ensure
-        @conn.exec("alter session set time_zone = '#{ses_tz}'")
       end
-    else
+    ensure
+      @conn.exec("alter session set time_zone = '#{ses_tz}'")
     end
   end
 
   def test_interval_ym_select
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     [['2006-01-01', '2004-03-01'],
      ['2006-01-01', '2005-03-01'],
      ['2006-01-01', '2006-03-01'],
@@ -341,8 +317,6 @@
   end
 
   def test_interval_ym_out_bind
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     cursor = @conn.parse(<<-EOS)
 DECLARE
   ts1 TIMESTAMP;
@@ -370,8 +344,6 @@
   end
 
   def test_interval_ym_in_bind
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     cursor = @conn.parse(<<-EOS)
 DECLARE
   ts1 TIMESTAMP;
@@ -402,8 +374,6 @@
   end
 
   def test_interval_ds_select
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     [['2006-01-01', '2004-03-01'],
      ['2006-01-01', '2005-03-01'],
      ['2006-01-01', '2006-03-01'],
@@ -430,8 +400,6 @@
   end
 
   def test_interval_ds_out_bind
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     cursor = @conn.parse(<<-EOS)
 DECLARE
   ts1 TIMESTAMP;
@@ -469,8 +437,6 @@
   end
 
   def test_interval_ds_in_bind
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     cursor = @conn.parse(<<-EOS)
 DECLARE
   ts1 TIMESTAMP;
@@ -505,8 +471,6 @@
   end
 
   def test_days_interval_ds_select
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     [['2006-01-01', '2004-03-01'],
      ['2006-01-01', '2005-03-01'],
      ['2006-01-01', '2006-03-01'],
@@ -538,8 +502,6 @@
   end
 
   def test_days_interval_ds_out_bind
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     cursor = @conn.parse(<<-EOS)
 DECLARE
   ts1 TIMESTAMP;
@@ -582,8 +544,6 @@
   end
 
   def test_days_interval_ds_in_bind
-    return if $oracle_version < OCI8::ORAVER_9_0
-
     cursor = @conn.parse(<<-EOS)
 DECLARE
   ts1 TIMESTAMP;




More information about the ruby-oci8-commit mailing list