!2058 修复group by负数的core问题

Merge pull request !2058 from pengjiong/array
This commit is contained in:
opengauss-bot
2022-08-23 12:05:35 +00:00
committed by Gitee
3 changed files with 9 additions and 1 deletions

View File

@ -4681,7 +4681,7 @@ static void transformGroupConstToColumn(ParseState* pstate, Node* groupClause, L
}
long target_pos = intVal(val);
if (target_pos <= list_length(targetList)) {
if (target_pos > 0 && target_pos <= list_length(targetList)) {
TargetEntry* tle = (TargetEntry*)list_nth(targetList, target_pos - 1);
lfirst(lc) = copyObject(tle->expr);

View File

@ -457,6 +457,11 @@ select count(*) from (select distinct(c*d) from t_agg1);
343
(1 row)
-- group by with negative value
SELECT ( 'x' , 'x' ) x GROUP BY -128 , ( );
ERROR: GROUP BY position -128 is not in select list
LINE 1: SELECT ( 'x' , 'x' ) x GROUP BY -128 , ( );
^
reset current_schema;
drop schema if exists distribute_aggregates_part2 cascade;
NOTICE: drop cascades to 3 other objects

View File

@ -76,5 +76,8 @@ select count(*) from (select distinct(c) from t_agg1);
explain (costs off) select count(*) from (select distinct(c*d) from t_agg1);
select count(*) from (select distinct(c*d) from t_agg1);
-- group by with negative value
SELECT ( 'x' , 'x' ) x GROUP BY -128 , ( );
reset current_schema;
drop schema if exists distribute_aggregates_part2 cascade;