cubicweb #1251252 subqueries and outer join can cause IndexError [validation pending]

The following RQL:

Any X,S,L WHERE X in_state S WITH X, L BEING (Any X,MAX(L) GROUPBY X WHERE X is RunExecution, T? wf_info_for X, T creation_date L)

can generate the following traceback:

2010-09-08 14:58:41 - (cubicweb.web) ERROR: IndexError('list index out of range',)
Traceback (most recent call last):
 File "/home/alf/cubicweb38/cubicweb/web/", line 389, in main_publish
   result = controller.publish(rset=rset)
 File "/home/alf/cubicweb38/cubicweb/web/views/", line 126, in publish
   rset=rset, view=view)
 File "/home/alf/cubicweb38/cubicweb/", line 378, in main_template
   res = obj.render(**kwargs)
 File "/home/alf/cubicweb38/cubicweb/", line 173, in render
 File "/home/alf/cubicweb38/cubicweb/web/views/", line 140, in call
 File "/home/alf/cubicweb38/cubicweb/", line 173, in render
 File "/home/alf/cubicweb38/cubicweb/web/views/", line 187, in call
 File "/home/alf/cubicweb38/cubicweb/web/", line 50, in render
 File "/home/alf/cubicweb38/cubicweb/web/", line 335, in _render
   for column, sortvalue in self.itercols(rowindex):
 File "/home/alf/cubicweb38/cubicweb/web/", line 349, in itercols
   yield column, self.model.sortvalue(rowindex, column.rset_sortcol)
 File "/home/alf/cubicweb38/cubicweb/", line 401, in newfunc
   ret = function(*args, **kwargs)
 File "/home/alf/cubicweb38/cubicweb/web/", line 73, in newfunc
   value = function(*args, **kwargs)
 File "/home/alf/cubicweb38/cubicweb/", line 392, in newfunc
   ret = function(*args, **kwargs)
 File "/home/alf/cubicweb38/cubicweb/web/views/", line 274, in sortvalue
   entity, rtype = self.cw_rset.related_entity(row, col)
 File "/home/alf/cubicweb38/logilab/common/", line 83, in cache_wrapper3
   _cache[args] = callableobj(self, *args)
 File "/home/alf/cubicweb38/cubicweb/", line 590, in related_entity
   col = rqlst.subquery_selection_index(select, col)
 File "/home/alf/cubicweb38/rql/", line 336, in subquery_selection_index
   termvar = subselect.aliases[subq.aliases[col].name]
IndexError: list index out of range

This is very likely caused by the outer join.

done in3.9.6
load left0.000
closed by<not specified>