mirror of
https://gitee.com/wangbin579/cetus.git
synced 2024-12-02 03:47:41 +08:00
Don't change sql when visiting only one group
This commit is contained in:
parent
347ca41e26
commit
32e6e1686a
@ -392,7 +392,8 @@ explain_shard_sql(network_mysqld_con *con, sharding_plan_t *plan)
|
||||
|
||||
rv = sharding_parse_groups(con->client->default_db, st->sql_context, &(con->srv->query_stats), con->key, plan);
|
||||
|
||||
con->modified_sql = sharding_modify_sql(st->sql_context, &(con->hav_condi), con->srv->is_groupby_need_reconstruct);
|
||||
con->modified_sql = sharding_modify_sql(st->sql_context, &(con->hav_condi),
|
||||
con->srv->is_groupby_need_reconstruct, plan->groups->len);
|
||||
if (con->modified_sql) {
|
||||
sharding_plan_set_modified_sql(plan, con->modified_sql);
|
||||
}
|
||||
@ -725,7 +726,8 @@ proxy_parse_query(network_mysqld_con *con)
|
||||
static int
|
||||
wrap_check_sql(network_mysqld_con *con, struct sql_context_t *sql_context)
|
||||
{
|
||||
con->modified_sql = sharding_modify_sql(sql_context, &(con->hav_condi), con->srv->is_groupby_need_reconstruct);
|
||||
con->modified_sql = sharding_modify_sql(sql_context, &(con->hav_condi),
|
||||
con->srv->is_groupby_need_reconstruct, con->sharding_plan->groups->len);
|
||||
if (con->modified_sql) {
|
||||
g_message("orig_sql: %s", con->orig_sql->str);
|
||||
g_message("modified: %s", con->modified_sql->str);
|
||||
|
@ -169,7 +169,7 @@ prepare_for_sql_modify_orderby(sql_select_t *select)
|
||||
}
|
||||
|
||||
GString *
|
||||
sharding_modify_sql(sql_context_t *context, having_condition_t *hav_condi, int is_groupby_need_reconstruct)
|
||||
sharding_modify_sql(sql_context_t *context, having_condition_t *hav_condi, int is_groupby_need_reconstruct, int groups)
|
||||
{
|
||||
if (context->stmt_type == STMT_SELECT && context->sql_statement) {
|
||||
sql_select_t *select = context->sql_statement;
|
||||
@ -206,7 +206,7 @@ sharding_modify_sql(sql_context_t *context, having_condition_t *hav_condi, int i
|
||||
guint64 orig_limit = 0;
|
||||
|
||||
/* (LIMIT a, b) ==> (LIMIT 0, a+b) */
|
||||
if (select->offset && select->offset->num_value > 0 && select->limit) {
|
||||
if (groups > 1 && select->offset && select->offset->num_value > 0 && select->limit) {
|
||||
prepare_for_sql_modify_limit(select, &orig_limit, &orig_offset);
|
||||
need_reconstruct = TRUE;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
NETWORK_API int sharding_parse_groups(GString *, sql_context_t *, query_stats_t *, guint64, sharding_plan_t *);
|
||||
|
||||
NETWORK_API GString *sharding_modify_sql(sql_context_t *, having_condition_t *, int);
|
||||
NETWORK_API GString *sharding_modify_sql(sql_context_t *, having_condition_t *, int, int);
|
||||
|
||||
NETWORK_API void sharding_filter_sql(sql_context_t *);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user