[ruby-oci8-commit] [334] branches/ruby-oci8-1.0: * lib/dbd/OCI8.rb: A data dictionary all_constraints doesn't have

nobody at rubyforge.org nobody at rubyforge.org
Sat Apr 11 22:59:35 EDT 2009


Revision: 334
Author:   kubo
Date:     2009-04-11 22:59:34 -0400 (Sat, 11 Apr 2009)

Log Message:
-----------
* lib/dbd/OCI8.rb: A data dictionary all_constraints doesn't have
    index_name column on Oracle 8i or lower. Rewrite
    DBI::DBD::OCI8::Database#column by using all_cons_columns.
    (backport from ruby-oci8 trunk)

Modified Paths:
--------------
    branches/ruby-oci8-1.0/ChangeLog
    branches/ruby-oci8-1.0/lib/dbd/OCI8.rb

Modified: branches/ruby-oci8-1.0/ChangeLog
===================================================================
--- branches/ruby-oci8-1.0/ChangeLog	2009-04-12 02:51:49 UTC (rev 333)
+++ branches/ruby-oci8-1.0/ChangeLog	2009-04-12 02:59:34 UTC (rev 334)
@@ -1,4 +1,10 @@
 2009-04-12  KUBO Takehiro  <kubo at jiubao.org>
+	* lib/dbd/OCI8.rb: A data dictionary all_constraints doesn't have
+	    index_name column on Oracle 8i or lower. Rewrite
+	    DBI::DBD::OCI8::Database#column by using all_cons_columns.
+	    (backport from ruby-oci8 trunk)
+
+2009-04-12  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/extconf.rb, ext/oci8/oci8.h, ext/oci8/oraconf.rb:
 	    fix a problem when compiling for Oracle 8.0.
 	    (reported by Axel Reinhold as a ruby-oci8 2.0 issue)

Modified: branches/ruby-oci8-1.0/lib/dbd/OCI8.rb
===================================================================
--- branches/ruby-oci8-1.0/lib/dbd/OCI8.rb	2009-04-12 02:51:49 UTC (rev 333)
+++ branches/ruby-oci8-1.0/lib/dbd/OCI8.rb	2009-04-12 02:59:34 UTC (rev 334)
@@ -245,19 +245,21 @@
 
     dbh = DBI::DatabaseHandle.new(self)
 
-    pk_index_name = nil
+    primaries = {}
     dbh.select_all(<<EOS, tab.obj_schema, tab.obj_name) do |row|
-select index_name
-  from all_constraints
- where constraint_type = 'P'
-   and owner = :1
-   and table_name = :2
+select column_name
+  from all_cons_columns a, all_constraints b
+ where a.owner = b.owner
+   and a.constraint_name = b.constraint_name
+   and a.table_name = b.table_name
+   and b.constraint_type = 'P'
+   and b.owner = :1
+   and b.table_name = :2
 EOS
-      pk_index_name = row[0]
+      primaries[row[0]] = true
     end
 
     indices = {}
-    primaries = {}
     uniques = {}
     dbh.select_all(<<EOS, tab.obj_schema, tab.obj_name) do |row|
 select a.column_name, a.index_name, b.uniqueness
@@ -269,7 +271,6 @@
 EOS
       col_name, index_name, uniqueness = row
       indices[col_name] = true
-      primaries[col_name] = true if index_name == pk_index_name
       uniques[col_name] = true if uniqueness == 'UNIQUE'
     end
 




More information about the ruby-oci8-commit mailing list