int newLimit = limit;
if (offset > count)
{
// return empty ResultSet because there are no enough nodes to return
return new EmptyResultSet();
}
else if (offset + limit > count)
{
// it is possible to select only count-offset nodes from temporary table #tempA
newLimit = count - offset;