def _collect_elements(self): # If expr is a ValueExpr, we must seek out the TableExprs that it # references, build their ASTs, and mark them in our QueryContext # For now, we need to make the simplifying assumption that a value # expression that is being translated only depends on a single table # expression. source_expr = self.query_expr # hm, is this the best place for this? root_op = source_expr.op() if (isinstance(root_op, ops.Join) and not isinstance(root_op, ops.MaterializedJoin)): # Unmaterialized join source_expr = source_expr.materialize() if isinstance(root_op, ops.TableNode): self._collect(source_expr, toplevel=True) if self.table_set is None: raise com.InternalError('no table set') else: # Expressions not depending on any table if isinstance(root_op, ir.ExpressionList): self.select_set = source_expr.exprs() else: self.select_set = [source_expr]
def _get_cursor(self): try: cur = self.connection_pool.get(False) if cur.database != self.database: cur = self._new_cursor() if cur.codegen_disabled != self.codegen_disabled: cur.disable_codegen(self.codegen_disabled) return cur except Queue.Empty: if self.connection_pool_size < self.max_pool_size: cursor = self._new_cursor() self.connection_pool_size += 1 return cursor else: raise com.InternalError('Too many concurrent / hung queries')