mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
MDEV-406: ANALYZE $stmt
- Testcase for ANALYZE UNION - Provide r_rows for union result.
This commit is contained in:
parent
5621aa3230
commit
917b22393f
3 changed files with 19 additions and 3 deletions
|
@ -28,4 +28,11 @@ analyze update t1 set b=100+b where a in (6,7,8);
|
|||
select * from t1;
|
||||
drop table t1;
|
||||
|
||||
--echo # Check that UNION works
|
||||
create table t1(a int, b int);
|
||||
insert into t1 select a,a from t0;
|
||||
analyze (select * from t1 A where a<5) union (select * from t1 B where a in (5,6));
|
||||
analyze (select * from t1 A where a<5) union (select * from t1 B where a in (1,2));
|
||||
drop table t1;
|
||||
|
||||
drop table t0;
|
||||
|
|
|
@ -291,7 +291,11 @@ int Explain_union::print_explain(Explain_query *query,
|
|||
|
||||
/* `r_rows` */
|
||||
if (is_analyze)
|
||||
item_list.push_back(item_null);
|
||||
{
|
||||
ha_rows avg_rows= fake_select_lex_tracker.get_avg_rows();
|
||||
item_list.push_back(new Item_int((longlong) (ulonglong) avg_rows,
|
||||
MY_INT64_NUM_DECIMAL_DIGITS));
|
||||
}
|
||||
|
||||
/* `filtered` */
|
||||
if (explain_flags & DESCRIBE_EXTENDED || is_analyze)
|
||||
|
@ -542,8 +546,8 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
|
|||
/* `r_rows` */
|
||||
if (is_analyze)
|
||||
{
|
||||
ha_rows avg_rows= tracker.r_scans ? round((double) tracker.r_rows / tracker.r_scans): 0;
|
||||
item_list.push_back(new Item_int((longlong) (ulonglong) avg_rows,
|
||||
ha_rows avg_rows= tracker.get_avg_rows();
|
||||
item_list.push_back(new Item_int((longlong) (ulonglong) avg_rows,
|
||||
MY_INT64_NUM_DECIMAL_DIGITS));
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,11 @@ public:
|
|||
ha_rows r_rows; /* How many rows we've got after that */
|
||||
ha_rows r_rows_after_table_cond; /* Rows after applying the table condition */
|
||||
ha_rows r_rows_after_where; /* Rows after applying attached part of WHERE */
|
||||
|
||||
ha_rows get_avg_rows()
|
||||
{
|
||||
return r_scans ? round((double) r_rows / r_scans): 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue