summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2012-02-01 15:48:02 -0800
committerIgor Babaev <igor@askmonty.org>2012-02-01 15:48:02 -0800
commit7b79d8a33f56d178c78209f910a0694807a63f8f (patch)
tree3d4a8131e8688c6599461bfce72bb87c718a53e4 /sql
parent7ed15e6e50aec65560d8988fc5713f1f489b6616 (diff)
parent81690cf326e09799ca77d9f7bc5601905b706548 (diff)
downloadmariadb-git-7b79d8a33f56d178c78209f910a0694807a63f8f.tar.gz
Merge 5.2->5.3 in preparation for the release of mariadb-5.3.4-rc.
Diffstat (limited to 'sql')
-rw-r--r--sql/item.cc5
-rw-r--r--sql/item_subselect.cc11
-rw-r--r--sql/item_sum.cc3
-rw-r--r--sql/mysql_priv.h4
-rw-r--r--sql/mysqld.cc4
-rw-r--r--sql/opt_sum.cc7
-rw-r--r--sql/scheduler.cc2
-rw-r--r--sql/sql_base.cc7
-rw-r--r--sql/sql_manager.cc12
-rw-r--r--sql/sql_parse.cc7
-rw-r--r--sql/sql_select.cc10
-rw-r--r--sql/sql_select.h2
-rw-r--r--sql/table.cc4
-rw-r--r--sql/winservice.c4
14 files changed, 60 insertions, 22 deletions
diff --git a/sql/item.cc b/sql/item.cc
index aaf9b0c2a12..752b2915dca 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -9168,6 +9168,8 @@ table_map Item_ref_null_helper::used_tables() const
}
+#ifndef DBUG_OFF
+
/* Debugger help function */
static char dbug_item_print_buf[256];
@@ -9184,6 +9186,9 @@ const char *dbug_print_item(Item *item)
else
return "Couldn't fit into buffer";
}
+
+#endif /*DBUG_OFF*/
+
/*****************************************************************************
** Instantiate templates
*****************************************************************************/
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index d66dbd12436..52a2c2a7d8b 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -1586,7 +1586,6 @@ Item_in_subselect::single_value_transformer(JOIN *join)
(Item**)optimizer->get_cache(),
(char *)"<no matter>",
(char *)in_left_expr_name);
-
}
DBUG_RETURN(false);
@@ -2229,7 +2228,12 @@ bool Item_in_subselect::create_in_to_exists_cond(JOIN *join_arg)
/*
The IN=>EXISTS transformation makes non-correlated subqueries correlated.
*/
- join_arg->select_lex->uncacheable|= UNCACHEABLE_DEPENDENT_INJECTED;
+ if (!left_expr->const_item() || left_expr->is_expensive())
+ {
+ join_arg->select_lex->uncacheable|= UNCACHEABLE_DEPENDENT_INJECTED;
+ join_arg->select_lex->master_unit()->uncacheable|=
+ UNCACHEABLE_DEPENDENT_INJECTED;
+ }
/*
The uncacheable property controls a number of actions, e.g. whether to
save/restore (via init_save_join_tab/restore_tmp) the original JOIN for
@@ -2495,6 +2499,7 @@ bool Item_in_subselect::fix_fields(THD *thd_arg, Item **ref)
left_expr && !left_expr->fixed &&
left_expr->fix_fields(thd_arg, &left_expr))
return TRUE;
+ else
if (Item_subselect::fix_fields(thd_arg, ref))
return TRUE;
fixed= TRUE;
@@ -3142,6 +3147,8 @@ bool subselect_uniquesubquery_engine::copy_ref_key()
for (store_key **copy= tab->ref.key_copy ; *copy ; copy++)
{
+ if ((*copy)->store_key_is_const())
+ continue;
tab->ref.key_err= (*copy)->copy();
/*
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 183f8ccff10..60ec27863bd 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -582,13 +582,12 @@ Item_sum_num::fix_fields(THD *thd, Item **ref)
return TRUE;
decimals=0;
- maybe_null=0;
+ maybe_null= sum_func() != COUNT_FUNC;
for (uint i=0 ; i < arg_count ; i++)
{
if (args[i]->fix_fields(thd, args + i) || args[i]->check_cols(1))
return TRUE;
set_if_bigger(decimals, args[i]->decimals);
- maybe_null |= args[i]->maybe_null;
}
result_field=0;
max_length=float_length(decimals);
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 253acff3405..2f5c89cb3a5 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -2258,7 +2258,7 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_lock_db,
LOCK_mapped_file,LOCK_user_locks, LOCK_status,
LOCK_error_log, LOCK_delayed_insert, LOCK_short_uuid_generator,
LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
- LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
+ LOCK_slave_list, LOCK_active_mi, LOCK_global_read_lock,
LOCK_global_system_variables, LOCK_user_conn,
LOCK_prepared_stmt_count,
LOCK_bytes_sent, LOCK_bytes_received, LOCK_connection_count;
@@ -2276,7 +2276,7 @@ extern pthread_mutex_t LOCK_stats;
extern int mysqld_server_started;
extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave;
extern rw_lock_t LOCK_system_variables_hash;
-extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager;
+extern pthread_cond_t COND_refresh, COND_thread_count;
extern pthread_cond_t COND_global_read_lock;
extern pthread_attr_t connection_attrib;
extern I_List<THD> threads;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index a090448ebae..7a701217bb0 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1588,7 +1588,6 @@ static void clean_up_mutexes()
(void) pthread_mutex_destroy(&LOCK_delayed_insert);
(void) pthread_mutex_destroy(&LOCK_delayed_status);
(void) pthread_mutex_destroy(&LOCK_delayed_create);
- (void) pthread_mutex_destroy(&LOCK_manager);
(void) pthread_mutex_destroy(&LOCK_crypt);
(void) pthread_mutex_destroy(&LOCK_bytes_sent);
(void) pthread_mutex_destroy(&LOCK_bytes_received);
@@ -1629,7 +1628,6 @@ static void clean_up_mutexes()
(void) pthread_cond_destroy(&COND_global_read_lock);
(void) pthread_cond_destroy(&COND_thread_cache);
(void) pthread_cond_destroy(&COND_flush_thread_cache);
- (void) pthread_cond_destroy(&COND_manager);
DBUG_VOID_RETURN;
}
@@ -3887,7 +3885,6 @@ static int init_thread_environment()
(void) pthread_mutex_init(&LOCK_delayed_insert,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_delayed_status,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_delayed_create,MY_MUTEX_INIT_SLOW);
- (void) pthread_mutex_init(&LOCK_manager,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_crypt,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_bytes_sent,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_bytes_received,MY_MUTEX_INIT_FAST);
@@ -3927,7 +3924,6 @@ static int init_thread_environment()
(void) pthread_cond_init(&COND_global_read_lock,NULL);
(void) pthread_cond_init(&COND_thread_cache,NULL);
(void) pthread_cond_init(&COND_flush_thread_cache,NULL);
- (void) pthread_cond_init(&COND_manager,NULL);
#ifdef HAVE_REPLICATION
(void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
(void) pthread_cond_init(&COND_rpl_status, NULL);
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index 08717142aa0..5298c57954d 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -623,7 +623,12 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
if (!cond)
DBUG_RETURN(TRUE);
Field *field= field_part->field;
- if (!(cond->used_tables() & field->table->map))
+ if (cond->used_tables() & OUTER_REF_TABLE_BIT)
+ {
+ DBUG_RETURN(FALSE);
+ }
+ if (!(cond->used_tables() & field->table->map) &&
+ test(cond->used_tables() & ~PSEUDO_TABLE_BITS))
{
/* Condition doesn't restrict the used table */
DBUG_RETURN(!cond->const_item());
diff --git a/sql/scheduler.cc b/sql/scheduler.cc
index 5b83bb4753e..2f8aa2bef11 100644
--- a/sql/scheduler.cc
+++ b/sql/scheduler.cc
@@ -512,7 +512,7 @@ static void libevent_connection_close(THD *thd)
thd->killed= KILL_CONNECTION; // Avoid error messages
- if (thd->net.vio->sd >= 0) // not already closed
+ if (thd->net.vio->type != VIO_CLOSED) // not already closed
{
end_connection(thd);
close_connection(thd, 0, 1);
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 558e7b0aa9e..6dd329f8c77 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -7197,11 +7197,16 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
if (!(eq_cond= new Item_func_eq(item_ident_1, item_ident_2)))
goto err; /* Out of memory. */
+ if (field_1 && field_1->vcol_info)
+ field_1->table->mark_virtual_col(field_1);
+ if (field_2 && field_2->vcol_info)
+ field_2->table->mark_virtual_col(field_2);
+
/*
Add the new equi-join condition to the ON clause. Notice that
fix_fields() is applied to all ON conditions in setup_conds()
so we don't do it here.
- */
+ */
add_join_on((table_ref_1->outer_join & JOIN_TYPE_RIGHT ?
table_ref_1 : table_ref_2),
eq_cond);
diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc
index cf0a73d0ce7..57fe5072dcd 100644
--- a/sql/sql_manager.cc
+++ b/sql/sql_manager.cc
@@ -44,6 +44,7 @@ static struct handler_cb * volatile cb_list;
bool mysql_manager_submit(void (*action)())
{
bool result= FALSE;
+ DBUG_ASSERT(manager_thread_in_use);
struct handler_cb * volatile *cb;
pthread_mutex_lock(&LOCK_manager);
cb= &cb_list;
@@ -75,8 +76,9 @@ pthread_handler_t handle_manager(void *arg __attribute__((unused)))
pthread_detach_this_thread();
manager_thread = pthread_self();
+ (void) pthread_cond_init(&COND_manager,NULL);
+ (void) pthread_mutex_init(&LOCK_manager,NULL);
manager_thread_in_use = 1;
-
for (;;)
{
pthread_mutex_lock(&LOCK_manager);
@@ -123,6 +125,8 @@ pthread_handler_t handle_manager(void *arg __attribute__((unused)))
}
}
manager_thread_in_use = 0;
+ (void) pthread_mutex_destroy(&LOCK_manager);
+ (void) pthread_cond_destroy(&COND_manager);
DBUG_LEAVE; // Can't use DBUG_RETURN after my_thread_end
my_thread_end();
return (NULL);
@@ -149,14 +153,14 @@ void stop_handle_manager()
{
DBUG_ENTER("stop_handle_manager");
abort_manager = true;
- pthread_mutex_lock(&LOCK_manager);
if (manager_thread_in_use)
{
+ pthread_mutex_lock(&LOCK_manager);
DBUG_PRINT("quit", ("initiate shutdown of handle manager thread: 0x%lx",
(ulong)manager_thread));
- pthread_cond_signal(&COND_manager);
+ pthread_cond_signal(&COND_manager);
+ pthread_mutex_unlock(&LOCK_manager);
}
- pthread_mutex_unlock(&LOCK_manager);
DBUG_VOID_RETURN;
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 1676d4a09f4..24976ff9f1a 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -191,7 +191,8 @@ bool end_active_trans(THD *thd)
if (ha_commit(thd))
error=1;
#ifdef WITH_ARIA_STORAGE_ENGINE
- ha_maria::implicit_commit(thd, TRUE);
+ if (ha_storage_engine_is_enabled(maria_hton))
+ ha_maria::implicit_commit(thd, TRUE);
#endif
}
thd->options&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
@@ -1231,6 +1232,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
char *beginning_of_next_stmt= (char*) end_of_stmt;
#ifdef WITH_ARIA_STORAGE_ENGINE
+ if (ha_storage_engine_is_enabled(maria_hton))
ha_maria::implicit_commit(thd, FALSE);
#endif
@@ -1608,7 +1610,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
thd->transaction.stmt.reset();
#ifdef WITH_ARIA_STORAGE_ENGINE
- ha_maria::implicit_commit(thd, FALSE);
+ if (ha_storage_engine_is_enabled(maria_hton))
+ ha_maria::implicit_commit(thd, FALSE);
#endif
if (!(sql_command_flags[thd->lex->sql_command] & CF_CHANGES_DATA))
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 9d03cdd55a2..05fba45792b 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -10332,6 +10332,15 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond,
}
+ /*
+ Cleanup to avoid interference of calls of this function for
+ ORDER BY and GROUP BY
+ */
+ for (JOIN_TAB *tab= join->join_tab + join->const_tables;
+ tab < join->join_tab + join->table_count;
+ tab++)
+ tab->cached_eq_ref_table= FALSE;
+
prev_ptr= &first_order;
*simple_order= *join->join_tab[join->const_tables].on_expr_ref ? 0 : 1;
@@ -18390,7 +18399,6 @@ create_sort_index(THD *thd, JOIN *join, ORDER *order,
table->sort.io_cache= NULL;
select->cleanup(); // filesort did select
- tab->select= 0;
table->quick_keys.clear_all(); // as far as we cleanup select->quick
table->intersect_keys.clear_all();
table->sort.io_cache= tablesort_result_cache;
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 002c5a2df5a..a5fa59a070a 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -1456,6 +1456,7 @@ public:
virtual ~store_key() {} /** Not actually needed */
virtual enum Type type() const=0;
virtual const char *name() const=0;
+ virtual bool store_key_is_const() { return false; }
/**
@brief sets ignore truncation warnings mode and calls the real copy method
@@ -1609,6 +1610,7 @@ public:
enum Type type() const { return CONST_ITEM_STORE_KEY; }
const char *name() const { return "const"; }
+ bool store_key_is_const() { return true; }
protected:
enum store_key_result copy_inner()
diff --git a/sql/table.cc b/sql/table.cc
index 7b417b95319..5fe2d8afc42 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -4481,6 +4481,7 @@ Item *Field_iterator_table::create_item(THD *thd)
{
select->non_agg_fields.push_back(item);
item->marker= select->cur_pos_in_select_list;
+ select->set_non_agg_field_used(true);
}
return item;
}
@@ -5184,6 +5185,9 @@ void st_table::mark_virtual_columns_for_write(bool insert_fl)
Field **vfield_ptr, *tmp_vfield;
bool bitmap_updated= FALSE;
+ if (!vfield)
+ return;
+
for (vfield_ptr= vfield; *vfield_ptr; vfield_ptr++)
{
tmp_vfield= *vfield_ptr;
diff --git a/sql/winservice.c b/sql/winservice.c
index 562f047fa79..3ec91c26835 100644
--- a/sql/winservice.c
+++ b/sql/winservice.c
@@ -116,7 +116,7 @@ int get_mysql_service_properties(const wchar_t *bin_path,
wcscat(mysqld_path, L".exe");
if(wcsicmp(file_part, L"mysqld.exe") != 0 &&
- wcsicmp(file_part, L"mysqld.exe") != 0 &&
+ wcsicmp(file_part, L"mysqld-debug.exe") != 0 &&
wcsicmp(file_part, L"mysqld-nt.exe") != 0)
{
/* The service executable is not mysqld. */
@@ -244,4 +244,4 @@ int get_mysql_service_properties(const wchar_t *bin_path,
end:
LocalFree((HLOCAL)args);
return retval;
-} \ No newline at end of file
+}