mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge chunk from trunk.
This commit is contained in:
@ -98,22 +98,7 @@ static bool do_command(THD *thd);
|
||||
#endif // EMBEDDED_LIBRARY
|
||||
|
||||
#ifdef __WIN__
|
||||
static void test_signal(int sig_ptr)
|
||||
{
|
||||
#if !defined( DBUG_OFF)
|
||||
MessageBox(NULL,"Test signal","DBUG",MB_OK);
|
||||
#endif
|
||||
#if defined(OS2)
|
||||
fprintf(stderr, "Test signal %d\n", sig_ptr);
|
||||
fflush(stderr);
|
||||
#endif
|
||||
}
|
||||
static void init_signals(void)
|
||||
{
|
||||
int signals[7] = {SIGINT,SIGILL,SIGFPE,SIGSEGV,SIGTERM,SIGBREAK,SIGABRT } ;
|
||||
for (int i=0 ; i < 7 ; i++)
|
||||
signal( signals[i], test_signal) ;
|
||||
}
|
||||
extern void win_install_sigabrt_handler(void);
|
||||
#endif
|
||||
|
||||
static void unlock_locked_tables(THD *thd)
|
||||
@ -1124,7 +1109,7 @@ pthread_handler_t handle_one_connection(void *arg)
|
||||
/* now that we've called my_thread_init(), it is safe to call DBUG_* */
|
||||
|
||||
#if defined(__WIN__)
|
||||
init_signals();
|
||||
win_install_sigabrt_handler();
|
||||
#elif !defined(OS2) && !defined(__NETWARE__)
|
||||
sigset_t set;
|
||||
VOID(sigemptyset(&set)); // Get mask in use
|
||||
@ -1615,6 +1600,74 @@ out:
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
|
||||
/**
|
||||
@brief Determine if an attempt to update a non-temporary table while the
|
||||
read-only option was enabled has been made.
|
||||
|
||||
This is a helper function to mysql_execute_command.
|
||||
|
||||
@note SQLCOM_MULTI_UPDATE is an exception and delt with elsewhere.
|
||||
|
||||
@see mysql_execute_command
|
||||
@returns Status code
|
||||
@retval TRUE The statement should be denied.
|
||||
@retval FALSE The statement isn't updating any relevant tables.
|
||||
*/
|
||||
|
||||
static my_bool deny_updates_if_read_only_option(THD *thd,
|
||||
TABLE_LIST *all_tables)
|
||||
{
|
||||
DBUG_ENTER("deny_updates_if_read_only_option");
|
||||
|
||||
if (!opt_readonly)
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
LEX *lex= thd->lex;
|
||||
|
||||
const my_bool user_is_super=
|
||||
((ulong)(thd->security_ctx->master_access & SUPER_ACL) ==
|
||||
(ulong)SUPER_ACL);
|
||||
|
||||
if (user_is_super)
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
if (!uc_update_queries[lex->sql_command])
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
/* Multi update is an exception and is dealt with later. */
|
||||
if (lex->sql_command == SQLCOM_UPDATE_MULTI)
|
||||
DBUG_RETURN(FALSE);
|
||||
|
||||
const my_bool create_temp_tables=
|
||||
(lex->sql_command == SQLCOM_CREATE_TABLE) &&
|
||||
(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE);
|
||||
|
||||
const my_bool drop_temp_tables=
|
||||
(lex->sql_command == SQLCOM_DROP_TABLE) &&
|
||||
lex->drop_temporary;
|
||||
|
||||
const my_bool update_real_tables=
|
||||
some_non_temp_table_to_be_updated(thd, all_tables) &&
|
||||
!(create_temp_tables || drop_temp_tables);
|
||||
|
||||
|
||||
const my_bool create_or_drop_databases=
|
||||
(lex->sql_command == SQLCOM_CREATE_DB) ||
|
||||
(lex->sql_command == SQLCOM_DROP_DB);
|
||||
|
||||
if (update_real_tables || create_or_drop_databases)
|
||||
{
|
||||
/*
|
||||
An attempt was made to modify one or more non-temporary tables.
|
||||
*/
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
|
||||
/* Assuming that only temporary tables are modified. */
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
Perform one connection-level (COM_XXXX) command.
|
||||
|
||||
@ -2027,7 +2080,6 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
unregister_slave(thd,1,1);
|
||||
/* fake COM_QUIT -- if we get here, the thread needs to terminate */
|
||||
error = TRUE;
|
||||
net->error = 0;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@ -2628,14 +2680,7 @@ mysql_execute_command(THD *thd)
|
||||
When option readonly is set deny operations which change non-temporary
|
||||
tables. Except for the replication thread and the 'super' users.
|
||||
*/
|
||||
if (opt_readonly &&
|
||||
!(thd->security_ctx->master_access & SUPER_ACL) &&
|
||||
uc_update_queries[lex->sql_command] &&
|
||||
!((lex->sql_command == SQLCOM_CREATE_TABLE) &&
|
||||
(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE)) &&
|
||||
!((lex->sql_command == SQLCOM_DROP_TABLE) && lex->drop_temporary) &&
|
||||
((lex->sql_command != SQLCOM_UPDATE_MULTI) &&
|
||||
some_non_temp_table_to_be_updated(thd, all_tables)))
|
||||
if (deny_updates_if_read_only_option(thd, all_tables))
|
||||
{
|
||||
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only");
|
||||
DBUG_RETURN(-1);
|
||||
|
Reference in New Issue
Block a user