summaryrefslogtreecommitdiff
path: root/sql/sql_class.cc
diff options
context:
space:
mode:
authorunknown <serg@sergbook.mysql.com>2007-04-16 10:37:50 +0200
committerunknown <serg@sergbook.mysql.com>2007-04-16 10:37:50 +0200
commit7cb8a33b1af33dcd8806ec6021655a39f375d904 (patch)
treedf4c92bcf5668ec88685604378ad6dc60bfcf269 /sql/sql_class.cc
parent2e73a53e033741b09a652646d9cfa0e76c33e6a1 (diff)
parentadd378761542ade65340b9477ed298e9a1677b10 (diff)
downloadmariadb-git-7cb8a33b1af33dcd8806ec6021655a39f375d904.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into sergbook.mysql.com:/usr/home/serg/Abk/mysql-5.1-wl2936 client/mysql.cc: Auto merged include/my_global.h: Auto merged include/my_sys.h: Auto merged include/mysql.h: Auto merged mysql-test/r/im_utils.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/ndb_dd_basic.test: Auto merged mysql-test/t/partition_innodb.test: Auto merged mysql-test/t/variables.test: Auto merged mysys/array.c: Auto merged mysys/typelib.c: Auto merged sql/event_queue.cc: Auto merged sql/ha_partition.cc: Auto merged sql/ha_partition.h: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item_func.cc: Auto merged sql/item_sum.cc: Auto merged sql/log.cc: Auto merged sql/mysql_priv.h: Auto merged sql/set_var.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_partition.cc: Auto merged sql/sql_plugin.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/table.cc: Auto merged sql/table.h: Auto merged storage/example/ha_example.cc: Auto merged storage/federated/ha_federated.cc: Auto merged storage/heap/ha_heap.cc: Auto merged storage/innobase/include/trx0trx.h: Auto merged storage/myisam/ha_myisam.cc: Auto merged storage/myisammrg/ha_myisammrg.cc: Auto merged storage/ndb/src/mgmsrv/InitConfigFileParser.cpp: Auto merged include/typelib.h: merged mysql-test/mysql-test-run.pl: merged mysql-test/r/flush2.result: merged mysql-test/r/ndb_dd_basic.result: merged mysql-test/r/partition_innodb.result: merged mysql-test/r/ps_1general.result: merged mysql-test/t/ps_1general.test: merged sql/ha_ndbcluster.cc: merged sql/item_create.cc: merged sql/mysqld.cc: merged sql/rpl_utility.h: merged sql/set_var.cc: merged sql/sql_class.cc: merged sql/sql_yacc.yy: merged storage/innobase/handler/ha_innodb.cc: merged storage/innobase/handler/ha_innodb.h: merged
Diffstat (limited to 'sql/sql_class.cc')
-rw-r--r--sql/sql_class.cc116
1 files changed, 108 insertions, 8 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 0abda16ea6a..3d2683786c4 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -167,18 +167,25 @@ Open_tables_state::Open_tables_state(ulong version_arg)
reset_open_tables_state();
}
-my_bool thd_in_lock_tables(const THD *thd)
+/*
+ The following functions form part of the C plugin API
+*/
+
+extern "C"
+int thd_in_lock_tables(const THD *thd)
{
- return thd->in_lock_tables;
+ return test(thd->in_lock_tables);
}
-my_bool thd_tablespace_op(const THD *thd)
+extern "C"
+int thd_tablespace_op(const THD *thd)
{
- return thd->tablespace_op;
+ return test(thd->tablespace_op);
}
+extern "C"
const char *thd_proc_info(THD *thd, const char *info)
{
const char *old_info= thd->proc_info;
@@ -186,11 +193,98 @@ const char *thd_proc_info(THD *thd, const char *info)
return old_info;
}
+extern "C"
void **thd_ha_data(const THD *thd, const struct handlerton *hton)
{
return (void **) thd->ha_data + hton->slot;
}
+extern "C"
+long long thd_test_options(const THD *thd, long long test_options)
+{
+ return thd->options & test_options;
+}
+
+extern "C"
+int thd_sql_command(const THD *thd)
+{
+ return (int) thd->lex->sql_command;
+}
+
+extern "C"
+int thd_tx_isolation(const THD *thd)
+{
+ return (int) thd->variables.tx_isolation;
+}
+
+
+/*
+ Dumps a text description of a thread, its security context
+ (user, host) and the current query.
+
+ SYNOPSIS
+ thd_security_context()
+ thd current thread context
+ buffer pointer to preferred result buffer
+ length length of buffer
+ max_query_len how many chars of query to copy (0 for all)
+
+ RETURN VALUES
+ pointer to string
+*/
+extern "C"
+char *thd_security_context(THD *thd, char *buffer, unsigned int length,
+ unsigned int max_query_len)
+{
+ String str(buffer, length, &my_charset_latin1);
+ const Security_context *sctx= &thd->main_security_ctx;
+ char header[64];
+ int len;
+
+ len= my_snprintf(header, sizeof(header),
+ "MySQL thread id %lu, query id %lu",
+ thd->thread_id, (ulong) thd->query_id);
+ str.length(0);
+ str.append(header, len);
+
+ if (sctx->host)
+ {
+ str.append(' ');
+ str.append(sctx->host);
+ }
+
+ if (sctx->ip)
+ {
+ str.append(' ');
+ str.append(sctx->ip);
+ }
+
+ if (sctx->user)
+ {
+ str.append(' ');
+ str.append(sctx->user);
+ }
+
+ if (thd->proc_info)
+ {
+ str.append(' ');
+ str.append(thd->proc_info);
+ }
+
+ if (thd->query)
+ {
+ if (max_query_len < 1)
+ len= thd->query_length;
+ else
+ len= min(thd->query_length, max_query_len);
+ str.append('\n');
+ str.append(thd->query, len);
+ }
+ if (str.c_ptr_safe() == buffer)
+ return buffer;
+ return thd->strmake(str.ptr(), str.length());
+}
+
THD::THD()
@@ -201,13 +295,16 @@ THD::THD()
user_time(0), in_sub_stmt(0),
binlog_table_maps(0),
global_read_lock(0), is_fatal_error(0),
- rand_used(0), time_zone_used(0),
arg_of_last_insert_id_function(FALSE),
first_successful_insert_id_in_prev_stmt(0),
first_successful_insert_id_in_prev_stmt_for_binlog(0),
first_successful_insert_id_in_cur_stmt(0),
- in_lock_tables(0), bootstrap(0), derived_tables_processing(FALSE),
+ rand_used(0),
+ time_zone_used(0),
+ in_lock_tables(0),
stmt_depends_on_first_successful_insert_id_in_prev_stmt(FALSE),
+ bootstrap(0),
+ derived_tables_processing(FALSE),
spcont(NULL)
{
ulong tmp;
@@ -356,6 +453,8 @@ void THD::init(void)
{
pthread_mutex_lock(&LOCK_global_system_variables);
variables= global_system_variables;
+ variables.table_plugin= NULL;
+ plugin_thdvar_init(this);
variables.time_format= date_time_format_copy((THD*) 0,
variables.time_format);
variables.date_format= date_time_format_copy((THD*) 0,
@@ -502,6 +601,7 @@ THD::~THD()
cleanup();
ha_close_connection(this);
+ plugin_thdvar_cleanup(this);
DBUG_PRINT("info", ("freeing security context"));
main_security_ctx.destroy();
@@ -1731,12 +1831,12 @@ void Query_arena::cleanup_stmt()
}
/*
- Statement functions
+ Statement functions
*/
Statement::Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg,
enum enum_state state_arg, ulong id_arg)
- :Query_arena(mem_root_arg, state_arg),
+ :Query_arena(mem_root_arg, state_arg), main_lex(),
id(id_arg),
mark_used_columns(MARK_COLUMNS_READ),
lex(lex_arg),