Index: django/db/models/sql/query.py
===================================================================
--- django/db/models/sql/query.py	(revision 9153)
+++ django/db/models/sql/query.py	(working copy)
@@ -27,9 +27,9 @@
 except NameError:
     from sets import Set as set     # Python 2.3 fallback
 
-__all__ = ['Query']
+__all__ = ['Query', 'BaseQuery']
 
-class Query(object):
+class BaseQuery(object):
     """
     A single SQL query.
     """
@@ -1747,7 +1747,9 @@
 # Use the backend's custom Query class if it defines one. Otherwise, use the
 # default.
 if connection.features.uses_custom_query_class:
-    Query = connection.ops.query_class(Query)
+    Query = connection.ops.query_class(BaseQuery)
+else:
+    Query = BaseQuery
 
 def get_order_dir(field, default='ASC'):
     """
Index: django/db/backends/oracle/query.py
===================================================================
--- django/db/backends/oracle/query.py	(revision 9153)
+++ django/db/backends/oracle/query.py	(working copy)
@@ -25,6 +25,18 @@
         pass
 
     class OracleQuery(QueryClass):
+        def __reduce__(self):
+            """
+            Enable pickling for this class (normal pickling handling doesn't
+            work as Python can only pickle module-level classes by default).
+            """
+            if hasattr(QueryClass, '__getstate__'):
+                assert hasattr(QueryClass, '__setstate__')
+                data = self.__getstate__()
+            else:
+                data = self.__dict__
+            return (unpickle_query_class, (QueryClass,), data)
+
         def resolve_columns(self, row, fields=()):
             index_start = len(self.extra_select.keys())
             values = [self.convert_values(v, None) for v in row[:index_start]]
@@ -143,3 +155,17 @@
 
     _classes[QueryClass] = OracleQuery
     return OracleQuery
+
+def unpickle_query_class(QueryClass):
+    """
+    Utility function for handling unpickling of Oracle Query subclasses. This
+    is called by Python's unpickling functions.
+    """
+    # FIXME: Would be nice to not have any dependency on cx_Oracle here. Since
+    # modules can't be pickled, we need a way to know to load the right module.
+    import cx_Oracle
+
+    klass = query_class(QueryClass, cx_Oracle)
+    return klass.__new__(klass)
+unpickle_query_class.__safe_for_unpickling__ = True
+
