Added option --read-only (Thanks to Markus Benning)
myisam/myisamchk.c: Removed warning from fulltext when repairing many tables with fulltext index sql/init.cc: Remove not used variables sql/mysql_priv.h: Remove not used variables sql/mysqld.cc: Removed not used variables Added option --read-only Change opt_do_pstack and master_ssl to get them to work with my_getopt sql/set_var.cc: Option --read-only sql/sql_parse.cc: Option --read-only
This commit is contained in:
parent
43d3714095
commit
18dd37b8a1
@ -45,6 +45,7 @@ static const char *set_charset_name;
|
|||||||
static CHARSET_INFO *set_charset;
|
static CHARSET_INFO *set_charset;
|
||||||
static long opt_myisam_block_size;
|
static long opt_myisam_block_size;
|
||||||
static const char *my_progname_short;
|
static const char *my_progname_short;
|
||||||
|
static int stopwords_inited= 0;
|
||||||
|
|
||||||
static const char *type_names[]=
|
static const char *type_names[]=
|
||||||
{ "?","char","binary", "short", "long", "float",
|
{ "?","char","binary", "short", "long", "float",
|
||||||
@ -861,7 +862,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (share->fulltext_index)
|
if (share->fulltext_index && !stopwords_inited++)
|
||||||
ft_init_stopwords();
|
ft_init_stopwords();
|
||||||
|
|
||||||
if (!(param->testflag & T_READONLY))
|
if (!(param->testflag & T_READONLY))
|
||||||
|
@ -38,13 +38,11 @@ void unireg_init(ulong options)
|
|||||||
init_my_atof(); /* use our atof */
|
init_my_atof(); /* use our atof */
|
||||||
#endif
|
#endif
|
||||||
my_abort_hook=unireg_abort; /* Abort with close of databases */
|
my_abort_hook=unireg_abort; /* Abort with close of databases */
|
||||||
f_fyllchar=' '; /* Input fill char */
|
|
||||||
|
|
||||||
VOID(strmov(reg_ext,".frm"));
|
VOID(strmov(reg_ext,".frm"));
|
||||||
for (i=0 ; i < 6 ; i++) // YYMMDDHHMMSS
|
for (i=0 ; i < 6 ; i++) // YYMMDDHHMMSS
|
||||||
dayord.pos[i]=i;
|
dayord.pos[i]=i;
|
||||||
specialflag=SPECIAL_SAME_DB_NAME;
|
specialflag=SPECIAL_SAME_DB_NAME;
|
||||||
blob_newline='^'; /* Convert newline in blobs to this */
|
|
||||||
/* 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... */
|
||||||
|
@ -627,7 +627,6 @@ extern char language[LIBLEN],reg_ext[FN_EXTLEN];
|
|||||||
extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
|
extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
|
||||||
extern char pidfile_name[FN_REFLEN], time_zone[30], *opt_init_file;
|
extern char pidfile_name[FN_REFLEN], time_zone[30], *opt_init_file;
|
||||||
extern char log_error_file[FN_REFLEN];
|
extern char log_error_file[FN_REFLEN];
|
||||||
extern char blob_newline;
|
|
||||||
extern double log_10[32];
|
extern double log_10[32];
|
||||||
extern ulonglong keybuff_size;
|
extern ulonglong keybuff_size;
|
||||||
extern ulong refresh_version,flush_version, thread_id,query_id,opened_tables;
|
extern ulong refresh_version,flush_version, thread_id,query_id,opened_tables;
|
||||||
@ -675,8 +674,8 @@ extern uint volatile thread_count, thread_running, global_read_lock;
|
|||||||
extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types;
|
extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types;
|
||||||
extern my_bool opt_safe_show_db, opt_local_infile, lower_case_table_names;
|
extern my_bool opt_safe_show_db, opt_local_infile, lower_case_table_names;
|
||||||
extern my_bool opt_slave_compressed_protocol, use_temp_pool;
|
extern my_bool opt_slave_compressed_protocol, use_temp_pool;
|
||||||
|
extern my_bool opt_readonly;
|
||||||
extern my_bool opt_enable_named_pipe;
|
extern my_bool opt_enable_named_pipe;
|
||||||
extern char f_fyllchar;
|
|
||||||
|
|
||||||
extern MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log;
|
extern MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log;
|
||||||
extern FILE *bootstrap_file;
|
extern FILE *bootstrap_file;
|
||||||
|
@ -289,7 +289,7 @@ my_bool opt_enable_named_pipe= 0;
|
|||||||
my_bool opt_local_infile, opt_external_locking, opt_slave_compressed_protocol;
|
my_bool opt_local_infile, opt_external_locking, opt_slave_compressed_protocol;
|
||||||
uint delay_key_write_options= (uint) DELAY_KEY_WRITE_ON;
|
uint delay_key_write_options= (uint) DELAY_KEY_WRITE_ON;
|
||||||
|
|
||||||
static bool opt_do_pstack = 0;
|
static my_bool opt_do_pstack = 0;
|
||||||
static ulong opt_specialflag=SPECIAL_ENGLISH;
|
static ulong opt_specialflag=SPECIAL_ENGLISH;
|
||||||
|
|
||||||
static ulong opt_myisam_block_size;
|
static ulong opt_myisam_block_size;
|
||||||
@ -306,6 +306,7 @@ my_bool opt_safe_user_create = 0, opt_no_mix_types = 0;
|
|||||||
my_bool lower_case_table_names, opt_old_rpl_compat;
|
my_bool lower_case_table_names, opt_old_rpl_compat;
|
||||||
my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
|
my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
|
||||||
my_bool opt_log_slave_updates= 0, opt_console= 0;
|
my_bool opt_log_slave_updates= 0, opt_console= 0;
|
||||||
|
my_bool opt_readonly = 0;
|
||||||
|
|
||||||
volatile bool mqh_used = 0;
|
volatile bool mqh_used = 0;
|
||||||
FILE *bootstrap_file=0;
|
FILE *bootstrap_file=0;
|
||||||
@ -376,7 +377,7 @@ const char *localhost=LOCAL_HOST;
|
|||||||
const char *delayed_user="DELAYED";
|
const char *delayed_user="DELAYED";
|
||||||
uint master_port = MYSQL_PORT, master_connect_retry = 60;
|
uint master_port = MYSQL_PORT, master_connect_retry = 60;
|
||||||
uint report_port = MYSQL_PORT;
|
uint report_port = MYSQL_PORT;
|
||||||
bool master_ssl = 0;
|
my_bool master_ssl = 0;
|
||||||
|
|
||||||
ulong master_retry_count=0;
|
ulong master_retry_count=0;
|
||||||
ulong bytes_sent = 0L, bytes_received = 0L;
|
ulong bytes_sent = 0L, bytes_received = 0L;
|
||||||
@ -404,8 +405,7 @@ ulong slow_launch_threads = 0;
|
|||||||
char mysql_real_data_home[FN_REFLEN],
|
char mysql_real_data_home[FN_REFLEN],
|
||||||
language[LIBLEN],reg_ext[FN_EXTLEN],
|
language[LIBLEN],reg_ext[FN_EXTLEN],
|
||||||
mysql_charsets_dir[FN_REFLEN], *charsets_list,
|
mysql_charsets_dir[FN_REFLEN], *charsets_list,
|
||||||
blob_newline,f_fyllchar,max_sort_char,*mysqld_user,*mysqld_chroot,
|
max_sort_char,*mysqld_user,*mysqld_chroot, *opt_init_file;
|
||||||
*opt_init_file;
|
|
||||||
char *language_ptr= language;
|
char *language_ptr= language;
|
||||||
char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
|
char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
|
||||||
#ifndef EMBEDDED_LIBRARY
|
#ifndef EMBEDDED_LIBRARY
|
||||||
@ -3143,6 +3143,7 @@ enum options {
|
|||||||
OPT_QUERY_CACHE_TYPE, OPT_RECORD_BUFFER,
|
OPT_QUERY_CACHE_TYPE, OPT_RECORD_BUFFER,
|
||||||
OPT_RECORD_RND_BUFFER, OPT_RELAY_LOG_SPACE_LIMIT,
|
OPT_RECORD_RND_BUFFER, OPT_RELAY_LOG_SPACE_LIMIT,
|
||||||
OPT_SLAVE_NET_TIMEOUT, OPT_SLAVE_COMPRESSED_PROTOCOL, OPT_SLOW_LAUNCH_TIME,
|
OPT_SLAVE_NET_TIMEOUT, OPT_SLAVE_COMPRESSED_PROTOCOL, OPT_SLOW_LAUNCH_TIME,
|
||||||
|
OPT_READONLY,
|
||||||
OPT_SORT_BUFFER, OPT_TABLE_CACHE,
|
OPT_SORT_BUFFER, OPT_TABLE_CACHE,
|
||||||
OPT_THREAD_CONCURRENCY, OPT_THREAD_CACHE_SIZE,
|
OPT_THREAD_CONCURRENCY, OPT_THREAD_CACHE_SIZE,
|
||||||
OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK,
|
OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK,
|
||||||
@ -3927,6 +3928,11 @@ replicating a LOAD DATA INFILE command",
|
|||||||
"Number of seconds to wait for more data from a master/slave connection before aborting the read.",
|
"Number of seconds to wait for more data from a master/slave connection before aborting the read.",
|
||||||
(gptr*) &slave_net_timeout, (gptr*) &slave_net_timeout, 0,
|
(gptr*) &slave_net_timeout, (gptr*) &slave_net_timeout, 0,
|
||||||
GET_ULONG, REQUIRED_ARG, SLAVE_NET_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
|
GET_ULONG, REQUIRED_ARG, SLAVE_NET_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
|
||||||
|
{"read-only", OPT_READONLY,
|
||||||
|
"Make all tables readonly, with the expections for replications (slave) threads and users with the SUPER privilege",
|
||||||
|
(gptr*) &opt_readonly,
|
||||||
|
(gptr*) &opt_readonly,
|
||||||
|
0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
|
||||||
{"slow_launch_time", OPT_SLOW_LAUNCH_TIME,
|
{"slow_launch_time", OPT_SLOW_LAUNCH_TIME,
|
||||||
"If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented.",
|
"If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented.",
|
||||||
(gptr*) &slow_launch_time, (gptr*) &slow_launch_time, 0, GET_ULONG,
|
(gptr*) &slow_launch_time, (gptr*) &slow_launch_time, 0, GET_ULONG,
|
||||||
|
@ -204,6 +204,8 @@ sys_var_bool_ptr sys_slave_compressed_protocol("slave_compressed_protocol",
|
|||||||
&opt_slave_compressed_protocol);
|
&opt_slave_compressed_protocol);
|
||||||
sys_var_long_ptr sys_slave_net_timeout("slave_net_timeout",
|
sys_var_long_ptr sys_slave_net_timeout("slave_net_timeout",
|
||||||
&slave_net_timeout);
|
&slave_net_timeout);
|
||||||
|
sys_var_bool_ptr sys_readonly("read_only",
|
||||||
|
&opt_readonly);
|
||||||
sys_var_long_ptr sys_slow_launch_time("slow_launch_time",
|
sys_var_long_ptr sys_slow_launch_time("slow_launch_time",
|
||||||
&slow_launch_time);
|
&slow_launch_time);
|
||||||
sys_var_thd_ulong sys_sort_buffer("sort_buffer_size",
|
sys_var_thd_ulong sys_sort_buffer("sort_buffer_size",
|
||||||
@ -375,6 +377,7 @@ sys_var *sys_variables[]=
|
|||||||
&sys_slave_compressed_protocol,
|
&sys_slave_compressed_protocol,
|
||||||
&sys_slave_net_timeout,
|
&sys_slave_net_timeout,
|
||||||
&sys_slave_skip_counter,
|
&sys_slave_skip_counter,
|
||||||
|
&sys_readonly,
|
||||||
&sys_slow_launch_time,
|
&sys_slow_launch_time,
|
||||||
&sys_sort_buffer,
|
&sys_sort_buffer,
|
||||||
&sys_sql_big_tables,
|
&sys_sql_big_tables,
|
||||||
@ -522,6 +525,7 @@ struct show_var_st init_vars[]= {
|
|||||||
#endif /* HAVE_QUERY_CACHE */
|
#endif /* HAVE_QUERY_CACHE */
|
||||||
{sys_server_id.name, (char*) &sys_server_id, SHOW_SYS},
|
{sys_server_id.name, (char*) &sys_server_id, SHOW_SYS},
|
||||||
{sys_slave_net_timeout.name,(char*) &sys_slave_net_timeout, SHOW_SYS},
|
{sys_slave_net_timeout.name,(char*) &sys_slave_net_timeout, SHOW_SYS},
|
||||||
|
{sys_readonly.name, (char*) &sys_readonly, SHOW_SYS},
|
||||||
{"skip_external_locking", (char*) &my_disable_locking, SHOW_MY_BOOL},
|
{"skip_external_locking", (char*) &my_disable_locking, SHOW_MY_BOOL},
|
||||||
{"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL},
|
{"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL},
|
||||||
{"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL},
|
{"skip_show_database", (char*) &opt_skip_show_db, SHOW_BOOL},
|
||||||
|
@ -1329,6 +1329,18 @@ mysql_execute_command(void)
|
|||||||
(table_rules_on && tables && thd->slave_thread &&
|
(table_rules_on && tables && thd->slave_thread &&
|
||||||
!tables_ok(thd,tables)))
|
!tables_ok(thd,tables)))
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
|
|
||||||
|
/*
|
||||||
|
When option readonly is set deny operations which change tables.
|
||||||
|
Except for the replication thread and the 'super' users.
|
||||||
|
*/
|
||||||
|
if (opt_readonly &&
|
||||||
|
!(thd->slave_thread || (thd->master_access & SUPER_ACL)) &&
|
||||||
|
(uc_update_queries[lex->sql_command] > 0))
|
||||||
|
{
|
||||||
|
send_error(&thd->net,ER_CANT_UPDATE_WITH_READLOCK);
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
|
}
|
||||||
|
|
||||||
statistic_increment(com_stat[lex->sql_command],&LOCK_status);
|
statistic_increment(com_stat[lex->sql_command],&LOCK_status);
|
||||||
switch (lex->sql_command) {
|
switch (lex->sql_command) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user