Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
e0f0ba80
Commit
e0f0ba80
authored
Apr 14, 2007
by
kostja@vajra.(none)
Browse files
Options
Browse Files
Download
Plain Diff
Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into vajra.(none):/opt/local/work/mysql-5.1-runtime
parents
3f72507d
8dcc629c
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
369 additions
and
373 deletions
+369
-373
client/mysqldump.c
client/mysqldump.c
+12
-4
mysql-test/r/rpl_events.result
mysql-test/r/rpl_events.result
+0
-2
mysql-test/t/mysqldump.test
mysql-test/t/mysqldump.test
+7
-0
sql/event_data_objects.cc
sql/event_data_objects.cc
+193
-271
sql/event_data_objects.h
sql/event_data_objects.h
+5
-10
sql/event_scheduler.cc
sql/event_scheduler.cc
+18
-36
sql/events.cc
sql/events.cc
+6
-3
sql/item_func.cc
sql/item_func.cc
+1
-1
sql/sp_head.cc
sql/sp_head.cc
+8
-42
sql/sql_class.cc
sql/sql_class.cc
+96
-0
sql/sql_class.h
sql/sql_class.h
+12
-0
sql/sql_trigger.cc
sql/sql_trigger.cc
+11
-4
No files found.
client/mysqldump.c
View file @
e0f0ba80
...
...
@@ -829,11 +829,15 @@ static int get_options(int *argc, char ***argv)
(
hash_get_key
)
get_table_key
,
(
hash_free_key
)
free_table_ent
,
0
))
return
(
EX_EOM
);
/* Don't copy
cluster
internal log tables */
/* Don't copy internal log tables */
if
(
my_hash_insert
(
&
ignore_table
,
(
byte
*
)
my_strdup
(
"mysql.apply_status"
,
MYF
(
MY_WME
)))
||
my_hash_insert
(
&
ignore_table
,
(
byte
*
)
my_strdup
(
"mysql.schema"
,
MYF
(
MY_WME
))))
(
byte
*
)
my_strdup
(
"mysql.schema"
,
MYF
(
MY_WME
)))
||
my_hash_insert
(
&
ignore_table
,
(
byte
*
)
my_strdup
(
"mysql.general_log"
,
MYF
(
MY_WME
)))
||
my_hash_insert
(
&
ignore_table
,
(
byte
*
)
my_strdup
(
"mysql.slow_log"
,
MYF
(
MY_WME
))))
return
(
EX_EOM
);
if
((
ho_error
=
handle_options
(
argc
,
argv
,
my_long_options
,
get_one_option
)))
...
...
@@ -3352,10 +3356,14 @@ static int dump_all_tables_in_db(char *database)
DYNAMIC_STRING
query
;
init_dynamic_string_checked
(
&
query
,
"LOCK TABLES "
,
256
,
1024
);
for
(
numrows
=
0
;
(
table
=
getTableName
(
1
))
;
numrows
++
)
{
char
*
end
=
strmov
(
afterdot
,
table
);
if
(
include_table
(
hash_key
,
end
-
hash_key
))
{
dynstr_append_checked
(
&
query
,
quote_name
(
table
,
table_buff
,
1
));
dynstr_append_checked
(
&
query
,
" READ /*!32311 LOCAL */,"
);
}
}
if
(
numrows
&&
mysql_real_query
(
mysql
,
query
.
str
,
query
.
length
-
1
))
DB_error
(
mysql
,
"when using LOCK TABLES"
);
/* We shall continue here, if --force was given */
...
...
mysql-test/r/rpl_events.result
View file @
e0f0ba80
...
...
@@ -34,7 +34,6 @@ id c ts
affected rows: 2
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce';
db name status originator
test justonce SLAVESIDE_DISABLED 1
DROP EVENT IF EXISTS test.slave_once;
CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE DO
INSERT INTO t1(c) VALUES ('from slave_once');
...
...
@@ -111,7 +110,6 @@ id c ts
affected rows: 2
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'justonce';
db name status originator
test justonce SLAVESIDE_DISABLED 1
DROP EVENT IF EXISTS test.slave_once;
CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE DO
INSERT INTO t1(c) VALUES ('from slave_once');
...
...
mysql-test/t/mysqldump.test
View file @
e0f0ba80
...
...
@@ -1612,6 +1612,13 @@ drop view v1;
drop
table
t1
;
drop
database
mysqldump_test_db
;
#
# BUG#26121 mysqldump includes LOCK TABLES general_log WRITE
#
--
exec
$MYSQL_DUMP
--
all
-
databases
>
$MYSQLTEST_VARDIR
/
tmp
/
bug26121
.
sql
--
exec
$MYSQL
<
$MYSQLTEST_VARDIR
/
tmp
/
bug26121
.
sql
--
remove_file
$MYSQLTEST_VARDIR
/
tmp
/
bug26121
.
sql
--
echo
#
--
echo
# End of 5.1 tests
--
echo
#
sql/event_data_objects.cc
View file @
e0f0ba80
This diff is collapsed.
Click to expand it.
sql/event_data_objects.h
View file @
e0f0ba80
...
...
@@ -17,7 +17,6 @@
#define EVEX_GET_FIELD_FAILED -2
#define EVEX_COMPILE_ERROR -3
#define EVEX_BAD_PARAMS -5
#define EVEX_MICROSECOND_UNSUP -6
...
...
@@ -169,8 +168,6 @@ class Event_timed : public Event_queue_element
class
Event_job_data
:
public
Event_basic
{
public:
sp_head
*
sphead
;
LEX_STRING
body
;
LEX_STRING
definer_user
;
LEX_STRING
definer_host
;
...
...
@@ -178,19 +175,17 @@ class Event_job_data : public Event_basic
ulong
sql_mode
;
Event_job_data
();
virtual
~
Event_job_data
();
virtual
int
load_from_row
(
THD
*
thd
,
TABLE
*
table
);
int
bool
execute
(
THD
*
thd
,
bool
drop
);
int
compile
(
THD
*
thd
,
MEM_ROOT
*
mem_root
);
private:
int
get_fake_create_event
(
String
*
buf
);
bool
construct_sp_sql
(
THD
*
thd
,
String
*
sp_sql
);
bool
construct_drop_event_sql
(
THD
*
thd
,
String
*
sp_sql
);
Event_job_data
(
const
Event_job_data
&
);
/* Prevent use of these */
void
operator
=
(
Event_job_data
&
);
...
...
sql/event_scheduler.cc
View file @
e0f0ba80
...
...
@@ -277,8 +277,7 @@ Event_worker_thread::run(THD *thd, Event_queue_element_for_exec *event)
{
/* needs to be first for thread_stack */
char
my_stack
;
int
ret
;
Event_job_data
*
job_data
=
NULL
;
Event_job_data
job_data
;
bool
res
;
thd
->
thread_stack
=
&
my_stack
;
// remember where our stack is
...
...
@@ -291,60 +290,43 @@ Event_worker_thread::run(THD *thd, Event_queue_element_for_exec *event)
if
(
res
)
goto
end
;
if
(
!
(
job_data
=
new
Event_job_data
()))
goto
end
;
else
if
((
ret
=
db_repository
->
load_named_event
(
thd
,
event
->
dbname
,
event
->
name
,
job_data
)))
if
((
res
=
db_repository
->
load_named_event
(
thd
,
event
->
dbname
,
event
->
name
,
&
job_data
)))
{
DBUG_PRINT
(
"error"
,
(
"Got
%d from load_named_event"
,
ret
));
DBUG_PRINT
(
"error"
,
(
"Got
error from load_named_event"
));
goto
end
;
}
sql_print_information
(
"Event Scheduler: "
"[%s.%s of %s] executing in thread %lu. "
,
job_data
->
dbname
.
str
,
job_data
->
name
.
str
,
job_data
->
definer
.
str
,
thd
->
thread_id
);
"[%s].[%s.%s] started in thread %lu."
,
job_data
.
definer
.
str
,
job_data
.
dbname
.
str
,
job_data
.
name
.
str
,
thd
->
thread_id
);
thd
->
enable_slow_log
=
TRUE
;
re
t
=
job_data
->
execute
(
thd
,
event
->
dropped
);
re
s
=
job_data
.
execute
(
thd
,
event
->
dropped
);
print_warnings
(
thd
,
job_data
);
print_warnings
(
thd
,
&
job_data
);
switch
(
ret
)
{
case
0
:
if
(
res
)
sql_print_information
(
"Event Scheduler: "
"[%s].[%s.%s] event execution failed."
,
job_data
.
definer
.
str
,
job_data
.
dbname
.
str
,
job_data
.
name
.
str
);
else
sql_print_information
(
"Event Scheduler: "
"[%s].[%s.%s] executed successfully in thread %lu."
,
job_data
->
definer
.
str
,
job_data
->
dbname
.
str
,
job_data
->
name
.
str
,
job_data
.
definer
.
str
,
job_data
.
dbname
.
str
,
job_data
.
name
.
str
,
thd
->
thread_id
);
break
;
case
EVEX_COMPILE_ERROR
:
sql_print_information
(
"Event Scheduler: "
"[%s].[%s.%s] event compilation failed."
,
job_data
->
definer
.
str
,
job_data
->
dbname
.
str
,
job_data
->
name
.
str
);
break
;
default:
sql_print_information
(
"Event Scheduler: "
"[%s].[%s.%s] event execution failed."
,
job_data
->
definer
.
str
,
job_data
->
dbname
.
str
,
job_data
->
name
.
str
);
break
;
}
end:
delete
job_data
;
DBUG_PRINT
(
"info"
,
(
"Done with Event %s.%s"
,
event
->
dbname
.
str
,
event
->
name
.
str
));
delete
event
;
deinit_event_thread
(
thd
);
/*
Do not pthread_exit since we want local destructors for stack objects
to be invoked.
*/
}
...
...
sql/events.cc
View file @
e0f0ba80
...
...
@@ -424,7 +424,8 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
if
(
event_queue
)
event_queue
->
create_event
(
thd
,
new_element
,
&
created
);
/* Binlog the create event. */
if
(
mysql_bin_log
.
is_open
()
&&
(
thd
->
query_length
>
0
))
DBUG_ASSERT
(
thd
->
query
&&
thd
->
query_length
);
if
(
mysql_bin_log
.
is_open
())
{
thd
->
clear_error
();
thd
->
binlog_query
(
THD
::
MYSQL_QUERY_TYPE
,
...
...
@@ -549,7 +550,8 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
event_queue
->
update_event
(
thd
,
parse_data
->
dbname
,
parse_data
->
name
,
new_element
);
/* Binlog the alter event. */
if
(
mysql_bin_log
.
is_open
()
&&
(
thd
->
query_length
>
0
))
DBUG_ASSERT
(
thd
->
query
&&
thd
->
query_length
);
if
(
mysql_bin_log
.
is_open
())
{
thd
->
clear_error
();
thd
->
binlog_query
(
THD
::
MYSQL_QUERY_TYPE
,
...
...
@@ -628,7 +630,8 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
if
(
event_queue
)
event_queue
->
drop_event
(
thd
,
dbname
,
name
);
/* Binlog the drop event. */
if
(
mysql_bin_log
.
is_open
()
&&
(
thd
->
query_length
>
0
))
DBUG_ASSERT
(
thd
->
query
&&
thd
->
query_length
);
if
(
mysql_bin_log
.
is_open
())
{
thd
->
clear_error
();
thd
->
binlog_query
(
THD
::
MYSQL_QUERY_TYPE
,
...
...
sql/item_func.cc
View file @
e0f0ba80
...
...
@@ -5351,7 +5351,7 @@ Item_func_sp::fix_fields(THD *thd, Item **ref)
Security_context
*
save_secutiry_ctx
;
res
=
set_routine_security_ctx
(
thd
,
m_sp
,
false
,
&
save_secutiry_ctx
);
if
(
!
res
)
sp_
restore_security_context
(
thd
,
save_secutiry_ctx
);
m_sp
->
m_security_ctx
.
restore_security_context
(
thd
,
save_secutiry_ctx
);
#endif
/* ! NO_EMBEDDED_ACCESS_CHECKS */
}
...
...
sql/sp_head.cc
View file @
e0f0ba80
...
...
@@ -1245,7 +1245,11 @@ set_routine_security_ctx(THD *thd, sp_head *sp, bool is_proc,
Security_context
**
save_ctx
)
{
*
save_ctx
=
0
;
if
(
sp_change_security_context
(
thd
,
sp
,
save_ctx
))
if
(
sp
->
m_chistics
->
suid
!=
SP_IS_NOT_SUID
&&
sp
->
m_security_ctx
.
change_security_context
(
thd
,
&
sp
->
m_definer_user
,
&
sp
->
m_definer_host
,
&
sp
->
m_db
,
save_ctx
))
return
TRUE
;
/*
...
...
@@ -1262,7 +1266,7 @@ set_routine_security_ctx(THD *thd, sp_head *sp, bool is_proc,
check_routine_access
(
thd
,
EXECUTE_ACL
,
sp
->
m_db
.
str
,
sp
->
m_name
.
str
,
is_proc
,
FALSE
))
{
sp
_
restore_security_context
(
thd
,
*
save_ctx
);
sp
->
m_security_ctx
.
restore_security_context
(
thd
,
*
save_ctx
);
*
save_ctx
=
0
;
return
TRUE
;
}
...
...
@@ -1573,7 +1577,7 @@ sp_head::execute_function(THD *thd, Item **argp, uint argcount,
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS
sp_
restore_security_context
(
thd
,
save_security_ctx
);
m_security_ctx
.
restore_security_context
(
thd
,
save_security_ctx
);
#endif
err_with_cleanup:
...
...
@@ -1791,7 +1795,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
#ifndef NO_EMBEDDED_ACCESS_CHECKS
if
(
save_security_ctx
)
sp_
restore_security_context
(
thd
,
save_security_ctx
);
m_security_ctx
.
restore_security_context
(
thd
,
save_security_ctx
);
#endif
if
(
!
save_spcont
)
...
...
@@ -3431,44 +3435,6 @@ sp_instr_set_case_expr::opt_move(uint dst, List<sp_instr> *bp)
/* ------------------------------------------------------------------ */
/*
Security context swapping
*/
#ifndef NO_EMBEDDED_ACCESS_CHECKS
bool
sp_change_security_context
(
THD
*
thd
,
sp_head
*
sp
,
Security_context
**
backup
)
{
*
backup
=
0
;
if
(
sp
->
m_chistics
->
suid
!=
SP_IS_NOT_SUID
&&
(
strcmp
(
sp
->
m_definer_user
.
str
,
thd
->
security_ctx
->
priv_user
)
||
my_strcasecmp
(
system_charset_info
,
sp
->
m_definer_host
.
str
,
thd
->
security_ctx
->
priv_host
)))
{
if
(
acl_getroot_no_password
(
&
sp
->
m_security_ctx
,
sp
->
m_definer_user
.
str
,
sp
->
m_definer_host
.
str
,
sp
->
m_definer_host
.
str
,
sp
->
m_db
.
str
))
{
my_error
(
ER_NO_SUCH_USER
,
MYF
(
0
),
sp
->
m_definer_user
.
str
,
sp
->
m_definer_host
.
str
);
return
TRUE
;
}
*
backup
=
thd
->
security_ctx
;
thd
->
security_ctx
=
&
sp
->
m_security_ctx
;
}
return
FALSE
;
}
void
sp_restore_security_context
(
THD
*
thd
,
Security_context
*
backup
)
{
if
(
backup
)
thd
->
security_ctx
=
backup
;
}
#endif
/* NO_EMBEDDED_ACCESS_CHECKS */
/*
Structure that represent all instances of one table
...
...
sql/sql_class.cc
View file @
e0f0ba80
...
...
@@ -2120,6 +2120,102 @@ bool Security_context::set_user(char *user_arg)
return
user
==
0
;
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS
/**
Initialize this security context from the passed in credentials
and activate it in the current thread.
@param[out] backup Save a pointer to the current security context
in the thread. In case of success it points to the
saved old context, otherwise it points to NULL.
During execution of a statement, multiple security contexts may
be needed:
- the security context of the authenticated user, used as the
default security context for all top-level statements
- in case of a view or a stored program, possibly the security
context of the definer of the routine, if the object is
defined with SQL SECURITY DEFINER option.
The currently "active" security context is parameterized in THD
member security_ctx. By default, after a connection is
established, this member points at the "main" security context
- the credentials of the authenticated user.
Later, if we would like to execute some sub-statement or a part
of a statement under credentials of a different user, e.g.
definer of a procedure, we authenticate this user in a local
instance of Security_context by means of this method (and
ultimately by means of acl_getroot_no_password), and make the
local instance active in the thread by re-setting
thd->security_ctx pointer.
Note, that the life cycle and memory management of the "main" and
temporary security contexts are different.
For the main security context, the memory for user/host/ip is
allocated on system heap, and the THD class frees this memory in
its destructor. The only case when contents of the main security
context may change during its life time is when someone issued
CHANGE USER command.
Memory management of a "temporary" security context is
responsibility of the module that creates it.
@retval TRUE there is no user with the given credentials. The erro
is reported in the thread.
@retval FALSE success
*/
bool
Security_context
::
change_security_context
(
THD
*
thd
,
LEX_STRING
*
definer_user
,
LEX_STRING
*
definer_host
,
LEX_STRING
*
db
,
Security_context
**
backup
)
{
bool
needs_change
;
DBUG_ENTER
(
"Security_context::change_security_context"
);
DBUG_ASSERT
(
definer_user
->
str
&&
definer_host
->
str
);
*
backup
=
NULL
;
/*
The current security context may have NULL members
if we have just started the thread and not authenticated
any user. This use case is currently in events worker thread.
*/
needs_change
=
(
thd
->
security_ctx
->
priv_user
==
NULL
||
strcmp
(
definer_user
->
str
,
thd
->
security_ctx
->
priv_user
)
||
thd
->
security_ctx
->
priv_host
==
NULL
||
my_strcasecmp
(
system_charset_info
,
definer_host
->
str
,
thd
->
security_ctx
->
priv_host
));
if
(
needs_change
)
{
if
(
acl_getroot_no_password
(
this
,
definer_user
->
str
,
definer_host
->
str
,
definer_host
->
str
,
db
->
str
))
{
my_error
(
ER_NO_SUCH_USER
,
MYF
(
0
),
definer_user
->
str
,
definer_host
->
str
);
DBUG_RETURN
(
TRUE
);
}
*
backup
=
thd
->
security_ctx
;
thd
->
security_ctx
=
this
;
}
DBUG_RETURN
(
FALSE
);
}
void
Security_context
::
restore_security_context
(
THD
*
thd
,
Security_context
*
backup
)
{
if
(
backup
)
thd
->
security_ctx
=
backup
;
}
#endif
/****************************************************************************
Handling of open and locked tables states.
...
...
sql/sql_class.h
View file @
e0f0ba80
...
...
@@ -656,6 +656,18 @@ class Security_context {
}
bool
set_user
(
char
*
user_arg
);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
bool
change_security_context
(
THD
*
thd
,
LEX_STRING
*
definer_user
,
LEX_STRING
*
definer_host
,
LEX_STRING
*
db
,
Security_context
**
backup
);
void
restore_security_context
(
THD
*
thd
,
Security_context
*
backup
);
#endif
};
...
...
sql/sql_trigger.cc
View file @
e0f0ba80
...
...
@@ -1543,9 +1543,16 @@ bool Table_triggers_list::process_triggers(THD *thd, trg_event_type event,
old_field
=
trigger_table
->
field
;
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS
Security_context
*
save_ctx
;
Security_context
*
sctx
=
&
sp_trigger
->
m_security_ctx
;
Security_context
*
save_ctx
=
NULL
;
if
(
sp_change_security_context
(
thd
,
sp_trigger
,
&
save_ctx
))
if
(
sp_trigger
->
m_chistics
->
suid
!=
SP_IS_NOT_SUID
&&
sctx
->
change_security_context
(
thd
,
&
sp_trigger
->
m_definer_user
,
&
sp_trigger
->
m_definer_host
,
&
sp_trigger
->
m_db
,
&
save_ctx
))
return
TRUE
;
/*
...
...
@@ -1570,7 +1577,7 @@ bool Table_triggers_list::process_triggers(THD *thd, trg_event_type event,
thd
->
security_ctx
->
priv_user
,
thd
->
security_ctx
->
host_or_ip
,
trigger_table
->
s
->
table_name
.
str
);
s
p_
restore_security_context
(
thd
,
save_ctx
);
s
ctx
->
restore_security_context
(
thd
,
save_ctx
);
return
TRUE
;
}
#endif // NO_EMBEDDED_ACCESS_CHECKS
...
...
@@ -1582,7 +1589,7 @@ bool Table_triggers_list::process_triggers(THD *thd, trg_event_type event,
thd
->
restore_sub_statement_state
(
&
statement_state
);
#ifndef NO_EMBEDDED_ACCESS_CHECKS
s
p_
restore_security_context
(
thd
,
save_ctx
);
s
ctx
->
restore_security_context
(
thd
,
save_ctx
);
#endif // NO_EMBEDDED_ACCESS_CHECKS
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment