'Change the alias prefix to the next letter in the alphabet in a way
that the outer query\'s aliases and this query\'s aliases will not
conflict. Even tables that previously had no alias will get an alias
after this call.'

def bump_prefix(self, outer_query):

    def prefix_gen():
        "\n                                                Generate    a    sequence    of    characters    in    alphabetical    order:\n                                                                ->    'A',    'B',    'C',    ...\n\n                                                When    the    alphabet    is    finished,    the    sequence    will    continue    with    the\n                                                Cartesian    product:\n                                                                ->    'AA',    'AB',    'AC',    ...\n                                                "
        alphabet = ascii_uppercase
        prefix = chr((ord(self.alias_prefix) + 1))
        (yield prefix)
        for n in count(1):
            seq = (alphabet[alphabet.index(prefix):] if prefix else alphabet)
            for s in product(seq, repeat=n):
                (yield ''.join(s))
            prefix = None
    if (self.alias_prefix != outer_query.alias_prefix):
        return
    local_recursion_limit = 127
    for (pos, prefix) in enumerate(prefix_gen()):
        if (prefix not in self.subq_aliases):
            self.alias_prefix = prefix
            break
        if (pos > local_recursion_limit):
            raise RuntimeError('Maximum    recursion    depth    exceeded:    too    many    subqueries.')
    self.subq_aliases = self.subq_aliases.union([self.alias_prefix])
    outer_query.subq_aliases = outer_query.subq_aliases.union(self.subq_aliases)
    change_map = OrderedDict()
    for (pos, alias) in enumerate(self.alias_map):
        new_alias = ('%s%d' % (self.alias_prefix, pos))
        change_map[alias] = new_alias
    self.change_aliases(change_map)
