Fix IndexOutOfBoundsException when sub-query uses "SELECT *".