]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- The "table_names" dialect function, used by MetaData
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 26 Dec 2009 22:34:28 +0000 (22:34 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 26 Dec 2009 22:34:28 +0000 (22:34 +0000)
.reflect(), omits Oracle "index overflow tables", a system
table generated by Oracle when "index only tables"
with overflow are used.  These tables aren't accessible
via SQL and can't be reflected.  [ticket:1637]

CHANGES
lib/sqlalchemy/databases/oracle.py
test/dialect/test_oracle.py

diff --git a/CHANGES b/CHANGES
index 86f3de00556401817d01eaf18dea0427f663c175..700d4b088a13861b8e7c95fdc6b66b2ae113255a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -131,7 +131,14 @@ CHANGES
     - Fixed erroneous reference to "owner" attribute in 
       Informix dialect when reflecting tables.
       [ticket:1645]
-      
+
+- oracle
+     - The "table_names" dialect function, used by MetaData
+       .reflect(), omits "index overflow tables", a system
+       table generated by Oracle when "index only tables"
+       with overflow are used.  These tables aren't accessible
+       via SQL and can't be reflected.  [ticket:1637]
+       
 - ext 
     - A column can be added to a joined-table declarative 
       superclass after the class has been constructed 
index 852cab448e78bf79c588544fedd8a72f062f1881..86c19aca428ab8648e82e3a606d90564f9913a23 100644 (file)
@@ -516,10 +516,13 @@ class OracleDialect(default.DefaultDialect):
     def table_names(self, connection, schema):
         # note that table_names() isnt loading DBLINKed or synonym'ed tables
         if schema is None:
-            s = "select table_name from all_tables where nvl(tablespace_name, 'no tablespace') NOT IN ('SYSTEM', 'SYSAUX')"
+            s = "select table_name from all_tables where nvl(tablespace_name, 'no tablespace') "\
+                "NOT IN ('SYSTEM', 'SYSAUX') AND IOT_NAME IS NULL"
             cursor = connection.execute(s)
         else:
-            s = "select table_name from all_tables where nvl(tablespace_name, 'no tablespace') NOT IN ('SYSTEM','SYSAUX') AND OWNER = :owner"
+            s = "select table_name from all_tables where nvl(tablespace_name, 'no tablespace') "\
+                "NOT IN ('SYSTEM','SYSAUX') AND OWNER = :owner "\
+                "AND IOT_NAME IS NULL"
             cursor = connection.execute(s, {'owner': self._denormalize_name(schema)})
         return [self._normalize_name(row[0]) for row in cursor]
 
index d9d64806e814d21efc439516cdbc5dd67f7c2889..de04beb394f29105bbdcb71c516a66985db63a03 100644 (file)
@@ -396,6 +396,35 @@ class TypesTest(TestBase, AssertsCompiledSQL):
             eq_(row['bindata'].read(), 'this is binary')
         finally:
             t.drop(engine)
+            
+class DontReflectIOTTest(TestBase):
+    """test that index overflow tables aren't included in table_names."""
+    
+    def setup(self):
+        testing.db.execute("""
+        CREATE TABLE admin_docindex(
+                token char(20), 
+                doc_id NUMBER,
+                token_frequency NUMBER,
+                token_offsets VARCHAR2(2000),
+                CONSTRAINT pk_admin_docindex PRIMARY KEY (token, doc_id))
+            ORGANIZATION INDEX 
+            TABLESPACE users
+            PCTTHRESHOLD 20
+            OVERFLOW TABLESPACE users
+        """)
+    
+    def teardown(self):
+        testing.db.execute("drop table admin_docindex")
+    
+    def test_reflect_all(self):
+        m = MetaData(testing.db)
+        m.reflect()
+        eq_(
+            set(t.name for t in m.tables.values()),
+            set(['admin_docindex'])
+        )
+        
 class BufferedColumnTest(TestBase, AssertsCompiledSQL):
     __only_on__ = 'oracle'