summaryrefslogtreecommitdiff
path: root/sql/sql_class.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r--sql/sql_class.h63
1 files changed, 49 insertions, 14 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h
index fa802fea7ad..7f3be97fe91 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -86,9 +86,10 @@ enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY, RNEXT_SAME };
enum enum_duplicates { DUP_ERROR, DUP_REPLACE, DUP_UPDATE };
enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON,
DELAY_KEY_WRITE_ALL };
-enum enum_slave_exec_mode { SLAVE_EXEC_MODE_STRICT,
- SLAVE_EXEC_MODE_IDEMPOTENT,
- SLAVE_EXEC_MODE_LAST_BIT};
+
+#define SLAVE_EXEC_MODE_STRICT (1U << 0)
+#define SLAVE_EXEC_MODE_IDEMPOTENT (1U << 1)
+
enum enum_mark_columns
{ MARK_COLUMNS_NONE, MARK_COLUMNS_READ, MARK_COLUMNS_WRITE};
@@ -415,12 +416,14 @@ struct system_variables
};
-/* per thread status variables */
+/**
+ Per thread status variables.
+ Must be long/ulong up to last_system_status_var so that
+ add_to_status/add_diff_to_status can work.
+*/
typedef struct system_status_var
{
- ulonglong bytes_received;
- ulonglong bytes_sent;
ulong com_other;
ulong com_stat[(uint) SQLCOM_END];
ulong created_tmp_disk_tables;
@@ -476,13 +479,14 @@ typedef struct system_status_var
Number of statements sent from the client
*/
ulong questions;
+
+ ulonglong bytes_received;
+ ulonglong bytes_sent;
/*
IMPORTANT!
SEE last_system_status_var DEFINITION BELOW.
- Below 'last_system_status_var' are all variables which doesn't make any
- sense to add to the /global/ status variable counter.
- Status variables which it does not make sense to add to
- global status variable counter
+ Below 'last_system_status_var' are all variables that cannot be handled
+ automatically by add_to_status()/add_diff_to_status().
*/
double last_query_cost;
} STATUS_VAR;
@@ -2360,6 +2364,18 @@ 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);
+ void set_invoker(const LEX_STRING *user, const LEX_STRING *host)
+ {
+ invoker_user= *user;
+ invoker_host= *host;
+ }
+ LEX_STRING get_invoker_user() { return invoker_user; }
+ LEX_STRING get_invoker_host() { return invoker_host; }
+ bool has_invoker() { return invoker_user.length > 0; }
private:
/** The current internal error handler for this thread, or NULL. */
Internal_error_handler *m_internal_handler;
@@ -2379,6 +2395,25 @@ private:
tree itself is reused between executions and thus is stored elsewhere.
*/
MEM_ROOT main_mem_root;
+
+ /**
+ It will be set TURE if CURRENT_USER() is called in account management
+ statements or default definer is set in CREATE/ALTER SP, SF, Event,
+ TRIGGER or VIEW statements.
+
+ Current user will be binlogged into Query_log_event if current_user_used
+ is TRUE; It will be stored into invoker_host and invoker_user by SQL thread.
+ */
+ bool current_user_used;
+
+ /**
+ It points to the invoker in the Query_log_event.
+ SQL thread use it as the default definer in CREATE/ALTER SP, SF, Event,
+ TRIGGER or VIEW statements or current user in account management
+ statements if it is not NULL.
+ */
+ LEX_STRING invoker_user;
+ LEX_STRING invoker_host;
};
@@ -2438,7 +2473,7 @@ class select_result :public Sql_alloc {
protected:
THD *thd;
SELECT_LEX_UNIT *unit;
- uint nest_level;
+ int nest_level;
public:
select_result();
virtual ~select_result() {};
@@ -2579,7 +2614,7 @@ public:
Creates a select_export to represent INTO OUTFILE <filename> with a
defined level of subquery nesting.
*/
- select_export(sql_exchange *ex, uint nest_level_arg) :select_to_file(ex)
+ select_export(sql_exchange *ex, int nest_level_arg) :select_to_file(ex)
{
nest_level= nest_level_arg;
}
@@ -2596,7 +2631,7 @@ public:
Creates a select_export to represent INTO DUMPFILE <filename> with a
defined level of subquery nesting.
*/
- select_dump(sql_exchange *ex, uint nest_level_arg) :
+ select_dump(sql_exchange *ex, int nest_level_arg) :
select_to_file(ex)
{
nest_level= nest_level_arg;
@@ -3073,7 +3108,7 @@ public:
Creates a select_dumpvar to represent INTO <variable> with a defined
level of subquery nesting.
*/
- select_dumpvar(uint nest_level_arg)
+ select_dumpvar(int nest_level_arg)
{
var_list.empty();
row_count= 0;