mirror of
https://gitee.com/wangbin579/cetus.git
synced 2024-11-30 10:57:37 +08:00
Forbid complex aggregate function on sharded SQL, Closes #12
This commit is contained in:
parent
8d33ae2151
commit
59cead53a1
@ -951,6 +951,9 @@ func_expr(A) ::= ID(X) LP distinct(D) exprlist(Y) RP(R). {
|
||||
}
|
||||
if (sql_func_type(X.z) != FT_UNKNOWN) {
|
||||
A->flags |= EP_AGGREGATE;
|
||||
if (context->parsing_place == SELECT_COLUMN) {
|
||||
context->clause_flags |= CF_AGGREGATE;
|
||||
}
|
||||
}
|
||||
if (D) {
|
||||
A->flags |= EP_DISTINCT;
|
||||
@ -961,6 +964,9 @@ func_expr(A) ::= ID(X) LP STAR RP(R). {
|
||||
A = function_expr_new(&X, 0, &R);
|
||||
if (sql_func_type(X.z) != FT_UNKNOWN) {
|
||||
A->flags |= EP_AGGREGATE;
|
||||
if (context->parsing_place == SELECT_COLUMN) {
|
||||
context->clause_flags |= CF_AGGREGATE;
|
||||
}
|
||||
}
|
||||
}
|
||||
func_expr(A) ::= JOIN_KW(N) LP expr(X) COMMA expr(Y) RP(R). {
|
||||
|
@ -120,6 +120,7 @@ enum sql_clause_flag_t {
|
||||
CF_LOCAL_QUERY = 0x20,
|
||||
CF_DISTINCT_AGGR = 0x40,
|
||||
CF_SUBQUERY = 0x80,
|
||||
CF_AGGREGATE = 0x0100,
|
||||
};
|
||||
|
||||
enum sql_sort_order_t {
|
||||
|
@ -1724,10 +1724,18 @@ sharding_filter_sql(sql_context_t *context)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (select_has_AVG(select)) {
|
||||
sql_context_set_error(context, PARSE_NOT_SUPPORT,
|
||||
"(cetus)this AVG would be routed to multiple shards, not allowed");
|
||||
return;
|
||||
if (context->clause_flags & CF_AGGREGATE) {
|
||||
if (select_has_AVG(select)) {
|
||||
sql_context_set_error(context, PARSE_NOT_SUPPORT,
|
||||
"(cetus)this AVG would be routed to multiple shards, not allowed");
|
||||
return;
|
||||
}
|
||||
/* if we can't find simple aggregates, it's inside complex expressions */
|
||||
if (sql_expr_list_find_aggregate(select->columns) == 0) {
|
||||
sql_context_set_error(context, PARSE_NOT_SUPPORT,
|
||||
"(cetus) Complex aggregate function not allowed on sharded sql");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (select->groupby_clause && select->orderby_clause && !select_groupby_orderby_have_same_column(select)) {
|
||||
sql_context_set_error(context, PARSE_NOT_SUPPORT,
|
||||
|
Loading…
Reference in New Issue
Block a user