Added protection agains stack overflow when parsing invalid join queries