when a relation isn't supported by a ms query parts, dereference introduced variable refs stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 15 Jun 2009 18:28:44 +0200
branchstable
changeset 2109 f469368df530
parent 2108 b3f6fa7ad59f
child 2110 d7773fb1b892
when a relation isn't supported by a ms query parts, dereference introduced variable refs
server/msplanner.py
--- a/server/msplanner.py	Mon Jun 15 18:26:31 2009 +0200
+++ b/server/msplanner.py	Mon Jun 15 18:28:44 2009 +0200
@@ -1216,6 +1216,7 @@
         self.terms = terms
         self.solindices = solindices
         self.final = final
+        self._pending_vrefs = []
         # terms which appear in unsupported branches
         needsel |= self.extneedsel
         self.needsel = needsel
@@ -1369,9 +1370,12 @@
         else:
             raise UnsupportedBranch()
         rschema = self.schema.rschema(node.r_type)
+        self._pending_vrefs = []
         try:
             res = self.visit_default(node, newroot, terms)[0]
-        except Exception, ex:
+        except:
+            for vref in self._pending_vrefs:
+                vref.unregister_reference()
             raise
         ored = node.ored()
         if rschema.is_final() or rschema.inlined:
@@ -1434,7 +1438,9 @@
         # set scope so we can insert types restriction properly
         newvar = newroot.get_variable(node.name)
         newvar.stinfo['scope'] = self.scopes.get(node.variable.scope, newroot)
-        return VariableRef(newvar), node
+        vref = VariableRef(newvar)
+        self._pending_vrefs.append(vref)
+        return vref, node
 
     def visit_constant(self, node, newroot, terms):
         return copy_node(newroot, node), node