Merge bk-internal.mysql.com:/home/bk/mysql-5.0

into  mysql.com:/home/my/mysql-5.0


sql/ha_ndbcluster.cc:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_union.cc:
  Manual merge (trivial)
This commit is contained in:
unknown 2005-08-12 13:57:20 +03:00
commit 7cfb6540f7
23 changed files with 314 additions and 264 deletions

View File

@ -2468,25 +2468,26 @@ drop table t3|
# #
# BUG#4318 # BUG#4318
# #
#QQ Don't know if HANDLER commands can work with SPs, or at all...
# --disable_parsing Don't know if HANDLER commands can work with SPs, or at all..
#create table t3 (s1 int)| create table t3 (s1 int)|
#insert into t3 values (3), (4)| insert into t3 values (3), (4)|
#
#--disable_warnings --disable_warnings
#drop procedure if exists bug4318| drop procedure if exists bug4318|
#--enable_warnings --enable_warnings
#create procedure bug4318() create procedure bug4318()
# handler t3 read next| handler t3 read next|
#
#handler t3 open| handler t3 open|
## Expect no results, as tables are closed, but there shouldn't be any errors # Expect no results, as tables are closed, but there shouldn't be any errors
#call bug4318()| call bug4318()|
#call bug4318()| call bug4318()|
#handler t3 close| handler t3 close|
#
#drop procedure bug4318| drop procedure bug4318|
#drop table t3| drop table t3|
--enable_parsing
# #
# BUG#4902: Stored procedure with SHOW WARNINGS leads to packet error # BUG#4902: Stored procedure with SHOW WARNINGS leads to packet error
@ -2834,26 +2835,27 @@ drop table t3|
# #
# BUG#6022: Stored procedure shutdown problem with self-calling function. # BUG#6022: Stored procedure shutdown problem with self-calling function.
# #
# This part of test is disabled until we implement support for
# recursive stored functions. --disable_parsing until we implement support for recursive stored functions.
#--disable_warnings --disable_warnings
#drop function if exists bug6022| drop function if exists bug6022|
#--enable_warnings --enable_warnings
#
#--disable_warnings --disable_warnings
#drop function if exists bug6022| drop function if exists bug6022|
#--enable_warnings --enable_warnings
#create function bug6022(x int) returns int create function bug6022(x int) returns int
#begin begin
# if x < 0 then if x < 0 then
# return 0; return 0;
# else else
# return bug6022(x-1); return bug6022(x-1);
# end if; end if;
#end| end|
#
#select bug6022(5)| select bug6022(5)|
#drop function bug6022| drop function bug6022|
--enable_parsing
# #
# BUG#6029: Stored procedure specific handlers should have priority # BUG#6029: Stored procedure specific handlers should have priority
@ -3760,27 +3762,28 @@ drop procedure if exists bug7088_1|
drop procedure if exists bug7088_2| drop procedure if exists bug7088_2|
--enable_warnings --enable_warnings
# psergey: temporarily disabled until Bar fixes BUG#11986 --disable_parsing temporarily disabled until Bar fixes BUG#11986
# create procedure bug6063() create procedure bug6063()
# lâbel: begin end| lâbel: begin end|
# call bug6063()| call bug6063()|
# # QQ Known bug: this will not show the label correctly. # QQ Known bug: this will not show the label correctly.
# show create procedure bug6063| show create procedure bug6063|
#
# set character set utf8| set character set utf8|
# create procedure bug7088_1() create procedure bug7088_1()
# label1: begin end label1| label1: begin end label1|
# create procedure bug7088_2() create procedure bug7088_2()
# läbel1: begin end| läbel1: begin end|
# call bug7088_1()| call bug7088_1()|
# call bug7088_2()| call bug7088_2()|
# set character set default| set character set default|
# show create procedure bug7088_1| show create procedure bug7088_1|
# show create procedure bug7088_2| show create procedure bug7088_2|
#
# drop procedure bug6063| drop procedure bug6063|
# drop procedure bug7088_1| drop procedure bug7088_1|
# drop procedure bug7088_2| drop procedure bug7088_2|
--enable_parsing
# #
# BUG#9565: "Wrong locking in stored procedure if a sub-sequent procedure # BUG#9565: "Wrong locking in stored procedure if a sub-sequent procedure

View File

@ -958,8 +958,6 @@ int ha_berkeley::write_row(byte * record)
{ {
DB_TXN *sub_trans = transaction; DB_TXN *sub_trans = transaction;
/* Don't use sub transactions in temporary tables */ /* Don't use sub transactions in temporary tables */
ulong thd_options= (table->s->tmp_table == NO_TMP_TABLE ?
table->in_use->options : 0);
for (uint retry=0 ; retry < berkeley_trans_retry ; retry++) for (uint retry=0 ; retry < berkeley_trans_retry ; retry++)
{ {
key_map changed_keys(0); key_map changed_keys(0);
@ -1070,7 +1068,7 @@ int ha_berkeley::key_cmp(uint keynr, const byte * old_row,
int ha_berkeley::update_primary_key(DB_TXN *trans, bool primary_key_changed, int ha_berkeley::update_primary_key(DB_TXN *trans, bool primary_key_changed,
const byte * old_row, DBT *old_key, const byte * old_row, DBT *old_key,
const byte * new_row, DBT *new_key, const byte * new_row, DBT *new_key,
ulong thd_options, bool local_using_ignore) bool local_using_ignore)
{ {
DBT row; DBT row;
int error; int error;
@ -1119,8 +1117,7 @@ int ha_berkeley::update_primary_key(DB_TXN *trans, bool primary_key_changed,
int ha_berkeley::restore_keys(DB_TXN *trans, key_map *changed_keys, int ha_berkeley::restore_keys(DB_TXN *trans, key_map *changed_keys,
uint primary_key, uint primary_key,
const byte *old_row, DBT *old_key, const byte *old_row, DBT *old_key,
const byte *new_row, DBT *new_key, const byte *new_row, DBT *new_key)
ulong thd_options)
{ {
int error; int error;
DBT tmp_key; DBT tmp_key;
@ -1130,7 +1127,7 @@ int ha_berkeley::restore_keys(DB_TXN *trans, key_map *changed_keys,
/* Restore the old primary key, and the old row, but don't ignore /* Restore the old primary key, and the old row, but don't ignore
duplicate key failure */ duplicate key failure */
if ((error=update_primary_key(trans, TRUE, new_row, new_key, if ((error=update_primary_key(trans, TRUE, new_row, new_key,
old_row, old_key, thd_options, FALSE))) old_row, old_key, FALSE)))
goto err; /* purecov: inspected */ goto err; /* purecov: inspected */
/* Remove the new key, and put back the old key /* Remove the new key, and put back the old key
@ -1167,8 +1164,6 @@ int ha_berkeley::update_row(const byte * old_row, byte * new_row)
DBT prim_key, key, old_prim_key; DBT prim_key, key, old_prim_key;
int error; int error;
DB_TXN *sub_trans; DB_TXN *sub_trans;
ulong thd_options= (table->s->tmp_table == NO_TMP_TABLE ?
table->in_use->options : 0);
bool primary_key_changed; bool primary_key_changed;
DBUG_ENTER("update_row"); DBUG_ENTER("update_row");
LINT_INIT(error); LINT_INIT(error);
@ -1204,7 +1199,7 @@ int ha_berkeley::update_row(const byte * old_row, byte * new_row)
if (!(error=update_primary_key(sub_trans, primary_key_changed, if (!(error=update_primary_key(sub_trans, primary_key_changed,
old_row, &old_prim_key, old_row, &old_prim_key,
new_row, &prim_key, new_row, &prim_key,
thd_options, using_ignore))) using_ignore)))
{ {
// Update all other keys // Update all other keys
for (uint keynr=0 ; keynr < table->s->keys ; keynr++) for (uint keynr=0 ; keynr < table->s->keys ; keynr++)
@ -1239,8 +1234,7 @@ int ha_berkeley::update_row(const byte * old_row, byte * new_row)
int new_error = 0; int new_error = 0;
if (!changed_keys.is_clear_all()) if (!changed_keys.is_clear_all())
new_error=restore_keys(transaction, &changed_keys, primary_key, new_error=restore_keys(transaction, &changed_keys, primary_key,
old_row, &old_prim_key, new_row, &prim_key, old_row, &old_prim_key, new_row, &prim_key);
thd_options);
if (new_error) if (new_error)
{ {
/* This shouldn't happen */ /* This shouldn't happen */
@ -1342,8 +1336,6 @@ int ha_berkeley::delete_row(const byte * record)
int error; int error;
DBT row, prim_key; DBT row, prim_key;
key_map keys= table->s->keys_in_use; key_map keys= table->s->keys_in_use;
ulong thd_options= (table->s->tmp_table == NO_TMP_TABLE ?
table->in_use->options : 0);
DBUG_ENTER("delete_row"); DBUG_ENTER("delete_row");
statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status); statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);

View File

@ -74,13 +74,12 @@ class ha_berkeley: public handler
DBT *prim_key, key_map *keys); DBT *prim_key, key_map *keys);
int restore_keys(DB_TXN *trans, key_map *changed_keys, uint primary_key, int restore_keys(DB_TXN *trans, key_map *changed_keys, uint primary_key,
const byte *old_row, DBT *old_key, const byte *old_row, DBT *old_key,
const byte *new_row, DBT *new_key, const byte *new_row, DBT *new_key);
ulong thd_options);
int key_cmp(uint keynr, const byte * old_row, const byte * new_row); int key_cmp(uint keynr, const byte * old_row, const byte * new_row);
int update_primary_key(DB_TXN *trans, bool primary_key_changed, int update_primary_key(DB_TXN *trans, bool primary_key_changed,
const byte * old_row, DBT *old_key, const byte * old_row, DBT *old_key,
const byte * new_row, DBT *prim_key, const byte * new_row, DBT *prim_key,
ulong thd_options, bool local_using_ignore); bool local_using_ignore);
int read_row(int error, char *buf, uint keynr, DBT *row, DBT *key, bool); int read_row(int error, char *buf, uint keynr, DBT *row, DBT *key, bool);
DBT *get_pos(DBT *to, byte *pos); DBT *get_pos(DBT *to, byte *pos);

View File

@ -6997,6 +6997,8 @@ ha_ndbcluster::build_scan_filter_predicate(Ndb_cond * &cond,
break; break;
Ndb_item *a= cond->next->ndb_item; Ndb_item *a= cond->next->ndb_item;
Ndb_item *b, *field, *value= NULL; Ndb_item *b, *field, *value= NULL;
LINT_INIT(field);
switch (cond->ndb_item->argument_count()) { switch (cond->ndb_item->argument_count()) {
case 1: case 1:
field= field=

View File

@ -39,12 +39,11 @@ void unireg_init(ulong options)
#endif #endif
VOID(strmov(reg_ext,".frm")); VOID(strmov(reg_ext,".frm"));
specialflag=SPECIAL_SAME_DB_NAME; specialflag=SPECIAL_SAME_DB_NAME | options; /* Set options from argv */
/* Make a tab of powers of 10 */ /* Make a tab of powers of 10 */
for (i=0,nr=1.0; i < array_elements(log_10) ; i++) for (i=0,nr=1.0; i < array_elements(log_10) ; i++)
{ /* It's used by filesort... */ { /* It's used by filesort... */
log_10[i]= nr ; nr*= 10.0; log_10[i]= nr ; nr*= 10.0;
} }
specialflag|=options; /* Set options from argv */
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }

View File

@ -2291,8 +2291,7 @@ bool Item_sum_count_distinct::setup(THD *thd)
DBUG_ASSERT(table == 0); DBUG_ASSERT(table == 0);
if (!(table= create_tmp_table(thd, tmp_table_param, list, (ORDER*) 0, 1, if (!(table= create_tmp_table(thd, tmp_table_param, list, (ORDER*) 0, 1,
0, 0,
(select_lex->options | thd->options) & (select_lex->options | thd->options),
~TMP_TABLE_FORCE_MYISAM,
HA_POS_ERROR, (char*)""))) HA_POS_ERROR, (char*)"")))
return TRUE; return TRUE;
table->file->extra(HA_EXTRA_NO_ROWS); // Don't update rows table->file->extra(HA_EXTRA_NO_ROWS); // Don't update rows
@ -3074,8 +3073,7 @@ bool Item_func_group_concat::setup(THD *thd)
*/ */
if (!(table= create_tmp_table(thd, tmp_table_param, all_fields, if (!(table= create_tmp_table(thd, tmp_table_param, all_fields,
(ORDER*) 0, 0, TRUE, (ORDER*) 0, 0, TRUE,
(select_lex->options | thd->options) & (select_lex->options | thd->options),
~TMP_TABLE_FORCE_MYISAM,
HA_POS_ERROR, (char*) ""))) HA_POS_ERROR, (char*) "")))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
table->file->extra(HA_EXTRA_NO_ROWS); table->file->extra(HA_EXTRA_NO_ROWS);

View File

@ -849,10 +849,6 @@ static void print_lock_error(int error, const char *table)
So in this exceptional case the COMMIT should not be blocked by the FLUSH So in this exceptional case the COMMIT should not be blocked by the FLUSH
TABLES WITH READ LOCK. TABLES WITH READ LOCK.
TODO in MySQL 5.x: make_global_read_lock_block_commit() should be
killable. Normally CPU does not spend a long time in this function (COMMITs
are quite fast), but it would still be nice.
****************************************************************************/ ****************************************************************************/
volatile uint global_read_lock=0; volatile uint global_read_lock=0;
@ -1003,7 +999,7 @@ bool make_global_read_lock_block_commit(THD *thd)
pthread_cond_wait(&COND_refresh, &LOCK_global_read_lock); pthread_cond_wait(&COND_refresh, &LOCK_global_read_lock);
DBUG_EXECUTE_IF("make_global_read_lock_block_commit_loop", DBUG_EXECUTE_IF("make_global_read_lock_block_commit_loop",
protect_against_global_read_lock--;); protect_against_global_read_lock--;);
if (error= thd->killed) if ((error= test(thd->killed)))
global_read_lock_blocks_commit--; // undo what we did global_read_lock_blocks_commit--; // undo what we did
else else
thd->global_read_lock= MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT; thd->global_read_lock= MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT;

View File

@ -256,13 +256,6 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset;
#define OPTION_WARNINGS (1L << 13) // THD, user #define OPTION_WARNINGS (1L << 13) // THD, user
#define OPTION_AUTO_IS_NULL (1L << 14) // THD, user, binlog #define OPTION_AUTO_IS_NULL (1L << 14) // THD, user, binlog
#define OPTION_FOUND_COMMENT (1L << 15) // SELECT, intern, parser #define OPTION_FOUND_COMMENT (1L << 15) // SELECT, intern, parser
/*
Force the used temporary table to be a MyISAM table (because we will use
fulltext functions when reading from it. This uses the same constant as
OPTION_FOUND_COMMENT because we've run out of bits and these two values
are not used together.
*/
#define TMP_TABLE_FORCE_MYISAM (1L << 15)
#define OPTION_SAFE_UPDATES (1L << 16) // THD, user #define OPTION_SAFE_UPDATES (1L << 16) // THD, user
#define OPTION_BUFFER_RESULT (1L << 17) // SELECT, user #define OPTION_BUFFER_RESULT (1L << 17) // SELECT, user
#define OPTION_BIN_LOG (1L << 18) // THD, user #define OPTION_BIN_LOG (1L << 18) // THD, user
@ -291,6 +284,11 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset;
#define OPTION_SETUP_TABLES_DONE (1L << 30) // intern #define OPTION_SETUP_TABLES_DONE (1L << 30) // intern
/* If not set then the thread will ignore all warnings with level notes. */ /* If not set then the thread will ignore all warnings with level notes. */
#define OPTION_SQL_NOTES (1L << 31) // THD, user #define OPTION_SQL_NOTES (1L << 31) // THD, user
/*
Force the used temporary table to be a MyISAM table (because we will use
fulltext functions when reading from it.
*/
#define TMP_TABLE_FORCE_MYISAM (LL(1) << 32)
/* /*
Maximum length of time zone name that we support Maximum length of time zone name that we support
@ -726,7 +724,7 @@ int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields,
enum enum_duplicates handle_duplicates, bool ignore); enum enum_duplicates handle_duplicates, bool ignore);
bool mysql_multi_update(THD *thd, TABLE_LIST *table_list, bool mysql_multi_update(THD *thd, TABLE_LIST *table_list,
List<Item> *fields, List<Item> *values, List<Item> *fields, List<Item> *values,
COND *conds, ulong options, COND *conds, ulonglong options,
enum enum_duplicates handle_duplicates, bool ignore, enum enum_duplicates handle_duplicates, bool ignore,
SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex); SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex);
bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table, bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
@ -742,7 +740,7 @@ int check_that_all_fields_are_given_values(THD *thd, TABLE *entry,
TABLE_LIST *table_list); TABLE_LIST *table_list);
bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds); bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds);
bool mysql_delete(THD *thd, TABLE_LIST *table, COND *conds, SQL_LIST *order, bool mysql_delete(THD *thd, TABLE_LIST *table, COND *conds, SQL_LIST *order,
ha_rows rows, ulong options); ha_rows rows, ulonglong options);
bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok); bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok);
bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create); bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create);
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update); TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update);
@ -1107,6 +1105,7 @@ extern char log_error_file[FN_REFLEN], *opt_tc_log_file;
extern double log_10[32]; extern double log_10[32];
extern ulonglong log_10_int[20]; extern ulonglong log_10_int[20];
extern ulonglong keybuff_size; extern ulonglong keybuff_size;
extern ulonglong thd_startup_options;
extern ulong refresh_version,flush_version, thread_id; extern ulong refresh_version,flush_version, thread_id;
extern ulong binlog_cache_use, binlog_cache_disk_use; extern ulong binlog_cache_use, binlog_cache_disk_use;
extern ulong aborted_threads,aborted_connects; extern ulong aborted_threads,aborted_connects;
@ -1116,7 +1115,7 @@ extern ulong delayed_insert_threads, delayed_insert_writes;
extern ulong delayed_rows_in_use,delayed_insert_errors; extern ulong delayed_rows_in_use,delayed_insert_errors;
extern ulong slave_open_temp_tables; extern ulong slave_open_temp_tables;
extern ulong query_cache_size, query_cache_min_res_unit; extern ulong query_cache_size, query_cache_min_res_unit;
extern ulong thd_startup_options, slow_launch_threads, slow_launch_time; extern ulong slow_launch_threads, slow_launch_time;
extern ulong table_cache_size; extern ulong table_cache_size;
extern ulong max_connections,max_connect_errors, connect_timeout; extern ulong max_connections,max_connect_errors, connect_timeout;
extern ulong slave_net_timeout, slave_trans_retries; extern ulong slave_net_timeout, slave_trans_retries;

View File

@ -387,8 +387,8 @@ uint delay_key_write_options, protocol_version;
uint lower_case_table_names; uint lower_case_table_names;
uint tc_heuristic_recover= 0; uint tc_heuristic_recover= 0;
uint volatile thread_count, thread_running; uint volatile thread_count, thread_running;
ulong back_log, connect_timeout, concurrency; ulonglong thd_startup_options;
ulong server_id, thd_startup_options; ulong back_log, connect_timeout, concurrency, server_id;
ulong table_cache_size, thread_stack, what_to_log; ulong table_cache_size, thread_stack, what_to_log;
ulong query_buff_size, slow_launch_time, slave_open_temp_tables; ulong query_buff_size, slow_launch_time, slave_open_temp_tables;
ulong open_files_limit, max_binlog_size, max_relay_log_size; ulong open_files_limit, max_binlog_size, max_relay_log_size;
@ -1908,7 +1908,8 @@ static void check_data_home(const char *path)
static void sig_reload(int signo) static void sig_reload(int signo)
{ {
// Flush everything // Flush everything
reload_acl_and_cache((THD*) 0,REFRESH_LOG, (TABLE_LIST*) 0, NULL); bool not_used;
reload_acl_and_cache((THD*) 0,REFRESH_LOG, (TABLE_LIST*) 0, &not_used);
signal(signo, SIG_ACK); signal(signo, SIG_ACK);
} }
@ -2267,12 +2268,13 @@ static void *signal_hand(void *arg __attribute__((unused)))
case SIGHUP: case SIGHUP:
if (!abort_loop) if (!abort_loop)
{ {
bool not_used;
mysql_print_status(); // Print some debug info mysql_print_status(); // Print some debug info
reload_acl_and_cache((THD*) 0, reload_acl_and_cache((THD*) 0,
(REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST | (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST |
REFRESH_GRANT | REFRESH_GRANT |
REFRESH_THREADS | REFRESH_HOSTS), REFRESH_THREADS | REFRESH_HOSTS),
(TABLE_LIST*) 0, NULL); // Flush logs (TABLE_LIST*) 0, &not_used); // Flush logs
} }
break; break;
#ifdef USE_ONE_SIGNAL_HAND #ifdef USE_ONE_SIGNAL_HAND

View File

@ -22,7 +22,7 @@
#include "sp_head.h" #include "sp_head.h"
static pthread_mutex_t Cversion_lock; static pthread_mutex_t Cversion_lock;
static ulong Cversion = 0; static ulong volatile Cversion= 0;
/* /*
@ -86,9 +86,11 @@ void sp_cache_init()
/* /*
Clear the cache *cp and set *cp to NULL. Clear the cache *cp and set *cp to NULL.
SYNOPSIS SYNOPSIS
sp_cache_clear() sp_cache_clear()
cp Pointer to cache to clear cp Pointer to cache to clear
NOTE NOTE
This function doesn't invalidate other caches. This function doesn't invalidate other caches.
*/ */
@ -96,6 +98,7 @@ void sp_cache_init()
void sp_cache_clear(sp_cache **cp) void sp_cache_clear(sp_cache **cp)
{ {
sp_cache *c= *cp; sp_cache *c= *cp;
if (c) if (c)
{ {
delete c; delete c;
@ -109,8 +112,8 @@ void sp_cache_clear(sp_cache **cp)
SYNOPSIS SYNOPSIS
sp_cache_insert() sp_cache_insert()
cp The cache to put routine into cp The cache to put routine into
sp Routine to insert. sp Routine to insert.
TODO: Perhaps it will be more straightforward if in case we returned an TODO: Perhaps it will be more straightforward if in case we returned an
error from this function when we couldn't allocate sp_cache. (right error from this function when we couldn't allocate sp_cache. (right
@ -120,22 +123,19 @@ void sp_cache_clear(sp_cache **cp)
void sp_cache_insert(sp_cache **cp, sp_head *sp) void sp_cache_insert(sp_cache **cp, sp_head *sp)
{ {
sp_cache *c= *cp; sp_cache *c;
ulong v;
if (!c && (c= new sp_cache())) if (!(c= *cp))
{ {
pthread_mutex_lock(&Cversion_lock); // LOCK if (!(c= new sp_cache()))
c->version= Cversion; return; // End of memory error
pthread_mutex_unlock(&Cversion_lock); // UNLOCK c->version= Cversion; // No need to lock when reading long variable
}
if (c)
{
DBUG_PRINT("info",("sp_cache: inserting: %*s", sp->m_qname.length,
sp->m_qname.str));
c->insert(sp);
if (*cp == NULL)
*cp= c;
} }
DBUG_PRINT("info",("sp_cache: inserting: %*s", sp->m_qname.length,
sp->m_qname.str));
c->insert(sp);
*cp= c; // Update *cp if it was NULL
} }
@ -158,7 +158,7 @@ void sp_cache_insert(sp_cache **cp, sp_head *sp)
sp_head *sp_cache_lookup(sp_cache **cp, sp_name *name) sp_head *sp_cache_lookup(sp_cache **cp, sp_name *name)
{ {
sp_cache *c= *cp; sp_cache *c= *cp;
if (!c) if (! c)
return NULL; return NULL;
return c->lookup(name->m_qname.str, name->m_qname.length); return c->lookup(name->m_qname.str, name->m_qname.length);
} }
@ -178,9 +178,7 @@ sp_head *sp_cache_lookup(sp_cache **cp, sp_name *name)
void sp_cache_invalidate() void sp_cache_invalidate()
{ {
DBUG_PRINT("info",("sp_cache: invalidating")); DBUG_PRINT("info",("sp_cache: invalidating"));
pthread_mutex_lock(&Cversion_lock); // LOCK thread_safe_increment(Cversion, &Cversion_lock);
Cversion++;
pthread_mutex_unlock(&Cversion_lock); // UNLOCK
} }
@ -202,9 +200,7 @@ void sp_cache_flush_obsolete(sp_cache **cp)
if (c) if (c)
{ {
ulong v; ulong v;
pthread_mutex_lock(&Cversion_lock); // LOCK v= Cversion; // No need to lock when reading long variable
v= Cversion;
pthread_mutex_unlock(&Cversion_lock); // UNLOCK
if (c->version < v) if (c->version < v)
{ {
DBUG_PRINT("info",("sp_cache: deleting all functions")); DBUG_PRINT("info",("sp_cache: deleting all functions"));
@ -215,20 +211,20 @@ void sp_cache_flush_obsolete(sp_cache **cp)
} }
} }
/************************************************************************* /*************************************************************************
Internal functions Internal functions
*************************************************************************/ *************************************************************************/
static byte * static byte *hash_get_key_for_sp_head(const byte *ptr, uint *plen,
hash_get_key_for_sp_head(const byte *ptr, uint *plen,
my_bool first) my_bool first)
{ {
sp_head *sp= (sp_head *)ptr; sp_head *sp= (sp_head *)ptr;
*plen= sp->m_qname.length; *plen= sp->m_qname.length;
return (byte*) sp->m_qname.str; return (byte*) sp->m_qname.str;
} }
static void static void
hash_free_sp_head(void *p) hash_free_sp_head(void *p)
{ {
@ -236,16 +232,19 @@ hash_free_sp_head(void *p)
delete sp; delete sp;
} }
sp_cache::sp_cache() sp_cache::sp_cache()
{ {
init(); init();
} }
sp_cache::~sp_cache() sp_cache::~sp_cache()
{ {
hash_free(&m_hashtable); hash_free(&m_hashtable);
} }
void void
sp_cache::init() sp_cache::init()
{ {
@ -254,6 +253,7 @@ sp_cache::init()
version= 0; version= 0;
} }
void void
sp_cache::cleanup() sp_cache::cleanup()
{ {

View File

@ -678,12 +678,14 @@ sp_head::execute(THD *thd)
cleanup_items(i->free_list); cleanup_items(i->free_list);
i->state= Query_arena::EXECUTED; i->state= Query_arena::EXECUTED;
// Check if an exception has occurred and a handler has been found /*
// Note: We havo to check even if ret==0, since warnings (and some Check if an exception has occurred and a handler has been found
// errors don't return a non-zero value. Note: We havo to check even if ret==0, since warnings (and some
// We also have to check even if thd->killed != 0, since some errors don't return a non-zero value.
// errors return with this even when a handler has been found We also have to check even if thd->killed != 0, since some
// (e.g. "bad data"). errors return with this even when a handler has been found
(e.g. "bad data").
*/
if (ctx) if (ctx)
{ {
uint hf; uint hf;
@ -759,8 +761,10 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp)
if (argcount != params) if (argcount != params)
{ {
// Need to use my_printf_error here, or it will not terminate the /*
// invoking query properly. Need to use my_printf_error here, or it will not terminate the
invoking query properly.
*/
my_error(ER_SP_WRONG_NO_OF_ARGS, MYF(0), my_error(ER_SP_WRONG_NO_OF_ARGS, MYF(0),
"FUNCTION", m_qname.str, params, argcount); "FUNCTION", m_qname.str, params, argcount);
DBUG_RETURN(-1); DBUG_RETURN(-1);
@ -784,9 +788,11 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp)
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
} }
// The rest of the frame are local variables which are all IN. /*
// Default all variables to null (those with default clauses will The rest of the frame are local variables which are all IN.
// be set by an set instruction). Default all variables to null (those with default clauses will
be set by an set instruction).
*/
{ {
Item_null *nit= NULL; // Re-use this, and only create if needed Item_null *nit= NULL; // Re-use this, and only create if needed
for (; i < csize ; i++) for (; i < csize ; i++)
@ -803,9 +809,11 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount, Item **resp)
ret= execute(thd); ret= execute(thd);
// Partially restore context now. /*
// We still need the call mem root and free list for processing Partially restore context now.
// of the result. We still need the call mem root and free list for processing
of the result.
*/
thd->restore_backup_item_arena(&call_arena, &backup_arena); thd->restore_backup_item_arena(&call_arena, &backup_arena);
if (m_type == TYPE_ENUM_FUNCTION && ret == 0) if (m_type == TYPE_ENUM_FUNCTION && ret == 0)
@ -932,9 +940,11 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
close_thread_tables(thd, 0, 0); close_thread_tables(thd, 0, 0);
DBUG_PRINT("info",(" %.*s: eval args done", m_name.length, m_name.str)); DBUG_PRINT("info",(" %.*s: eval args done", m_name.length, m_name.str));
// The rest of the frame are local variables which are all IN. /*
// Default all variables to null (those with default clauses will The rest of the frame are local variables which are all IN.
// be set by an set instruction). Default all variables to null (those with default clauses will
be set by an set instruction).
*/
for (; i < csize ; i++) for (; i < csize ; i++)
{ {
if (! nit) if (! nit)
@ -956,8 +966,10 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
List_iterator<Item> li(*args); List_iterator<Item> li(*args);
Item *it; Item *it;
// Copy back all OUT or INOUT values to the previous frame, or /*
// set global user variables Copy back all OUT or INOUT values to the previous frame, or
set global user variables
*/
for (uint i = 0 ; (it= li++) && i < params ; i++) for (uint i = 0 ; (it= li++) && i < params ; i++)
{ {
sp_pvar_t *pvar= m_pcont->find_pvar(i); sp_pvar_t *pvar= m_pcont->find_pvar(i);
@ -987,8 +999,10 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
octx->set_item(offset, copy); octx->set_item(offset, copy);
if (orig && copy == orig) if (orig && copy == orig)
{ {
// A reused item slot, where the constructor put it in the /*
// free_list, so we have to restore the list. A reused item slot, where the constructor put it in the
free_list, so we have to restore the list.
*/
thd->free_list= o_free_list; thd->free_list= o_free_list;
copy->next= o_item_next; copy->next= o_item_next;
} }
@ -1420,8 +1434,6 @@ sp_head::opt_mark(uint ip)
ip= i->opt_mark(this); ip= i->opt_mark(this);
} }
// ------------------------------------------------------------------
/* /*
Prepare LEX and thread for execution of instruction, if requested open Prepare LEX and thread for execution of instruction, if requested open
@ -1513,6 +1525,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp,
thd->proc_info="closing tables"; thd->proc_info="closing tables";
close_thread_tables(thd); close_thread_tables(thd);
thd->proc_info= 0;
if (m_lex->query_tables_own_last) if (m_lex->query_tables_own_last)
{ {
@ -1549,9 +1562,10 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp,
} }
// /*
// sp_instr sp_instr class functions
// */
int sp_instr::exec_core(THD *thd, uint *nextp) int sp_instr::exec_core(THD *thd, uint *nextp)
{ {
DBUG_ASSERT(0); DBUG_ASSERT(0);
@ -1559,9 +1573,10 @@ int sp_instr::exec_core(THD *thd, uint *nextp)
} }
// /*
// sp_instr_stmt sp_instr_stmt class functions
// */
int int
sp_instr_stmt::execute(THD *thd, uint *nextp) sp_instr_stmt::execute(THD *thd, uint *nextp)
{ {
@ -1606,9 +1621,11 @@ sp_instr_stmt::exec_core(THD *thd, uint *nextp)
return res; return res;
} }
//
// sp_instr_set /*
// sp_instr_set class functions
*/
int int
sp_instr_set::execute(THD *thd, uint *nextp) sp_instr_set::execute(THD *thd, uint *nextp)
{ {
@ -1618,6 +1635,7 @@ sp_instr_set::execute(THD *thd, uint *nextp)
DBUG_RETURN(m_lex_keeper.reset_lex_and_exec_core(thd, nextp, TRUE, this)); DBUG_RETURN(m_lex_keeper.reset_lex_and_exec_core(thd, nextp, TRUE, this));
} }
int int
sp_instr_set::exec_core(THD *thd, uint *nextp) sp_instr_set::exec_core(THD *thd, uint *nextp)
{ {
@ -1638,9 +1656,10 @@ sp_instr_set::print(String *str)
} }
// /*
// sp_instr_set_trigger_field sp_instr_set_trigger_field class functions
// */
int int
sp_instr_set_trigger_field::execute(THD *thd, uint *nextp) sp_instr_set_trigger_field::execute(THD *thd, uint *nextp)
{ {
@ -1671,9 +1690,11 @@ sp_instr_set_trigger_field::print(String *str)
value->print(str); value->print(str);
} }
//
// sp_instr_jump /*
// sp_instr_jump class functions
*/
int int
sp_instr_jump::execute(THD *thd, uint *nextp) sp_instr_jump::execute(THD *thd, uint *nextp)
{ {
@ -1732,9 +1753,10 @@ sp_instr_jump::opt_move(uint dst, List<sp_instr> *bp)
m_ip= dst; m_ip= dst;
} }
//
// sp_instr_jump_if /*
// sp_instr_jump_if class functions
*/
int int
sp_instr_jump_if::execute(THD *thd, uint *nextp) sp_instr_jump_if::execute(THD *thd, uint *nextp)
@ -1790,9 +1812,11 @@ sp_instr_jump_if::opt_mark(sp_head *sp)
return m_ip+1; return m_ip+1;
} }
//
// sp_instr_jump_if_not /*
// sp_instr_jump_if_not class functions
*/
int int
sp_instr_jump_if_not::execute(THD *thd, uint *nextp) sp_instr_jump_if_not::execute(THD *thd, uint *nextp)
{ {
@ -1823,6 +1847,7 @@ sp_instr_jump_if_not::exec_core(THD *thd, uint *nextp)
return res; return res;
} }
void void
sp_instr_jump_if_not::print(String *str) sp_instr_jump_if_not::print(String *str)
{ {
@ -1833,6 +1858,7 @@ sp_instr_jump_if_not::print(String *str)
m_expr->print(str); m_expr->print(str);
} }
uint uint
sp_instr_jump_if_not::opt_mark(sp_head *sp) sp_instr_jump_if_not::opt_mark(sp_head *sp)
{ {
@ -1848,9 +1874,10 @@ sp_instr_jump_if_not::opt_mark(sp_head *sp)
return m_ip+1; return m_ip+1;
} }
//
// sp_instr_freturn /*
// sp_instr_freturn class functions
*/
int int
sp_instr_freturn::execute(THD *thd, uint *nextp) sp_instr_freturn::execute(THD *thd, uint *nextp)
@ -1889,9 +1916,10 @@ sp_instr_freturn::print(String *str)
m_value->print(str); m_value->print(str);
} }
// /*
// sp_instr_hpush_jump sp_instr_hpush_jump class functions
// */
int int
sp_instr_hpush_jump::execute(THD *thd, uint *nextp) sp_instr_hpush_jump::execute(THD *thd, uint *nextp)
{ {
@ -1935,9 +1963,11 @@ sp_instr_hpush_jump::opt_mark(sp_head *sp)
return m_ip+1; return m_ip+1;
} }
//
// sp_instr_hpop /*
// sp_instr_hpop class functions
*/
int int
sp_instr_hpop::execute(THD *thd, uint *nextp) sp_instr_hpop::execute(THD *thd, uint *nextp)
{ {
@ -1962,9 +1992,10 @@ sp_instr_hpop::backpatch(uint dest, sp_pcontext *dst_ctx)
} }
// /*
// sp_instr_hreturn sp_instr_hreturn class functions
// */
int int
sp_instr_hreturn::execute(THD *thd, uint *nextp) sp_instr_hreturn::execute(THD *thd, uint *nextp)
{ {
@ -1980,6 +2011,7 @@ sp_instr_hreturn::execute(THD *thd, uint *nextp)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
void void
sp_instr_hreturn::print(String *str) sp_instr_hreturn::print(String *str)
{ {
@ -1990,6 +2022,7 @@ sp_instr_hreturn::print(String *str)
str->qs_append(m_dest); str->qs_append(m_dest);
} }
uint uint
sp_instr_hreturn::opt_mark(sp_head *sp) sp_instr_hreturn::opt_mark(sp_head *sp)
{ {
@ -2003,9 +2036,10 @@ sp_instr_hreturn::opt_mark(sp_head *sp)
} }
// /*
// sp_instr_cpush sp_instr_cpush class functions
// */
int int
sp_instr_cpush::execute(THD *thd, uint *nextp) sp_instr_cpush::execute(THD *thd, uint *nextp)
{ {
@ -2015,15 +2049,18 @@ sp_instr_cpush::execute(THD *thd, uint *nextp)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
void void
sp_instr_cpush::print(String *str) sp_instr_cpush::print(String *str)
{ {
str->append("cpush"); str->append("cpush");
} }
//
// sp_instr_cpop /*
// sp_instr_cpop class functions
*/
int int
sp_instr_cpop::execute(THD *thd, uint *nextp) sp_instr_cpop::execute(THD *thd, uint *nextp)
{ {
@ -2033,6 +2070,7 @@ sp_instr_cpop::execute(THD *thd, uint *nextp)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
void void
sp_instr_cpop::print(String *str) sp_instr_cpop::print(String *str)
{ {
@ -2047,9 +2085,11 @@ sp_instr_cpop::backpatch(uint dest, sp_pcontext *dst_ctx)
m_count= m_ctx->diff_cursors(dst_ctx); m_count= m_ctx->diff_cursors(dst_ctx);
} }
//
// sp_instr_copen /*
// sp_instr_copen class functions
*/
int int
sp_instr_copen::execute(THD *thd, uint *nextp) sp_instr_copen::execute(THD *thd, uint *nextp)
{ {
@ -2117,9 +2157,11 @@ sp_instr_copen::print(String *str)
str->qs_append(m_cursor); str->qs_append(m_cursor);
} }
//
// sp_instr_cclose /*
// sp_instr_cclose class functions
*/
int int
sp_instr_cclose::execute(THD *thd, uint *nextp) sp_instr_cclose::execute(THD *thd, uint *nextp)
{ {
@ -2135,6 +2177,7 @@ sp_instr_cclose::execute(THD *thd, uint *nextp)
DBUG_RETURN(res); DBUG_RETURN(res);
} }
void void
sp_instr_cclose::print(String *str) sp_instr_cclose::print(String *str)
{ {
@ -2143,9 +2186,11 @@ sp_instr_cclose::print(String *str)
str->qs_append(m_cursor); str->qs_append(m_cursor);
} }
//
// sp_instr_cfetch /*
// sp_instr_cfetch class functions
*/
int int
sp_instr_cfetch::execute(THD *thd, uint *nextp) sp_instr_cfetch::execute(THD *thd, uint *nextp)
{ {
@ -2161,6 +2206,7 @@ sp_instr_cfetch::execute(THD *thd, uint *nextp)
DBUG_RETURN(res); DBUG_RETURN(res);
} }
void void
sp_instr_cfetch::print(String *str) sp_instr_cfetch::print(String *str)
{ {
@ -2178,9 +2224,11 @@ sp_instr_cfetch::print(String *str)
} }
} }
//
// sp_instr_error /*
// sp_instr_error class functions
*/
int int
sp_instr_error::execute(THD *thd, uint *nextp) sp_instr_error::execute(THD *thd, uint *nextp)
{ {
@ -2191,6 +2239,7 @@ sp_instr_error::execute(THD *thd, uint *nextp)
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
void void
sp_instr_error::print(String *str) sp_instr_error::print(String *str)
{ {
@ -2199,12 +2248,12 @@ sp_instr_error::print(String *str)
str->qs_append(m_errcode); str->qs_append(m_errcode);
} }
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/*
// Security context swapping
// Security context swapping */
//
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
void void
@ -2453,11 +2502,12 @@ sp_head::add_used_tables_to_table_list(THD *thd,
DBUG_RETURN(result); DBUG_RETURN(result);
} }
/* /*
* Simple function for adding an explicetly named (systems) table to Simple function for adding an explicetly named (systems) table to
* the global table list, e.g. "mysql", "proc". the global table list, e.g. "mysql", "proc".
* */
*/
TABLE_LIST * TABLE_LIST *
sp_add_to_query_tables(THD *thd, LEX *lex, sp_add_to_query_tables(THD *thd, LEX *lex,
const char *db, const char *name, const char *db, const char *name,

View File

@ -1921,8 +1921,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
has added its base tables after itself, adjust the boundary pointer has added its base tables after itself, adjust the boundary pointer
accordingly. accordingly.
*/ */
if (query_tables_last_own && if (query_tables_last_own == &(tables->next_global) &&
query_tables_last_own == &(tables->next_global) &&
tables->view->query_tables) tables->view->query_tables)
query_tables_last_own= tables->view->query_tables_last; query_tables_last_own= tables->view->query_tables_last;

View File

@ -1246,7 +1246,8 @@ public:
update auto-updatable fields (like auto_increment and timestamp). update auto-updatable fields (like auto_increment and timestamp).
*/ */
query_id_t query_id, warn_id; query_id_t query_id, warn_id;
ulong options, thread_id, col_access; ulonglong options;
ulong thread_id, col_access;
/* Statement id is thread-wide. This counter is used to generate ids */ /* Statement id is thread-wide. This counter is used to generate ids */
ulong statement_id_counter; ulong statement_id_counter;
@ -1498,7 +1499,7 @@ public:
#define tmp_disable_binlog(A) \ #define tmp_disable_binlog(A) \
{ulong tmp_disable_binlog__save_options= (A)->options; \ {ulonglong tmp_disable_binlog__save_options= (A)->options; \
(A)->options&= ~OPTION_BIN_LOG (A)->options&= ~OPTION_BIN_LOG
#define reenable_binlog(A) (A)->options= tmp_disable_binlog__save_options;} #define reenable_binlog(A) (A)->options= tmp_disable_binlog__save_options;}

View File

@ -30,7 +30,7 @@
#include "sql_trigger.h" #include "sql_trigger.h"
bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
SQL_LIST *order, ha_rows limit, ulong options) SQL_LIST *order, ha_rows limit, ulonglong options)
{ {
int error; int error;
TABLE *table; TABLE *table;
@ -807,7 +807,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok)
ha_enable_transaction(thd, FALSE); ha_enable_transaction(thd, FALSE);
mysql_init_select(thd->lex); mysql_init_select(thd->lex);
error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0, error= mysql_delete(thd, table_list, (COND*) 0, (SQL_LIST*) 0,
HA_POS_ERROR, 0); HA_POS_ERROR, LL(0));
ha_enable_transaction(thd, TRUE); ha_enable_transaction(thd, TRUE);
thd->options= save_options; thd->options= save_options;
DBUG_RETURN(error); DBUG_RETURN(error);

View File

@ -142,8 +142,7 @@ int mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *orig_table_list)
unit->types, (ORDER*) 0, unit->types, (ORDER*) 0,
FALSE, 1, FALSE, 1,
(first_select->options | thd->options | (first_select->options | thd->options |
TMP_TABLE_ALL_COLUMNS) & TMP_TABLE_ALL_COLUMNS),
~TMP_TABLE_FORCE_MYISAM,
HA_POS_ERROR, HA_POS_ERROR,
orig_table_list->alias))) orig_table_list->alias)))
{ {

View File

@ -305,7 +305,7 @@ protected:
*link_next, **link_prev; /* list of whole SELECT_LEX */ *link_next, **link_prev; /* list of whole SELECT_LEX */
public: public:
ulong options; ulonglong options;
/* /*
result of this query can't be cached, bit field, can be : result of this query can't be cached, bit field, can be :
UNCACHEABLE_DEPENDENT UNCACHEABLE_DEPENDENT

View File

@ -1863,17 +1863,18 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
} }
#endif #endif
case COM_REFRESH: case COM_REFRESH:
{ {
statistic_increment(thd->status_var.com_stat[SQLCOM_FLUSH], bool not_used;
&LOCK_status); statistic_increment(thd->status_var.com_stat[SQLCOM_FLUSH],
ulong options= (ulong) (uchar) packet[0]; &LOCK_status);
if (check_global_access(thd,RELOAD_ACL)) ulong options= (ulong) (uchar) packet[0];
break; if (check_global_access(thd,RELOAD_ACL))
mysql_log.write(thd,command,NullS);
if (!reload_acl_and_cache(thd, options, (TABLE_LIST*) 0, NULL))
send_ok(thd);
break; break;
} mysql_log.write(thd,command,NullS);
if (!reload_acl_and_cache(thd, options, (TABLE_LIST*) 0, &not_used))
send_ok(thd);
break;
}
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
case COM_SHUTDOWN: case COM_SHUTDOWN:
{ {
@ -2942,8 +2943,8 @@ end_with_restore_list:
*/ */
if (thd->locked_tables || thd->active_transaction()) if (thd->locked_tables || thd->active_transaction())
{ {
my_message(ER_LOCK_OR_ACTIVE_TRANSACTION, ER(ER_LOCK_OR_ACTIVE_TRANSACTION), my_message(ER_LOCK_OR_ACTIVE_TRANSACTION,
MYF(0)); ER(ER_LOCK_OR_ACTIVE_TRANSACTION), MYF(0));
goto error; goto error;
} }
{ {
@ -3822,13 +3823,13 @@ end_with_restore_list:
lex->no_write_to_binlog= 1; lex->no_write_to_binlog= 1;
case SQLCOM_FLUSH: case SQLCOM_FLUSH:
{ {
bool write_to_binlog;
if (check_global_access(thd,RELOAD_ACL) || check_db_used(thd, all_tables)) if (check_global_access(thd,RELOAD_ACL) || check_db_used(thd, all_tables))
goto error; goto error;
/* /*
reload_acl_and_cache() will tell us if we are allowed to write to the reload_acl_and_cache() will tell us if we are allowed to write to the
binlog or not. binlog or not.
*/ */
bool write_to_binlog;
if (!reload_acl_and_cache(thd, lex->type, first_table, &write_to_binlog)) if (!reload_acl_and_cache(thd, lex->type, first_table, &write_to_binlog))
{ {
/* /*
@ -6379,13 +6380,13 @@ void add_join_natural(TABLE_LIST *a,TABLE_LIST *b)
tables Tables to flush (if any) tables Tables to flush (if any)
write_to_binlog Depending on 'options', it may be very bad to write the write_to_binlog Depending on 'options', it may be very bad to write the
query to the binlog (e.g. FLUSH SLAVE); this is a query to the binlog (e.g. FLUSH SLAVE); this is a
pointer where, if it is not NULL, reload_acl_and_cache() pointer where reload_acl_and_cache() will put 0 if
will put 0 if it thinks we really should not write to it thinks we really should not write to the binlog.
the binlog. Otherwise it will put 1. Otherwise it will put 1.
RETURN RETURN
0 ok 0 ok
!=0 error !=0 error. thd->killed or thd->net.report_error is set
*/ */
bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
@ -6480,10 +6481,10 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
*/ */
tmp_write_to_binlog= 0; tmp_write_to_binlog= 0;
if (lock_global_read_lock(thd)) if (lock_global_read_lock(thd))
return 1; return 1; // Killed
result=close_cached_tables(thd,(options & REFRESH_FAST) ? 0 : 1, result=close_cached_tables(thd,(options & REFRESH_FAST) ? 0 : 1,
tables); tables);
if (make_global_read_lock_block_commit(thd)) if (make_global_read_lock_block_commit(thd)) // Killed
{ {
/* Don't leave things in a half-locked state */ /* Don't leave things in a half-locked state */
unlock_global_read_lock(thd); unlock_global_read_lock(thd);
@ -6505,7 +6506,10 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
{ {
tmp_write_to_binlog= 0; tmp_write_to_binlog= 0;
if (reset_master(thd)) if (reset_master(thd))
{
result=1; result=1;
thd->fatal_error(); // Ensure client get error
}
} }
#endif #endif
#ifdef OPENSSL #ifdef OPENSSL
@ -6527,8 +6531,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
#endif #endif
if (options & REFRESH_USER_RESOURCES) if (options & REFRESH_USER_RESOURCES)
reset_mqh((LEX_USER *) NULL); reset_mqh((LEX_USER *) NULL);
if (write_to_binlog) *write_to_binlog= tmp_write_to_binlog;
*write_to_binlog= tmp_write_to_binlog;
return result; return result;
} }

View File

@ -1016,7 +1016,7 @@ JOIN::optimize()
group_list : (ORDER*) 0), group_list : (ORDER*) 0),
group_list ? 0 : select_distinct, group_list ? 0 : select_distinct,
group_list && simple_group, group_list && simple_group,
select_options & ~TMP_TABLE_FORCE_MYISAM, select_options,
(order == 0 || skip_sort_order) ? select_limit : (order == 0 || skip_sort_order) ? select_limit :
HA_POS_ERROR, HA_POS_ERROR,
(char *) ""))) (char *) "")))
@ -1287,7 +1287,15 @@ JOIN::exec()
if (need_tmp) if (need_tmp)
{ {
if (tmp_join) if (tmp_join)
{
/*
We are in a non cacheable sub query. Get the saved join structure
after optimization.
(curr_join may have been modified during last exection and we need
to reset it)
*/
curr_join= tmp_join; curr_join= tmp_join;
}
curr_tmp_table= exec_tmp_table1; curr_tmp_table= exec_tmp_table1;
/* Copy data to the temporary table */ /* Copy data to the temporary table */
@ -1397,8 +1405,7 @@ JOIN::exec()
(ORDER*) 0, (ORDER*) 0,
curr_join->select_distinct && curr_join->select_distinct &&
!curr_join->group_list, !curr_join->group_list,
1, curr_join->select_options 1, curr_join->select_options,
& ~TMP_TABLE_FORCE_MYISAM,
HA_POS_ERROR, HA_POS_ERROR,
(char *) ""))) (char *) "")))
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
@ -8128,7 +8135,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
TABLE * TABLE *
create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
ORDER *group, bool distinct, bool save_sum_fields, ORDER *group, bool distinct, bool save_sum_fields,
ulong select_options, ha_rows rows_limit, ulonglong select_options, ha_rows rows_limit,
char *table_alias) char *table_alias)
{ {
TABLE *table; TABLE *table;
@ -8382,7 +8389,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
/* If result table is small; use a heap */ /* If result table is small; use a heap */
if (blob_count || using_unique_constraint || if (blob_count || using_unique_constraint ||
(select_options & (OPTION_BIG_TABLES | SELECT_SMALL_RESULT)) == (select_options & (OPTION_BIG_TABLES | SELECT_SMALL_RESULT)) ==
OPTION_BIG_TABLES ||(select_options & TMP_TABLE_FORCE_MYISAM)) OPTION_BIG_TABLES || (select_options & TMP_TABLE_FORCE_MYISAM))
{ {
table->file=get_new_handler(table,table->s->db_type= DB_TYPE_MYISAM); table->file=get_new_handler(table,table->s->db_type= DB_TYPE_MYISAM);
if (group && if (group &&

View File

@ -202,7 +202,7 @@ class JOIN :public Sql_alloc
Item *having; Item *having;
Item *tmp_having; // To store having when processed temporary table Item *tmp_having; // To store having when processed temporary table
Item *having_history; // Store having for explain Item *having_history; // Store having for explain
uint select_options; ulonglong select_options;
select_result *result; select_result *result;
TMP_TABLE_PARAM tmp_table_param; TMP_TABLE_PARAM tmp_table_param;
MYSQL_LOCK *lock; MYSQL_LOCK *lock;
@ -258,14 +258,14 @@ class JOIN :public Sql_alloc
bool union_part; // this subselect is part of union bool union_part; // this subselect is part of union
bool optimized; // flag to avoid double optimization in EXPLAIN bool optimized; // flag to avoid double optimization in EXPLAIN
JOIN(THD *thd_arg, List<Item> &fields_arg, ulong select_options_arg, JOIN(THD *thd_arg, List<Item> &fields_arg, ulonglong select_options_arg,
select_result *result_arg) select_result *result_arg)
:fields_list(fields_arg) :fields_list(fields_arg)
{ {
init(thd_arg, fields_arg, select_options_arg, result_arg); init(thd_arg, fields_arg, select_options_arg, result_arg);
} }
void init(THD *thd_arg, List<Item> &fields_arg, ulong select_options_arg, void init(THD *thd_arg, List<Item> &fields_arg, ulonglong select_options_arg,
select_result *result_arg) select_result *result_arg)
{ {
join_tab= join_tab_save= 0; join_tab= join_tab_save= 0;
@ -437,7 +437,7 @@ void TEST_join(JOIN *join);
bool store_val_in_field(Field *field,Item *val); bool store_val_in_field(Field *field,Item *val);
TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
ORDER *group, bool distinct, bool save_sum_fields, ORDER *group, bool distinct, bool save_sum_fields,
ulong select_options, ha_rows rows_limit, ulonglong select_options, ha_rows rows_limit,
char* alias); char* alias);
TABLE *create_virtual_tmp_table(THD *thd, List<create_field> &field_list); TABLE *create_virtual_tmp_table(THD *thd, List<create_field> &field_list);
void free_tmp_table(THD *thd, TABLE *entry); void free_tmp_table(THD *thd, TABLE *entry);

View File

@ -3332,8 +3332,7 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list)
if (!(table= create_tmp_table(thd, tmp_table_param, if (!(table= create_tmp_table(thd, tmp_table_param,
field_list, (ORDER*) 0, 0, 0, field_list, (ORDER*) 0, 0, 0,
(select_lex->options | thd->options | (select_lex->options | thd->options |
TMP_TABLE_ALL_COLUMNS) & TMP_TABLE_ALL_COLUMNS),
~TMP_TABLE_FORCE_MYISAM,
HA_POS_ERROR, table_list->alias))) HA_POS_ERROR, table_list->alias)))
DBUG_RETURN(0); DBUG_RETURN(0);
table_list->schema_table_param= tmp_table_param; table_list->schema_table_param= tmp_table_param;

View File

@ -289,7 +289,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
List_iterator_fast<Item> tp(types); List_iterator_fast<Item> tp(types);
Query_arena *arena= thd->current_arena; Query_arena *arena= thd->current_arena;
Item *type; Item *type;
ulong create_options; ulonglong create_options;
while ((type= tp++)) while ((type= tp++))
{ {
@ -302,7 +302,7 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
} }
create_options= (first_select_in_union()->options | thd_arg->options | create_options= (first_select_in_union()->options | thd_arg->options |
TMP_TABLE_ALL_COLUMNS) & ~TMP_TABLE_FORCE_MYISAM; TMP_TABLE_ALL_COLUMNS);
/* /*
Force the temporary table to be a MyISAM table if we're going to use Force the temporary table to be a MyISAM table if we're going to use
fullext functions (MATCH ... AGAINST .. IN BOOLEAN MODE) when reading fullext functions (MATCH ... AGAINST .. IN BOOLEAN MODE) when reading

View File

@ -811,7 +811,7 @@ bool mysql_multi_update(THD *thd,
List<Item> *fields, List<Item> *fields,
List<Item> *values, List<Item> *values,
COND *conds, COND *conds,
ulong options, ulonglong options,
enum enum_duplicates handle_duplicates, bool ignore, enum enum_duplicates handle_duplicates, bool ignore,
SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex) SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex)
{ {

View File

@ -7752,7 +7752,8 @@ sys_option_value:
/* We are in trigger and assigning value to field of new row */ /* We are in trigger and assigning value to field of new row */
Item *it; Item *it;
Item_trigger_field *trg_fld; Item_trigger_field *trg_fld;
sp_instr_set_trigger_field *i; sp_instr_set_trigger_field *sp_fld;
LINT_INIT(sp_fld);
if ($1) if ($1)
{ {
yyerror(ER(ER_SYNTAX_ERROR)); yyerror(ER(ER_SYNTAX_ERROR));
@ -7770,10 +7771,11 @@ sys_option_value:
context, context,
Item_trigger_field::NEW_ROW, Item_trigger_field::NEW_ROW,
$2.base_name.str)) || $2.base_name.str)) ||
!(i= new sp_instr_set_trigger_field(lex->sphead-> !(sp_fld= new sp_instr_set_trigger_field(lex->sphead->
instructions(), instructions(),
lex->spcont, trg_fld, lex->spcont,
it, lex))) trg_fld,
it, lex)))
YYABORT; YYABORT;
/* /*
@ -7783,7 +7785,7 @@ sys_option_value:
lex->trg_table_fields.link_in_list((byte *)trg_fld, lex->trg_table_fields.link_in_list((byte *)trg_fld,
(byte **)&trg_fld->next_trg_field); (byte **)&trg_fld->next_trg_field);
lex->sphead->add_instr(i); lex->sphead->add_instr(sp_fld);
} }
else if ($2.var) else if ($2.var)
{ /* System variable */ { /* System variable */
@ -7797,7 +7799,7 @@ sys_option_value:
/* An SP local variable */ /* An SP local variable */
sp_pcontext *ctx= lex->spcont; sp_pcontext *ctx= lex->spcont;
sp_pvar_t *spv; sp_pvar_t *spv;
sp_instr_set *i; sp_instr_set *sp_set;
Item *it; Item *it;
if ($1) if ($1)
{ {
@ -7813,9 +7815,9 @@ sys_option_value:
it= spv->dflt; it= spv->dflt;
else else
it= new Item_null(); it= new Item_null();
i= new sp_instr_set(lex->sphead->instructions(), ctx, sp_set= new sp_instr_set(lex->sphead->instructions(), ctx,
spv->offset, it, spv->type, lex, TRUE); spv->offset, it, spv->type, lex, TRUE);
lex->sphead->add_instr(i); lex->sphead->add_instr(sp_set);
spv->isset= TRUE; spv->isset= TRUE;
} }
} }