summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-04-25 17:22:25 +0200
committerSergei Golubchik <sergii@pisem.net>2011-04-25 17:22:25 +0200
commit0accbd0364e0333e0b119aa9ce93e34ded9df6cb (patch)
treebdf0738c29dc1f57fbfba3a1754524e238f15b52 /sql
parent37f87d73ae8dc6c30594867b40a5d70159acf63c (diff)
downloadmariadb-git-0accbd0364e0333e0b119aa9ce93e34ded9df6cb.tar.gz
lots of post-merge changes
Diffstat (limited to 'sql')
-rw-r--r--sql/CMakeLists.txt3
-rw-r--r--sql/create_options.cc1
-rw-r--r--sql/create_options.h3
-rw-r--r--sql/datadict.h1
-rw-r--r--sql/events.h1
-rw-r--r--sql/filesort.cc2
-rw-r--r--sql/gstream.h3
-rw-r--r--sql/handler.cc43
-rw-r--r--sql/handler.h6
-rw-r--r--sql/item.cc12
-rw-r--r--sql/item.h78
-rw-r--r--sql/item_create.cc8
-rw-r--r--sql/item_func.cc4
-rw-r--r--sql/item_strfunc.cc4
-rw-r--r--sql/item_subselect.cc10
-rw-r--r--sql/item_subselect.h2
-rw-r--r--sql/item_sum.cc7
-rw-r--r--sql/keycaches.cc7
-rw-r--r--sql/keycaches.h4
-rw-r--r--sql/lock.cc34
-rw-r--r--sql/log.cc37
-rw-r--r--sql/log_event.cc6
-rw-r--r--sql/log_slow.h9
-rw-r--r--sql/mdl.h1
-rw-r--r--sql/multi_range_read.cc2
-rw-r--r--sql/mysqld.cc159
-rw-r--r--sql/mysqld.h30
-rw-r--r--sql/net_serv.cc7
-rw-r--r--sql/opt_index_cond_pushdown.cc2
-rw-r--r--sql/opt_range.cc13
-rw-r--r--sql/opt_range.h3
-rw-r--r--sql/opt_range_mrr.cc4
-rw-r--r--sql/opt_subselect.cc7
-rw-r--r--sql/opt_subselect.h4
-rw-r--r--sql/opt_table_elimination.cc1
-rw-r--r--sql/procedure.h3
-rw-r--r--sql/records.cc6
-rw-r--r--sql/rpl_filter.cc2
-rw-r--r--sql/rpl_handler.cc10
-rw-r--r--sql/rpl_mi.cc7
-rw-r--r--sql/scheduler.cc72
-rw-r--r--sql/scheduler.h34
-rw-r--r--sql/set_var.h2
-rw-r--r--sql/slave.h5
-rw-r--r--sql/sp_cache.cc2
-rw-r--r--sql/sql_acl.cc19
-rw-r--r--sql/sql_admin.cc12
-rw-r--r--sql/sql_audit.cc2
-rw-r--r--sql/sql_base.cc13
-rw-r--r--sql/sql_bitmap.h2
-rw-r--r--sql/sql_cache.cc3
-rw-r--r--sql/sql_callback.h8
-rw-r--r--sql/sql_class.cc21
-rw-r--r--sql/sql_class.h134
-rw-r--r--sql/sql_connect.cc65
-rw-r--r--sql/sql_connect.h8
-rw-r--r--sql/sql_db.h2
-rw-r--r--sql/sql_delete.cc1
-rw-r--r--sql/sql_error.h2
-rw-r--r--sql/sql_expression_cache.cc12
-rw-r--r--sql/sql_insert.cc4
-rw-r--r--sql/sql_join_cache.cc3
-rw-r--r--sql/sql_lex.cc84
-rw-r--r--sql/sql_lex.h2
-rw-r--r--sql/sql_list.cc1
-rw-r--r--sql/sql_list.h7
-rw-r--r--sql/sql_parse.cc20
-rw-r--r--sql/sql_parse.h2
-rw-r--r--sql/sql_partition.cc83
-rw-r--r--sql/sql_partition_admin.cc1
-rw-r--r--sql/sql_plugin.cc10
-rw-r--r--sql/sql_plugin.h5
-rw-r--r--sql/sql_prepare.cc4
-rw-r--r--sql/sql_repl.cc2
-rw-r--r--sql/sql_select.cc33
-rw-r--r--sql/sql_select.h13
-rw-r--r--sql/sql_show.cc112
-rw-r--r--sql/sql_sort.h2
-rw-r--r--sql/sql_string.cc58
-rw-r--r--sql/sql_string.h1
-rw-r--r--sql/sql_table.cc19
-rw-r--r--sql/sql_table.h1
-rw-r--r--sql/sql_test.cc19
-rw-r--r--sql/sql_trigger.cc3
-rw-r--r--sql/sql_yacc.yy3
-rw-r--r--sql/strfunc.h2
-rw-r--r--sql/structs.h1
-rw-r--r--sql/sys_vars.cc47
-rw-r--r--sql/sys_vars.h16
-rw-r--r--sql/table.cc71
-rw-r--r--sql/table.h3
-rw-r--r--sql/thr_malloc.h1
92 files changed, 670 insertions, 928 deletions
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 9bcce146ebe..9a808b62f24 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -20,7 +20,6 @@ ${CMAKE_SOURCE_DIR}/regex
${ZLIB_INCLUDE_DIR}
${SSL_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}/sql
-${CMAKE_SOURCE_DIR}/extra/libevent
)
SET(GEN_SOURCES
@@ -90,7 +89,7 @@ ADD_LIBRARY(sql STATIC ${SQL_SOURCE})
ADD_DEPENDENCIES(sql GenServerSource)
DTRACE_INSTRUMENT(sql)
TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATIC_PLUGIN_LIBS}
- mysys dbug strings vio regex libevent psapi.lib
+ mysys dbug strings vio regex
${LIBWRAP} ${LIBCRYPT} ${LIBDL}
${SSL_LIBRARIES})
diff --git a/sql/create_options.cc b/sql/create_options.cc
index 4478fc14791..e80b213cc81 100644
--- a/sql/create_options.cc
+++ b/sql/create_options.cc
@@ -19,7 +19,6 @@
Engine defined options of tables/fields/keys in CREATE/ALTER TABLE.
*/
-#include "mysql_priv.h"
#include "create_options.h"
#include <my_getopt.h>
diff --git a/sql/create_options.h b/sql/create_options.h
index b66bbf43570..1bd6ecd81e6 100644
--- a/sql/create_options.h
+++ b/sql/create_options.h
@@ -22,7 +22,8 @@
#ifndef SQL_CREATE_OPTIONS_INCLUDED
#define SQL_CREATE_OPTIONS_INCLUDED
-#include "handler.h"
+#include "sql_class.h"
+//#include "handler.h"
class engine_option_value: public Sql_alloc
{
diff --git a/sql/datadict.h b/sql/datadict.h
index 65e40998929..f852b02f52c 100644
--- a/sql/datadict.h
+++ b/sql/datadict.h
@@ -28,7 +28,6 @@ enum frm_type_enum
FRMTYPE_VIEW
};
-
frm_type_enum dd_frm_type(THD *thd, char *path, enum legacy_db_type *dbt);
bool dd_frm_storage_engine(THD *thd, const char *db, const char *table_name,
diff --git a/sql/events.h b/sql/events.h
index 39e9510c15b..4cb93ce8415 100644
--- a/sql/events.h
+++ b/sql/events.h
@@ -42,7 +42,6 @@ class Event_scheduler;
struct TABLE_LIST;
class THD;
typedef class Item COND;
-typedef struct charset_info_st CHARSET_INFO;
/* Return codes */
enum enum_events_error_code
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 0b61c65d2b7..69df42da95f 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -32,6 +32,8 @@
#include "probes_mysql.h"
#include "sql_test.h" // TEST_filesort
#include "opt_range.h" // SQL_SELECT
+#include "log_slow.h"
+#include "sql_base.h"
#ifndef THREAD
#define SKIP_DBUG_IN_FILESORT
diff --git a/sql/gstream.h b/sql/gstream.h
index 6bb3c9bac10..7c079c7bdb3 100644
--- a/sql/gstream.h
+++ b/sql/gstream.h
@@ -21,9 +21,6 @@
#include "my_sys.h" /* MY_ALLOW_ZERO_PTR */
#include "m_ctype.h" /* my_charset_latin1, my_charset_bin */
-typedef struct charset_info_st CHARSET_INFO;
-typedef struct st_mysql_lex_string LEX_STRING;
-
class Gis_read_stream
{
public:
diff --git a/sql/handler.cc b/sql/handler.cc
index 94b3e175ca0..1737d5554b9 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -42,11 +42,16 @@
#include "transaction.h"
#include "myisam.h"
#include "probes_mysql.h"
+#include "sql_connect.h"
#ifdef WITH_PARTITION_STORAGE_ENGINE
#include "ha_partition.h"
#endif
+#ifdef WITH_ARIA_STORAGE_ENGINE
+#include "../storage/maria/ha_maria.h"
+#endif
+
/*
While we have legacy_db_type, we have this array to
check for dups and to find handlerton from legacy_db_type.
@@ -93,8 +98,6 @@ TYPELIB tx_isolation_typelib= {array_elements(tx_isolation_names)-1,"",
static TYPELIB known_extensions= {0,"known_exts", NULL, NULL};
uint known_extensions_id= 0;
-
-
static plugin_ref ha_default_plugin(THD *thd)
{
if (thd->variables.table_plugin)
@@ -487,8 +490,6 @@ int ha_initialize_handlerton(st_plugin_int *plugin)
if (idx == (int) DB_TYPE_DEFAULT)
{
sql_print_warning("Too many storage engines!");
- my_free(hton, MYF(0));
- plugin->data= 0;
goto err_deinit;
}
if (hton->db_type != DB_TYPE_UNKNOWN)
@@ -1159,6 +1160,10 @@ int ha_commit_trans(THD *thd, bool all)
DBUG_RETURN(2);
}
+#ifdef WITH_ARIA_STORAGE_ENGINE
+ ha_maria::implicit_commit(thd, TRUE);
+#endif
+
if (ha_info)
{
uint rw_ha_count;
@@ -1300,9 +1305,6 @@ int ha_commit_one_phase(THD *thd, bool all)
#endif
}
}
-#ifdef WITH_ARIA_STORAGE_ENGINE
- ha_maria::implicit_commit(thd, TRUE);
-#endif
/* Free resources and perform other cleanup even for 'empty' transactions. */
if (is_real_trans)
thd->transaction.cleanup();
@@ -2890,7 +2892,6 @@ void handler::print_error(int error, myf errflag)
}
}
my_error(textno, errflag, table_share->table_name.str, error);
- DBUG_ASSERT(!fatal_error || !debug_assert_if_crashed_table);
DBUG_VOID_RETURN;
}
@@ -3643,10 +3644,10 @@ void handler::update_global_table_stats()
DBUG_ASSERT(table->s && table->s->table_cache_key.str);
- pthread_mutex_lock(&LOCK_global_table_stats);
+ mysql_mutex_lock(&LOCK_global_table_stats);
/* Gets the global table stats, creating one if necessary. */
if (!(table_stats= (TABLE_STATS*)
- hash_search(&global_table_stats,
+ my_hash_search(&global_table_stats,
(uchar*) table->s->table_cache_key.str,
table->s->table_cache_key.length)))
{
@@ -3666,7 +3667,7 @@ void handler::update_global_table_stats()
if (my_hash_insert(&global_table_stats, (uchar*) table_stats))
{
/* Out of memory error is already given */
- my_free(table_stats, 0);
+ my_free(table_stats);
goto end;
}
}
@@ -3678,7 +3679,7 @@ void handler::update_global_table_stats()
1));
rows_read= rows_changed= 0;
end:
- pthread_mutex_unlock(&LOCK_global_table_stats);
+ mysql_mutex_unlock(&LOCK_global_table_stats);
}
@@ -3709,9 +3710,9 @@ void handler::update_global_index_stats()
if (!key_info->cache_name)
continue;
key_length= table->s->table_cache_key.length + key_info->name_length + 1;
- pthread_mutex_lock(&LOCK_global_index_stats);
+ mysql_mutex_lock(&LOCK_global_index_stats);
// Gets the global index stats, creating one if necessary.
- if (!(index_stats= (INDEX_STATS*) hash_search(&global_index_stats,
+ if (!(index_stats= (INDEX_STATS*) my_hash_search(&global_index_stats,
key_info->cache_name,
key_length)))
{
@@ -3724,7 +3725,7 @@ void handler::update_global_index_stats()
index_stats->index_name_length= key_length;
if (my_hash_insert(&global_index_stats, (uchar*) index_stats))
{
- my_free(index_stats, 0);
+ my_free(index_stats);
goto end;
}
}
@@ -3732,7 +3733,7 @@ void handler::update_global_index_stats()
index_stats->rows_read+= index_rows_read[index];
index_rows_read[index]= 0;
end:
- pthread_mutex_unlock(&LOCK_global_index_stats);
+ mysql_mutex_unlock(&LOCK_global_index_stats);
}
}
}
@@ -3897,7 +3898,8 @@ void st_ha_check_opt::init()
/**
Init a key cache if it has not been initied before.
*/
-int ha_init_key_cache(const char *name, KEY_CACHE *key_cache)
+int ha_init_key_cache(const char *name, KEY_CACHE *key_cache, void *unused
+ __attribute__((unused)))
{
DBUG_ENTER("ha_init_key_cache");
@@ -3971,13 +3973,13 @@ int ha_repartition_key_cache(KEY_CACHE *key_cache)
if (key_cache->key_cache_inited)
{
- pthread_mutex_lock(&LOCK_global_system_variables);
+ mysql_mutex_lock(&LOCK_global_system_variables);
size_t tmp_buff_size= (size_t) key_cache->param_buff_size;
long tmp_block_size= (long) key_cache->param_block_size;
uint division_limit= key_cache->param_division_limit;
uint age_threshold= key_cache->param_age_threshold;
uint partitions= key_cache->param_partitions;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ mysql_mutex_unlock(&LOCK_global_system_variables);
DBUG_RETURN(!repartition_key_cache(key_cache, tmp_block_size,
tmp_buff_size,
division_limit, age_threshold,
@@ -4087,8 +4089,7 @@ ha_find_files(THD *thd,const char *db,const char *path,
int error= 0;
DBUG_ENTER("ha_find_files");
DBUG_PRINT("enter", ("db: '%s' path: '%s' wild: '%s' dir: %d",
- val_or_null(db), val_or_null(path),
- val_or_null(wild), dir));
+ db, path, wild, dir));
st_find_files_args args= {db, path, wild, dir, files};
plugin_foreach(thd, find_files_handlerton,
diff --git a/sql/handler.h b/sql/handler.h
index bbdc38eba4d..656c9403b8c 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1,6 +1,5 @@
#ifndef HANDLER_INCLUDED
#define HANDLER_INCLUDED
-#error don't forget to merge mysql_priv.h!
/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
@@ -577,10 +576,10 @@ enum enum_schema_tables
SCH_PARAMETERS,
SCH_PARTITIONS,
SCH_PLUGINS,
- SCH_PROCEDURES,
SCH_PROCESSLIST,
SCH_PROFILES,
SCH_REFERENTIAL_CONSTRAINTS,
+ SCH_PROCEDURES,
SCH_SCHEMATA,
SCH_SCHEMA_PRIVILEGES,
SCH_SESSION_STATUS,
@@ -2263,6 +2262,7 @@ public:
@retval
TRUE if the engine supports virtual columns
*/
+
virtual bool check_if_supported_virtual_columns(void) { return FALSE;}
protected:
@@ -2567,7 +2567,7 @@ int ha_find_files(THD *thd,const char *db,const char *path,
int ha_table_exists_in_engine(THD* thd, const char* db, const char* name);
/* key cache */
-extern "C" int ha_init_key_cache(const char *name, KEY_CACHE *key_cache);
+extern "C" int ha_init_key_cache(const char *name, KEY_CACHE *key_cache, void *);
int ha_resize_key_cache(KEY_CACHE *key_cache);
int ha_change_key_cache_param(KEY_CACHE *key_cache);
int ha_repartition_key_cache(KEY_CACHE *key_cache);
diff --git a/sql/item.cc b/sql/item.cc
index 8dd6d3b3159..f2e9e8202c5 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -40,6 +40,7 @@
// find_item_in_list,
// RESOLVED_AGAINST_ALIAS, ...
#include "log_event.h" // append_query_string
+#include "sql_expression_cache.h"
const String my_null_string("NULL", 4, default_charset_info);
@@ -432,7 +433,7 @@ Item::Item():
maybe_null=null_value=with_sum_func=unsigned_flag=0;
decimals= 0; max_length= 0;
with_subselect= 0;
- cmp_context= IMPOSSIBLE_RESULT;
+ cmp_context= (Item_result)-1;
/* Put item in free list so that we can free all items at end */
THD *thd= current_thd;
@@ -6931,7 +6932,6 @@ Item_cache_wrapper::~Item_cache_wrapper()
/* expr_value is Item so it will be destroyed from list of Items */
}
-
Item_cache_wrapper::Item_cache_wrapper(Item *item_arg)
:orig_item(item_arg), expr_cache(NULL), expr_value(NULL)
{
@@ -6979,6 +6979,12 @@ bool Item_cache_wrapper::fix_fields(THD *thd __attribute__((unused)),
return FALSE;
}
+bool Item_cache_wrapper::send(Protocol *protocol, String *buffer)
+{
+ if (result_field)
+ return protocol->store(result_field);
+ return Item::send(protocol, buffer);
+}
/**
Clean the expression cache wrapper up before reusing it.
@@ -8201,7 +8207,7 @@ String *Item_cache_datetime::val_str(String *str)
else if (!cache_value())
return NULL;
}
- return &str_value;
+ return null_value ? NULL : &str_value;
}
diff --git a/sql/item.h b/sql/item.h
index 4c5475fb080..26ee946f147 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -2829,9 +2829,8 @@ public:
virtual Ref_Type ref_type() { return DIRECT_REF; }
};
-class Expression_cache;
class Item_cache;
-
+class Expression_cache;
/**
The objects of this class can store its values in an expression cache.
@@ -2879,12 +2878,7 @@ public:
bool is_null();
bool get_date(MYSQL_TIME *ltime, uint fuzzydate);
bool get_time(MYSQL_TIME *ltime);
- bool send(Protocol *protocol, String *buffer)
- {
- if (result_field)
- return protocol->store(result_field);
- return Item::send(protocol, buffer);
- }
+ bool send(Protocol *protocol, String *buffer);
void save_org_in_field(Field *field)
{
save_val(field);
@@ -3896,4 +3890,72 @@ extern int stored_field_cmp_to_item(THD *thd, Field *field, Item *item);
extern const String my_null_string;
+/**
+ Interface for Item iterator
+*/
+
+class Item_iterator
+{
+public:
+ /**
+ Shall set this iterator to the position before the first item
+
+ @note
+ This method also may perform some other initialization actions like
+ allocation of certain resources.
+ */
+ virtual void open()= 0;
+ /**
+ Shall return the next Item (or NULL if there is no next item) and
+ move pointer to position after it.
+ */
+ virtual Item *next()= 0;
+ /**
+ Shall force iterator to free resources (if it holds them)
+
+ @note
+ One should not use the iterator without open() call after close()
+ */
+ virtual void close()= 0;
+
+ virtual ~Item_iterator() {}
+};
+
+
+/**
+ Item iterator over List_iterator_fast for Item references
+*/
+
+class Item_iterator_ref_list: public Item_iterator
+{
+ List_iterator<Item*> list;
+public:
+ Item_iterator_ref_list(List_iterator<Item*> &arg_list):
+ list(arg_list) {}
+ void open() { list.rewind(); }
+ Item *next() { return *(list++); }
+ void close() {}
+};
+
+
+/**
+ Item iterator over Item interface for rows
+*/
+
+class Item_iterator_row: public Item_iterator
+{
+ Item *base_item;
+ uint current;
+public:
+ Item_iterator_row(Item *base) : base_item(base), current(0) {}
+ void open() { current= 0; }
+ Item *next()
+ {
+ if (current >= base_item->cols())
+ return NULL;
+ return base_item->element_index(current++);
+ }
+ void close() {}
+};
+
#endif /* SQL_ITEM_INCLUDED */
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 7bddc29b812..6cb45f05efc 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -1837,7 +1837,7 @@ protected:
class Create_func_sha2 : public Create_func_arg2
{
public:
- virtual Item* create(THD *thd, Item *arg1, Item *arg2);
+ virtual Item* create_2_arg(THD *thd, Item *arg1, Item *arg2);
static Create_func_sha2 s_singleton;
@@ -2074,7 +2074,7 @@ protected:
class Create_func_to_seconds : public Create_func_arg1
{
public:
- virtual Item* create(THD *thd, Item *arg1);
+ virtual Item* create_1_arg(THD *thd, Item *arg1);
static Create_func_to_seconds s_singleton;
@@ -4382,7 +4382,7 @@ Create_func_sha::create_1_arg(THD *thd, Item *arg1)
Create_func_sha2 Create_func_sha2::s_singleton;
Item*
-Create_func_sha2::create(THD *thd, Item *arg1, Item *arg2)
+Create_func_sha2::create_2_arg(THD *thd, Item *arg1, Item *arg2)
{
return new (thd->mem_root) Item_func_sha2(arg1, arg2);
}
@@ -4570,7 +4570,7 @@ Create_func_to_days::create_1_arg(THD *thd, Item *arg1)
Create_func_to_seconds Create_func_to_seconds::s_singleton;
Item*
-Create_func_to_seconds::create(THD *thd, Item *arg1)
+Create_func_to_seconds::create_1_arg(THD *thd, Item *arg1)
{
return new (thd->mem_root) Item_func_to_seconds(arg1);
}
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 65585378f6a..fb4883ec393 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -4392,7 +4392,6 @@ double user_var_entry::val_real(bool *null_value)
case STRING_RESULT:
return my_atof(value); // This is null terminated
case ROW_RESULT:
- case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0); // Impossible
break;
}
@@ -4424,7 +4423,6 @@ longlong user_var_entry::val_int(bool *null_value) const
return my_strtoll10(value, (char**) 0, &error);// String is null terminated
}
case ROW_RESULT:
- case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0); // Impossible
break;
}
@@ -4458,7 +4456,6 @@ String *user_var_entry::val_str(bool *null_value, String *str,
str= 0; // EOM error
break;
case ROW_RESULT:
- case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0); // Impossible
break;
}
@@ -4486,7 +4483,6 @@ my_decimal *user_var_entry::val_decimal(bool *null_value, my_decimal *val)
str2my_decimal(E_DEC_FATAL_ERROR, value, length, collation.collation, val);
break;
case ROW_RESULT:
- case IMPOSSIBLE_RESULT:
DBUG_ASSERT(0); // Impossible
break;
}
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 8e8bb6c7f09..4b87b0439ee 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -2898,7 +2898,7 @@ String *Item_func_conv::val_str(String *str)
from_base, &endptr, &err);
}
- ptr= longlong2str(dec, ans, to_base, 1);
+ ptr= longlong2str(dec, ans, to_base);
if (str->copy(ans, (uint32) (ptr-ans), default_charset()))
return &my_empty_string;
return str;
@@ -3065,7 +3065,7 @@ String *Item_func_hex::val_str_ascii(String *str)
if ((null_value= args[0]->null_value))
return 0;
- ptr= longlong2str(dec,ans,16,1);
+ ptr= longlong2str(dec,ans,16);
if (str->copy(ans,(uint32) (ptr-ans), &my_charset_numeric))
return &my_empty_string; // End of memory
return str;
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 53950b70e69..a69910da700 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -3800,7 +3800,7 @@ bitmap_init_memroot(MY_BITMAP *map, uint n_bits, MEM_ROOT *mem_root)
bool subselect_hash_sj_engine::init_permanent(List<Item> *tmp_columns)
{
/* Options to create_tmp_table. */
- ulonglong tmp_create_options= thd->options | TMP_TABLE_ALL_COLUMNS;
+ ulonglong tmp_create_options= thd->variables.option_bits | TMP_TABLE_ALL_COLUMNS;
/* | TMP_TABLE_FORCE_MYISAM; TIMOUR: force MYISAM */
DBUG_ENTER("subselect_hash_sj_engine::init_permanent");
@@ -3918,7 +3918,9 @@ bool subselect_hash_sj_engine::make_semi_join_conds()
if (!(tmp_table_ref= (TABLE_LIST*) thd->alloc(sizeof(TABLE_LIST))))
DBUG_RETURN(TRUE);
- tmp_table_ref->init_one_table("", "materialized subselect", TL_READ);
+ tmp_table_ref->init_one_table(STRING_WITH_LEN(""),
+ STRING_WITH_LEN("materialized subselect"),
+ NULL, TL_READ);
tmp_table_ref->table= tmp_table;
context= new Name_resolution_context;
@@ -4277,7 +4279,7 @@ Ordered_key::Ordered_key(uint keyid_arg, TABLE *tbl_arg, Item *search_key_arg,
Ordered_key::~Ordered_key()
{
- my_free((char*) key_buff, MYF(0));
+ my_free(key_buff);
bitmap_free(&null_key);
}
@@ -4905,7 +4907,7 @@ subselect_rowid_merge_engine::~subselect_rowid_merge_engine()
/* None of the resources below is allocated if there are no ordered keys. */
if (keys_count)
{
- my_free((char*) row_num_to_rowid, MYF(0));
+ my_free(row_num_to_rowid);
for (uint i= 0; i < keys_count; i++)
delete merge_keys[i];
delete_queue(&pq);
diff --git a/sql/item_subselect.h b/sql/item_subselect.h
index 88bd057b7f4..e4a49fe032d 100644
--- a/sql/item_subselect.h
+++ b/sql/item_subselect.h
@@ -22,6 +22,8 @@
#pragma interface /* gcc class implementation */
#endif
+#include <queues.h>
+
class st_select_lex;
class st_select_lex_unit;
class JOIN;
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index a9c77e2fea5..4a7f2a54659 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -539,6 +539,11 @@ void Item_sum::update_used_tables ()
args[i]->update_used_tables();
used_tables_cache|= args[i]->used_tables();
}
+
+ used_tables_cache&= PSEUDO_TABLE_BITS;
+
+ /* the aggregate function is aggregated into its local context */
+ used_tables_cache |= (1 << aggr_sel->join->tables) - 1;
}
}
@@ -762,7 +767,7 @@ bool Aggregator_distinct::setup(THD *thd)
if (!(table= create_tmp_table(thd, tmp_table_param, list, (ORDER*) 0, 1,
0,
(select_lex->options | thd->variables.option_bits),
- HA_POS_ERROR, "")))
+ HA_POS_ERROR, const_cast<char*>(""))))
return TRUE;
table->file->extra(HA_EXTRA_NO_ROWS); // Don't update rows
table->no_rows=1;
diff --git a/sql/keycaches.cc b/sql/keycaches.cc
index 1da2f33fdad..984b5a6768b 100644
--- a/sql/keycaches.cc
+++ b/sql/keycaches.cc
@@ -145,17 +145,18 @@ void free_key_cache(const char *name, KEY_CACHE *key_cache)
}
-bool process_key_caches(process_key_cache_t func)
+bool process_key_caches(process_key_cache_t func, void *param)
{
I_List_iterator<NAMED_ILINK> it(key_caches);
NAMED_ILINK *element;
+ int res= 0;
while ((element= it++))
{
KEY_CACHE *key_cache= (KEY_CACHE *) element->data;
- func(element->name, key_cache);
+ res |= func(element->name, key_cache, param);
}
- return 0;
+ return res != 0;
}
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
diff --git a/sql/keycaches.h b/sql/keycaches.h
index 66d24b59465..52bd163a0be 100644
--- a/sql/keycaches.h
+++ b/sql/keycaches.h
@@ -21,7 +21,7 @@
extern "C"
{
- typedef int (*process_key_cache_t) (const char *, KEY_CACHE *);
+ typedef int (*process_key_cache_t) (const char *, KEY_CACHE *, void *);
}
class NAMED_ILINK;
@@ -40,6 +40,6 @@ KEY_CACHE *create_key_cache(const char *name, uint length);
KEY_CACHE *get_key_cache(LEX_STRING *cache_name);
KEY_CACHE *get_or_create_key_cache(const char *name, uint length);
void free_key_cache(const char *name, KEY_CACHE *key_cache);
-bool process_key_caches(process_key_cache_t func);
+bool process_key_caches(process_key_cache_t func, void *param);
#endif /* KEYCACHES_INCLUDED */
diff --git a/sql/lock.cc b/sql/lock.cc
index 66b59fa5466..26a8a1ba35b 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -293,13 +293,13 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, uint flags)
if (lock_tables_check(thd, tables, count, flags))
DBUG_RETURN(NULL);
- if (! (sql_lock= get_lock_data(thd, tables, count, GET_LOCK_STORE_LOCKS)) ||
- ! sql_lock->table_count)
+ if (! (sql_lock= get_lock_data(thd, tables, count, GET_LOCK_STORE_LOCKS)))
DBUG_RETURN(NULL);
thd_proc_info(thd, "System lock");
DBUG_PRINT("info", ("thd->proc_info %s", thd->proc_info));
- if (lock_external(thd, sql_lock->table, sql_lock->table_count))
+ if (sql_lock->table_count && lock_external(thd, sql_lock->table,
+ sql_lock->table_count))
{
/* Clear the lock type of all lock data to avoid reusage. */
reset_lock_data_and_free(&sql_lock);
@@ -316,7 +316,8 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, uint flags)
&thd->lock_info, timeout)];
if (rc)
{
- (void) unlock_external(thd, sql_lock->table, sql_lock->table_count);
+ if (sql_lock->table_count)
+ (void) unlock_external(thd, sql_lock->table, sql_lock->table_count);
reset_lock_data_and_free(&sql_lock);
if (! thd->killed)
my_error(rc, MYF(0));
@@ -379,10 +380,10 @@ static int lock_external(THD *thd, TABLE **tables, uint count)
void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock)
{
DBUG_ENTER("mysql_unlock_tables");
- if (sql_lock->lock_count)
- thr_multi_unlock(sql_lock->locks,sql_lock->lock_count);
if (sql_lock->table_count)
- unlock_external(thd,sql_lock->table,sql_lock->table_count);
+ unlock_external(thd, sql_lock->table, sql_lock->table_count);
+ if (sql_lock->lock_count)
+ thr_multi_unlock(sql_lock->locks, sql_lock->lock_count, 0);
my_free(sql_lock);
DBUG_VOID_RETURN;
}
@@ -546,21 +547,8 @@ void mysql_lock_abort(THD *thd, TABLE *table, bool upgrade_lock)
if ((locked= get_lock_data(thd, &table, 1, GET_LOCK_UNLOCK)))
{
- if (table->children_attached)
- {
- /*
- Don't abort locks for underlying tables just because merge table
- is deleted. Doing would cause anyone accessing these tables to
- spin in open_table/close_table forever until lock is released.
- */
- thr_multi_unlock(locked->locks, locked->lock_count,
- THR_UNLOCK_UPDATE_STATUS);
- }
- else
- {
- for (uint i=0; i < locked->lock_count; i++)
- thr_abort_locks(locked->locks[i]->lock, upgrade_lock);
- }
+ for (uint i=0; i < locked->lock_count; i++)
+ thr_abort_locks(locked->locks[i]->lock, upgrade_lock);
my_free(locked);
}
DBUG_VOID_RETURN;
@@ -664,8 +652,6 @@ MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b)
/* Delete old, not needed locks */
my_free(a);
my_free(b);
-
- thr_lock_merge_status(sql_lock->locks, sql_lock->lock_count);
DBUG_RETURN(sql_lock);
}
diff --git a/sql/log.cc b/sql/log.cc
index 114cb3236b6..a9452ed1c26 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -38,6 +38,7 @@
#include "rpl_filter.h"
#include "rpl_rli.h"
#include "sql_audit.h"
+#include "log_slow.h"
#include <my_dir.h>
#include <stdarg.h>
@@ -921,13 +922,6 @@ void Log_to_file_event_handler::flush()
mysql_slow_log.reopen_file();
}
-void Log_to_file_event_handler::flush_slow_log()
-{
- /* reopen slow log file */
- if (opt_slow_log)
- mysql_slow_log.reopen_file();
-}
-
/*
Log error with all enabled log event handlers
@@ -1038,24 +1032,6 @@ bool LOGGER::flush_logs(THD *thd)
}
-#error remove percona's flush log implementation
-bool LOGGER::flush_slow_log(THD *thd)
-{
- /*
- Now we lock logger, as nobody should be able to use logging routines while
- log tables are closed
- */
- logger.lock_exclusive();
-
- /* reopen log files */
- file_log_handler->flush_slow_log();
-
- /* end of log flush */
- logger.unlock();
- return 0;
-}
-
-
/**
Close and reopen the slow log (with locks).
@@ -4748,11 +4724,11 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info)
#endif /* HAVE_REPLICATION */
IO_CACHE *file= NULL;
- my_org_b_tell= my_b_tell(file);
if (event_info->use_direct_logging())
{
file= &log_file;
+ my_org_b_tell= my_b_tell(file);
mysql_mutex_lock(&LOCK_log);
}
else
@@ -4842,9 +4818,6 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info)
DBUG_EVALUATE_IF("injecting_fault_writing", 1, 0))
goto err;
- status_var_add(thd->status_var.binlog_bytes_written,
- my_b_tell(file) - my_org_b_tell);
-
error= 0;
err:
@@ -4853,9 +4826,13 @@ err:
if (!error)
{
bool synced;
+
if ((error= flush_and_sync(&synced)))
goto unlock;
+ status_var_add(thd->status_var.binlog_bytes_written,
+ my_b_tell(file) - my_org_b_tell);
+
if ((error= RUN_HOOK(binlog_storage, after_flush,
(thd, log_file_name, file->pos_in_file, synced))))
{
@@ -5966,7 +5943,7 @@ void TC_LOG_MMAP::get_active_from_pool()
}
while ((*best_p == 0 || best_free == 0) && overflow());
- safe_mutex_assert_owner(&LOCK_active);
+ mysql_mutex_assert_owner(&LOCK_active);
active=*best_p;
if ((*best_p)->next) // unlink the page from the pool
diff --git a/sql/log_event.cc b/sql/log_event.cc
index d45fa1e1ba7..6f83e5f4db2 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -5627,7 +5627,6 @@ void User_var_log_event::pack_info(Protocol* protocol)
}
break;
case ROW_RESULT:
- case IMPOSSIBLE_RESULT:
default:
DBUG_ASSERT(0);
return;
@@ -5743,7 +5742,6 @@ bool User_var_log_event::write(IO_CACHE* file)
pos= (uchar*) val;
break;
case ROW_RESULT:
- case IMPOSSIBLE_RESULT:
default:
DBUG_ASSERT(0);
return 0;
@@ -5927,7 +5925,6 @@ int User_var_log_event::do_apply_event(Relay_log_info const *rli)
it= new Item_string(val, val_len, charset);
break;
case ROW_RESULT:
- case IMPOSSIBLE_RESULT:
default:
DBUG_ASSERT(0);
return 0;
@@ -8432,7 +8429,7 @@ int Table_map_log_event::rewrite_db(const char* new_db, size_t new_len,
memcpy((void*)m_tblnam, tblnam, m_tbllen + 1);
memcpy(m_coltype, coltype, m_colcnt);
- my_free(memory, MYF(MY_WME));
+ my_free(memory);
DBUG_RETURN(0);
}
#endif /* MYSQL_CLIENT */
@@ -9926,3 +9923,4 @@ bool rpl_get_position_info(const char **log_file_name, ulonglong *log_pos,
return TRUE;
#endif
}
+#endif
diff --git a/sql/log_slow.h b/sql/log_slow.h
index 91b74e690a0..92a2d1bf4f6 100644
--- a/sql/log_slow.h
+++ b/sql/log_slow.h
@@ -19,11 +19,7 @@
#define LOG_SLOW_VERBOSITY_INNODB 1 << 0
#define LOG_SLOW_VERBOSITY_QUERY_PLAN 1 << 1
-/*
- We init the used query plan with a bit that is alwyas set and all 'no' bits
- to enable easy testing of what to log in sql_log.cc
-*/
-#define QPLAN_INIT (QPLAN_ALWAYS_SET | QPLAN_QC_NO)
+#define QPLAN_INIT QPLAN_QC_NO
#define QPLAN_ADMIN 1 << 0
#define QPLAN_FILESORT 1 << 1
@@ -36,7 +32,4 @@
#define QPLAN_TMP_TABLE 1 << 8
/* ... */
#define QPLAN_MAX ((ulong) 1) << 31 /* reserved as placeholder */
-#define QPLAN_ALWAYS_SET QPLAN_MAX
-#define QPLAN_VISIBLE_MASK (~(QPLAN_ALWAYS_SET))
-#warning simplify
diff --git a/sql/mdl.h b/sql/mdl.h
index e1d4cf74dd6..b9dad0597da 100644
--- a/sql/mdl.h
+++ b/sql/mdl.h
@@ -26,6 +26,7 @@
#include "sql_plist.h"
#include <my_sys.h>
+#include <my_pthread.h>
#include <m_string.h>
#include <mysql_com.h>
diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc
index 53699c47688..e539f30d978 100644
--- a/sql/multi_range_read.cc
+++ b/sql/multi_range_read.cc
@@ -1,4 +1,4 @@
-#include "mysql_priv.h"
+#include "sql_parse.h"
#include "sql_select.h"
/****************************************************************************
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 106e2a4f0f5..5d581920a21 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -51,6 +51,7 @@
#include "derror.h" // init_errmessage
#include "des_key_file.h" // load_des_key_file
#include "sql_manager.h" // stop_handle_manager, start_handle_manager
+#include "sql_expression_cache.h" // subquery_cache_miss, subquery_cache_hit
#include <m_ctype.h>
#include <my_dir.h>
@@ -291,7 +292,6 @@ static TYPELIB tc_heuristic_recover_typelib=
tc_heuristic_recover_names, NULL
};
-const int server_maturity= MariaDB_PLUGIN_MATURITY_UNKNOWN;
const char *first_keyword= "first", *binary_keyword= "BINARY";
const char *my_localhost= "localhost", *delayed_user= "DELAYED";
@@ -358,8 +358,6 @@ static bool binlog_format_used= false;
LEX_STRING opt_init_connect, opt_init_slave;
static mysql_cond_t COND_thread_cache, COND_flush_thread_cache;
-static ulong opt_my_crc_dbug_check;
-
/* Global variables */
bool opt_bin_log, opt_ignore_builtin_innodb= 0;
@@ -923,7 +921,7 @@ my_bool opt_use_ssl = 0;
char *opt_ssl_ca= NULL, *opt_ssl_capath= NULL, *opt_ssl_cert= NULL,
*opt_ssl_cipher= NULL, *opt_ssl_key= NULL;
-scheduler_functions *thread_scheduler, *extra_thread_scheduler;
+scheduler_functions thread_scheduler, extra_thread_scheduler;
#ifdef HAVE_OPENSSL
#include <openssl/crypto.h>
@@ -979,9 +977,9 @@ pthread_handler_t handle_connections_shared_memory(void *arg);
pthread_handler_t handle_slave(void *arg);
static void clean_up(bool print_message);
static int test_if_case_insensitive(const char *dir_name);
-static void register_mutex_order();
#ifndef EMBEDDED_LIBRARY
+static void register_mutex_order();
static void usage(void);
static void start_signal_handler(void);
static void close_server_sock();
@@ -1115,7 +1113,7 @@ static void close_connections(void)
continue;
tmp->killed= THD::KILL_CONNECTION;
- thread_scheduler.post_kill_notification(tmp);
+ MYSQL_CALLBACK(&thread_scheduler, post_kill_notification, (tmp));
mysql_mutex_lock(&tmp->LOCK_thd_data);
if (tmp->mysys_var)
{
@@ -1126,25 +1124,6 @@ static void close_connections(void)
mysql_mutex_lock(tmp->mysys_var->current_mutex);
mysql_cond_broadcast(tmp->mysys_var->current_cond);
mysql_mutex_unlock(tmp->mysys_var->current_mutex);
-#error search for mysys_var->mutex / mysys_var->current_mutex lock order
-#error or/add safe_mutex_assert every time
-#if 0
-=======
- uint i;
- for (i=0; i < 2; i++)
- {
- int ret= pthread_mutex_trylock(tmp->mysys_var->current_mutex);
- pthread_cond_broadcast(tmp->mysys_var->current_cond);
- if (!ret)
- {
- /* Thread has surely got the signal, unlock and abort */
- pthread_mutex_unlock(tmp->mysys_var->current_mutex);
- break;
- }
- sleep(1);
- }
->>>>>>> MERGE-SOURCE
-#endif
}
mysql_mutex_unlock(&tmp->mysys_var->mutex);
}
@@ -1559,7 +1538,7 @@ void clean_up(bool print_message)
if (print_message && my_default_lc_messages && server_start_time)
sql_print_information(ER_DEFAULT(ER_SHUTDOWN_COMPLETE),my_progname);
cleanup_errmsgs();
- thread_scheduler.end();
+ MYSQL_CALLBACK(&thread_scheduler, end, ());
mysql_library_end();
finish_client_errs();
(void) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST); // finish server errs
@@ -1654,7 +1633,6 @@ static void clean_up_mutexes()
mysql_cond_destroy(&COND_server_started);
DBUG_VOID_RETURN;
}
-#endif /*EMBEDDED_LIBRARY*/
/**
@@ -1666,8 +1644,8 @@ static void clean_up_mutexes()
#ifdef SAFE_MUTEX
#define always_in_that_order(A,B) \
- pthread_mutex_lock(A); pthread_mutex_lock(B); \
- pthread_mutex_unlock(B); pthread_mutex_unlock(A)
+ mysql_mutex_lock(A); mysql_mutex_lock(B); \
+ mysql_mutex_unlock(B); mysql_mutex_unlock(A)
#else
#define always_in_that_order(A,B)
#endif
@@ -1682,6 +1660,7 @@ static void register_mutex_order()
}
#undef always_in_that_order
+#endif /*EMBEDDED_LIBRARY*/
/****************************************************************************
** Init IP and UNIX socket
@@ -1862,14 +1841,18 @@ static my_socket activate_tcp_port(uint port)
struct addrinfo *ai, *a;
struct addrinfo hints;
int error;
- DBUG_PRINT("general",("IP Socket is %d",mysqld_port));
+ int arg;
+ char port_buf[NI_MAXSERV];
+ my_socket ip_sock;
+ DBUG_ENTER("activate_tcp_port");
+ DBUG_PRINT("general",("IP Socket is %d",port));
bzero(&hints, sizeof (hints));
hints.ai_flags= AI_PASSIVE;
hints.ai_socktype= SOCK_STREAM;
hints.ai_family= AF_UNSPEC;
- my_snprintf(port_buf, NI_MAXSERV, "%d", mysqld_port);
+ my_snprintf(port_buf, NI_MAXSERV, "%d", port);
error= getaddrinfo(my_bind_addr_str, port_buf, &hints, &ai);
if (error != 0)
{
@@ -1926,13 +1909,15 @@ static my_socket activate_tcp_port(uint port)
Retry at second: 1, 3, 7, 13, 22, 35, 52, 74, ...
Limit the sequence by mysqld_port_timeout (set --port-open-timeout=#).
*/
+ int ret;
+ uint waited, retry, this_wait;
for (waited= 0, retry= 1; ; retry++, waited+= this_wait)
{
if (((ret= bind(ip_sock, a->ai_addr, a->ai_addrlen)) >= 0 ) ||
(socket_errno != SOCKET_EADDRINUSE) ||
(waited >= mysqld_port_timeout))
break;
- sql_print_information("Retrying bind on TCP/IP port %u", mysqld_port);
+ sql_print_information("Retrying bind on TCP/IP port %u", port);
this_wait= retry * retry / 3 + 1;
sleep(this_wait);
}
@@ -1941,7 +1926,7 @@ static my_socket activate_tcp_port(uint port)
{
DBUG_PRINT("error",("Got error: %d from bind",socket_errno));
sql_perror("Can't start server: Bind on TCP/IP port");
- sql_print_error("Do you already have another mysqld server running on port: %d ?",mysqld_port);
+ sql_print_error("Do you already have another mysqld server running on port: %d ?",port);
unireg_abort(1);
}
if (listen(ip_sock,(int) back_log) < 0)
@@ -1959,11 +1944,10 @@ static void network_init(void)
#ifdef HAVE_SYS_UN_H
struct sockaddr_un UNIXaddr;
#endif
- int arg=1;
- char port_buf[NI_MAXSERV];
+ int arg;
DBUG_ENTER("network_init");
- if (MYSQL_CALLBACK(thread_scheduler, init, ()))
+ if (MYSQL_CALLBACK_ELSE(&thread_scheduler, init, (), 0))
unireg_abort(1); /* purecov: inspected */
set_ports();
@@ -2047,10 +2031,11 @@ static void network_init(void)
UNIXaddr.sun_family = AF_UNIX;
strmov(UNIXaddr.sun_path, mysqld_unix_port);
(void) unlink(mysqld_unix_port);
+ arg= 1;
(void) setsockopt(unix_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg,
sizeof(arg));
umask(0);
- if (bind(unix_sock, my_reinterpret_cast(struct sockaddr *) (&UNIXaddr),
+ if (bind(unix_sock, reinterpret_cast<struct sockaddr *>(&UNIXaddr),
sizeof(UNIXaddr)) < 0)
{
sql_perror("Can't start server : Bind on unix socket"); /* purecov: tested */
@@ -2522,7 +2507,7 @@ and this may fail.\n\n");
(ulong) dflt_key_cache->key_cache_mem_size);
fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size);
fprintf(stderr, "max_used_connections=%lu\n", max_used_connections);
- fprintf(stderr, "max_threads=%u\n", thread_scheduler->max_threads +
+ fprintf(stderr, "max_threads=%u\n", thread_scheduler.max_threads +
(uint) extra_max_connections);
fprintf(stderr, "thread_count=%u\n", thread_count);
fprintf(stderr, "It is possible that mysqld could use up to \n\
@@ -2530,7 +2515,7 @@ key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = %lu K\n\
bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size +
(global_system_variables.read_buff_size +
global_system_variables.sortbuff_size) *
- (thread_scheduler->max_threads + extra_max_connections) +
+ (thread_scheduler.max_threads + extra_max_connections) +
(max_connections + extra_max_connections)* sizeof(THD)) / 1024);
fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n");
@@ -2631,7 +2616,6 @@ bugs.\n");
}
#endif
-end:
#ifndef __WIN__
/* Terminate */
exit(1);
@@ -2781,7 +2765,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
This should actually be '+ max_number_of_slaves' instead of +10,
but the +10 should be quite safe.
*/
- init_thr_alarm(thread_scheduler->max_threads + extra_max_connections +
+ init_thr_alarm(thread_scheduler.max_threads + extra_max_connections +
global_system_variables.max_insert_delayed_threads + 10);
if (test_flags & TEST_SIGINT)
{
@@ -2938,23 +2922,7 @@ void my_message_sql(uint error, const char *str, myf MyFlags)
DBUG_PRINT("error", ("error: %u message: '%s'", error, str));
DBUG_ASSERT(str != NULL);
- /*
- An error should have a valid error number (!= 0), so it can be caught
- in stored procedures by SQL exception handlers.
- Calling my_error() with error == 0 is a bug.
- Remaining known places to fix:
- - storage/myisam/mi_create.c, my_printf_error()
- TODO:
- DBUG_ASSERT(error != 0);
- */
-#warning FIXME
- if (error == 0)
- {
- /* At least, prevent new abuse ... */
- DBUG_ASSERT(strncmp(str, "MyISAM table", 12) == 0 ||
- strncmp(str, "Aria table", 11) == 0);
- error= ER_UNKNOWN_ERROR;
- }
+ DBUG_ASSERT(error != 0);
mysql_audit_general(thd, MYSQL_AUDIT_GENERAL_ERROR, error, str);
if (MyFlags & ME_JUST_INFO)
@@ -3312,7 +3280,7 @@ static int init_common_variables()
(except in the embedded server, where the default continues to
be MyISAM)
*/
-#ifdef EMBEDDED_LIBRARY
+#ifndef WITH_INNOBASE_STORAGE_ENGINE
default_storage_engine= const_cast<char *>("MyISAM");
#else
default_storage_engine= const_cast<char *>("InnoDB");
@@ -3686,11 +3654,13 @@ static int init_thread_environment()
&LOCK_uuid_generator, MY_MUTEX_INIT_FAST);
mysql_mutex_init(key_LOCK_connection_count,
&LOCK_connection_count, MY_MUTEX_INIT_FAST);
- mysql_mutex_init(&LOCK_stats, MY_MUTEX_INIT_FAST);
- mysql_mutex_init(&LOCK_global_user_client_stats,
- MY_MUTEX_INIT_FAST);
- mysql_mutex_init(&LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
- mysql_mutex_init(&LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
+ mysql_mutex_init(key_LOCK_stats, &LOCK_stats, MY_MUTEX_INIT_FAST);
+ mysql_mutex_init(key_LOCK_global_user_client_stats,
+ &LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST);
+ mysql_mutex_init(key_LOCK_global_table_stats,
+ &LOCK_global_table_stats, MY_MUTEX_INIT_FAST);
+ mysql_mutex_init(key_LOCK_global_index_stats,
+ &LOCK_global_index_stats, MY_MUTEX_INIT_FAST);
#ifdef HAVE_OPENSSL
mysql_mutex_init(key_LOCK_des_key_file,
@@ -3738,7 +3708,6 @@ static int init_thread_environment()
sql_print_error("Can't create thread-keys");
return 1;
}
- register_mutex_order();
return 0;
}
@@ -3919,6 +3888,8 @@ static int init_server_components()
}
}
+ /* set up the hook before initializing plugins which may use it */
+ error_handler_hook= my_message_sql;
proc_info_hook= set_thd_proc_info;
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
@@ -4030,7 +4001,7 @@ a file name for --log-bin-index option", opt_binlog_index_name);
}
/* call ha_init_key_cache() on all key caches to init them */
- process_key_caches(&ha_init_key_cache);
+ process_key_caches(&ha_init_key_cache, 0);
init_global_table_stats();
init_global_index_stats();
@@ -4168,7 +4139,7 @@ a file name for --log-bin-index option", opt_binlog_index_name);
global_system_variables.table_plugin= plugin;
mysql_mutex_unlock(&LOCK_global_system_variables);
}
-#if defined(WITH_ARIA_STORAGE_ENGINE) && defined(USE_MARIA_FOR_TMP_TABLES)
+#if defined(WITH_ARIA_STORAGE_ENGINE) && defined(USE_ARIA_FOR_TMP_TABLES)
if (!ha_storage_engine_is_enabled(maria_hton) && !opt_bootstrap)
{
sql_print_error("Aria engine is not enabled or did not start. The Aria engine must be enabled to continue as mysqld was configured with --with-aria-tmp-tables");
@@ -4714,6 +4685,8 @@ int mysqld_main(int argc, char **argv)
unireg_abort(1);
}
+ register_mutex_order();
+
create_shutdown_thread();
start_handle_manager();
@@ -5232,17 +5205,14 @@ void handle_connections_sockets()
socket_count++
#else
fd_set readFDs,clientFDs;
- uint max_used_connection;
+ uint max_used_connection= (uint)
+ max(max(base_ip_sock, unix_sock), extra_ip_sock) + 1;
#define setup_fds(X) FD_SET(X,&clientFDs)
FD_ZERO(&clientFDs);
#endif
DBUG_ENTER("handle_connections_sockets");
- max_used_connection= (uint) (max(base_ip_sock, unix_sock));
- max_used_connection= (uint) (max(extra_ip_sock, (int) max_used_connection));
- max_used_connection++;
-
if (base_ip_sock != INVALID_SOCKET)
{
setup_fds(base_ip_sock);
@@ -6733,8 +6703,8 @@ SHOW_VAR status_vars[]= {
Expression cache used only for caching subqueries now, so its statistic
variables we call subquery_cache*.
*/
- {"Subquery_cache_hit", (char*) &subquery_cache_hit, SHOW_LONG},
- {"Subquery_cache_miss", (char*) &subquery_cache_miss, SHOW_LONG},
+ {"Subquery_cache_hit", (char*) &subquery_cache_hit, SHOW_LONG},
+ {"Subquery_cache_miss", (char*) &subquery_cache_miss, SHOW_LONG},
{"Table_locks_immediate", (char*) &locks_immediate, SHOW_LONG},
{"Table_locks_waited", (char*) &locks_waited, SHOW_LONG},
#ifdef HAVE_MMAP
@@ -6984,7 +6954,6 @@ static int mysql_init_variables(void)
/* Variables that depends on compile options */
#ifndef DBUG_OFF
-#warning test that --disable-debug --debug works
default_dbug_option=IF_WIN("d:t:i:O,\\mysqld.trace",
"d:t:i:o,/tmp/mysqld.trace");
current_dbug_option= default_dbug_option;
@@ -7254,8 +7223,6 @@ mysqld_get_one_option(int optid,
WARN_DEPRECATED(NULL, 7, 0, "--log-slow-queries", "'--slow-query-log'/'--slow-query-log-file'");
opt_slow_log= 1;
break;
-#endif
- break;
case (int) OPT_SAFE:
opt_specialflag|= SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC;
delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE;
@@ -7322,10 +7289,6 @@ mysqld_get_one_option(int optid,
case OPT_LOWER_CASE_TABLE_NAMES:
lower_case_table_names_used= 1;
break;
- case OPT_TEST_IGNORE_WRONG_OPTIONS:
- /* Used for testing options */
- opt_ignore_wrong_options= 1;
- break;
#if defined(ENABLED_DEBUG_SYNC)
case OPT_DEBUG_SYNC_TIMEOUT:
/*
@@ -7542,8 +7505,6 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
/* Set global MyISAM variables from delay_key_write_options */
fix_delay_key_write(0, 0, OPT_GLOBAL);
- global_system_variables.log_slow_filter=
- fix_log_slow_filter(global_system_variables.log_slow_filter);
#ifndef EMBEDDED_LIBRARY
if (mysqld_chroot)
set_root(mysqld_chroot);
@@ -7578,17 +7539,17 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
return 1;
#ifdef EMBEDDED_LIBRARY
- one_thread_scheduler(thread_scheduler);
- one_thread_scheduler(extra_thread_scheduler);
+ one_thread_scheduler(&thread_scheduler);
+ one_thread_scheduler(&extra_thread_scheduler);
#else
if (thread_handling <= SCHEDULER_ONE_THREAD_PER_CONNECTION)
- one_thread_per_connection_scheduler(thread_scheduler, &max_connections,
+ one_thread_per_connection_scheduler(&thread_scheduler, &max_connections,
&connection_count);
else if (thread_handling == SCHEDULER_NO_THREADS)
- one_thread_scheduler(thread_scheduler);
+ one_thread_scheduler(&thread_scheduler);
else
- pool_of_threads_scheduler(thread_scheduler); /* purecov: tested */
- one_thread_per_connection_scheduler(extra_thread_scheduler,
+ pool_of_threads_scheduler(&thread_scheduler); /* purecov: tested */
+ one_thread_per_connection_scheduler(&extra_thread_scheduler,
&extra_max_connections,
&extra_connection_count);
#endif
@@ -7764,19 +7725,19 @@ static int fix_paths(void)
{
if (*opt_secure_file_priv == 0)
{
- /* For easy check later */
- my_free(opt_secure_file_priv, MYF(0));
+ my_free(opt_secure_file_priv);
opt_secure_file_priv= 0;
}
else
{
- char *secure_file_real_path;
+ if (strlen(opt_secure_file_priv) >= FN_REFLEN)
+ opt_secure_file_priv[FN_REFLEN-1]= '\0';
if (my_realpath(buff, opt_secure_file_priv, 0))
{
sql_print_warning("Failed to normalize the argument for --secure-file-priv.");
DBUG_RETURN(1);
}
- secure_file_real_path= (char *)my_malloc(FN_REFLEN, MYF(MY_FAE));
+ char *secure_file_real_path= (char *)my_malloc(FN_REFLEN, MYF(MY_FAE));
convert_dirname(secure_file_real_path, buff, NullS);
my_free(opt_secure_file_priv);
opt_secure_file_priv= secure_file_real_path;
@@ -7867,7 +7828,7 @@ void refresh_status(THD *thd)
reset_status_vars();
/* Reset the counters of all key caches (default and named). */
- process_key_caches(reset_key_cache_counters);
+ process_key_caches(reset_key_cache_counters, 0);
flush_status_time= time((time_t*) 0);
mysql_mutex_unlock(&LOCK_status);
@@ -7916,7 +7877,7 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids,
key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create,
key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log,
key_LOCK_gdl, key_LOCK_global_read_lock, key_LOCK_global_system_variables,
- key_LOCK_manager,
+ key_LOCK_manager,
key_LOCK_prepared_stmt_count,
key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status,
key_LOCK_system_variables_hash, key_LOCK_table_share, key_LOCK_thd_data,
@@ -7928,6 +7889,10 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids,
key_LOCK_error_messages, key_LOG_INFO_lock, key_LOCK_thread_count,
key_PARTITION_LOCK_auto_inc;
+PSI_mutex_key key_LOCK_stats,
+ key_LOCK_global_user_client_stats, key_LOCK_global_table_stats,
+ key_LOCK_global_index_stats;
+
static PSI_mutex_info all_server_mutexes[]=
{
#ifdef HAVE_MMAP
@@ -7962,6 +7927,10 @@ static PSI_mutex_info all_server_mutexes[]=
{ &key_LOCK_status, "LOCK_status", PSI_FLAG_GLOBAL},
{ &key_LOCK_system_variables_hash, "LOCK_system_variables_hash", PSI_FLAG_GLOBAL},
{ &key_LOCK_table_share, "LOCK_table_share", PSI_FLAG_GLOBAL},
+ { &key_LOCK_stats, "LOCK_stats", PSI_FLAG_GLOBAL},
+ { &key_LOCK_global_user_client_stats, "LOCK_global_user_client_stats", PSI_FLAG_GLOBAL},
+ { &key_LOCK_global_table_stats, "LOCK_global_table_stats", PSI_FLAG_GLOBAL},
+ { &key_LOCK_global_index_stats, "LOCK_global_index_stats", PSI_FLAG_GLOBAL},
{ &key_LOCK_thd_data, "THD::LOCK_thd_data", 0},
{ &key_LOCK_user_conn, "LOCK_user_conn", PSI_FLAG_GLOBAL},
{ &key_LOCK_uuid_generator, "LOCK_uuid_generator", PSI_FLAG_GLOBAL},
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 66acf086886..a4482b655ee 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -33,16 +33,6 @@ struct scheduler_functions;
typedef struct st_mysql_const_lex_string LEX_CSTRING;
typedef struct st_mysql_show_var SHOW_VAR;
-/*
- This forward declaration is used from C files where the real
- definition is included before. Since C does not allow repeated
- typedef declarations, even when identical, the definition may not be
- repeated.
-*/
-#ifndef CHARSET_INFO_DEFINED
-typedef struct charset_info_st CHARSET_INFO;
-#endif /* CHARSET_INFO_DEFINED */
-
#if MAX_INDEXES <= 64
typedef Bitmap<64> key_map; /* Used for finding keys */
#else
@@ -239,6 +229,10 @@ extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids,
key_structure_guard_mutex, key_TABLE_SHARE_LOCK_ha_data,
key_LOCK_error_messages, key_LOCK_thread_count, key_PARTITION_LOCK_auto_inc;
+extern PSI_mutex_key key_LOCK_stats,
+ key_LOCK_global_user_client_stats, key_LOCK_global_table_stats,
+ key_LOCK_global_index_stats;
+
extern PSI_rwlock_key key_rwlock_LOCK_grant, key_rwlock_LOCK_logger,
key_rwlock_LOCK_sys_init_connect, key_rwlock_LOCK_sys_init_slave,
key_rwlock_LOCK_system_variables_hash, key_rwlock_query_cache_query_lock;
@@ -342,6 +336,7 @@ extern char *opt_ssl_ca, *opt_ssl_capath, *opt_ssl_cert, *opt_ssl_cipher,
extern MYSQL_PLUGIN_IMPORT pthread_key(THD*, THR_THD);
+#ifdef MYSQL_SERVER
/**
only options that need special treatment in get_one_option() deserve
to be listed below
@@ -394,7 +389,7 @@ enum options_mysqld
OPT_ENGINE_CONDITION_PUSHDOWN,
OPT_LOG_ERROR
};
-
+#endif
/**
Query type constants.
@@ -509,20 +504,11 @@ inline THD *_current_thd(void)
*/
extern handlerton *maria_hton;
-extern HASH global_user_stats;
-extern HASH global_client_stats;
-extern HASH global_table_stats;
-extern HASH global_index_stats;
-
-extern mysql_mutex_t LOCK_global_user_client_stats;
-extern mysql_mutex_t LOCK_global_table_stats;
-extern mysql_mutex_t LOCK_global_index_stats;
-extern mysql_mutex_t LOCK_stats;
-
extern uint extra_connection_count;
-extern my_bool opt_userstat_running, debug_assert_if_crashed_table;
+extern my_bool opt_userstat_running;
extern uint mysqld_extra_port;
extern ulong extra_max_connections;
extern ulonglong denied_connections;
extern ulong thread_created;
+extern scheduler_functions thread_scheduler, extra_thread_scheduler;
#endif /* MYSQLD_INCLUDED */
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index a2f17075ea6..5f7f0b25fc1 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -85,19 +85,14 @@ void sql_print_error(const char *format,...);
*/
extern uint test_flags;
extern ulong bytes_sent, bytes_received, net_big_packet_count;
-#ifndef MYSQL_INSTANCE_MANAGER
#ifdef HAVE_QUERY_CACHE
#define USE_QUERY_CACHE
extern void query_cache_insert(const char *packet, ulong length,
unsigned pkt_nr);
#endif // HAVE_QUERY_CACHE
#define update_statistics(A) A
-#endif /* MYSQL_INSTANCE_MANGER */
-#endif /* defined(MYSQL_SERVER) && !defined(MYSQL_INSTANCE_MANAGER) */
-
-#if !defined(MYSQL_SERVER) || defined(MYSQL_INSTANCE_MANAGER)
+#else
#define update_statistics(A)
-#define thd_increment_bytes_sent(N)
#endif
#define TEST_BLOCKING 8
diff --git a/sql/opt_index_cond_pushdown.cc b/sql/opt_index_cond_pushdown.cc
index 277343b81a5..572f314162a 100644
--- a/sql/opt_index_cond_pushdown.cc
+++ b/sql/opt_index_cond_pushdown.cc
@@ -1,5 +1,5 @@
-#include "mysql_priv.h"
#include "sql_select.h"
+#include "sql_test.h"
/****************************************************************************
* Index Condition Pushdown code starts
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 829d97373a1..ed39c632735 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1183,7 +1183,7 @@ QUICK_SELECT_I::QUICK_SELECT_I()
QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr,
bool no_alloc, MEM_ROOT *parent_alloc,
bool *create_error)
- :doing_key_read(0),/*error(0),*/free_file(0),/*in_range(0),*/cur_range(NULL),last_range(0),dont_free(0)
+ :doing_key_read(0),free_file(0),cur_range(NULL),last_range(0),dont_free(0)
{
my_bitmap_map *bitmap;
DBUG_ENTER("QUICK_RANGE_SELECT::QUICK_RANGE_SELECT");
@@ -8090,11 +8090,6 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
(table->key_read ? HA_MRR_INDEX_ONLY : 0);
if (thd->lex->sql_command != SQLCOM_SELECT)
quick->mrr_flags |= HA_MRR_USE_DEFAULT_IMPL;
-#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
- if (!ref->null_ref_key && !key_has_nulls(key_info, range->min_key,
- ref->key_length))
- quick->mrr_flags |= HA_MRR_NO_NULL_ENDPOINTS;
-#endif
quick->mrr_buf_size= thd->variables.mrr_buff_size;
if (table->file->multi_range_read_info(quick->index, 1, (uint)records,
@@ -8815,7 +8810,7 @@ int QUICK_SELECT_DESC::get_next()
QUICK_SELECT_I *QUICK_RANGE_SELECT::make_reverse(uint used_key_parts_arg)
{
QUICK_SELECT_DESC *new_quick= new QUICK_SELECT_DESC(this, used_key_parts_arg);
- if (new_quick == NULL || new_quick->error != 0)
+ if (new_quick == NULL)
{
delete new_quick;
return NULL;
@@ -10869,14 +10864,14 @@ static int index_next_different (bool is_index_scan, handler *file,
while (!key_cmp (key_part, group_prefix, group_prefix_len))
{
- result= file->index_next(record);
+ result= file->ha_index_next(record);
if (result)
return(result);
}
return result;
}
else
- return file->index_read_map(record, group_prefix,
+ return file->ha_index_read_map(record, group_prefix,
make_prev_keypart_map(group_key_parts),
HA_READ_AFTER_KEY);
}
diff --git a/sql/opt_range.h b/sql/opt_range.h
index 34335c7baf3..585f655aeac 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -832,8 +832,7 @@ public:
class QUICK_SELECT_DESC: public QUICK_RANGE_SELECT
{
public:
- QUICK_SELECT_DESC(QUICK_RANGE_SELECT *q, uint used_key_parts,
- bool *create_err);
+ QUICK_SELECT_DESC(QUICK_RANGE_SELECT *q, uint used_key_parts);
int get_next();
bool reverse_sorted() { return 1; }
int get_type() { return QS_TYPE_RANGE_DESC; }
diff --git a/sql/opt_range_mrr.cc b/sql/opt_range_mrr.cc
index 9eeec653355..acf22bd7a49 100644
--- a/sql/opt_range_mrr.cc
+++ b/sql/opt_range_mrr.cc
@@ -188,12 +188,12 @@ walk_right_n_up:
cur->min_key_parts +=
key_tree->next_key_part->store_min_key(seq->param->key[seq->keyno],
&cur->min_key,
- &cur->min_key_flag);
+ &cur->min_key_flag, MAX_KEY);
if (!key_tree->max_flag)
cur->max_key_parts +=
key_tree->next_key_part->store_max_key(seq->param->key[seq->keyno],
&cur->max_key,
- &cur->max_key_flag);
+ &cur->max_key_flag, MAX_KEY);
break;
}
}
diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc
index a58313ec9fd..a4e626e90cd 100644
--- a/sql/opt_subselect.cc
+++ b/sql/opt_subselect.cc
@@ -10,10 +10,9 @@
#pragma implementation // gcc: Class implementation
#endif
-#include "mysql_priv.h"
#include "sql_select.h"
#include "opt_subselect.h"
-
+#include "sql_test.h"
#include <my_bit.h>
// Our own:
@@ -2240,7 +2239,7 @@ bool setup_sj_materialization(JOIN_TAB *tab)
sjm->sjm_table_cols, (ORDER*) 0,
TRUE /* distinct */,
1, /*save_sum_fields*/
- thd->options | TMP_TABLE_ALL_COLUMNS,
+ thd->variables.option_bits | TMP_TABLE_ALL_COLUMNS,
HA_POS_ERROR /*rows_limit */,
(char*)"sj-materialize")))
DBUG_RETURN(TRUE); /* purecov: inspected */
@@ -2800,7 +2799,7 @@ TABLE *create_duplicate_weedout_tmp_table(THD *thd,
if (share->db_type() == TMP_ENGINE_HTON)
{
recinfo++;
- if (create_internal_tmp_table(table, keyinfo, start_recinfo, &recinfo, 0))
+ if (create_internal_tmp_table(table, keyinfo, start_recinfo, &recinfo, 0, 0))
goto err;
}
sjtbl->start_recinfo= start_recinfo;
diff --git a/sql/opt_subselect.h b/sql/opt_subselect.h
index d0206b0fd05..532e43567e8 100644
--- a/sql/opt_subselect.h
+++ b/sql/opt_subselect.h
@@ -164,8 +164,8 @@ public:
*/
if (try_loosescan && // (1)
- (handled_sj_equalities | bound_sj_equalities) == // (2)
- PREV_BITS(ulonglong, s->emb_sj_nest->sj_in_exprs) && // (2)
+ (handled_sj_equalities | bound_sj_equalities) == // (2)
+ PREV_BITS(ulonglong, s->emb_sj_nest->sj_in_exprs) && // (2)
(PREV_BITS(key_part_map, max_loose_keypart+1) & // (3)
(found_part | loose_scan_keyparts)) == // (3)
(found_part | loose_scan_keyparts) && // (3)
diff --git a/sql/opt_table_elimination.cc b/sql/opt_table_elimination.cc
index 1e4e87ebac7..33eeec46217 100644
--- a/sql/opt_table_elimination.cc
+++ b/sql/opt_table_elimination.cc
@@ -12,7 +12,6 @@
#pragma implementation // gcc: Class implementation
#endif
-#include "mysql_priv.h"
#include "my_bit.h"
#include "sql_select.h"
diff --git a/sql/procedure.h b/sql/procedure.h
index 5e62f4dd5cc..b0b5583dcb6 100644
--- a/sql/procedure.h
+++ b/sql/procedure.h
@@ -16,9 +16,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#ifndef PROCEDURE_INCLUDED
-#define PROCEDURE_INCLUDED
-
/* When using sql procedures */
#ifdef USE_PRAGMA_INTERFACE
diff --git a/sql/records.cc b/sql/records.cc
index a7af42fc86a..ed1edcaf487 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -30,7 +30,7 @@
#include "filesort.h" // filesort_free_buffers
#include "opt_range.h" // SQL_SELECT
#include "sql_class.h" // THD
-
+#include "sql_base.h"
static int rr_quick(READ_RECORD *info);
int rr_sequential(READ_RECORD *info);
@@ -387,7 +387,7 @@ static int rr_index_first(READ_RECORD *info)
static int rr_index_last(READ_RECORD *info)
{
- int tmp= info->file->index_last(info->record);
+ int tmp= info->file->ha_index_last(info->record);
info->read_record= rr_index_desc;
if (tmp)
tmp= rr_handle_error(info, tmp);
@@ -438,7 +438,7 @@ static int rr_index(READ_RECORD *info)
static int rr_index_desc(READ_RECORD *info)
{
- int tmp= info->file->index_prev(info->record);
+ int tmp= info->file->ha_index_prev(info->record);
if (tmp)
tmp= rr_handle_error(info, tmp);
return tmp;
diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc
index 6dfaa1bf253..1f0b752c8c8 100644
--- a/sql/rpl_filter.cc
+++ b/sql/rpl_filter.cc
@@ -14,7 +14,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "sql_priv.h"
-#include "unireg.h" // REQUIRED by other includes
+//#include "unireg.h" // REQUIRED by other includes
#include "rpl_filter.h"
#include "hash.h" // my_hash_free
#include "table.h" // TABLE_LIST
diff --git a/sql/rpl_handler.cc b/sql/rpl_handler.cc
index 5f16544d855..9e59c4fe5fd 100644
--- a/sql/rpl_handler.cc
+++ b/sql/rpl_handler.cc
@@ -43,7 +43,7 @@ static pthread_key(Trans_binlog_info*, RPL_TRANS_BINLOG_INFO);
int get_user_var_int(const char *name,
long long int *value, int *null_value)
{
- my_bool null_val;
+ bool null_val;
user_var_entry *entry=
(user_var_entry*) my_hash_search(&current_thd->user_vars,
(uchar*) name, strlen(name));
@@ -58,7 +58,7 @@ int get_user_var_int(const char *name,
int get_user_var_real(const char *name,
double *value, int *null_value)
{
- my_bool null_val;
+ bool null_val;
user_var_entry *entry=
(user_var_entry*) my_hash_search(&current_thd->user_vars,
(uchar*) name, strlen(name));
@@ -74,7 +74,7 @@ int get_user_var_str(const char *name, char *value,
size_t len, unsigned int precision, int *null_value)
{
String str;
- my_bool null_val;
+ bool null_val;
user_var_entry *entry=
(user_var_entry*) my_hash_search(&current_thd->user_vars,
(uchar*) name, strlen(name));
@@ -175,7 +175,7 @@ void delegates_destroy()
for (; info; info= iter++) \
{ \
plugin_ref plugin= \
- my_plugin_lock(0, &info->plugin); \
+ my_plugin_lock(0, info->plugin); \
if (!plugin) \
{ \
/* plugin is not intialized or deleted, this is not an error */ \
@@ -336,7 +336,7 @@ int Binlog_transmit_delegate::reserve_header(THD *thd, ushort flags,
for (; info; info= iter++)
{
plugin_ref plugin=
- my_plugin_lock(thd, &info->plugin);
+ my_plugin_lock(thd, info->plugin);
if (!plugin)
{
ret= 1;
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index 646593ed98f..776bb95c4e5 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -24,13 +24,6 @@
#define DEFAULT_CONNECT_RETRY 60
-// Defined in slave.cc
-int init_intvar_from_file(int* var, IO_CACHE* f, int default_val);
-int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
- const char *default_val);
-int init_floatvar_from_file(float* var, IO_CACHE* f, float default_val);
-int init_dynarray_intvar_from_file(DYNAMIC_ARRAY* arr, IO_CACHE* f);
-
Master_info::Master_info(bool is_slave_recovery)
:Slave_reporting_capability("I/O"),
ssl(0), ssl_verify_server_cert(0), fd(-1), io_thd(0),
diff --git a/sql/scheduler.cc b/sql/scheduler.cc
index 4a5a99bf40e..a9146682da6 100644
--- a/sql/scheduler.cc
+++ b/sql/scheduler.cc
@@ -40,40 +40,6 @@ static bool no_threads_end(THD *thd, bool put_in_cache)
return 1; // Abort handle_one_connection
}
-static scheduler_functions one_thread_scheduler_functions=
-{
- 1, // max_threads
- NULL, NULL,
- NULL, // init
- init_new_connection_handler_thread, // init_new_connection_thread
-#ifndef EMBEDDED_LIBRARY
- handle_connection_in_main_thread, // add_connection
-#else
- NULL, // add_connection
-#endif // EMBEDDED_LIBRARY
- NULL, // thd_wait_begin
- NULL, // thd_wait_end
- NULL, // post_kill_notification
- no_threads_end, // end_thread
- NULL, // end
-};
-
-#ifndef EMBEDDED_LIBRARY
-static scheduler_functions one_thread_per_connection_scheduler_functions=
-{
- 0, // max_threads
- NULL, NULL,
- NULL, // init
- init_new_connection_handler_thread, // init_new_connection_thread
- create_thread_to_handle_connection, // add_connection
- NULL, // thd_wait_begin
- NULL, // thd_wait_end
- NULL, // post_kill_notification
- one_thread_per_connection_end, // end_thread
- NULL, // end
-};
-#endif // EMBEDDED_LIBRARY
-
/** @internal
Helper functions to allow mysys to call the thread scheduler when
waiting for locks.
@@ -102,8 +68,7 @@ static void scheduler_wait_end(void) {
mysqld.cc, so this init function will always be called.
*/
static void scheduler_init() {
- mysys_var->scheduler_before_lock_wait= &scheduler_wait_begin;
- mysys_var->scheduler_after_lock_wait= &scheduler_wait_end;
+ thr_set_lock_wait_callback(scheduler_wait_begin, scheduler_wait_end);
}
/*
@@ -111,15 +76,17 @@ static void scheduler_init() {
*/
#ifndef EMBEDDED_LIBRARY
-scheduler_functions *one_thread_per_connection_scheduler(
+void one_thread_per_connection_scheduler(scheduler_functions *func,
ulong *arg_max_connections,
uint *arg_connection_count)
{
scheduler_init();
- one_thread_per_connection_scheduler_functions.max_threads= *arg_max_connections + 1;
- one_thread_per_connection_scheduler_functions.max_connections= arg_max_connections;
- one_thread_per_connection_scheduler_functions.connection_count= arg_connection_count;
- return &one_thread_per_connection_scheduler_functions;
+ func->max_threads= *arg_max_connections + 1;
+ func->max_connections= arg_max_connections;
+ func->connection_count= arg_connection_count;
+ func->init_new_connection_thread= init_new_connection_handler_thread;
+ func->add_connection= create_thread_to_handle_connection;
+ func->end_thread= one_thread_per_connection_end;
}
#endif
@@ -127,16 +94,22 @@ scheduler_functions *one_thread_per_connection_scheduler(
Initailize scheduler for --thread-handling=no-threads
*/
-scheduler_functions *one_thread_scheduler()
+void one_thread_scheduler(scheduler_functions *func)
{
scheduler_init();
- return &one_thread_scheduler_functions;
+ func->max_threads= 1;
+ //max_connections= 1;
+ func->max_connections= &max_connections;
+ func->connection_count= &connection_count;
+#ifndef EMBEDDED_LIBRARY
+ func->init_new_connection_thread= init_new_connection_handler_thread;
+ func->add_connection= handle_connection_in_main_thread;
+#endif
+ func->end_thread= no_threads_end;
}
-/*
- Initialize scheduler for --thread-handling=one-thread-per-connection
-*/
+#ifdef HAVE_POOL_OF_THREADS
/*
thd_scheduler keeps the link between THD and events.
@@ -144,7 +117,7 @@ scheduler_functions *one_thread_scheduler()
*/
thd_scheduler::thd_scheduler()
- : m_psi(NULL), data(NULL)
+ : m_psi(NULL), logged_in(FALSE), io_event(NULL), thread_attached(FALSE)
{
#ifndef DBUG_OFF
dbug_explain[0]= '\0';
@@ -155,8 +128,11 @@ thd_scheduler::thd_scheduler()
thd_scheduler::~thd_scheduler()
{
+ my_free(io_event);
}
+#endif
+
/*
no pluggable schedulers in mariadb.
when we'll want it, we'll do it properly
@@ -204,5 +180,3 @@ extern "C" int my_thread_scheduler_reset()
{ return 1; }
#endif
-#warning restore libevent
-
diff --git a/sql/scheduler.h b/sql/scheduler.h
index 32ba3e63953..cb7568b566a 100644
--- a/sql/scheduler.h
+++ b/sql/scheduler.h
@@ -63,17 +63,21 @@ enum scheduler_types
SCHEDULER_TYPES_COUNT
};
-scheduler_functions *one_thread_per_connection_scheduler(ulong *, uint *);
-scheduler_functions *one_thread_scheduler();
+void one_thread_per_connection_scheduler(scheduler_functions *func,
+ ulong *arg_max_connections, uint *arg_connection_count);
+void one_thread_scheduler(scheduler_functions *func);
enum pool_command_op
{
NOT_IN_USE_OP= 0, NORMAL_OP= 1, CONNECT_OP, KILL_OP, DIE_OP
};
-/*
- To be used for pool-of-threads (implemeneted differently on various OSs)
-*/
+#if defined(HAVE_LIBEVENT) && !defined(EMBEDDED_LIBRARY)
+
+#define HAVE_POOL_OF_THREADS 1
+
+struct event;
+
class thd_scheduler
{
public:
@@ -89,7 +93,10 @@ public:
*/
PSI_thread *m_psi;
- void *data; /* scheduler-specific data structure */
+ bool logged_in;
+ struct event* io_event;
+ LIST list;
+ bool thread_attached; /* Indicates if THD is attached to the OS thread */
# ifndef DBUG_OFF
char dbug_explain[512];
@@ -98,6 +105,21 @@ public:
thd_scheduler();
~thd_scheduler();
+ bool init(THD* parent_thd);
+ bool thread_attach();
+ void thread_detach();
};
+void pool_of_threads_scheduler(scheduler_functions* func);
+#else
+
+#define pool_of_threads_scheduler(A) \
+ one_thread_per_connection_scheduler(A, &max_connections, \
+ &connection_count)
+
+class thd_scheduler
+{};
+
+#endif
+
#endif
diff --git a/sql/set_var.h b/sql/set_var.h
index 2972b430e48..17792a689d2 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -209,7 +209,7 @@ public:
plugin_ref plugin; ///< for Sys_var_plugin
Time_zone *time_zone; ///< for Sys_var_tz
LEX_STRING string_value; ///< for Sys_var_charptr and others
- void *ptr; ///< for Sys_var_struct
+ const void *ptr; ///< for Sys_var_struct
} save_result;
LEX_STRING base; /**< for structured variables, like keycache_name.variable_name */
diff --git a/sql/slave.h b/sql/slave.h
index 02095fad6b1..737e23c6cdc 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -48,6 +48,11 @@
class Relay_log_info;
class Master_info;
+int init_intvar_from_file(int* var, IO_CACHE* f, int default_val);
+int init_strvar_from_file(char *var, int max_size, IO_CACHE *f,
+ const char *default_val);
+int init_floatvar_from_file(float* var, IO_CACHE* f, float default_val);
+int init_dynarray_intvar_from_file(DYNAMIC_ARRAY* arr, IO_CACHE* f);
/*****************************************************************************
diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc
index 662570d8d8b..eaac4459e99 100644
--- a/sql/sp_cache.cc
+++ b/sql/sp_cache.cc
@@ -123,7 +123,7 @@ void sp_cache_clear(sp_cache **cp)
void sp_cache_end()
{
- pthread_mutex_destroy(&Cversion_lock);
+ mysql_mutex_destroy(&Cversion_lock);
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 4dda2d7263a..41163ee629e 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -44,6 +44,9 @@
#include "transaction.h"
#include "lock.h" // MYSQL_LOCK_IGNORE_TIMEOUT
#include "records.h" // init_read_record, end_read_record
+#include "hostname.h"
+#include "sql_db.h"
+#include "sql_connect.h"
#include <sql_common.h>
#include <mysql/plugin_auth.h>
@@ -4608,14 +4611,14 @@ bool check_routine_level_acl(THD *thd, const char *db, const char *name,
ulong get_table_grant(THD *thd, TABLE_LIST *table)
{
ulong privilege;
+ Security_context *sctx= thd->security_ctx;
+ const char *db = table->db ? table->db : thd->db;
GRANT_TABLE *grant_table;
- rw_rdlock(&LOCK_grant);
+ mysql_rwlock_rdlock(&LOCK_grant);
#ifdef EMBEDDED_LIBRARY
grant_table= NULL;
#else
- Security_context *sctx= thd->security_ctx;
- const char *db = table->db ? table->db : thd->db;
grant_table= table_hash_search(sctx->host, sctx->ip, db, sctx->priv_user,
table->table_name, 0);
#endif
@@ -7486,7 +7489,7 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio, Security_context *sctx)
{
DBUG_ASSERT(mpvio->acl_user == 0);
- pthread_mutex_lock(&acl_cache->lock);
+ mysql_mutex_lock(&acl_cache->lock);
for (uint i=0 ; i < acl_users.elements ; i++)
{
ACL_USER *acl_user_tmp= dynamic_element(&acl_users,i,ACL_USER*);
@@ -7497,7 +7500,7 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio, Security_context *sctx)
break;
}
}
- pthread_mutex_unlock(&acl_cache->lock);
+ mysql_mutex_unlock(&acl_cache->lock);
if (!mpvio->acl_user)
{
@@ -8366,10 +8369,10 @@ bool acl_authenticate(THD *thd, uint connect_errors, uint com_change_user_pkt_le
if (command == COM_CONNECT &&
!(thd->main_security_ctx.master_access & SUPER_ACL))
{
- pthread_mutex_lock(&LOCK_connection_count);
+ mysql_mutex_lock(&LOCK_connection_count);
bool count_ok= (*thd->scheduler->connection_count <=
*thd->scheduler->max_connections);
- VOID(pthread_mutex_unlock(&LOCK_connection_count));
+ mysql_mutex_unlock(&LOCK_connection_count);
if (!count_ok)
{ // too many connections
my_error(ER_CON_COUNT_ERROR, MYF(0));
@@ -8403,7 +8406,7 @@ bool acl_authenticate(THD *thd, uint connect_errors, uint com_change_user_pkt_le
thd->net.net_skip_rest_factor= 2; // skip at most 2*max_packet_size
if (res == CR_OK_HANDSHAKE_COMPLETE)
- thd->main_da.disable_status();
+ thd->stmt_da->disable_status();
else
my_ok(thd);
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index d21341fac08..874e91c4040 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -40,8 +40,9 @@ static bool admin_recreate_table(THD *thd, TABLE_LIST *table_list)
trans_rollback(thd);
close_thread_tables(thd);
thd->mdl_context.release_transactional_locks();
+ DEBUG_SYNC(thd, "ha_admin_try_alter");
tmp_disable_binlog(thd); // binlogging is done by caller if wanted
- result_code= mysql_recreate_table(thd, table);
+ result_code= mysql_recreate_table(thd, table_list);
reenable_binlog(thd);
/*
mysql_recreate_table() can push OK or ERROR.
@@ -51,7 +52,7 @@ static bool admin_recreate_table(THD *thd, TABLE_LIST *table_list)
*/
if (thd->stmt_da->is_ok())
thd->stmt_da->reset_diagnostics_area();
- table->table= NULL;
+ table_list->table= NULL;
result_code= result_code ? HA_ADMIN_FAILED : HA_ADMIN_OK;
DBUG_RETURN(result_code);
}
@@ -665,14 +666,13 @@ send_result_message:
reopen the table and do ha_innobase::analyze() on it.
We have to end the row, so analyze could return more rows.
*/
- if (protocol->write())
- goto err;
- DBUG_PRINT("info", ("HA_ADMIN_TRY_ALTER, trying analyze..."));
- DEBUG_SYNC(thd, "ha_admin_try_alter");
protocol->store(STRING_WITH_LEN("note"), system_charset_info);
protocol->store(STRING_WITH_LEN(
"Table does not support optimize, doing recreate + analyze instead"),
system_charset_info);
+ if (protocol->write())
+ goto err;
+ DBUG_PRINT("info", ("HA_ADMIN_TRY_ALTER, trying analyze..."));
TABLE_LIST *save_next_local= table->next_local,
*save_next_global= table->next_global;
table->next_local= table->next_global= 0;
diff --git a/sql/sql_audit.cc b/sql/sql_audit.cc
index b7d363dc09a..3f5c96ef9ff 100644
--- a/sql/sql_audit.cc
+++ b/sql/sql_audit.cc
@@ -130,7 +130,7 @@ static my_bool acquire_plugins(THD *thd, plugin_ref plugin, void *arg)
}
/* lock the plugin and add it to the list */
- plugin= my_plugin_lock(NULL, &plugin);
+ plugin= my_plugin_lock(NULL, plugin);
insert_dynamic(&thd->audit_class_plugins, (uchar*) &plugin);
return 0;
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index af81246253b..7116d046a8c 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -38,6 +38,7 @@
// mysql_handle_derived,
// mysql_derived_filling
#include "sql_handler.h" // mysql_ha_flush
+#include "sql_test.h"
#include "sql_partition.h" // ALTER_PARTITION_PARAM_TYPE
#include "log_event.h" // Query_log_event
#include "sql_select.h"
@@ -1360,8 +1361,10 @@ close_all_tables_for_name(THD *thd, TABLE_SHARE *share,
mysql_lock_remove(thd, thd->lock, table);
/* Inform handler that table will be dropped after close */
- if (table->db_stat) /* Not true for partitioned tables. */
+#ifdef MERGE_FOR_MONTY_TO_FIX
+ if (remove_from_locked_tables && table->db_stat) /* Not true for partitioned tables. */
table->file->extra(HA_EXTRA_PREPARE_FOR_DROP);
+#endif
close_thread_table(thd, prev);
}
else
@@ -1404,6 +1407,11 @@ void close_thread_tables(THD *thd)
TABLE *table;
DBUG_ENTER("close_thread_tables");
+#ifdef WITH_ARIA_STORAGE_ENGINE
+ if (!thd->in_sub_stmt)
+ ha_maria::implicit_commit(thd, FALSE);
+#endif
+
#ifdef EXTRA_DEBUG
DBUG_PRINT("tcache", ("open tables:"));
for (table= thd->open_tables; table; table= table->next)
@@ -8786,7 +8794,6 @@ my_bool mysql_rm_tmp_tables(void)
}
-
/*****************************************************************************
unireg support functions
*****************************************************************************/
@@ -8806,8 +8813,6 @@ void tdc_flush_unused_tables()
free_cache_entry(unused_tables);
mysql_mutex_unlock(&LOCK_open);
}
-#error restore table->s->deleting
-#error restore changes from monty@askmonty.org-20101102152257-mwa7etvs9nxewjf2
/**
diff --git a/sql/sql_bitmap.h b/sql/sql_bitmap.h
index cd3442d306c..0449611e27a 100644
--- a/sql/sql_bitmap.h
+++ b/sql/sql_bitmap.h
@@ -157,7 +157,7 @@ public:
bool is_subset(const Bitmap<64>& map2) const { return !(map & ~map2.map); }
bool is_overlapping(const Bitmap<64>& map2) const { return (map & map2.map)!= 0; }
bool operator==(const Bitmap<64>& map2) const { return map == map2.map; }
- char *print(char *buf) const { longlong2str(map,buf,16,1); return buf; }
+ char *print(char *buf) const { longlong2str(map,buf,16); return buf; }
ulonglong to_ulonglong() const { return map; }
class Iterator : public Table_map_iterator
{
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index a536c5b35b4..30dd835e9eb 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -341,6 +341,7 @@ TODO list:
#include "../storage/myisammrg/ha_myisammrg.h"
#include "../storage/myisammrg/myrg_def.h"
#include "probes_mysql.h"
+#include "log_slow.h"
#ifdef EMBEDDED_LIBRARY
#include "emb_qcache.h"
@@ -945,7 +946,6 @@ Query_cache::abort(Query_cache_tls *query_cache_tls)
if (try_lock())
DBUG_VOID_RETURN;
- }
/*
While we were waiting another thread might have changed the status
@@ -997,7 +997,6 @@ void Query_cache::end_of_result(THD *thd)
if (try_lock())
DBUG_VOID_RETURN;
- }
query_block= query_cache_tls->first_query_block;
if (query_block)
diff --git a/sql/sql_callback.h b/sql/sql_callback.h
index 834d8b74c7a..ea51c107ff9 100644
--- a/sql/sql_callback.h
+++ b/sql/sql_callback.h
@@ -31,10 +31,12 @@
*/
#define MYSQL_CALLBACK(OBJ, FUNC, PARAMS) \
- (((OBJ) && ((OBJ)->FUNC)) ? (OBJ)->FUNC PARAMS : 0)
+ do { \
+ if ((OBJ) && ((OBJ)->FUNC)) \
+ (OBJ)->FUNC PARAMS; \
+ } while (0)
-#define MYSQL_CALLBACK_ELSE0(OBJ, FUNC, PARAMS, ELSE) \
+#define MYSQL_CALLBACK_ELSE(OBJ, FUNC, PARAMS, ELSE) \
(((OBJ) && ((OBJ)->FUNC)) ? (OBJ)->FUNC PARAMS : (ELSE))
-
#endif /* SQL_CALLBACK_INCLUDED */
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 2fcb6120076..7638cf8f8f6 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -59,6 +59,7 @@
#include "debug_sync.h"
#include "sql_parse.h" // is_update_query
#include "sql_callback.h"
+#include "sql_connect.h"
/*
The following is used to initialise Table_ident with a internal
@@ -236,7 +237,7 @@ bool Foreign_key::validate(List<Create_field> &table_fields)
it.rewind();
while ((sql_field= it++) &&
my_strcasecmp(system_charset_info,
- column->field_name,
+ column->field_name.str,
sql_field->field_name)) {}
if (!sql_field)
{
@@ -316,11 +317,13 @@ int thd_tablespace_op(const THD *thd)
extern "C"
-const char *set_thd_proc_info(THD *thd, const char *info,
+const char *set_thd_proc_info(void *thd_arg, const char *info,
const char *calling_function,
const char *calling_file,
const unsigned int calling_line)
{
+ THD *thd= (THD *) thd_arg;
+
if (!thd)
thd= current_thd;
@@ -1322,7 +1325,7 @@ void THD::awake(THD::killed_state state_to_set)
{
thr_alarm_kill(thread_id);
if (!slave_thread)
- MYSQL_CALLBACK(thread_scheduler, post_kill_notification, (this));
+ MYSQL_CALLBACK(scheduler, post_kill_notification, (this));
#ifdef SIGNAL_WITH_VIO_CLOSE
if (this != current_thd)
{
@@ -1416,7 +1419,6 @@ bool THD::store_globals()
*/
thr_lock_info_init(&lock_info);
-#warning add registration of mutex order if needed
return 0;
}
@@ -1429,9 +1431,9 @@ bool THD::store_globals()
void THD::reset_globals()
{
- pthread_mutex_lock(&LOCK_thd_data);
+ mysql_mutex_lock(&LOCK_thd_data);
mysys_var= 0;
- pthread_mutex_unlock(&LOCK_thd_data);
+ mysql_mutex_unlock(&LOCK_thd_data);
}
/*
@@ -2558,7 +2560,6 @@ bool select_max_min_finder_subselect::send_data(List<Item> &items)
op= &select_max_min_finder_subselect::cmp_decimal;
break;
case ROW_RESULT:
- case IMPOSSIBLE_RESULT:
// This case should never be choosen
DBUG_ASSERT(0);
op= 0;
@@ -3421,7 +3422,7 @@ extern "C" bool thd_sqlcom_can_generate_row_events(const MYSQL_THD thd)
return sqlcom_can_generate_row_events(thd);
}
-#ifndef EMBEDDED_LIBRARY
+#ifdef NOT_USED /* we'll do the correctly instead */
extern "C" void thd_pool_wait_begin(MYSQL_THD thd, int wait_type);
extern "C" void thd_pool_wait_end(MYSQL_THD thd);
@@ -3448,7 +3449,7 @@ extern "C" void thd_pool_wait_end(MYSQL_THD thd);
*/
extern "C" void thd_wait_begin(MYSQL_THD thd, thd_wait_type wait_type)
{
- MYSQL_CALLBACK(thread_scheduler, thd_wait_begin, (thd, wait_type));
+ MYSQL_CALLBACK(thd->scheduler, thd_wait_begin, (thd, wait_type));
}
/**
@@ -3459,7 +3460,7 @@ extern "C" void thd_wait_begin(MYSQL_THD thd, thd_wait_type wait_type)
*/
extern "C" void thd_wait_end(MYSQL_THD thd)
{
- MYSQL_CALLBACK(thread_scheduler, thd_wait_end, (thd));
+ MYSQL_CALLBACK(thd->scheduler, thd_wait_end, (thd));
}
#else
extern "C" void thd_wait_begin(MYSQL_THD thd, thd_wait_type wait_type)
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 4dc8abc64d5..05082a8e8fe 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -43,123 +43,6 @@
class Reprepare_observer;
-
-
-/**
- Interface for Item iterator
-*/
-
-class Item_iterator
-{
-public:
- /**
- Shall set this iterator to the position before the first item
-
- @note
- This method also may perform some other initialization actions like
- allocation of certain resources.
- */
- virtual void open()= 0;
- /**
- Shall return the next Item (or NULL if there is no next item) and
- move pointer to position after it.
- */
- virtual Item *next()= 0;
- /**
- Shall force iterator to free resources (if it holds them)
-
- @note
- One should not use the iterator without open() call after close()
- */
- virtual void close()= 0;
-
- virtual ~Item_iterator() {}
-};
-
-
-/**
- Item iterator over List_iterator_fast for Item references
-*/
-
-class Item_iterator_ref_list: public Item_iterator
-{
- List_iterator<Item*> list;
-public:
- Item_iterator_ref_list(List_iterator<Item*> &arg_list):
- list(arg_list) {}
- void open() { list.rewind(); }
- Item *next() { return *(list++); }
- void close() {}
-};
-
-
-/**
- Item iterator over Item interface for rows
-*/
-
-class Item_iterator_row: public Item_iterator
-{
- Item *base_item;
- uint current;
-public:
- Item_iterator_row(Item *base) : base_item(base), current(0) {}
- void open() { current= 0; }
- Item *next()
- {
- if (current >= base_item->cols())
- return NULL;
- return base_item->element_index(current++);
- }
- void close() {}
-};
-
-
-/**
- An interface that is used to take an action when
- the locking module notices that a table version has changed
- since the last execution. "Table" here may refer to any kind of
- table -- a base table, a temporary table, a view or an
- information schema table.
-
- When we open and lock tables for execution of a prepared
- statement, we must verify that they did not change
- since statement prepare. If some table did change, the statement
- parse tree *may* be no longer valid, e.g. in case it contains
- optimizations that depend on table metadata.
-
- This class provides an interface (a method) that is
- invoked when such a situation takes place.
- The implementation of the method simply reports an error, but
- the exact details depend on the nature of the SQL statement.
-
- At most 1 instance of this class is active at a time, in which
- case THD::m_reprepare_observer is not NULL.
-
- @sa check_and_update_table_version() for details of the
- version tracking algorithm
-
- @sa Open_tables_state::m_reprepare_observer for the life cycle
- of metadata observers.
-*/
-
-class Reprepare_observer
-{
-public:
- /**
- Check if a change of metadata is OK. In future
- the signature of this method may be extended to accept the old
- and the new versions, but since currently the check is very
- simple, we only need the THD to report an error.
- */
- bool report_error(THD *thd);
- bool is_invalidated() const { return m_invalidated; }
- void reset_reprepare_observer() { m_invalidated= FALSE; }
- Reprepare_observer() {} /* Remove gcc warning */
-private:
- bool m_invalidated;
-};
-
-
class Relay_log_info;
class Query_log_event;
@@ -353,9 +236,10 @@ public:
{}
Key(enum Keytype type_par, const char *name_arg, size_t name_len_arg,
KEY_CREATE_INFO *key_info_arg, bool generated_arg,
- List<Key_part_spec> &cols)
+ List<Key_part_spec> &cols,
+ engine_option_value *create_opt)
:type(type_par), key_create_info(*key_info_arg), columns(cols),
- generated(generated_arg)
+ option_list(create_opt), generated(generated_arg)
{
name.str= (char *)name_arg;
name.length= name_len_arg;
@@ -3230,12 +3114,15 @@ public:
int prepare2(void) { return 0; }
};
+#include <myisam.h>
-#if defined(WITH_ARIA_STORAGE_ENGINE) && defined(USE_MARIA_FOR_TMP_TABLES)
+#ifdef WITH_ARIA_STORAGE_ENGINE
#include <maria.h>
+#endif
+
+#ifdef USE_ARIA_FOR_TMP_TABLES
#define ENGINE_COLUMNDEF MARIA_COLUMNDEF
#else
-#include <myisam.h>
#define ENGINE_COLUMNDEF MI_COLUMNDEF
#endif
@@ -4064,17 +3951,18 @@ inline int handler::ha_read_first_row(uchar *buf, uint primary_key)
#endif /* MYSQL_SERVER */
+#if 0
/**
The meat of thd_proc_info(THD*, char*), a macro that packs the last
three calling-info parameters.
*/
extern "C"
-const char *set_thd_proc_info(THD *thd, const char *info,
+const char *set_thd_proc_info(void *thd_arg, const char *info,
const char *calling_func,
const char *calling_file,
const unsigned int calling_line);
#define thd_proc_info(thd, msg) \
set_thd_proc_info(thd, msg, __func__, __FILE__, __LINE__)
-
+#endif
#endif /* SQL_CLASS_INCLUDED */
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index 800ff7d7585..0fe43fb5ebb 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -25,7 +25,6 @@
#endif
#include "sql_audit.h"
#include "sql_connect.h"
-#include "my_global.h"
#include "probes_mysql.h"
#include "unireg.h" // REQUIRED: for other includes
#include "sql_parse.h" // sql_command_flags,
@@ -396,7 +395,7 @@ extern "C" uchar *get_key_user_stats(USER_STATS *user_stats, size_t *length,
void free_user_stats(USER_STATS* user_stats)
{
- my_free(user_stats, MYF(0));
+ my_free(user_stats);
}
void init_user_stats(USER_STATS *user_stats,
@@ -459,7 +458,7 @@ void init_user_stats(USER_STATS *user_stats,
}
-#ifdef COMPLEAT_PATCH_NOT_ADDED_YET
+#ifdef COMPLETE_PATCH_NOT_ADDED_YET
void add_user_stats(USER_STATS *user_stats,
uint total_connections,
@@ -513,9 +512,9 @@ void add_user_stats(USER_STATS *user_stats,
void init_global_user_stats(void)
{
- if (hash_init(&global_user_stats, system_charset_info, max_connections,
- 0, 0, (hash_get_key) get_key_user_stats,
- (hash_free_key)free_user_stats, 0))
+ if (my_hash_init(&global_user_stats, system_charset_info, max_connections,
+ 0, 0, (my_hash_get_key) get_key_user_stats,
+ (my_hash_free_key)free_user_stats, 0))
{
sql_print_error("Initializing global_user_stats failed.");
exit(1);
@@ -524,9 +523,9 @@ void init_global_user_stats(void)
void init_global_client_stats(void)
{
- if (hash_init(&global_client_stats, system_charset_info, max_connections,
- 0, 0, (hash_get_key) get_key_user_stats,
- (hash_free_key)free_user_stats, 0))
+ if (my_hash_init(&global_client_stats, system_charset_info, max_connections,
+ 0, 0, (my_hash_get_key) get_key_user_stats,
+ (my_hash_free_key)free_user_stats, 0))
{
sql_print_error("Initializing global_client_stats failed.");
exit(1);
@@ -542,14 +541,14 @@ extern "C" uchar *get_key_table_stats(TABLE_STATS *table_stats, size_t *length,
extern "C" void free_table_stats(TABLE_STATS* table_stats)
{
- my_free(table_stats, MYF(0));
+ my_free(table_stats);
}
void init_global_table_stats(void)
{
- if (hash_init(&global_table_stats, system_charset_info, max_connections,
- 0, 0, (hash_get_key) get_key_table_stats,
- (hash_free_key)free_table_stats, 0)) {
+ if (my_hash_init(&global_table_stats, system_charset_info, max_connections,
+ 0, 0, (my_hash_get_key) get_key_table_stats,
+ (my_hash_free_key)free_table_stats, 0)) {
sql_print_error("Initializing global_table_stats failed.");
exit(1);
}
@@ -564,14 +563,14 @@ extern "C" uchar *get_key_index_stats(INDEX_STATS *index_stats, size_t *length,
extern "C" void free_index_stats(INDEX_STATS* index_stats)
{
- my_free(index_stats, MYF(0));
+ my_free(index_stats);
}
void init_global_index_stats(void)
{
- if (hash_init(&global_index_stats, system_charset_info, max_connections,
- 0, 0, (hash_get_key) get_key_index_stats,
- (hash_free_key)free_index_stats, 0))
+ if (my_hash_init(&global_index_stats, system_charset_info, max_connections,
+ 0, 0, (my_hash_get_key) get_key_index_stats,
+ (my_hash_free_key)free_index_stats, 0))
{
sql_print_error("Initializing global_index_stats failed.");
exit(1);
@@ -581,22 +580,22 @@ void init_global_index_stats(void)
void free_global_user_stats(void)
{
- hash_free(&global_user_stats);
+ my_hash_free(&global_user_stats);
}
void free_global_table_stats(void)
{
- hash_free(&global_table_stats);
+ my_hash_free(&global_table_stats);
}
void free_global_index_stats(void)
{
- hash_free(&global_index_stats);
+ my_hash_free(&global_index_stats);
}
void free_global_client_stats(void)
{
- hash_free(&global_client_stats);
+ my_hash_free(&global_client_stats);
}
/*
@@ -611,7 +610,7 @@ static bool increment_count_by_name(const char *name, size_t name_length,
{
USER_STATS *user_stats;
- if (!(user_stats= (USER_STATS*) hash_search(users_or_clients, (uchar*) name,
+ if (!(user_stats= (USER_STATS*) my_hash_search(users_or_clients, (uchar*) name,
name_length)))
{
/* First connection for this user or client */
@@ -635,7 +634,7 @@ static bool increment_count_by_name(const char *name, size_t name_length,
if (my_hash_insert(users_or_clients, (uchar*)user_stats))
{
- my_free(user_stats, 0);
+ my_free(user_stats);
return TRUE; // Out of memory
}
}
@@ -664,7 +663,7 @@ static bool increment_connection_count(THD* thd, bool use_lock)
return FALSE;
if (use_lock)
- pthread_mutex_lock(&LOCK_global_user_client_stats);
+ mysql_mutex_lock(&LOCK_global_user_client_stats);
if (increment_count_by_name(user_string, strlen(user_string), user_string,
&global_user_stats, thd))
@@ -681,7 +680,7 @@ static bool increment_connection_count(THD* thd, bool use_lock)
end:
if (use_lock)
- pthread_mutex_unlock(&LOCK_global_user_client_stats);
+ mysql_mutex_unlock(&LOCK_global_user_client_stats);
return return_value;
}
#endif
@@ -757,10 +756,10 @@ void update_global_user_stats(THD *thd, bool create_user, time_t now)
client_string= get_client_host(thd);
client_string_length= strlen(client_string);
- pthread_mutex_lock(&LOCK_global_user_client_stats);
+ mysql_mutex_lock(&LOCK_global_user_client_stats);
// Update by user name
- if ((user_stats= (USER_STATS*) hash_search(&global_user_stats,
+ if ((user_stats= (USER_STATS*) my_hash_search(&global_user_stats,
(uchar*) user_string,
user_string_length)))
{
@@ -778,7 +777,7 @@ void update_global_user_stats(THD *thd, bool create_user, time_t now)
}
/* Update by client IP */
- if ((user_stats= (USER_STATS*)hash_search(&global_client_stats,
+ if ((user_stats= (USER_STATS*)my_hash_search(&global_client_stats,
(uchar*) client_string,
client_string_length)))
{
@@ -798,7 +797,7 @@ void update_global_user_stats(THD *thd, bool create_user, time_t now)
thd->select_commands= thd->update_commands= thd->other_commands= 0;
thd->last_global_update_time= now;
- pthread_mutex_unlock(&LOCK_global_user_client_stats);
+ mysql_mutex_unlock(&LOCK_global_user_client_stats);
}
@@ -1005,7 +1004,7 @@ bool login_connection(THD *thd)
/* Updates global user connection stats. */
if (increment_connection_count(thd, TRUE))
{
- net_send_error(thd, ER_OUTOFMEMORY); // Out of memory
+ my_error(ER_OUTOFMEMORY, MYF(0), 2*sizeof(USER_STATS));
DBUG_RETURN(1);
}
@@ -1131,11 +1130,11 @@ void do_handle_one_connection(THD *thd_arg)
thd->thr_create_utime= my_micro_time();
- if (MYSQL_CALLBACK(thread_scheduler, init_new_connection_thread, ()))
+ if (MYSQL_CALLBACK_ELSE(&thread_scheduler, init_new_connection_thread, (), 0))
{
close_connection(thd, ER_OUT_OF_RESOURCES, 1);
statistic_increment(aborted_connects,&LOCK_status);
- MYSQL_CALLBACK(thd->thread_scheduler, end_thread, (thd, 0));
+ MYSQL_CALLBACK(thd->scheduler, end_thread, (thd, 0));
return;
}
@@ -1197,7 +1196,7 @@ end_thread:
if (thd->userstat_running)
update_global_user_stats(thd, create_user, time(NULL));
- if (MYSQL_CALLBACK(thd->scheduler, end_thread, (thd, 1)))
+ if (MYSQL_CALLBACK_ELSE(thd->scheduler, end_thread, (thd, 1), 0))
return; // Probably no-threads
/*
diff --git a/sql/sql_connect.h b/sql/sql_connect.h
index 9653d3988c0..18dd2b31305 100644
--- a/sql/sql_connect.h
+++ b/sql/sql_connect.h
@@ -52,6 +52,14 @@ int get_or_create_user_conn(THD *thd, const char *user,
const char *host, USER_RESOURCES *mqh);
int check_for_max_user_connections(THD *thd, USER_CONN *uc);
+extern HASH global_user_stats;
+extern HASH global_client_stats;
+extern HASH global_table_stats;
+extern HASH global_index_stats;
+extern mysql_mutex_t LOCK_global_user_client_stats;
+extern mysql_mutex_t LOCK_global_table_stats;
+extern mysql_mutex_t LOCK_global_index_stats;
+extern mysql_mutex_t LOCK_stats;
#endif /* SQL_CONNECT_INCLUDED */
diff --git a/sql/sql_db.h b/sql/sql_db.h
index ecb8deaa397..c99bdb63fc5 100644
--- a/sql/sql_db.h
+++ b/sql/sql_db.h
@@ -19,9 +19,7 @@
#include "hash.h" /* HASH */
class THD;
-typedef struct charset_info_st CHARSET_INFO;
typedef struct st_ha_create_information HA_CREATE_INFO;
-typedef struct st_mysql_lex_string LEX_STRING;
int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent);
bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create);
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 9d13fa1b01b..d80eb4d4dfe 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -59,7 +59,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
bool const_cond_result;
ha_rows deleted= 0;
bool reverse= FALSE;
- bool skip_record;
ORDER *order= (ORDER *) ((order_list && order_list->elements) ?
order_list->first : NULL);
uint usable_index= MAX_KEY;
diff --git a/sql/sql_error.h b/sql/sql_error.h
index c0f28c20286..8495a8cfa57 100644
--- a/sql/sql_error.h
+++ b/sql/sql_error.h
@@ -101,7 +101,7 @@ public:
void increment_warning()
{
if (m_status != DA_EMPTY)
- m_total_warn_count++;
+ m_statement_warn_count++;
}
Diagnostics_area() { reset_diagnostics_area(); }
diff --git a/sql/sql_expression_cache.cc b/sql/sql_expression_cache.cc
index 50fd7c7ee4d..d91868ca916 100644
--- a/sql/sql_expression_cache.cc
+++ b/sql/sql_expression_cache.cc
@@ -1,6 +1,7 @@
-#include "mysql_priv.h"
+#include "sql_base.h"
#include "sql_select.h"
+#include "sql_expression_cache.h"
/*
Expression cache is used only for caching subqueries now, so its statistic
@@ -91,10 +92,9 @@ void Expression_cache_tmptable::init()
if (!(cache_table= create_tmp_table(table_thd, &cache_table_param,
items, (ORDER*) NULL,
FALSE, FALSE,
- ((table_thd->options |
+ ((table_thd->variables.option_bits |
TMP_TABLE_ALL_COLUMNS) &
- ~(OPTION_BIG_TABLES |
- TMP_TABLE_FORCE_MYISAM)),
+ ~TMP_TABLE_FORCE_MYISAM),
HA_POS_ERROR,
(char *)"subquery-cache-table")))
{
@@ -155,7 +155,10 @@ error:
Expression_cache_tmptable::~Expression_cache_tmptable()
{
if (cache_table)
+ {
+ cache_table->file->ha_index_end();
free_tmp_table(table_thd, cache_table);
+ }
}
@@ -253,6 +256,7 @@ my_bool Expression_cache_tmptable::put_value(Item *value)
DBUG_RETURN(FALSE);
err:
+ cache_table->file->ha_index_end();
free_tmp_table(table_thd, cache_table);
cache_table= NULL;
DBUG_RETURN(TRUE);
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index c562a5c6cb4..99a8378961e 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -2491,7 +2491,7 @@ void kill_delayed_threads(void)
while ((di= it++))
{
di->thd.killed= THD::KILL_CONNECTION;
- pthread_mutex_lock(&di->thd.LOCK_thd_data);
+ mysql_mutex_lock(&di->thd.LOCK_thd_data);
if (di->thd.mysys_var)
{
mysql_mutex_lock(&di->thd.mysys_var->mutex);
@@ -2509,7 +2509,7 @@ void kill_delayed_threads(void)
}
mysql_mutex_unlock(&di->thd.mysys_var->mutex);
}
- pthread_mutex_unlock(&di->thd.LOCK_thd_data);
+ mysql_mutex_unlock(&di->thd.LOCK_thd_data);
}
mysql_mutex_unlock(&LOCK_delayed_insert); // For unlink from list
}
diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc
index 10064590a75..7a08dadf049 100644
--- a/sql/sql_join_cache.cc
+++ b/sql/sql_join_cache.cc
@@ -27,7 +27,8 @@
#pragma implementation // gcc: Class implementation
#endif
-#include "mysql_priv.h"
+#include "key.h"
+#include "sql_base.h"
#include "sql_select.h"
#include "opt_subselect.h"
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 67717ebab29..b24744571e6 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -38,10 +38,6 @@ static int lex_one_token(void *arg, void *yythd);
sys_var *trg_new_row_fake_var= (sys_var*) 0x01;
/**
- LEX_STRING constant for null-string to be used in parser and other places.
-*/
-const LEX_STRING null_lex_str= {NULL, 0};
-/**
@note The order of the elements of this array must correspond to
the order of elements in enum_binlog_stmt_unsafe.
*/
@@ -131,6 +127,86 @@ void lex_free(void)
DBUG_VOID_RETURN;
}
+/**
+ Initialize lex object for use in fix_fields and parsing.
+
+ SYNOPSIS
+ init_lex_with_single_table()
+ @param thd The thread object
+ @param table The table object
+ @return Operation status
+ @retval TRUE An error occurred, memory allocation error
+ @retval FALSE Ok
+
+ DESCRIPTION
+ This function is used to initialize a lex object on the
+ stack for use by fix_fields and for parsing. In order to
+ work properly it also needs to initialize the
+ Name_resolution_context object of the lexer.
+ Finally it needs to set a couple of variables to ensure
+ proper functioning of fix_fields.
+*/
+
+int
+init_lex_with_single_table(THD *thd, TABLE *table, LEX *lex)
+{
+ TABLE_LIST *table_list;
+ Table_ident *table_ident;
+ SELECT_LEX *select_lex= &lex->select_lex;
+ Name_resolution_context *context= &select_lex->context;
+ /*
+ We will call the parser to create a part_info struct based on the
+ partition string stored in the frm file.
+ We will use a local lex object for this purpose. However we also
+ need to set the Name_resolution_object for this lex object. We
+ do this by using add_table_to_list where we add the table that
+ we're working with to the Name_resolution_context.
+ */
+ thd->lex= lex;
+ lex_start(thd);
+ context->init();
+ if ((!(table_ident= new Table_ident(thd,
+ table->s->table_name,
+ table->s->db, TRUE))) ||
+ (!(table_list= select_lex->add_table_to_list(thd,
+ table_ident,
+ NULL,
+ 0))))
+ return TRUE;
+ context->resolve_in_table_list_only(table_list);
+ lex->use_only_table_context= TRUE;
+ select_lex->cur_pos_in_select_list= UNDEF_POS;
+ table->map= 1; //To ensure correct calculation of const item
+ table->get_fields_in_item_tree= TRUE;
+ table_list->table= table;
+ return FALSE;
+}
+
+/**
+ End use of local lex with single table
+
+ SYNOPSIS
+ end_lex_with_single_table()
+ @param thd The thread object
+ @param table The table object
+ @param old_lex The real lex object connected to THD
+
+ DESCRIPTION
+ This function restores the real lex object after calling
+ init_lex_with_single_table and also restores some table
+ variables temporarily set.
+*/
+
+void
+end_lex_with_single_table(THD *thd, TABLE *table, LEX *old_lex)
+{
+ LEX *lex= thd->lex;
+ table->map= 0;
+ table->get_fields_in_item_tree= FALSE;
+ lex_end(lex);
+ thd->lex= old_lex;
+}
+
void
st_parsing_options::reset()
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index f40797d6829..94d698d4358 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -2719,6 +2719,8 @@ extern void lex_init(void);
extern void lex_free(void);
extern void lex_start(THD *thd);
extern void lex_end(LEX *lex);
+void end_lex_with_single_table(THD *thd, TABLE *table, LEX *old_lex);
+int init_lex_with_single_table(THD *thd, TABLE *table, LEX *lex);
extern int MYSQLlex(void *arg, void *yythd);
extern void trim_whitespace(CHARSET_INFO *cs, LEX_STRING *str);
diff --git a/sql/sql_list.cc b/sql/sql_list.cc
index 31f0ba28b85..a256212471d 100644
--- a/sql/sql_list.cc
+++ b/sql/sql_list.cc
@@ -18,7 +18,6 @@
#pragma implementation // gcc: Class implementation
#endif
-#include "unireg.h"
#include "sql_list.h"
list_node end_of_list;
diff --git a/sql/sql_list.h b/sql/sql_list.h
index 78549b73cef..cf19cf82607 100644
--- a/sql/sql_list.h
+++ b/sql/sql_list.h
@@ -15,17 +15,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#include "my_global.h"
-#include "my_sys.h"
-#include "m_string.h" /* for TRASH */
-
-
#ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */
#endif
-void *sql_alloc(size_t);
-
#include "my_sys.h" /* alloc_root, TRASH, MY_WME,
MY_FAE, MY_ALLOW_ZERO_PTR */
#include "m_string.h" /* bfill */
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 786636addfe..1a4d6d9b38d 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -98,6 +98,7 @@
#include "debug_sync.h"
#include "probes_mysql.h"
#include "set_var.h"
+#include "log_slow.h"
#define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
@@ -538,9 +539,9 @@ static void handle_bootstrap_impl(THD *thd)
}
buff= (char*) thd->net.buff;
res= mysql_file_fgets(buff + length, thd->net.max_packet - length, file);
- if (!res && !feof(file))
+ if (!res && !mysql_file_feof(file))
{
- net_end_statement(thd);
+ thd->protocol->end_statement();
bootstrap_error= 1;
break;
}
@@ -1086,10 +1087,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
char *beginning_of_next_stmt= (char*)
parser_state.m_lip.found_semicolon;
-#ifdef WITH_ARIA_STORAGE_ENGINE
- ha_maria::implicit_commit(thd, FALSE);
-#endif
-
/*
Multiple queries exits, execute them individually
*/
@@ -1182,7 +1179,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
break;
}
packet= arg_end + 1;
- mysql_reset_thd_for_next_command(thd);
+ mysql_reset_thd_for_next_command(thd, opt_userstat_running);
lex_start(thd);
/* Must be before we init the table list. */
if (lower_case_table_names)
@@ -1247,6 +1244,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
uint32 slave_server_id;
status_var_increment(thd->status_var.com_other);
+
thd->enable_slow_log= opt_log_slow_admin_statements;
thd->query_plan_flags|= QPLAN_ADMIN;
if (check_global_access(thd, REPL_SLAVE_ACL))
@@ -1346,9 +1344,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
{
STATUS_VAR *current_global_status_var; // Big; Don't allocate on stack
ulong uptime;
-#if defined(SAFEMALLOC) || !defined(EMBEDDED_LIBRARY)
uint length;
-#endif
ulonglong queries_per_second1000;
char buff[250];
uint buff_len= sizeof(buff);
@@ -1485,6 +1481,8 @@ void log_slow_statement(THD *thd)
{
DBUG_ENTER("log_slow_statement");
+ thd->update_all_stats();
+
/*
The following should never be true with our current code base,
but better to keep this here so we don't accidently try to log a
@@ -1494,7 +1492,6 @@ void log_slow_statement(THD *thd)
DBUG_VOID_RETURN; // Don't set time for sub stmt
/* Follow the slow log filter configuration. */
- DBUG_ASSERT(thd->variables.log_slow_filter != 0);
if (!(thd->variables.log_slow_filter & thd->query_plan_flags))
DBUG_VOID_RETURN;
@@ -2638,7 +2635,6 @@ end_with_restore_list:
}
#endif /* HAVE_REPLICATION */
-#error set QPLAN_ADMIN somehow universally, not per statement
case SQLCOM_RENAME_TABLE:
{
if (execute_rename_table(thd, first_table, all_tables))
@@ -4345,6 +4341,7 @@ create_sp_error:
case SQLCOM_REPAIR:
case SQLCOM_TRUNCATE:
case SQLCOM_ALTER_TABLE:
+ thd->query_plan_flags|= QPLAN_ADMIN;
DBUG_ASSERT(first_table == all_tables && first_table != 0);
/* fall through */
case SQLCOM_SIGNAL:
@@ -4876,6 +4873,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
(db ? db : (thd->db ?
thd->db :
"unknown")));
+ }
DBUG_RETURN(TRUE);
}
diff --git a/sql/sql_parse.h b/sql/sql_parse.h
index ef19df682dc..11177a9bcf7 100644
--- a/sql/sql_parse.h
+++ b/sql/sql_parse.h
@@ -85,7 +85,7 @@ bool alloc_query(THD *thd, const char *packet, uint packet_length);
void mysql_init_select(LEX *lex);
void mysql_parse(THD *thd, char *rawbuf, uint length,
Parser_state *parser_state);
-void mysql_reset_thd_for_next_command(THD *thd);
+void mysql_reset_thd_for_next_command(THD *thd, my_bool calculate_userstat);
bool mysql_new_select(LEX *lex, bool move_down);
void create_select_for_variable(const char *var_name);
void create_table_set_open_action_and_adjust_tables(LEX *lex);
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 9ab4e0c5226..2d15ca24733 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -951,86 +951,11 @@ int check_signed_flag(partition_info *part_info)
return error;
}
-/**
- Initialize lex object for use in fix_fields and parsing.
-
- SYNOPSIS
- init_lex_with_single_table()
- @param thd The thread object
- @param table The table object
- @return Operation status
- @retval TRUE An error occurred, memory allocation error
- @retval FALSE Ok
-
- DESCRIPTION
- This function is used to initialize a lex object on the
- stack for use by fix_fields and for parsing. In order to
- work properly it also needs to initialize the
- Name_resolution_context object of the lexer.
- Finally it needs to set a couple of variables to ensure
- proper functioning of fix_fields.
-*/
-
-static int
-init_lex_with_single_table(THD *thd, TABLE *table, LEX *lex)
-{
- TABLE_LIST *table_list;
- Table_ident *table_ident;
- SELECT_LEX *select_lex= &lex->select_lex;
- Name_resolution_context *context= &select_lex->context;
- /*
- We will call the parser to create a part_info struct based on the
- partition string stored in the frm file.
- We will use a local lex object for this purpose. However we also
- need to set the Name_resolution_object for this lex object. We
- do this by using add_table_to_list where we add the table that
- we're working with to the Name_resolution_context.
- */
- thd->lex= lex;
- lex_start(thd);
- context->init();
- if ((!(table_ident= new Table_ident(thd,
- table->s->table_name,
- table->s->db, TRUE))) ||
- (!(table_list= select_lex->add_table_to_list(thd,
- table_ident,
- NULL,
- 0))))
- return TRUE;
- context->resolve_in_table_list_only(table_list);
- lex->use_only_table_context= TRUE;
- select_lex->cur_pos_in_select_list= UNDEF_POS;
- table->map= 1; //To ensure correct calculation of const item
- table->get_fields_in_item_tree= TRUE;
- table_list->table= table;
- return FALSE;
-}
-
-/**
- End use of local lex with single table
-
- SYNOPSIS
- end_lex_with_single_table()
- @param thd The thread object
- @param table The table object
- @param old_lex The real lex object connected to THD
-
- DESCRIPTION
- This function restores the real lex object after calling
- init_lex_with_single_table and also restores some table
- variables temporarily set.
+/*
+ init_lex_with_single_table and end_lex_with_single_table
+ are now in sql_lex.cc
*/
-static void
-end_lex_with_single_table(THD *thd, TABLE *table, LEX *old_lex)
-{
- LEX *lex= thd->lex;
- table->map= 0;
- table->get_fields_in_item_tree= FALSE;
- lex_end(lex);
- thd->lex= old_lex;
-}
-
/*
The function uses a new feature in fix_fields where the flag
GET_FIXED_FIELDS_FLAG is set for all fields in the item tree.
@@ -2033,7 +1958,7 @@ static int add_int(File fptr, longlong number)
static int add_uint(File fptr, ulonglong number)
{
char buff[32];
- longlong2str(number, buff, 10, 1);
+ longlong2str(number, buff, 10);
return add_string(fptr, buff);
}
diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc
index fee33303a04..795760c855c 100644
--- a/sql/sql_partition_admin.cc
+++ b/sql/sql_partition_admin.cc
@@ -15,7 +15,6 @@
#include "sql_parse.h" // check_one_table_access
#include "sql_table.h" // mysql_alter_table, etc.
-#include "sql_lex.h" // Sql_statement
#include "sql_truncate.h" // mysql_truncate_table,
// Truncate_statement
#include "sql_admin.h" // Analyze/Check/.._table_statement
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index e046a9fc273..066a7512eaf 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -35,8 +35,8 @@
#define REPORT_TO_LOG 1
#define REPORT_TO_USER 2
-extern struct st_mysql_plugin *mysql_optional_plugins[];
-extern struct st_mysql_plugin *mysql_mandatory_plugins[];
+extern struct st_maria_plugin *mysql_optional_plugins[];
+extern struct st_maria_plugin *mysql_mandatory_plugins[];
/**
@note The order of the enumeration is critical.
@@ -53,7 +53,7 @@ static TYPELIB global_plugin_typelib=
char *opt_plugin_load= NULL;
char *opt_plugin_dir_ptr;
char opt_plugin_dir[FN_REFLEN];
-uint plugin_maturity;
+ulong plugin_maturity;
/*
not really needed now, this map will become essential when we add more
@@ -885,7 +885,7 @@ static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref rc)
}
-plugin_ref plugin_lock(THD *thd, plugin_ref *ptr)
+plugin_ref plugin_lock(THD *thd, plugin_ref ptr)
{
LEX *lex= thd ? thd->lex : 0;
plugin_ref rc;
@@ -911,7 +911,7 @@ plugin_ref plugin_lock(THD *thd, plugin_ref *ptr)
DBUG_RETURN(ptr);
#endif
mysql_mutex_lock(&LOCK_plugin);
- rc= my_intern_plugin_lock_ci(lex, *ptr);
+ rc= my_intern_plugin_lock_ci(lex, ptr);
mysql_mutex_unlock(&LOCK_plugin);
DBUG_RETURN(rc);
}
diff --git a/sql/sql_plugin.h b/sql/sql_plugin.h
index 756328579f1..478bc787d40 100644
--- a/sql/sql_plugin.h
+++ b/sql/sql_plugin.h
@@ -54,7 +54,6 @@ enum SHOW_COMP_OPTION { SHOW_OPTION_YES, SHOW_OPTION_NO, SHOW_OPTION_DISABLED};
typedef enum enum_mysql_show_type SHOW_TYPE;
typedef struct st_mysql_show_var SHOW_VAR;
-typedef struct st_mysql_lex_string LEX_STRING;
#define MYSQL_ANY_PLUGIN -1
@@ -133,7 +132,7 @@ extern char *opt_plugin_load;
extern char *opt_plugin_dir_ptr;
extern char opt_plugin_dir[FN_REFLEN];
extern const LEX_STRING plugin_type_names[];
-extern uint plugin_maturity;
+extern ulong plugin_maturity;
extern TYPELIB plugin_maturity_values;
extern const char *plugin_maturity_names[];
@@ -145,7 +144,7 @@ extern bool plugin_is_ready(const LEX_STRING *name, int type);
#define my_plugin_lock_by_name_ci(A,B,C) plugin_lock_by_name(A,B,C)
#define my_plugin_lock(A,B) plugin_lock(A,B)
#define my_plugin_lock_ci(A,B) plugin_lock(A,B)
-extern plugin_ref plugin_lock(THD *thd, plugin_ref ptr CALLER_INFO_PROTO);
+extern plugin_ref plugin_lock(THD *thd, plugin_ref ptr);
extern plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name,
int type);
extern void plugin_unlock(THD *thd, plugin_ref plugin);
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 9cd5d498c14..c57c9dacceb 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1245,8 +1245,8 @@ static bool mysql_test_insert(Prepared_statement *stmt,
if (insert_precheck(thd, table_list))
goto error;
- upgrade_lock_type_for_insert(thd, &table_list->lock_type, duplic,
- values_list.elements > 1);
+ //upgrade_lock_type_for_insert(thd, &table_list->lock_type, duplic,
+ // values_list.elements > 1);
/*
open temporary memory pool for temporary data allocated by derived
tables & preparation procedure
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 7bca41f1265..ee9f1b5066f 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -372,7 +372,7 @@ Increase max_allowed_packet on master";
*/
static ulonglong get_heartbeat_period(THD * thd)
{
- my_bool null_value;
+ bool null_value;
LEX_STRING name= { C_STRING_WITH_LEN("master_heartbeat_period")};
user_var_entry *entry=
(user_var_entry*) my_hash_search(&thd->user_vars, (uchar*) name.str,
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 32387d676c9..171e9a7f7a5 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -49,19 +49,12 @@
#include "filesort.h" // filesort_free_buffers
#include "sql_union.h" // mysql_union
#include "opt_subselect.h"
+#include "log_slow.h"
#include <m_ctype.h>
#include <my_bit.h>
#include <hash.h>
#include <ft_global.h>
-//#if defined(WITH_ARIA_STORAGE_ENGINE) && defined(USE_MARIA_FOR_TMP_TABLES)
-//#include "../storage/maria/ha_maria.h"
-//#define TMP_ENGINE_HTON maria_hton
-//#else
-//#define TMP_ENGINE_HTON myisam_hton
-//#endif
-
-#define PREV_BITS(type,A) ((type) (((type) 1 << (A)) -1))
const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref",
"MAYBE_REF","ALL","range","index","fulltext",
@@ -83,7 +76,6 @@ static bool update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,
static int sort_keyuse(KEYUSE *a,KEYUSE *b);
static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
table_map used_tables);
-bool choose_plan(JOIN *join,table_map join_tables);
void best_access_path(JOIN *join, JOIN_TAB *s,
table_map remaining_tables, uint idx,
@@ -149,30 +141,24 @@ static COND *optimize_cond(JOIN *join, COND *conds,
List<TABLE_LIST> *join_list,
Item::cond_result *cond_value,
COND_EQUAL **cond_equal);
-static bool const_expression_in_where(COND *conds,Item *item, Item **comp_item);
+bool const_expression_in_where(COND *conds,Item *item, Item **comp_item);
static bool create_internal_tmp_table_from_heap2(THD *, TABLE *,
ENGINE_COLUMNDEF *, ENGINE_COLUMNDEF **,
int, bool, handlerton *, const char *);
static int do_select(JOIN *join,List<Item> *fields,TABLE *tmp_table,
Procedure *proc);
-static enum_nested_loop_state
-evaluate_join_record(JOIN *join, JOIN_TAB *join_tab,
- int error);
+static enum_nested_loop_state evaluate_join_record(JOIN *, JOIN_TAB *, int);
static enum_nested_loop_state
evaluate_null_complemented_join_record(JOIN *join, JOIN_TAB *join_tab);
static enum_nested_loop_state
end_send(JOIN *join, JOIN_TAB *join_tab, bool end_of_records);
-enum_nested_loop_state
-end_send_group(JOIN *join, JOIN_TAB *join_tab, bool end_of_records);
static enum_nested_loop_state
end_write(JOIN *join, JOIN_TAB *join_tab, bool end_of_records);
static enum_nested_loop_state
end_update(JOIN *join, JOIN_TAB *join_tab, bool end_of_records);
static enum_nested_loop_state
end_unique_update(JOIN *join, JOIN_TAB *join_tab, bool end_of_records);
-enum_nested_loop_state
-end_write_group(JOIN *join, JOIN_TAB *join_tab, bool end_of_records);
static int test_if_group_changed(List<Cached_item> &list);
static int join_read_const_table(JOIN_TAB *tab, POSITION *pos);
@@ -770,6 +756,7 @@ err:
int
JOIN::optimize()
{
+ bool need_distinct= TRUE;
ulonglong select_opts_for_readinfo;
uint no_jbuf_after;
@@ -1084,6 +1071,9 @@ JOIN::optimize()
conds=new Item_int((longlong) 0,1); // Always false
}
+ /* Cache constant expressions in WHERE, HAVING, ON clauses. */
+ cache_const_exprs();
+
if (make_join_select(this, select, conds))
{
zero_result_cause=
@@ -1437,7 +1427,6 @@ JOIN::optimize()
single table queries, thus it is sufficient to test only the first
join_tab element of the plan for its access method.
*/
- bool need_distinct= TRUE;
if (join_tab->is_using_loose_index_scan())
{
tmp_table_param.precomputed_group_by= TRUE;
@@ -2821,6 +2810,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables_arg, COND *conds,
if (bitmap_is_set(stat[j].dependent, i) &&
bitmap_is_set(stat[i].dependent, k))
bitmap_set_bit(stat[j].dependent, k);
+ }
}
}
*/
@@ -9253,8 +9243,7 @@ static COND *build_equal_items_for_cond(THD *thd, COND *cond,
pointer to the transformed condition containing multiple equalities
*/
-static COND *build_equal_items(THD *thd, COND *cond,
- COND_EQUAL *inherited,
+static COND *build_equal_items(THD *thd, COND *cond, COND_EQUAL *inherited,
List<TABLE_LIST> *join_list,
COND_EQUAL **cond_equal_ref)
{
@@ -12265,7 +12254,7 @@ bool open_tmp_table(TABLE *table)
}
-#if defined(WITH_ARIA_STORAGE_ENGINE) && defined(USE_MARIA_FOR_TMP_TABLES)
+#if defined(WITH_ARIA_STORAGE_ENGINE) && defined(USE_ARIA_FOR_TMP_TABLES)
/*
Create internal (MyISAM or Maria) temporary table
@@ -19060,7 +19049,7 @@ static void print_join(THD *thd,
*/
if ((*table)->sj_inner_tables)
{
- TABLE_LIST **end= table + tables->elements;
+ TABLE_LIST **end= table + non_const_tables;
for (TABLE_LIST **t2= table; t2!=end; t2++)
{
if (!(*t2)->sj_inner_tables)
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 1c24ed37581..8d487021a04 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -16,9 +16,6 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-#ifndef SQL_SELECT_INCLUDED
-#define SQL_SELECT_INCLUDED
/**
@file
@@ -37,8 +34,10 @@
#include "opt_range.h" /* SQL_SELECT, QUICK_SELECT_I */
-#if defined(WITH_ARIA_STORAGE_ENGINE) && defined(USE_MARIA_FOR_TMP_TABLES)
+#if defined(WITH_ARIA_STORAGE_ENGINE)
#include "../storage/maria/ha_maria.h"
+#endif
+#if defined(USE_ARIA_FOR_TMP_TABLES)
#define TMP_ENGINE_HTON maria_hton
#else
#define TMP_ENGINE_HTON myisam_hton
@@ -779,7 +778,7 @@ public:
void reset_join(JOIN *j) { join= j; }
void free()
{
- x_free(buff);
+ my_free(buff);
buff= 0;
}
@@ -2065,7 +2064,7 @@ void push_index_cond(JOIN_TAB *tab, uint keyno, bool other_tbls_ok);
TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
ORDER *group, bool distinct, bool save_sum_fields,
ulonglong select_options, ha_rows rows_limit,
- char* alias);
+ const char* alias);
void free_tmp_table(THD *thd, TABLE *entry);
bool create_internal_tmp_table_from_heap(THD *thd, TABLE *table,
ENGINE_COLUMNDEF *start_recinfo,
@@ -2074,7 +2073,7 @@ bool create_internal_tmp_table_from_heap(THD *thd, TABLE *table,
bool create_internal_tmp_table(TABLE *table, KEY *keyinfo,
ENGINE_COLUMNDEF *start_recinfo,
ENGINE_COLUMNDEF **recinfo,
- ulonglong options);
+ ulonglong options, my_bool big_tables);
bool open_tmp_table(TABLE *table);
void setup_tmp_table_column_bitmaps(TABLE *table, uchar *bitmaps);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index c7cdab06d7b..ea17cd73e1c 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -41,6 +41,7 @@
#include "sp_pcontext.h"
#include "set_var.h"
#include "sql_trigger.h"
+#include "sql_connect.h"
#include "authors.h"
#include "contributors.h"
#include "sql_partition.h"
@@ -52,6 +53,7 @@
#include "lock.h" // MYSQL_OPEN_IGNORE_FLUSH
#include "debug_sync.h"
#include "datadict.h" // dd_frm_type()
+#include "keycaches.h"
#define STR_OR_NIL(S) ((S) ? (S) : "<nil>")
@@ -1110,7 +1112,7 @@ static bool get_field_default_value(THD *thd, Field *timestamp_field,
if (field_type == MYSQL_TYPE_BIT)
{
longlong dec= field->val_int();
- char *ptr= longlong2str(dec, tmp + 2, 2, 1);
+ char *ptr= longlong2str(dec, tmp + 2, 2);
uint32 length= (uint32) (ptr - tmp);
tmp[0]= 'b';
tmp[1]= '\'';
@@ -2380,7 +2382,6 @@ static bool show_status_array(THD *thd, const char *wild,
DBUG_ASSERT(0);
break;
}
- pthread_mutex_unlock(&LOCK_global_system_variables);
table->field[1]->store(pos, (uint32) (end - pos), charset);
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
table->field[1]->set_notnull();
@@ -2400,7 +2401,7 @@ end:
DBUG_RETURN(res);
}
-#ifdef COMPLEAT_PATCH_NOT_ADDED_YET
+#ifdef COMPLETE_PATCH_NOT_ADDED_YET
/*
Aggregate values for mapped_user entries by their role.
@@ -2417,10 +2418,10 @@ end:
static int aggregate_user_stats(HASH *all_user_stats, HASH *agg_user_stats)
{
DBUG_ENTER("aggregate_user_stats");
- if (hash_init(agg_user_stats, system_charset_info,
+ if (my_hash_init(agg_user_stats, system_charset_info,
max(all_user_stats->records, 1),
- 0, 0, (hash_get_key)get_key_user_stats,
- (hash_free_key)free_user_stats, 0))
+ 0, 0, (my_hash_get_key)get_key_user_stats,
+ (my_hash_free_key)free_user_stats, 0))
{
sql_print_error("Malloc in aggregate_user_stats failed");
DBUG_RETURN(1);
@@ -2428,11 +2429,11 @@ static int aggregate_user_stats(HASH *all_user_stats, HASH *agg_user_stats)
for (uint i= 0; i < all_user_stats->records; i++)
{
- USER_STATS *user= (USER_STATS*)hash_element(all_user_stats, i);
+ USER_STATS *user= (USER_STATS*)my_hash_element(all_user_stats, i);
USER_STATS *agg_user;
uint name_length= strlen(user->priv_user);
- if (!(agg_user= (USER_STATS*) hash_search(agg_user_stats,
+ if (!(agg_user= (USER_STATS*) my_hash_search(agg_user_stats,
(uchar*)user->priv_user,
name_length)))
{
@@ -2511,7 +2512,7 @@ int send_user_stats(THD* thd, HASH *all_user_stats, TABLE *table)
for (uint i= 0; i < all_user_stats->records; i++)
{
uint j= 0;
- USER_STATS *user_stats= (USER_STATS*) hash_element(all_user_stats, i);
+ USER_STATS *user_stats= (USER_STATS*) my_hash_element(all_user_stats, i);
table->field[j++]->store(user_stats->user, user_stats->user_name_length,
system_charset_info);
@@ -2574,9 +2575,9 @@ int fill_schema_user_stats(THD* thd, TABLE_LIST* tables, COND* cond)
Pattern matching on the client IP is supported.
*/
- pthread_mutex_lock(&LOCK_global_user_client_stats);
+ mysql_mutex_lock(&LOCK_global_user_client_stats);
result= send_user_stats(thd, &global_user_stats, table) != 0;
- pthread_mutex_unlock(&LOCK_global_user_client_stats);
+ mysql_mutex_unlock(&LOCK_global_user_client_stats);
DBUG_PRINT("exit", ("result: %d", result));
DBUG_RETURN(result);
@@ -2609,9 +2610,9 @@ int fill_schema_client_stats(THD* thd, TABLE_LIST* tables, COND* cond)
Pattern matching on the client IP is supported.
*/
- pthread_mutex_lock(&LOCK_global_user_client_stats);
+ mysql_mutex_lock(&LOCK_global_user_client_stats);
result= send_user_stats(thd, &global_client_stats, table) != 0;
- pthread_mutex_unlock(&LOCK_global_user_client_stats);
+ mysql_mutex_unlock(&LOCK_global_user_client_stats);
DBUG_PRINT("exit", ("result: %d", result));
DBUG_RETURN(result);
@@ -2625,12 +2626,12 @@ int fill_schema_table_stats(THD *thd, TABLE_LIST *tables, COND *cond)
TABLE *table= tables->table;
DBUG_ENTER("fill_schema_table_stats");
- pthread_mutex_lock(&LOCK_global_table_stats);
+ mysql_mutex_lock(&LOCK_global_table_stats);
for (uint i= 0; i < global_table_stats.records; i++)
{
char *end_of_schema;
TABLE_STATS *table_stats=
- (TABLE_STATS*)hash_element(&global_table_stats, i);
+ (TABLE_STATS*)my_hash_element(&global_table_stats, i);
TABLE_LIST tmp_table;
size_t schema_length, table_name_length;
@@ -2642,9 +2643,8 @@ int fill_schema_table_stats(THD *thd, TABLE_LIST *tables, COND *cond)
tmp_table.db= table_stats->table;
tmp_table.table_name= end_of_schema+1;
tmp_table.grant.privilege= 0;
- if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
- &tmp_table.grant.privilege, 0, 0,
- is_schema_db(tmp_table.db)) ||
+ if (check_access(thd, SELECT_ACL, tmp_table.db,
+ &tmp_table.grant.privilege, NULL, 0, 1) ||
check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX,
1))
continue;
@@ -2659,11 +2659,11 @@ int fill_schema_table_stats(THD *thd, TABLE_LIST *tables, COND *cond)
TRUE);
if (schema_table_store_record(thd, table))
{
- VOID(pthread_mutex_unlock(&LOCK_global_table_stats));
+ mysql_mutex_unlock(&LOCK_global_table_stats);
DBUG_RETURN(1);
}
}
- pthread_mutex_unlock(&LOCK_global_table_stats);
+ mysql_mutex_unlock(&LOCK_global_table_stats);
DBUG_RETURN(0);
}
@@ -2675,11 +2675,11 @@ int fill_schema_index_stats(THD *thd, TABLE_LIST *tables, COND *cond)
TABLE *table= tables->table;
DBUG_ENTER("fill_schema_index_stats");
- pthread_mutex_lock(&LOCK_global_index_stats);
+ mysql_mutex_lock(&LOCK_global_index_stats);
for (uint i= 0; i < global_index_stats.records; i++)
{
INDEX_STATS *index_stats =
- (INDEX_STATS*) hash_element(&global_index_stats, i);
+ (INDEX_STATS*) my_hash_element(&global_index_stats, i);
TABLE_LIST tmp_table;
char *index_name;
size_t schema_name_length, table_name_length, index_name_length;
@@ -2688,9 +2688,8 @@ int fill_schema_index_stats(THD *thd, TABLE_LIST *tables, COND *cond)
tmp_table.db= index_stats->index;
tmp_table.table_name= strend(index_stats->index)+1;
tmp_table.grant.privilege= 0;
- if (check_access(thd, SELECT_ACL | EXTRA_ACL, tmp_table.db,
- &tmp_table.grant.privilege, 0, 0,
- is_schema_db(tmp_table.db)) ||
+ if (check_access(thd, SELECT_ACL, tmp_table.db,
+ &tmp_table.grant.privilege, NULL, 0, 1) ||
check_grant(thd, SELECT_ACL, &tmp_table, 1, UINT_MAX, 1))
continue;
@@ -2709,11 +2708,11 @@ int fill_schema_index_stats(THD *thd, TABLE_LIST *tables, COND *cond)
if (schema_table_store_record(thd, table))
{
- VOID(pthread_mutex_unlock(&LOCK_global_index_stats));
+ mysql_mutex_unlock(&LOCK_global_index_stats);
DBUG_RETURN(1);
}
}
- pthread_mutex_unlock(&LOCK_global_index_stats);
+ mysql_mutex_unlock(&LOCK_global_index_stats);
DBUG_RETURN(0);
}
@@ -4114,8 +4113,8 @@ int fill_schema_schemata(THD *thd, TABLE_LIST *tables, COND *cond)
if (get_lookup_field_values(thd, cond, tables, &lookup_field_vals))
DBUG_RETURN(0);
DBUG_PRINT("INDEX VALUES",("db_name: %s table_name: %s",
- val_or_null(lookup_field_vals.db_value.str),
- val_or_null(lookup_field_vals.table_value.str)));
+ lookup_field_vals.db_value.str,
+ lookup_field_vals.table_value.str));
if (make_db_list(thd, &db_names, &lookup_field_vals,
&with_i_schema))
DBUG_RETURN(1);
@@ -7256,43 +7255,44 @@ int store_key_cache_table_record(THD *thd, TABLE *table,
DBUG_RETURN(err);
}
-
-int fill_key_cache_tables(THD *thd, TABLE_LIST *tables, COND *cond)
+int run_fill_key_cache_tables(const char *name, KEY_CACHE *key_cache, void *p)
{
- TABLE *table= tables->table;
- I_List_iterator<NAMED_LIST> it(key_caches);
- NAMED_LIST *element;
- DBUG_ENTER("fill_key_cache_tables");
-
- while ((element= it++))
- {
- KEY_CACHE *key_cache= (KEY_CACHE *) element->data;
+ DBUG_ENTER("run_fill_key_cache_tables");
- if (!key_cache->key_cache_inited)
- continue;
+ if (!key_cache->key_cache_inited)
+ DBUG_RETURN(0);
- uint partitions= key_cache->partitions;
- DBUG_ASSERT(partitions <= MAX_KEY_CACHE_PARTITIONS);
+ TABLE *table= (TABLE *)p;
+ THD *thd= table->in_use;
+ uint partitions= key_cache->partitions;
+ size_t namelen= strlen(name);
+ DBUG_ASSERT(partitions <= MAX_KEY_CACHE_PARTITIONS);
- if (partitions)
+ if (partitions)
+ {
+ for (uint i= 0; i < partitions; i++)
{
- for (uint i= 0; i < partitions; i++)
- {
- if (store_key_cache_table_record(thd, table,
- element->name, element->name_length,
- key_cache, partitions, i+1))
- DBUG_RETURN(1);
- }
+ if (store_key_cache_table_record(thd, table, name, namelen,
+ key_cache, partitions, i+1))
+ DBUG_RETURN(1);
}
-
- if (store_key_cache_table_record(thd, table,
- element->name, element->name_length,
- key_cache, partitions, 0))
- DBUG_RETURN(1);
}
+
+ if (store_key_cache_table_record(thd, table, name, namelen,
+ key_cache, partitions, 0))
+ DBUG_RETURN(1);
DBUG_RETURN(0);
}
+int fill_key_cache_tables(THD *thd, TABLE_LIST *tables, COND *cond)
+{
+ DBUG_ENTER("fill_key_cache_tables");
+
+ int res= process_key_caches(run_fill_key_cache_tables, tables->table);
+
+ DBUG_RETURN(res);
+}
+
ST_FIELD_INFO schema_fields_info[]=
{
diff --git a/sql/sql_sort.h b/sql/sql_sort.h
index 6c185b4a61d..98a45f14a36 100644
--- a/sql/sql_sort.h
+++ b/sql/sql_sort.h
@@ -19,9 +19,9 @@
#include "my_global.h" /* uchar */
#include "my_base.h" /* ha_rows */
#include "my_sys.h" /* qsort2_cmp */
+#include "queues.h"
typedef struct st_buffpek BUFFPEK;
-typedef struct st_queue QUEUE;
typedef struct st_sort_field SORT_FIELD;
class Field;
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 058af3c6826..c5544164dbf 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -916,64 +916,6 @@ my_copy_with_hex_escaping(CHARSET_INFO *cs,
return dst - dst0;
}
-/*
- Optimized for quick copying of ASCII characters in the range 0x00..0x7F.
-*/
-uint32
-copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
- const char *from, uint32 from_length, CHARSET_INFO *from_cs,
- uint *errors)
-{
- /*
- If any of the character sets is not ASCII compatible,
- immediately switch to slow mb_wc->wc_mb method.
- */
- if ((to_cs->state | from_cs->state) & MY_CS_NONASCII)
- return copy_and_convert_extended(to, to_length, to_cs,
- from, from_length, from_cs, errors);
-
- uint32 length= min(to_length, from_length), length2= length;
-
-#if defined(__i386__)
- /*
- Special loop for i386, it allows to refer to a
- non-aligned memory block as UINT32, which makes
- it possible to copy four bytes at once. This
- gives about 10% performance improvement comparing
- to byte-by-byte loop.
- */
- for ( ; length >= 4; length-= 4, from+= 4, to+= 4)
- {
- if ((*(uint32*)from) & 0x80808080)
- break;
- *((uint32*) to)= *((const uint32*) from);
- }
-#endif
-
- for (; ; *to++= *from++, length--)
- {
- if (!length)
- {
- *errors= 0;
- return length2;
- }
- if (*((unsigned char*) from) > 0x7F) /* A non-ASCII character */
- {
- uint32 copied_length= length2 - length;
- to_length-= copied_length;
- from_length-= copied_length;
- return copied_length + copy_and_convert_extended(to, to_length,
- to_cs,
- from, from_length,
- from_cs,
- errors);
- }
- }
-
- DBUG_ASSERT(FALSE); // Should never get to here
- return 0; // Make compiler happy
-}
-
/*
copy a string,
diff --git a/sql/sql_string.h b/sql/sql_string.h
index 880edce0e77..c25a9cd8214 100644
--- a/sql/sql_string.h
+++ b/sql/sql_string.h
@@ -31,7 +31,6 @@
#endif
class String;
-typedef struct charset_info_st CHARSET_INFO;
typedef struct st_io_cache IO_CACHE;
typedef struct st_mem_root MEM_ROOT;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 98b3e4ebaf2..1a7162313f5 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -4142,7 +4142,7 @@ bool mysql_create_table_no_lock(THD *thd,
/* Give warnings for not supported table options */
if (create_info->transactional && !file->ht->commit)
- push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
ER(ER_ILLEGAL_HA_CREATE_OPTION),
file->engine_name()->str,
@@ -5729,8 +5729,9 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
uint candidate_key_count= 0;
bool no_pk;
ulong explicit_used_fields= 0;
- enum ha_extra_function extra_func= thd->locked_tables ? HA_EXTRA_NOT_USED
- : HA_EXTRA_FORCE_REOPEN;
+ enum ha_extra_function extra_func= thd->locked_tables_mode
+ ? HA_EXTRA_NOT_USED
+ : HA_EXTRA_FORCE_REOPEN;
DBUG_ENTER("mysql_alter_table");
/*
@@ -6509,8 +6510,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
/* Add the indexes. */
if ((error= table->file->add_index(table, key_info, index_add_count)))
{
-#warning fix the following
-#ifdef UNKNOWN_MONTY_ADDITION
+#ifdef MERGE_MONTY_ADDITION_THAT_BREAKS_5_5_TESTS
/* Only report error if handler has not already reported an error */
if (!thd->main_da.is_error())
#endif
@@ -7199,10 +7199,8 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
{
/* Call ->checksum() if the table checksum matches 'old_mode' settings */
if (!(check_opt->flags & T_EXTEND) &&
- (((t->file->ha_table_flags() & HA_HAS_OLD_CHECKSUM) &&
- thd->variables.old_mode) ||
- ((t->file->ha_table_flags() & HA_HAS_NEW_CHECKSUM) &&
- !thd->variables.old_mode)))
+ (((t->file->ha_table_flags() & HA_HAS_OLD_CHECKSUM) && old_mode) ||
+ ((t->file->ha_table_flags() & HA_HAS_NEW_CHECKSUM) && !old_mode)))
protocol->store((ulonglong)t->file->checksum());
else if (check_opt->flags & T_QUICK)
protocol->store_null();
@@ -7252,8 +7250,7 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables,
{
Field *f= t->field[i];
- if (! thd->variables.old_mode &&
- f->is_real_null(0))
+ if (! old_mode && f->is_real_null(0))
continue;
/*
BLOB and VARCHAR have pointers in their field, we must convert
diff --git a/sql/sql_table.h b/sql/sql_table.h
index bc32235aaff..a2df9ee7572 100644
--- a/sql/sql_table.h
+++ b/sql/sql_table.h
@@ -30,7 +30,6 @@ typedef struct st_ha_create_information HA_CREATE_INFO;
typedef struct st_key KEY;
typedef struct st_key_cache KEY_CACHE;
typedef struct st_lock_param_type ALTER_PARTITION_PARAM_TYPE;
-typedef struct st_mysql_lex_string LEX_STRING;
typedef struct st_order ORDER;
class Alter_table_change_level;
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 9dda1113294..d567624ba44 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -253,7 +253,7 @@ void print_keyuse(KEYUSE *keyuse)
fieldname= "FT_KEYPART";
else
fieldname= keyuse->table->key_info[keyuse->key].key_part[keyuse->keypart].field->field_name;
- longlong2str(keyuse->used_tables, buf2, 16, 0);
+ ll2str(keyuse->used_tables, buf2, 16, 0);
DBUG_LOCK_FILE;
fprintf(DBUG_FILE, "KEYUSE: %s.%s=%s optimize= %d used_tables=%s "
"ref_table_rows= %lu keypart_map= %0lx\n",
@@ -399,11 +399,6 @@ void print_sjm(SJ_MATERIALIZATION_INFO *sjm)
#endif
-C_MODE_START
-static int dl_compare(const void *p1, const void *p2);
-static int print_key_cache_status(const char *name, KEY_CACHE *key_cache);
-C_MODE_END
-
typedef struct st_debug_lock
{
ulong thread_id;
@@ -413,6 +408,7 @@ typedef struct st_debug_lock
enum thr_lock_type type;
} TABLE_LOCK_INFO;
+C_MODE_START
static int dl_compare(const void *p1, const void *p2)
{
TABLE_LOCK_INFO *a, *b;
@@ -430,6 +426,7 @@ static int dl_compare(const void *p1, const void *p2)
return -1;
return 1;
}
+C_MODE_END
static void push_locks_into_array(DYNAMIC_ARRAY *ar, THR_LOCK_DATA *data,
@@ -516,8 +513,9 @@ end:
delete_dynamic(&saved_table_locks);
}
-
-static int print_key_cache_status(const char *name, KEY_CACHE *key_cache)
+C_MODE_START
+static int print_key_cache_status(const char *name, KEY_CACHE *key_cache,
+ void *unused __attribute__((unused)))
{
char llbuff1[22];
char llbuff2[22];
@@ -550,7 +548,7 @@ reads: %10s\n\n",
(ulong)key_cache->param_block_size,
(ulong)key_cache->param_division_limit,
(ulong)key_cache->param_age_threshold,
- key_cache->param_partitions,
+ (ulong)key_cache->param_partitions,
(ulong)stats.blocks_used,
(ulong)stats.blocks_changed,
llstr(stats.write_requests,llbuff1),
@@ -560,6 +558,7 @@ reads: %10s\n\n",
}
return 0;
}
+C_MODE_END
void mysql_print_status()
@@ -579,7 +578,7 @@ void mysql_print_status()
#endif
/* Print key cache status */
puts("\nKey caches:");
- process_key_caches(print_key_cache_status);
+ process_key_caches(print_key_cache_status, 0);
mysql_mutex_lock(&LOCK_status);
printf("\nhandler status:\n\
read_key: %10lu\n\
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 5c158bae398..26bc59a5886 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -527,7 +527,8 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
Ignore the return value for now. It's better to
keep master/slave in consistent state.
*/
- thd->locked_tables_list.reopen_tables(thd);
+ if (thd->locked_tables_list.reopen_tables(thd))
+ thd->clear_error();
end:
if (!result)
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 608a105efaa..9f34180662c 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -12872,7 +12872,6 @@ keyword_sp:
| SIMPLE_SYM {}
| SHARE_SYM {}
| SHUTDOWN {}
- | SLOW_SYM {}
| SNAPSHOT_SYM {}
| SOUNDS_SYM {}
| SOURCE_SYM {}
@@ -13419,6 +13418,8 @@ table_lock:
bool lock_for_write= (lock_type >= TL_WRITE_ALLOW_WRITE);
if (!Select->add_table_to_list(YYTHD, $1, $2, 0, lock_type,
(lock_for_write ?
+ lock_type == TL_WRITE_CONCURRENT_INSERT ?
+ MDL_SHARED_WRITE :
MDL_SHARED_NO_READ_WRITE :
MDL_SHARED_READ)))
MYSQL_YYABORT;
diff --git a/sql/strfunc.h b/sql/strfunc.h
index f1eb83ff0de..6aa446e59ac 100644
--- a/sql/strfunc.h
+++ b/sql/strfunc.h
@@ -18,8 +18,6 @@
#include "my_global.h" /* ulonglong, uint */
-typedef struct charset_info_st CHARSET_INFO;
-typedef struct st_mysql_lex_string LEX_STRING;
typedef struct st_typelib TYPELIB;
ulonglong find_set(TYPELIB *lib, const char *x, uint length, CHARSET_INFO *cs,
diff --git a/sql/structs.h b/sql/structs.h
index 327b28fe79c..fb2f2f6fec8 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -25,6 +25,7 @@
#include "my_time.h" /* enum_mysql_timestamp_type */
#include "thr_lock.h" /* thr_lock_type */
#include "my_base.h" /* ha_rows, ha_key_alg */
+#include <mysql_com.h> /* USERNAME_LENGTH */
struct TABLE;
class Field;
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index c4f9e131e58..56440368acf 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -44,20 +44,14 @@
// mysql_user_table_is_in_short_password_format
#include "derror.h" // read_texts
#include "sql_base.h" // close_cached_tables
+#include <myisam.h>
+#include "log_slow.h"
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
#include "../storage/perfschema/pfs_server.h"
#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
/*
- This forward declaration is needed because including sql_base.h
- causes further includes. [TODO] Eliminate this forward declaration
- and include a file with the prototype instead.
-*/
-extern void close_thread_tables(THD *thd);
-#warning remove that
-
-/*
The rule for this file: everything should be 'static'. When a sys_var
variable or a function from this file is - in very rare cases - needed
elsewhere it should be explicitly declared 'export' here to show that it's
@@ -70,7 +64,6 @@ extern void close_thread_tables(THD *thd);
#define PFS_TRAILING_PROPERTIES \
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL), ON_UPDATE(NULL), \
0, NULL, sys_var::PARSE_EARLY
-#warning move PARSE_EARLY where it belongs
static Sys_var_mybool Sys_pfs_enabled(
"performance_schema",
@@ -399,7 +392,7 @@ static bool check_charset(sys_var *self, THD *thd, set_var *var)
else if (!(var->save_result.ptr= get_charset_by_csname(res->c_ptr(),
MY_CS_PRIMARY,
MYF(0))) &&
- !(var->save_result.ptr= get_old_charset_by_name(res->c_ptr())))
+ !(var->save_result.ptr=get_old_charset_by_name(res->c_ptr())))
{
ErrConvString err(res);
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), err.ptr());
@@ -1685,7 +1678,7 @@ static Sys_var_ulong Sys_trans_prealloc_size(
static const char *thread_handling_names[]=
{
"one-thread-per-connection", "no-threads",
-#if HAVE_POOL_OF_THREADS == 1
+#ifdef HAVE_POOL_OF_THREADS
"pool-of-threads",
#endif
0
@@ -1693,9 +1686,9 @@ static const char *thread_handling_names[]=
static Sys_var_enum Sys_thread_handling(
"thread_handling",
"Define threads usage for handling queries, one of "
- "one-thread-per-connection, no-threads, "
-#if HAVE_POOL_OF_THREADS == 1
- "pool-of-threads"
+ "one-thread-per-connection, no-threads"
+#ifdef HAVE_POOL_OF_THREADS
+ ", pool-of-threads"
#endif
, READ_ONLY GLOBAL_VAR(thread_handling), CMD_LINE(REQUIRED_ARG),
thread_handling_names, DEFAULT(0));
@@ -2024,7 +2017,7 @@ static Sys_var_ulong Sys_thread_cache_size(
GLOBAL_VAR(thread_cache_size), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, 16384), DEFAULT(0), BLOCK_SIZE(1));
-#if HAVE_POOL_OF_THREADS == 1
+#ifdef HAVE_POOL_OF_THREADS
static Sys_var_ulong Sys_thread_pool_size(
"thread_pool_size",
"How many threads we should create to handle query requests in "
@@ -3125,13 +3118,13 @@ static Sys_var_tz Sys_time_zone(
SESSION_VAR(time_zone), NO_CMD_LINE,
DEFAULT(&default_tz), NO_MUTEX_GUARD, IN_BINLOG);
-const char *plugin_maturity_names[]=
+export const char *plugin_maturity_names[]=
{ "unknown", "experimental", "alpha", "beta", "gamma", "stable", 0 };
static Sys_var_enum Sys_plugin_maturity(
"plugin_maturity",
"The lowest desirable plugin maturity. Plugins less mature than "
"that will not be installed or loaded.",
- READ_ONLY GLOBAL_VAR(server_maturity), CMD_LINE(REQUIRED_ARG),
+ READ_ONLY GLOBAL_VAR(plugin_maturity), CMD_LINE(REQUIRED_ARG),
plugin_maturity_names, DEFAULT(MariaDB_PLUGIN_MATURITY_UNKNOWN));
static Sys_var_ulong Sys_deadlock_search_depth_short(
@@ -3172,7 +3165,6 @@ static Sys_var_uint Sys_extra_port(
"one-thread-per-connection manner. 0 means don't use another port",
READ_ONLY GLOBAL_VAR(mysqld_extra_port), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, UINT_MAX32), DEFAULT(0), BLOCK_SIZE(1));
-#warning generalize that
static Sys_var_ulong Sys_extra_max_connections(
"extra_max_connections", "The number of connections on extra-port",
@@ -3207,8 +3199,8 @@ static Sys_var_set Sys_log_slow_filter(
"slave, filesort, filesort_on_disk, full_join, full_scan, query_cache, "
"query_cache_miss, tmp_table, tmp_table_on_disk",
SESSION_VAR(log_slow_filter), CMD_LINE(REQUIRED_ARG),
- log_slow_filter_names, DEFAULT(QPLAN_ALWAYS_SET));
-#warning fix log-slow-slave-statements and log-slow-admin-statements
+ log_slow_filter_names,
+ DEFAULT(MAX_SET(array_elements(log_slow_filter_names)-1)));
static Sys_var_ulong Sys_log_slow_rate_limit(
"log_slow_rate_limit",
@@ -3222,7 +3214,7 @@ static const char *log_slow_verbosity_names[]= { "innodb", "query_plan", 0 };
static Sys_var_set Sys_log_slow_verbosity(
"log_slow_verbosity",
"log-slow-verbosity=[value[,value ...]] where value is one of "
- "'innodb', 'query_plan'"
+ "'innodb', 'query_plan'",
SESSION_VAR(log_slow_verbosity), CMD_LINE(REQUIRED_ARG),
log_slow_verbosity_names, DEFAULT(LOG_SLOW_VERBOSITY_INIT));
@@ -3234,6 +3226,15 @@ static Sys_var_ulong Sys_join_cache_level(
SESSION_VAR(join_cache_level), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, 8), DEFAULT(1), BLOCK_SIZE(1));
+static const char *optimizer_use_mrr_names[]= {"auto", "force", "disable", 0};
+static Sys_var_enum Sys_optimizer_use_mrr(
+ "optimizer_use_mrr", "Whether the server should use "
+ "multi-read-range optimization when resolving queries, "
+ "one of AUTO (as appropriate), FORCE (always where applicable), "
+ "DISABLE (never)",
+ SESSION_VAR(optimizer_use_mrr), CMD_LINE(REQUIRED_ARG),
+ optimizer_use_mrr_names, DEFAULT(1));
+
static Sys_var_ulong Sys_mrr_buffer_size(
"mrr_buffer_size",
"Size of buffer to use when using MRR with range access",
@@ -3249,7 +3250,7 @@ static Sys_var_ulong Sys_rowid_merge_buff_size(
"rowid_merge_buff_size",
"The size of the buffers used [NOT] IN evaluation via partial matching",
SESSION_VAR(rowid_merge_buff_size), CMD_LINE(REQUIRED_ARG),
- VALID_RANGE(0, MAX_MEM_TABLE_SIZE/2), DEFAULT(8*1024*1024),
+ VALID_RANGE(0, ((ulonglong)~(intptr)0)/2), DEFAULT(8*1024*1024),
BLOCK_SIZE(1));
static Sys_var_mybool Sys_userstat(
@@ -3257,4 +3258,4 @@ static Sys_var_mybool Sys_userstat(
"Enables statistics gathering for USER_STATISTICS, CLIENT_STATISTICS, "
"INDEX_STATISTICS and TABLE_STATISTICS tables in the INFORMATION_SCHEMA",
GLOBAL_VAR(opt_userstat_running),
- CMD_LINE(OPT_ARG), DEFAULT(TRUE));
+ CMD_LINE(OPT_ARG), DEFAULT(FALSE));
diff --git a/sql/sys_vars.h b/sql/sys_vars.h
index e0769836e61..25ad412e62c 100644
--- a/sql/sys_vars.h
+++ b/sql/sys_vars.h
@@ -693,7 +693,7 @@ static bool update_buffer_size(THD *thd, KEY_CACHE *key_cache,
mysql_mutex_unlock(&LOCK_global_system_variables);
if (!key_cache->key_cache_inited)
- error= ha_init_key_cache(0, key_cache);
+ error= ha_init_key_cache(0, key_cache, 0);
else
error= ha_resize_key_cache(key_cache);
@@ -705,7 +705,7 @@ static bool update_buffer_size(THD *thd, KEY_CACHE *key_cache,
static bool update_keycache(THD *thd, KEY_CACHE *key_cache,
ptrdiff_t offset, ulonglong new_value,
- (int)(*)(KEY_CACHE *) func)
+ int (*func)(KEY_CACHE *))
{
bool error= false;
DBUG_ASSERT(offset != offsetof(KEY_CACHE, param_buff_size));
@@ -987,7 +987,7 @@ public:
global_var(ulonglong)= def_val;
DBUG_ASSERT(typelib.count > 0);
DBUG_ASSERT(typelib.count <= 64);
- DBUG_ASSERT(def_val < MAX_SET(typelib.count));
+ DBUG_ASSERT(def_val <= MAX_SET(typelib.count));
DBUG_ASSERT(size == sizeof(ulonglong));
}
bool do_check(THD *thd, set_var *var)
@@ -1130,7 +1130,7 @@ public:
plugin_ref oldval= *valptr;
if (oldval != newval)
{
- *valptr= my_plugin_lock(NULL, &newval);
+ *valptr= my_plugin_lock(NULL, newval);
plugin_unlock(NULL, oldval);
}
}
@@ -1149,7 +1149,7 @@ public:
void session_save_default(THD *thd, set_var *var)
{
plugin_ref plugin= global_var(plugin_ref);
- var->save_result.plugin= my_plugin_lock(thd, &plugin);
+ var->save_result.plugin= my_plugin_lock(thd, plugin);
}
void global_save_default(THD *thd, set_var *var)
{
@@ -1164,7 +1164,7 @@ public:
plugin= my_plugin_lock_by_name(thd, &pname, plugin_type);
DBUG_ASSERT(plugin);
- var->save_result.plugin= my_plugin_lock(thd, &plugin);
+ var->save_result.plugin= my_plugin_lock(thd, plugin);
}
bool check_update_type(Item_result type)
{ return type != STRING_RESULT; }
@@ -1508,12 +1508,12 @@ public:
{ return false; }
bool session_update(THD *thd, set_var *var)
{
- session_var(thd, void*)= var->save_result.ptr;
+ session_var(thd, const void*)= var->save_result.ptr;
return false;
}
bool global_update(THD *thd, set_var *var)
{
- global_var(void*)= var->save_result.ptr;
+ global_var(const void*)= var->save_result.ptr;
return false;
}
void session_save_default(THD *thd, set_var *var)
diff --git a/sql/table.cc b/sql/table.cc
index 2bde110f57f..a7fd0715f0f 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1726,7 +1726,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
}
if (parse_engine_table_options(thd, handler_file->partition_ht(), share))
goto free_and_err;
- my_free(buff, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(buff);
if (share->found_next_number_field)
{
@@ -1790,7 +1790,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
DBUG_RETURN (0);
free_and_err:
- my_free(buff, MYF(MY_ALLOW_ZERO_PTR));
+ my_free(buff);
err:
share->error= error;
share->open_errno= my_errno;
@@ -1869,64 +1869,22 @@ bool fix_vcol_expr(THD *thd,
{
Virtual_column_info *vcol_info= vcol_field->vcol_info;
Item* func_expr= vcol_info->expr_item;
- uint dir_length, home_dir_length;
bool result= TRUE;
TABLE_LIST tables;
- TABLE_LIST *save_table_list, *save_first_table, *save_last_table;
int error;
- Name_resolution_context *context;
const char *save_where;
- char* db_name;
- char db_name_string[FN_REFLEN];
- bool save_use_only_table_context;
Field **ptr, *field;
enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
DBUG_ASSERT(func_expr);
DBUG_ENTER("fix_vcol_expr");
- /*
- Set-up the TABLE_LIST object to be a list with a single table
- Set the object to zero to create NULL pointers and set alias
- and real name to table name and get database name from file name.
- */
-
- bzero((void*)&tables, sizeof(TABLE_LIST));
- tables.alias= tables.table_name= (char*) table->s->table_name.str;
- tables.table= table;
- tables.next_local= 0;
- tables.next_name_resolution_table= 0;
- strmov(db_name_string, table->s->normalized_path.str);
- dir_length= dirname_length(db_name_string);
- db_name_string[dir_length - 1]= 0;
- home_dir_length= dirname_length(db_name_string);
- db_name= &db_name_string[home_dir_length];
- tables.db= db_name;
-
thd->mark_used_columns= MARK_COLUMNS_NONE;
- context= thd->lex->current_context();
- table->map= 1; //To ensure correct calculation of const item
- table->get_fields_in_item_tree= TRUE;
- save_table_list= context->table_list;
- save_first_table= context->first_name_resolution_table;
- save_last_table= context->last_name_resolution_table;
- context->table_list= &tables;
- context->first_name_resolution_table= &tables;
- context->last_name_resolution_table= NULL;
- func_expr->walk(&Item::change_context_processor, 0, (uchar*) context);
save_where= thd->where;
thd->where= "virtual column function";
- /* Save the context before fixing the fields*/
- save_use_only_table_context= thd->lex->use_only_table_context;
- thd->lex->use_only_table_context= TRUE;
/* Fix fields referenced to by the virtual column function */
error= func_expr->fix_fields(thd, (Item**)0);
- /* Restore the original context*/
- thd->lex->use_only_table_context= save_use_only_table_context;
- context->table_list= save_table_list;
- context->first_name_resolution_table= save_first_table;
- context->last_name_resolution_table= save_last_table;
if (unlikely(error))
{
@@ -2030,6 +1988,8 @@ bool unpack_vcol_info_from_frm(THD *thd,
Query_arena backup_arena;
Query_arena *vcol_arena= 0;
Parser_state parser_state;
+ LEX *old_lex= thd->lex;
+ LEX lex;
DBUG_ENTER("unpack_vcol_info_from_frm");
DBUG_ASSERT(vcol_expr);
@@ -2082,6 +2042,9 @@ bool unpack_vcol_info_from_frm(THD *thd,
thd->set_n_backup_active_arena(vcol_arena, &backup_arena);
thd->stmt_arena= vcol_arena;
+ if (init_lex_with_single_table(thd, table, &lex))
+ goto end;
+
thd->lex->parse_vcol_expr= TRUE;
/*
@@ -2106,12 +2069,12 @@ bool unpack_vcol_info_from_frm(THD *thd,
err:
rc= TRUE;
- thd->lex->parse_vcol_expr= FALSE;
thd->free_items();
end:
thd->stmt_arena= backup_stmt_arena_ptr;
if (vcol_arena)
thd->restore_active_arena(vcol_arena, &backup_arena);
+ end_lex_with_single_table(thd, table, old_lex);
thd->variables.character_set_client= old_character_set_client;
DBUG_RETURN(rc);
@@ -2404,12 +2367,10 @@ partititon_err:
/* Check virtual columns against table's storage engine. */
if (share->vfields &&
((outparam->file &&
- !outparam->file->check_if_supported_virtual_columns()) ||
- (!outparam->file && share->db_type() &&
- share->db_type()->db_type == DB_TYPE_CSV_DB))) // Workaround for CSV
+ !outparam->file->check_if_supported_virtual_columns())))
{
my_error(ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN,
- MYF(0),
+ MYF(0), share->db_plugin ? plugin_name(share->db_plugin)->str :
"Specified storage engine");
error_reported= TRUE;
goto err;
@@ -5409,7 +5370,7 @@ void TABLE::mark_columns_needed_for_insert()
FALSE otherwise
*/
-bool st_table::mark_virtual_col(Field *field)
+bool TABLE::mark_virtual_col(Field *field)
{
bool res;
DBUG_ASSERT(field->vcol_info);
@@ -5451,7 +5412,7 @@ bool st_table::mark_virtual_col(Field *field)
be added to read_set either.
*/
-void st_table::mark_virtual_columns_for_write(bool insert_fl)
+void TABLE::mark_virtual_columns_for_write(bool insert_fl)
{
Field **vfield_ptr, *tmp_vfield;
bool bitmap_updated= FALSE;
@@ -5675,10 +5636,10 @@ Item_subselect *TABLE_LIST::containing_subselect()
DESCRIPTION
The parser collects the index hints for each table in a "tagged list"
(TABLE_LIST::index_hints). Using the information in this tagged list
- this function sets the members st_table::keys_in_use_for_query,
- st_table::keys_in_use_for_group_by, st_table::keys_in_use_for_order_by,
- st_table::force_index, st_table::force_index_order,
- st_table::force_index_group and st_table::covering_keys.
+ this function sets the members TABLE::keys_in_use_for_query,
+ TABLE::keys_in_use_for_group_by, TABLE::keys_in_use_for_order_by,
+ TABLE::force_index, TABLE::force_index_order,
+ TABLE::force_index_group and TABLE::covering_keys.
Current implementation of the runtime does not allow mixing FORCE INDEX
and USE INDEX, so this is checked here. Then the FORCE INDEX list
diff --git a/sql/table.h b/sql/table.h
index 2ba4b9dccd3..5b0a74a2828 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -676,7 +676,6 @@ struct TABLE_SHARE
bool is_view;
bool deleting; /* going to delete this table */
bool can_cmp_whole_record;
-#warning look at can_cmp_whole_record
ulong table_map_id; /* for row-based replication */
/*
@@ -1456,7 +1455,7 @@ struct TABLE_LIST
db_length= db_length_arg;
table_name= (char*) table_name_arg;
table_name_length= table_name_length_arg;
- alias= (char*) alias_arg;
+ alias= (char*) (alias_arg ? alias_arg : table_name_arg);
lock_type= lock_type_arg;
mdl_request.init(MDL_key::TABLE, db, table_name,
(lock_type >= TL_WRITE_ALLOW_WRITE) ?
diff --git a/sql/thr_malloc.h b/sql/thr_malloc.h
index 6b372a285a2..52e6752ab70 100644
--- a/sql/thr_malloc.h
+++ b/sql/thr_malloc.h
@@ -18,7 +18,6 @@
#include "my_global.h" // uint, size_t
-typedef struct charset_info_st CHARSET_INFO;
typedef struct st_mem_root MEM_ROOT;
void init_sql_alloc(MEM_ROOT *root, uint block_size, uint pre_alloc_size);