From 5bb5e0f25e083368fa919631426aa66afb98484f Mon Sep 17 00:00:00 2001 From: Staale Smedseng Date: Wed, 12 May 2010 13:19:12 +0200 Subject: Bug #49756 Rows_examined is always 0 in the slow query log for update statements Only SELECT statements report any examined rows in the slow log. Slow UPDATE, DELETE and INSERT statements report 0 rows examined, unless the statement has a condition including a SELECT substatement. This patch adds counting of examined rows for the UPDATE and DELETE statements. An INSERT ... VALUES statement will still not report any rows as examined. sql/sql_class.h: Added more docs for THD::examined_row_count. sql/sql_delete.cc: Add incrementing thd->examined_row_count. sql/sql_update.cc: Add incrementing thd->examined_row_count. --- sql/sql_class.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'sql/sql_class.h') diff --git a/sql/sql_class.h b/sql/sql_class.h index 4d0552c5b9d..bd3cf8bc401 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1716,8 +1716,15 @@ public: */ ha_rows sent_row_count; - /* - number of rows we read, sent or not, including in create_sort_index() + /** + Number of rows read and/or evaluated for a statement. Used for + slow log reporting. + + An examined row is defined as a row that is read and/or evaluated + according to a statement condition, including in + create_sort_index(). Rows may be counted more than once, e.g., a + statement including ORDER BY could possibly evaluate the row in + filesort() before reading it for e.g. update. */ ha_rows examined_row_count; -- cgit v1.2.1 From a4cd7f2c277ea7bf2be2ab4fc6655337a80b0e01 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Fri, 4 Jun 2010 16:21:19 +0300 Subject: Bug #52315: utc_date() crashes when system time > year 2037 Some of the server implementations don't support dates later than 2038 due to the internal time type being 32 bit. Added checks so that the server will refuse dates that cannot be handled by either throwing an error when setting date at runtime or by refusing to start or shutting down the server if the system date cannot be stored in my_time_t. --- sql/sql_class.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sql/sql_class.h') diff --git a/sql/sql_class.h b/sql/sql_class.h index ac058bca4f9..c195c8be864 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1707,6 +1707,11 @@ public: inline void end_time() { safe_time(&start_time); } inline void set_time(time_t t) { time_after_lock=start_time=user_time=t; } inline void lock_time() { safe_time(&time_after_lock); } + /*TODO: this will be obsolete when we have support for 64 bit my_time_t */ + inline bool is_valid_time() + { + return (start_time < (time_t) MY_TIME_T_MAX); + } inline void insert_id(ulonglong id_arg) { last_insert_id= id_arg; -- cgit v1.2.1 From e0a4b8387c0a0eb3d5d92b3d8bbd3db891a567fc Mon Sep 17 00:00:00 2001 From: Martin Hansson Date: Thu, 24 Jun 2010 15:21:23 +0200 Subject: Bug#41660: Sort-index_merge for non-first join table may require O(#scans) memory When an index merge operation was restarted, it would re-allocate the Unique object controlling the duplicate row ID elimination. Fixed by making the Unique object a member of QUICK_INDEX_MERGE_SELECT and thus reusing it throughout the lifetime of this object. --- sql/sql_class.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sql/sql_class.h') diff --git a/sql/sql_class.h b/sql/sql_class.h index 19a433746e4..4c1d4a98db0 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2935,6 +2935,9 @@ public: void reset(); bool walk(tree_walk_action action, void *walk_action_arg); + uint get_size() const { return size; } + ulonglong get_max_in_memory_size() const { return max_in_memory_size; } + friend int unique_write_to_file(uchar* key, element_count count, Unique *unique); friend int unique_write_to_ptrs(uchar* key, element_count count, Unique *unique); }; -- cgit v1.2.1 From 95e5c8688e5afdad73d114ea2061e0fc85754c38 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 27 Jun 2010 12:42:06 +0800 Subject: The following statements support the CURRENT_USER() where a user is needed. DROP USER RENAME USER CURRENT_USER() ... GRANT ... TO CURRENT_USER() REVOKE ... FROM CURRENT_USER() ALTER DEFINER = CURRENT_USER() EVENTbut, When these statements are binlogged, CURRENT_USER() just is binlogged as 'CURRENT_USER()', it is not expanded to the real user name. When slave executes the log event, 'CURRENT_USER()' is expand to the user of slave SQL thread, but SQL thread's user name always NULL. This breaks the replication. After this patch, session's user will be written into query log events if these statements call CURREN_USER() or 'ALTER EVENT' does not assign a definer. mysql-test/include/diff_tables.inc: Expend its abilities. Now it can diff not only in sessions of 'master' and 'slave', but other sessions as well. mysql-test/include/rpl_diff_tables.inc: Diff the same table between master and slaves. sql/log_event.cc: session's user will be written into Query_log_event, if is_current_user_used() is TRUE. On slave SQL thread, Only thd->variables.current_user is written into Query_log_event, if it exists. sql/sql_acl.cc: On slave SQL thread, grantor should copy from thd->variables.current_user, if it exists sql/sql_class.h: On slave SQL thread, thd->variables.current_user is used to store the applying event's invoker. --- sql/sql_class.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'sql/sql_class.h') diff --git a/sql/sql_class.h b/sql/sql_class.h index 4c1d4a98db0..72ffa2e6ba4 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -401,6 +401,7 @@ struct system_variables DATE_TIME_FORMAT *datetime_format; DATE_TIME_FORMAT *time_format; my_bool sysdate_is_now; + LEX_USER current_user; }; @@ -2340,6 +2341,19 @@ public: Protected with LOCK_thd_data mutex. */ void set_query(char *query_arg, uint32 query_length_arg); + void set_current_user_used() { current_user_used= TRUE; } + bool is_current_user_used() { return current_user_used; } + void clean_current_user_used() { current_user_used= FALSE; } + void get_definer(LEX_USER *definer) + { + set_current_user_used(); +#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) + if (slave_thread && variables.current_user.user.length) + *definer= variables.current_user; + else +#endif + get_default_definer(this, definer); + } private: /** The current internal error handler for this thread, or NULL. */ Internal_error_handler *m_internal_handler; @@ -2359,6 +2373,8 @@ private: tree itself is reused between executions and thus is stored elsewhere. */ MEM_ROOT main_mem_root; + + bool current_user_used; }; -- cgit v1.2.1 From b594cee712de3c8e3b965226e4880e89e0bdabeb Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Mon, 28 Jun 2010 17:59:41 -0300 Subject: Revert Bug#48321 due to build breakage and failing tests. --- sql/sql_class.h | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'sql/sql_class.h') diff --git a/sql/sql_class.h b/sql/sql_class.h index 72ffa2e6ba4..4c1d4a98db0 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -401,7 +401,6 @@ struct system_variables DATE_TIME_FORMAT *datetime_format; DATE_TIME_FORMAT *time_format; my_bool sysdate_is_now; - LEX_USER current_user; }; @@ -2341,19 +2340,6 @@ public: Protected with LOCK_thd_data mutex. */ void set_query(char *query_arg, uint32 query_length_arg); - void set_current_user_used() { current_user_used= TRUE; } - bool is_current_user_used() { return current_user_used; } - void clean_current_user_used() { current_user_used= FALSE; } - void get_definer(LEX_USER *definer) - { - set_current_user_used(); -#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - if (slave_thread && variables.current_user.user.length) - *definer= variables.current_user; - else -#endif - get_default_definer(this, definer); - } private: /** The current internal error handler for this thread, or NULL. */ Internal_error_handler *m_internal_handler; @@ -2373,8 +2359,6 @@ private: tree itself is reused between executions and thus is stored elsewhere. */ MEM_ROOT main_mem_root; - - bool current_user_used; }; -- cgit v1.2.1