[code notes] check_agg_arguments
The SQL
select sum(sum(a)) from myt1 group by a;
This note focuses only on sum(sum(a)) and it's about how postgres rejects the sql above.
Notes
sum(sum(a))
^ ^ ^__ inner most argument, Var node
| |
| \_ function call
\_ function call
Function call is handled by function transformFuncCall. Here's overview how tranformFuncCall works:
- transform arguments first
- if it's an aggregate function, transform aggregate call.
- check_agg_arguments
For sum(sum(a)), the recursive way is like this:
FuncCall
FuncCall
AggCall
check_agg_arguments
AggCall
check_agg_arguments
Here's the detail,
sum(sum(a))is a FuncCall, handle its arguementssum(a).sum(a)is a FuncCall, handle its argumentsa.- check the arguments
a, is's a simpleVarnode, that's fine. sum(a)is an AggCall, check_agg_arguments ofsum(a). AVarnode, that's fine.sum(sum(a))is an AggCall, check_agg_arguments ofsum(sum(a)), which issum(a). Sincesum(a)
is an AggCall, postgres rejects this sql.
posted on 2024-05-11 20:25 winter-loo 阅读(42) 评论(0) 收藏 举报
浙公网安备 33010602011771号