Commit 9036233c authored by unknown's avatar unknown

automatic merge

parents d270325a 1177bea2
No related merge requests found
......@@ -112,7 +112,7 @@ static my_bool display_result_vertically= FALSE, display_result_lower= FALSE,
display_metadata= FALSE, display_result_sorted= FALSE;
static my_bool disable_query_log= 0, disable_result_log= 0;
static my_bool disable_connect_log= 1;
static my_bool disable_warnings= 0;
static my_bool disable_warnings= 0, disable_column_names= 0;
static my_bool prepare_warnings_enabled= 0;
static my_bool disable_info= 1;
static my_bool abort_on_error= 1;
......@@ -298,6 +298,7 @@ enum enum_commands {
Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS,
Q_ENABLE_INFO, Q_DISABLE_INFO,
Q_ENABLE_METADATA, Q_DISABLE_METADATA,
Q_ENABLE_COLUMN_NAMES, Q_DISABLE_COLUMN_NAMES,
Q_EXEC, Q_DELIMITER,
Q_DISABLE_ABORT_ON_ERROR, Q_ENABLE_ABORT_ON_ERROR,
Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS,
......@@ -371,6 +372,8 @@ const char *command_names[]=
"disable_info",
"enable_metadata",
"disable_metadata",
"enable_column_names",
"disable_column_names",
"exec",
"delimiter",
"disable_abort_on_error",
......@@ -6837,6 +6840,8 @@ void append_table_headings(DYNAMIC_STRING *ds,
uint num_fields)
{
uint col_idx;
if (disable_column_names)
return;
for (col_idx= 0; col_idx < num_fields; col_idx++)
{
if (col_idx)
......@@ -8349,6 +8354,14 @@ int main(int argc, char **argv)
display_metadata= 0;
var_set_int("$ENABLED_METADATA", 0);
break;
case Q_ENABLE_COLUMN_NAMES:
disable_column_names= 0;
var_set_int("$ENABLED_COLUMN_NAMES", 0);
break;
case Q_DISABLE_COLUMN_NAMES:
disable_column_names= 1;
var_set_int("$ENABLED_COLUMN_NAMES", 1);
break;
case Q_SOURCE: do_source(command); break;
case Q_SLEEP: do_sleep(command, 0); break;
case Q_REAL_SLEEP: do_sleep(command, 1); break;
......
......@@ -148,7 +148,8 @@ enum my_lex_states
MY_LEX_USER_VARIABLE_DELIMITER, MY_LEX_SYSTEM_VAR,
MY_LEX_IDENT_OR_KEYWORD,
MY_LEX_IDENT_OR_HEX, MY_LEX_IDENT_OR_BIN, MY_LEX_IDENT_OR_NCHAR,
MY_LEX_STRING_OR_DELIMITER
MY_LEX_STRING_OR_DELIMITER, MY_LEX_MINUS_OR_COMMENT, MY_LEX_PLACEHOLDER,
MY_LEX_COMMA
};
struct charset_info_st;
......
......@@ -174,7 +174,7 @@ Variable_name Value
Qcache_hits 7
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 7
Qcache_not_cached 4
----- establish connection user4 (user=mysqltest_1) -----
select "user4";
user4
......@@ -205,7 +205,7 @@ Variable_name Value
Qcache_hits 8
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 8
Qcache_not_cached 5
----- close connections -----
----- switch to connection default -----
set names binary;
......
......@@ -174,7 +174,7 @@ Variable_name Value
Qcache_hits 7
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 4
Qcache_not_cached 3
----- establish connection user4 (user=mysqltest_1) -----
select "user4";
user4
......@@ -205,7 +205,7 @@ Variable_name Value
Qcache_hits 8
show status like "Qcache_not_cached";
Variable_name Value
Qcache_not_cached 5
Qcache_not_cached 4
----- close connections -----
----- switch to connection default -----
set names binary;
......
......@@ -1639,6 +1639,7 @@ set GLOBAL query_cache_type=default;
set GLOBAL query_cache_limit=default;
set GLOBAL query_cache_min_res_unit=default;
set GLOBAL query_cache_size=default;
set local query_cache_type=default;
FLUSH STATUS;
SET GLOBAL query_cache_size=10*1024*1024;
SET @save_concurrent_insert= @@concurrent_insert;
......@@ -1823,3 +1824,33 @@ SELECT 1 FROM t1 GROUP BY
DROP TABLE t1;
SET GLOBAL query_cache_size= default;
End of 5.1 tests
New query cache switching OFF mechanism test
set global query_cache_size=1024*1024*20;
set global query_cache_type=on;
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
@@query_cache_size @@global.query_cache_type @@local.query_cache_type
20971520 ON ON
set global query_cache_size=0;
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
@@query_cache_size @@global.query_cache_type @@local.query_cache_type
0 ON ON
set global query_cache_size=1024*1024*20;
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
@@query_cache_size @@global.query_cache_type @@local.query_cache_type
20971520 ON ON
set global query_cache_type=off;
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
@@query_cache_size @@global.query_cache_type @@local.query_cache_type
20971520 OFF OFF
set global query_cache_type=on;
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
@@query_cache_size @@global.query_cache_type @@local.query_cache_type
20971520 ON OFF
set local query_cache_type= on;
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
@@query_cache_size @@global.query_cache_type @@local.query_cache_type
20971520 ON ON
restore defaults
SET GLOBAL query_cache_type= default;
SET GLOBAL query_cache_size= default;
SET LOCAL query_cache_type= default;
......@@ -1255,6 +1255,7 @@ set GLOBAL query_cache_type=default;
set GLOBAL query_cache_limit=default;
set GLOBAL query_cache_min_res_unit=default;
set GLOBAL query_cache_size=default;
set local query_cache_type=default;
#
# Bug#33756 - query cache with concurrent_insert=0 appears broken
......@@ -1515,3 +1516,23 @@ SET GLOBAL query_cache_size= default;
--echo End of 5.1 tests
--echo New query cache switching OFF mechanism test
set global query_cache_size=1024*1024*20;
set global query_cache_type=on;
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
set global query_cache_size=0;
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
set global query_cache_size=1024*1024*20;
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
set global query_cache_type=off;
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
set global query_cache_type=on;
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
set local query_cache_type= on;
select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type;
--echo restore defaults
SET GLOBAL query_cache_type= default;
SET GLOBAL query_cache_size= default;
SET LOCAL query_cache_type= default;
......@@ -97,6 +97,9 @@ static my_bool init_state_maps(struct charset_info_st *cs)
state_map[(uchar)'@']= (uchar) MY_LEX_USER_END;
state_map[(uchar) '`']= (uchar) MY_LEX_USER_VARIABLE_DELIMITER;
state_map[(uchar)'"']= (uchar) MY_LEX_STRING_OR_DELIMITER;
state_map[(uchar)'-']= (uchar) MY_LEX_MINUS_OR_COMMENT;
state_map[(uchar)',']= (uchar) MY_LEX_COMMA;
state_map[(uchar)'?']= (uchar) MY_LEX_PLACEHOLDER;
/*
Create a second map to make it faster to find identifiers
......
......@@ -1311,7 +1311,7 @@ commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans, bool is_real_trans)
{
#ifdef HAVE_QUERY_CACHE
if (thd->transaction.changed_tables)
query_cache.invalidate(thd->transaction.changed_tables);
query_cache.invalidate(thd, thd->transaction.changed_tables);
#endif
thd->variables.tx_isolation=thd->session_tx_isolation;
}
......
......@@ -7964,7 +7964,7 @@ int Rows_log_event::do_apply_event(Relay_log_info const *rli)
const_cast<Relay_log_info*>(rli)->m_table_map.set_table(ptr->table_id, ptr->table);
}
#ifdef HAVE_QUERY_CACHE
query_cache.invalidate_locked_for_write(rli->tables_to_lock);
query_cache.invalidate_locked_for_write(thd, rli->tables_to_lock);
#endif
}
......
......@@ -137,7 +137,7 @@ Old_rows_log_event::do_apply_event(Old_rows_log_event *ev, const Relay_log_info
const_cast<Relay_log_info*>(rli)->m_table_map.set_table(ptr->table_id, ptr->table);
}
#ifdef HAVE_QUERY_CACHE
query_cache.invalidate_locked_for_write(rli->tables_to_lock);
query_cache.invalidate_locked_for_write(thd, rli->tables_to_lock);
#endif
}
......@@ -1636,7 +1636,7 @@ int Old_rows_log_event::do_apply_event(Relay_log_info const *rli)
const_cast<Relay_log_info*>(rli)->m_table_map.set_table(ptr->table_id, ptr->table);
}
#ifdef HAVE_QUERY_CACHE
query_cache.invalidate_locked_for_write(rli->tables_to_lock);
query_cache.invalidate_locked_for_write(thd, rli->tables_to_lock);
#endif
}
......
......@@ -989,7 +989,7 @@ struct Query_cache_query_flags
#define query_cache_resize(A) query_cache.resize(A)
#define query_cache_set_min_res_unit(A) query_cache.set_min_res_unit(A)
#define query_cache_invalidate3(A, B, C) query_cache.invalidate(A, B, C)
#define query_cache_invalidate1(A) query_cache.invalidate(A)
#define query_cache_invalidate1(A,B) query_cache.invalidate(A,B)
#define query_cache_send_result_to_client(A, B, C) \
query_cache.send_result_to_client(A, B, C)
#define query_cache_invalidate_by_MyISAM_filename_ref \
......@@ -1011,9 +1011,8 @@ struct Query_cache_query_flags
#define query_cache_invalidate1(A) do { } while(0)
#define query_cache_send_result_to_client(A, B, C) 0
#define query_cache_invalidate_by_MyISAM_filename_ref NULL
#define query_cache_abort(A)
#define query_cache_end_of_result(A)
#define query_cache_abort(A) do { } while(0)
#define query_cache_end_of_result(A) do { } while(0)
#define query_cache_maybe_disabled(T) 1
#define query_cache_is_cacheable_query(L) 0
#endif /*HAVE_QUERY_CACHE*/
......@@ -2145,6 +2144,7 @@ extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs;
extern my_bool opt_secure_auth, debug_assert_if_crashed_table;
extern char* opt_secure_file_priv;
extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
extern my_bool opt_query_cache_strip_comments;
extern my_bool sp_automatic_privileges, opt_noacl;
extern my_bool opt_old_style_user_limits, trust_function_creators;
extern uint opt_crash_binlog_innodb;
......
......@@ -587,6 +587,7 @@ my_bool opt_secure_auth= 0;
char* opt_secure_file_priv= 0;
my_bool opt_log_slow_admin_statements= 0;
my_bool opt_log_slow_slave_statements= 0;
my_bool opt_query_cache_strip_comments = 0;
my_bool lower_case_file_system= 0;
my_bool opt_large_pages= 0;
my_bool opt_myisam_use_mmap= 0;
......@@ -6113,7 +6114,8 @@ enum options_mysqld
OPT_DEFAULT_CHARACTER_SET_OLD,
OPT_MAX_LONG_DATA_SIZE,
OPT_MASTER_VERIFY_CHECKSUM,
OPT_SLAVE_SQL_VERIFY_CHECKSUM
OPT_SLAVE_SQL_VERIFY_CHECKSUM,
OPT_QUERY_CACHE_STRIP_COMMENTS
};
......@@ -7552,6 +7554,13 @@ each time the SQL thread starts.",
&query_cache_size, &query_cache_size, 0, GET_ULONG,
REQUIRED_ARG, 0, 0, (longlong) ULONG_MAX, 0, 1024, 0},
#ifdef HAVE_QUERY_CACHE
{"query_cache_strip_comments", OPT_QUERY_CACHE_STRIP_COMMENTS,
"Enable and disable optimisation \"strip comment for query cache\" - "
"optimisation strip all comments from query while search query result "
"in query cache",
(uchar**) &opt_query_cache_strip_comments,
(uchar**) &opt_query_cache_strip_comments,
0, GET_BOOL, REQUIRED_ARG, 0, 0, 1, 0, 1, 0},
{"query_cache_type", OPT_QUERY_CACHE_TYPE,
"0 = OFF = Don't cache or retrieve results. 1 = ON = Cache all results "
"except SELECT SQL_NO_CACHE ... queries. 2 = DEMAND = Cache only SELECT "
......
......@@ -128,9 +128,11 @@ static void fix_net_read_timeout(THD *thd, enum_var_type type);
static void fix_net_write_timeout(THD *thd, enum_var_type type);
static void fix_net_retry_count(THD *thd, enum_var_type type);
static void fix_max_join_size(THD *thd, enum_var_type type);
static void fix_query_cache_size(THD *thd, enum_var_type type);
#ifdef HAVE_QUERY_CACHE
static void fix_query_cache_size(THD *thd, enum_var_type type);
static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type);
static int check_query_cache_type(THD *thd, set_var *var);
static void fix_query_cache_type(THD *thd, enum_var_type type);
#endif
static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
static void fix_max_binlog_size(THD *thd, enum_var_type type);
......@@ -565,9 +567,6 @@ static sys_var_thd_ulong sys_div_precincrement(&vars, "div_precision_increment",
&SV::div_precincrement);
static sys_var_long_ptr sys_rpl_recovery_rank(&vars, "rpl_recovery_rank",
&rpl_recovery_rank);
static sys_var_long_ptr sys_query_cache_size(&vars, "query_cache_size",
&query_cache_size,
fix_query_cache_size);
static sys_var_thd_ulong sys_range_alloc_block_size(&vars, "range_alloc_block_size",
&SV::range_alloc_block_size);
......@@ -635,14 +634,20 @@ sys_var_enum_const sys_thread_handling(&vars, "thread_handling",
&thread_handling_typelib);
#ifdef HAVE_QUERY_CACHE
static sys_var_long_ptr sys_query_cache_size(&vars, "query_cache_size",
&query_cache_size,
fix_query_cache_size);
static sys_var_long_ptr sys_query_cache_limit(&vars, "query_cache_limit",
&query_cache.query_cache_limit);
static sys_var_long_ptr sys_query_cache_min_res_unit(&vars, "query_cache_min_res_unit",
&query_cache_min_res_unit,
fix_query_cache_min_res_unit);
&query_cache.query_cache_limit);
static sys_var_long_ptr
sys_query_cache_min_res_unit(&vars, "query_cache_min_res_unit",
&query_cache_min_res_unit,
fix_query_cache_min_res_unit);
static sys_var_thd_enum sys_query_cache_type(&vars, "query_cache_type",
&SV::query_cache_type,
&query_cache_type_typelib);
&query_cache_type_typelib,
fix_query_cache_type,
check_query_cache_type);
static sys_var_thd_bool
sys_query_cache_wlock_invalidate(&vars, "query_cache_wlock_invalidate",
&SV::query_cache_wlock_invalidate);
......@@ -938,6 +943,8 @@ static sys_var_const_str_ptr sys_log_basename(&vars, "log_basename",
#ifndef EMBEDDED_LIBRARY
static sys_var_const_str_ptr sys_repl_report_host(&vars, "report_host", &report_host);
static sys_var_const_str_ptr sys_repl_report_user(&vars, "report_user", &report_user);
static sys_var_bool_ptr sys_query_cache_strip_comments(&vars, "query_cache_strip_comments",
&opt_query_cache_strip_comments);
static sys_var_const_str_ptr sys_repl_report_password(&vars, "report_password", &report_password);
static uchar *slave_get_report_port(THD *thd)
......@@ -1227,10 +1234,9 @@ static void fix_net_retry_count(THD *thd __attribute__((unused)),
{}
#endif /* HAVE_REPLICATION */
#ifdef HAVE_QUERY_CACHE
static void fix_query_cache_size(THD *thd, enum_var_type type)
{
#ifdef HAVE_QUERY_CACHE
ulong new_cache_size= query_cache.resize(query_cache_size);
/*
......@@ -1244,11 +1250,60 @@ static void fix_query_cache_size(THD *thd, enum_var_type type)
query_cache_size, new_cache_size);
query_cache_size= new_cache_size;
#endif
}
#ifdef HAVE_QUERY_CACHE
/**
Trigger before query_cache_type variable is updated.
@param thd Thread handler
@param var Pointer to the new variable status
@return Status code
@retval TRUE Failure
@retval FALSE Success
*/
static int check_query_cache_type(THD *thd, set_var *var)
{
/*
Don't allow changes of the query_cache_type if the query cache
is disabled.
*/
if (query_cache.is_disable_in_progress())
{
my_error(ER_QUERY_CACHE_IS_DISABLED, MYF(0));
return TRUE;
}
if (var->type != OPT_GLOBAL &&
global_system_variables.query_cache_type == 0 &&
var->value->val_int() != 0)
{
my_error(ER_QUERY_CACHE_IS_GLOBALY_DISABLED, MYF(0));
return TRUE;
}
return FALSE;
}
static void fix_query_cache_type(THD *thd, enum_var_type type)
{
if (type == OPT_GLOBAL)
{
if (global_system_variables.query_cache_type != 0 &&
query_cache.is_disabled())
{
/* if disabling in progress variable will not be set */
DBUG_ASSERT(!query_cache.is_disable_in_progress());
/* Enable query cache because it was disabled */
fix_query_cache_size(thd, type);
}
else if (global_system_variables.query_cache_type == 0)
query_cache.disable_query_cache();
}
}
static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type)
{
query_cache_min_res_unit=
......@@ -3672,6 +3727,16 @@ bool not_all_support_one_shot(List<set_var_base> *var_list)
Functions to handle SET mysql_internal_variable=const_expr
*****************************************************************************/
/**
Verify that the supplied value is correct.
@param thd Thread handler
@return status code
@retval -1 Failure
@retval 0 Success
*/
int set_var::check(THD *thd)
{
if (var->is_readonly())
......
......@@ -516,10 +516,15 @@ public:
{ chain_sys_var(chain); }
bool check(THD *thd, set_var *var)
{
int ret= 0;
if (check_func)
ret= (*check_func)(thd, var);
return ret ? ret : check_enum(thd, var, enum_names);
/*
check_enum fails if the character representation supplied was wrong
or that the integer value was wrong or missing.
*/
if (check_enum(thd, var, enum_names))
return TRUE;
if ((check_func && (*check_func)(thd, var)))
return TRUE;
return FALSE;
}
bool update(THD *thd, set_var *var);
void set_default(THD *thd, enum_var_type type);
......
......@@ -6271,3 +6271,7 @@ ER_DYN_COL_WRONG_CHARSET
eng "Dynamic column contains unknown character set"
ER_ILLEGAL_SUBQUERY_OPTIMIZER_SWITCHES
eng "At least one of the 'in_to_exists' or 'materialization' optimizer_switch flags must be 'on'."
ER_QUERY_CACHE_IS_DISABLED
eng "Query cache is disabled (resize or similar command in progress); repeat this command later"
ER_QUERY_CACHE_IS_GLOBALY_DISABLED
eng "Query cache is globally disabled and you can't enable it only for this session"
This diff is collapsed.
......@@ -276,8 +276,11 @@ private:
my_thread_id m_cache_lock_thread_id;
#endif
pthread_cond_t COND_cache_status_changed;
uint m_requests_in_progress;
enum Cache_lock_status { UNLOCKED, LOCKED_NO_WAIT, LOCKED };
Cache_lock_status m_cache_lock_status;
enum Cache_staus {OK, DISABLE_REQUEST, DISABLED};
Cache_staus m_cache_status;
void free_query_internal(Query_cache_block *point);
void invalidate_table_internal(THD *thd, uchar *key, uint32 key_length);
......@@ -292,7 +295,7 @@ protected:
2. query block (for operation inside query (query block/results))
Thread doing cache flush releases the mutex once it sets
m_cache_status flag, so other threads may bypass the cache as
m_cache_lock_status flag, so other threads may bypass the cache as
if it is disabled, not waiting for reset to finish. The exception
is other threads that were going to do cache flush---they'll wait
till the end of a flush operation.
......@@ -407,7 +410,7 @@ protected:
If query is cacheable return number tables in query
(query without tables not cached)
*/
TABLE_COUNTER_TYPE is_cacheable(THD *thd, uint32 query_len, char *query,
TABLE_COUNTER_TYPE is_cacheable(THD *thd,
LEX *lex, TABLE_LIST *tables_used,
uint8 *tables_type);
TABLE_COUNTER_TYPE process_and_count_tables(THD *thd,
......@@ -423,6 +426,10 @@ protected:
uint def_query_hash_size = QUERY_CACHE_DEF_QUERY_HASH_SIZE,
uint def_table_hash_size = QUERY_CACHE_DEF_TABLE_HASH_SIZE);
bool is_disabled(void) { return m_cache_status != OK; }
bool is_disable_in_progress(void)
{ return m_cache_status == DISABLE_REQUEST; }
/* initialize cache (mutex) */
void init();
/* resize query cache (return real query size, 0 if disabled) */
......@@ -442,22 +449,23 @@ protected:
int send_result_to_client(THD *thd, char *query, uint query_length);
/* Remove all queries that uses any of the listed following tables */
void invalidate(THD* thd, TABLE_LIST *tables_used,
void invalidate(THD *thd, TABLE_LIST *tables_used,
my_bool using_transactions);
void invalidate(CHANGED_TABLE_LIST *tables_used);
void invalidate_locked_for_write(TABLE_LIST *tables_used);
void invalidate(THD* thd, TABLE *table, my_bool using_transactions);
void invalidate(THD *thd, CHANGED_TABLE_LIST *tables_used);
void invalidate_locked_for_write(THD *thd, TABLE_LIST *tables_used);
void invalidate(THD *thd, TABLE *table, my_bool using_transactions);
void invalidate(THD *thd, const char *key, uint32 key_length,
my_bool using_transactions);
/* Remove all queries that uses any of the tables in following database */
void invalidate(char *db);
void invalidate(THD *thd, char *db);
/* Remove all queries that uses any of the listed following table */
void invalidate_by_MyISAM_filename(const char *filename);
void flush();
void pack(ulong join_limit = QUERY_CACHE_PACK_LIMIT,
void pack(THD *thd,
ulong join_limit = QUERY_CACHE_PACK_LIMIT,
uint iteration_limit = QUERY_CACHE_PACK_ITERATION);
void destroy();
......@@ -485,10 +493,13 @@ protected:
const char *name);
my_bool in_blocks(Query_cache_block * point);
bool try_lock(bool use_timeout= FALSE);
void lock(void);
enum Cache_try_lock_mode {WAIT, TIMEOUT, TRY};
bool try_lock(THD *thd, Cache_try_lock_mode mode= WAIT);
void lock(THD *thd);
void lock_and_suspend(void);
void unlock(void);
void disable_query_cache(void);
};
extern Query_cache query_cache;
......
......@@ -767,8 +767,12 @@ public:
ENGINE INNODB STATUS.
*/
LEX_STRING query_string;
/*
If opt_query_cache_strip_comments is set, this contains query without
comments. If not set, it contains pointer to query_string.
*/
String base_query;
Server_side_cursor *cursor;
inline char *query() { return query_string.str; }
inline uint32 query_length() { return (uint32)query_string.length; }
void set_query_inner(char *query_arg, uint32 query_length_arg);
......@@ -789,7 +793,8 @@ public:
char *db;
size_t db_length;
public:
/* This is set to 1 of last call to send_result_to_client() was ok */
my_bool query_cache_is_applicable;
/* This constructor is called for backup statements */
Statement() {}
......
......@@ -973,7 +973,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
{
ha_drop_database(path);
tmp_disable_binlog(thd);
query_cache_invalidate1(db);
query_cache_invalidate1(thd, db);
(void) sp_drop_db_routines(thd, db); /* @todo Do not ignore errors */
#ifdef HAVE_EVENT_SCHEDULER
Events::drop_schema_events(thd, db);
......
......@@ -818,45 +818,48 @@ int MYSQLlex(void *arg, void *yythd)
yylval->lex_str.length=2;
return NULL_SYM;
}
/* Fall through */
case MY_LEX_CHAR: // Unknown or single char token
case MY_LEX_SKIP: // This should not happen
if (c == '-' && lip->yyPeek() == '-' &&
if (c != ')')
lip->next_state= MY_LEX_START; // Allow signed numbers
return((int) c);
case MY_LEX_MINUS_OR_COMMENT:
if (lip->yyPeek() == '-' &&
(my_isspace(cs,lip->yyPeekn(1)) ||
my_iscntrl(cs,lip->yyPeekn(1))))
{
state=MY_LEX_COMMENT;
break;
}
lip->next_state= MY_LEX_START; // Allow signed numbers
return((int) c);
if (c != ')')
lip->next_state= MY_LEX_START; // Allow signed numbers
if (c == ',')
{
/*
Warning:
This is a work around, to make the "remember_name" rule in
sql/sql_yacc.yy work properly.
The problem is that, when parsing "select expr1, expr2",
the code generated by bison executes the *pre* action
remember_name (see select_item) *before* actually parsing the
first token of expr2.
*/
lip->restart_token();
}
else
{
/*
Check for a placeholder: it should not precede a possible identifier
because of binlogging: when a placeholder is replaced with
its value in a query for the binlog, the query must stay
grammatically correct.
*/
if (c == '?' && lip->stmt_prepare_mode &&
!ident_map[(uchar) lip->yyPeek()])
case MY_LEX_PLACEHOLDER:
/*
Check for a placeholder: it should not precede a possible identifier
because of binlogging: when a placeholder is replaced with
its value in a query for the binlog, the query must stay
grammatically correct.
*/
lip->next_state= MY_LEX_START; // Allow signed numbers
if (lip->stmt_prepare_mode && !ident_map[(uchar) lip->yyPeek()])
return(PARAM_MARKER);
}
return((int) c);
case MY_LEX_COMMA:
lip->next_state= MY_LEX_START; // Allow signed numbers
/*
Warning:
This is a work around, to make the "remember_name" rule in
sql/sql_yacc.yy work properly.
The problem is that, when parsing "select expr1, expr2",
the code generated by bison executes the *pre* action
remember_name (see select_item) *before* actually parsing the
first token of expr2.
*/
lip->restart_token();
return((int) c);
case MY_LEX_IDENT_OR_NCHAR:
......
......@@ -1055,7 +1055,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
}
thread_running++;
/* TODO: set thd->lex->sql_command to SQLCOM_END here */
VOID(pthread_mutex_unlock(&LOCK_thread_count));
/**
......@@ -1252,15 +1251,15 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
#endif
thd->set_query(beginning_of_next_stmt, length);
VOID(pthread_mutex_lock(&LOCK_thread_count));
/*
Count each statement from the client.
*/
statistic_increment(thd->status_var.questions, &LOCK_status);
thd->set_time(); /* Reset the query start time for next query. */
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query_id= next_query_id();
thd->set_time(); /* Reset the query start time. */
/* TODO: set thd->lex->sql_command to SQLCOM_END here */
VOID(pthread_mutex_unlock(&LOCK_thread_count));
/* TODO: set thd->lex->sql_command to SQLCOM_END here */
mysql_parse(thd, beginning_of_next_stmt, length, &end_of_stmt);
}
......@@ -3552,7 +3551,7 @@ end_with_restore_list:
{
#ifdef HAVE_QUERY_CACHE
if (thd->variables.query_cache_wlock_invalidate)
query_cache.invalidate_locked_for_write(first_table);
query_cache.invalidate_locked_for_write(thd, first_table);
#endif /*HAVE_QUERY_CACHE*/
thd->locked_tables=thd->lock;
thd->lock=0;
......@@ -7010,7 +7009,7 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables,
#ifdef HAVE_QUERY_CACHE
if (options & REFRESH_QUERY_CACHE_FREE)
{
query_cache.pack(); // FLUSH QUERY CACHE
query_cache.pack(thd); // FLUSH QUERY CACHE
options &= ~REFRESH_QUERY_CACHE; // Don't flush cache, just free memory
}
if (options & (REFRESH_TABLES | REFRESH_QUERY_CACHE))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment