/* * If we have an ORDER BY, transform it. This will add columns to the * tlist if they appear in ORDER BY but weren't already in the arg list. * They will be marked resjunk = true so we can tell them apart from * regular aggregate arguments later. * * We need to mess with p_next_resno since it will be used to number any * new targetlist entries. */ save_next_resno = pstate->p_next_resno; pstate->p_next_resno = attno; torder = transformSortClause(pstate, aggorder, &tlist, true /* fix unknowns */ , true /* force SQL99 rules */ ); /* * If we have DISTINCT, transform that to produce a distinctList. */ if (agg_distinct) { tdistinct = transformDistinctClause(pstate, &tlist, torder, true); /* * Remove this check if executor support for hashed distinct for * aggregates is ever added. */ foreach(lc, tdistinct)
/* * If we have an ORDER BY, transform it. This will add columns to the * tlist if they appear in ORDER BY but weren't already in the arg list. * They will be marked resjunk = true so we can tell them apart from * regular aggregate arguments later. * * We need to mess with p_next_resno since it will be used to number any * new targetlist entries. */ save_next_resno = pstate->p_next_resno; pstate->p_next_resno = attno; torder = transformSortClause(pstate, aggorder, &tlist, EXPR_KIND_ORDER_BY, true /* fix unknowns */ , true /* force SQL99 rules */ ); /* * If we have DISTINCT, transform that to produce a distinctList. */ if (agg_distinct) { tdistinct = transformDistinctClause(pstate, &tlist, torder, true); /* * Remove this check if executor support for hashed distinct for * aggregates is ever added. */ foreach(lc, tdistinct)