Skip to content

Commit 62df311

Browse files
committed
Add a counter for the number of select statements using window functions
The counter is available via SHOW [GLOBAL] STATUS and will be reported by the feedback plugin.
1 parent 5cb5687 commit 62df311

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

sql/mysqld.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8411,6 +8411,7 @@ SHOW_VAR status_vars[]= {
84118411
{"Feature_subquery", (char*) offsetof(STATUS_VAR, feature_subquery), SHOW_LONG_STATUS},
84128412
{"Feature_timezone", (char*) offsetof(STATUS_VAR, feature_timezone), SHOW_LONG_STATUS},
84138413
{"Feature_trigger", (char*) offsetof(STATUS_VAR, feature_trigger), SHOW_LONG_STATUS},
8414+
{"Feature_window_functions", (char*) offsetof(STATUS_VAR, feature_window_functions), SHOW_LONG_STATUS},
84148415
{"Feature_xml", (char*) offsetof(STATUS_VAR, feature_xml), SHOW_LONG_STATUS},
84158416
{"Flush_commands", (char*) &show_flush_commands, SHOW_SIMPLE_FUNC},
84168417
{"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},

sql/sql_class.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ typedef struct system_status_var
789789
ulong feature_timezone; /* +1 when XPATH is used */
790790
ulong feature_trigger; /* +1 opening a table with triggers */
791791
ulong feature_xml; /* +1 when XPATH is used */
792+
ulong feature_window_functions; /* +1 when window functions are used */
792793

793794
/* From MASTER_GTID_WAIT usage */
794795
ulonglong master_gtid_wait_timeouts; /* Number of timeouts */

sql/sql_select.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2699,6 +2699,8 @@ bool JOIN::make_aggr_tables_info()
26992699
if (curr_tab->window_funcs_step->setup(thd, &select_lex->window_funcs,
27002700
curr_tab))
27012701
DBUG_RETURN(true);
2702+
/* Count that we're using window functions. */
2703+
status_var_increment(thd->status_var.feature_window_functions);
27022704
}
27032705

27042706
fields= curr_fields_list;

0 commit comments

Comments
 (0)