diff options
author | unknown <timour@askmonty.org> | 2012-03-12 00:45:18 +0200 |
---|---|---|
committer | unknown <timour@askmonty.org> | 2012-03-12 00:45:18 +0200 |
commit | ecbd868f58db42e52a2dd8f46c6ee39dc4425cc5 (patch) | |
tree | 56fd7bd0b23d301d39db1b98d969e1fd5942a665 /sql/sql_class.h | |
parent | 96a21ab324d02b53cbc7ee8d4585d66eda6dd429 (diff) | |
parent | 8aebd44e0ea9c4ae6f573f1ece27b276452122b8 (diff) | |
download | mariadb-git-ecbd868f58db42e52a2dd8f46c6ee39dc4425cc5.tar.gz |
Merged the implementation of MDEV-28 LIMIT ROWS EXAMINED into MariaDB 5.5.
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index 5c35bc37623..c6c46975076 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -396,7 +396,10 @@ typedef enum enum_diag_condition_item_name */ extern const LEX_STRING Diag_condition_item_names[]; -/* Note: these states are actually bit coded with HARD */ +/** + These states are bit coded with HARD. For each state there must be a pair + <state_even_num>, and <state_odd_num>_HARD. +*/ enum killed_state { NOT_KILLED= 0, @@ -406,15 +409,23 @@ enum killed_state KILL_QUERY= 4, KILL_QUERY_HARD= 5, /* + ABORT_QUERY signals to the query processor to stop execution ASAP without + issuing an error. Instead a warning is issued, and when possible a partial + query result is returned to the client. + */ + ABORT_QUERY= 6, + ABORT_QUERY_HARD= 7, + /* All of the following killed states will kill the connection - KILL_CONNECTION must be the first of these! - */ - KILL_CONNECTION= 6, - KILL_CONNECTION_HARD= 7, - KILL_SYSTEM_THREAD= 8, - KILL_SYSTEM_THREAD_HARD= 9, - KILL_SERVER= 10, - KILL_SERVER_HARD= 11 + KILL_CONNECTION must be the first of these and it must start with + an even number (becasue of HARD bit)! + */ + KILL_CONNECTION= 8, + KILL_CONNECTION_HARD= 9, + KILL_SYSTEM_THREAD= 10, + KILL_SYSTEM_THREAD_HARD= 11, + KILL_SERVER= 12, + KILL_SERVER_HARD= 13 }; extern int killed_errno(killed_state killed); @@ -2091,6 +2102,20 @@ public: filesort() before reading it for e.g. update. */ ha_rows examined_row_count; + /** + The number of rows and/or keys examined by the query, both read, + changed or written. + */ + ulonglong accessed_rows_and_keys; + /** + Check if the number of rows accessed by a statement exceeded + LIMIT ROWS EXAMINED. If so, signal the query engine to stop execution. + */ + void check_limit_rows_examined() + { + if (++accessed_rows_and_keys > lex->limit_rows_examined_cnt) + killed= ABORT_QUERY; + } USER_CONN *user_connect; CHARSET_INFO *db_charset; @@ -4102,6 +4127,7 @@ inline bool add_group_to_list(THD *thd, Item *item, bool asc) inline void handler::increment_statistics(ulong SSV::*offset) const { status_var_increment(table->in_use->status_var.*offset); + table->in_use->check_limit_rows_examined(); } inline void handler::decrement_statistics(ulong SSV::*offset) const |