Below is the list of changes that have just been committed into a local
5.1 repository of andrey. When andrey does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2115 06/02/16 05:21:02 andrey@lmy004. +5 -0
small post-merge fixes for bug#16406
(pre-push)
sql/event_timed.cc
1.32 06/02/16 05:20:55 andrey@lmy004. +32 -14
-initialize s_ctx to be the context to be used.
don't use sphead->m_security_ctx but we will copy
the initted ctx to there
- first init the context
- then compile the event
- and then copy the context
- don't use mysql_change_db() for now change_security_context() gets the
right context info
sql/event.h
1.22 06/02/16 05:20:55 andrey@lmy004. +2 -1
initialize s_ctx to be the context to be used.
don't use sphead->m_security_ctx but we will copy
the initted ctx to there
sql/event.cc
1.29 06/02/16 05:20:54 andrey@lmy004. +2 -2
fix compilation failure after big merge
mysql-test/t/events.test
1.20 06/02/16 05:20:54 andrey@lmy004. +10 -2
few more tests
mysql-test/r/events.result
1.20 06/02/16 05:20:54 andrey@lmy004. +9 -1
update result
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: andrey
# Host: lmy004.
# Root: /work/mysql-5.1-bug16406
--- 1.19/mysql-test/r/events.result 2006-02-16 00:49:28 +01:00
+++ 1.20/mysql-test/r/events.result 2006-02-16 05:20:54 +01:00
@@ -23,6 +23,7 @@ DROP EVENT e_x2;
DROP DATABASE db_x;
DROP USER pauline@localhost;
USE events_test;
+SET GLOBAL event_scheduler=0;
drop event if exists event1;
Warnings:
Note 1305 Event event1 does not exist
@@ -43,6 +44,14 @@ select db, name, body, status, interval_
db name body status interval_field interval_value
events_test e_43 set @a = 4 ENABLED SECOND 1
drop event e_43;
+"Let's check whether we can use non-qualified names"
+create table non_qualif(a int);
+create event non_qualif_ev on schedule every 10 minute do insert into non_qualif values
(800219);
+select * from non_qualif;
+a
+800219
+drop event non_qualif_ev;
+drop table non_qualif;
set global event_scheduler = 0;
create table t_event3 (a int, b float);
drop event if exists event3;
@@ -374,7 +383,6 @@ show processlist;
Id User Host db Command Time State Info
# root localhost events_test Query # NULL show processlist
# event_scheduler connecting host NULL Connect # Sleeping NULL
-# root localhost events_test Connect # User lock select get_lock("test_lock2_1", 20)
"Release the lock so the child process should finish. Hence the scheduler also"
select release_lock("test_lock2_1");
release_lock("test_lock2_1")
--- 1.19/mysql-test/t/events.test 2006-02-16 00:49:28 +01:00
+++ 1.20/mysql-test/t/events.test 2006-02-16 05:20:54 +01:00
@@ -28,11 +28,11 @@ connection default;
DROP DATABASE db_x;
DROP USER pauline@localhost;
USE events_test;
---sleep 1
#
# END: BUG #17289 Events: missing privilege check for drop database
#
-
+SET GLOBAL event_scheduler=0;
+--sleep 1
drop event if exists event1;
create event event1 on schedule every 15 minute starts now() ends date_add(now(),
interval 5 hour) DO begin end;
alter event event1 rename to event2 enable;
@@ -56,6 +56,14 @@ alter event e_43 do alter event e_43 do
select db, name, body, status, interval_field, interval_value from mysql.event;
drop event e_43;
--sleep 1
+
+--echo "Let's check whether we can use non-qualified names"
+create table non_qualif(a int);
+create event non_qualif_ev on schedule every 10 minute do insert into non_qualif values
(800219);
+--sleep 2
+select * from non_qualif;
+drop event non_qualif_ev;
+drop table non_qualif;
set global event_scheduler = 0;
create table t_event3 (a int, b float);
--- 1.28/sql/event.cc 2006-02-16 01:27:30 +01:00
+++ 1.29/sql/event.cc 2006-02-16 05:20:54 +01:00
@@ -1272,7 +1272,7 @@ int db_drop_event(THD *thd, event_timed
goto done;
}
- if (!(ret= evex_db_find_event_aux(thd,
et->dbname,et->name,et->definer,table)))
+ if (!(ret= evex_db_find_event_aux(thd, et, table)))
{
if ((ret= table->file->ha_delete_row(table->record[0])))
{
@@ -1452,7 +1452,7 @@ evex_drop_db_events(THD *thd, char *db)
READ_RECORD read_record_info;
MYSQL_LOCK *lock;
int ret= 0;
- int i;
+ uint i;
LEX_STRING db_lex= {db, strlen(db)};
DBUG_ENTER("evex_drop_db_events");
--- 1.21/sql/event.h 2006-02-16 01:27:30 +01:00
+++ 1.22/sql/event.h 2006-02-16 05:20:55 +01:00
@@ -247,7 +247,8 @@ public:
}
protected:
bool
- change_security_context(THD *thd, Security_context **backup);
+ change_security_context(THD *thd, Security_context *s_ctx,
+ Security_context **backup);
void
restore_security_context(THD *thd, Security_context *backup);
--- 1.31/sql/event_timed.cc 2006-02-16 01:27:30 +01:00
+++ 1.32/sql/event_timed.cc 2006-02-16 05:20:55 +01:00
@@ -412,21 +412,30 @@ event_timed::init_definer(THD *thd)
{
DBUG_ENTER("event_timed::init_definer");
+ DBUG_PRINT("info",("init definer_user thd->mem_root=0x%lx "
+ "thd->sec_ctx->priv_user=0x%lx", thd->mem_root,
+ thd->security_ctx->priv_user));
definer_user.str= strdup_root(thd->mem_root, thd->security_ctx->priv_user);
definer_user.length= strlen(thd->security_ctx->priv_user);
+ DBUG_PRINT("info",("init definer_host thd->s_c->priv_host=0x%lx",
+ thd->security_ctx->priv_host));
definer_host.str= strdup_root(thd->mem_root, thd->security_ctx->priv_host);
definer_host.length= strlen(thd->security_ctx->priv_host);
+ DBUG_PRINT("info",("init definer as whole"));
definer.length= definer_user.length + definer_host.length + 1;
definer.str= alloc_root(thd->mem_root, definer.length + 1);
+ DBUG_PRINT("info",("copy the user"));
memcpy(definer.str, definer_user.str, definer_user.length);
definer.str[definer_user.length]= '@';
+ DBUG_PRINT("info",("copy the host"));
memcpy(definer.str + definer_user.length + 1, definer_host.str,
definer_host.length);
definer.str[definer.length]= '\0';
+ DBUG_PRINT("info",("definer initted"));
DBUG_RETURN(0);
}
@@ -1070,6 +1079,8 @@ int
event_timed::execute(THD *thd, MEM_ROOT *mem_root)
{
Security_context *save_ctx;
+ /* this one is local and not needed after exec */
+ Security_context security_ctx;
int ret= 0;
DBUG_ENTER("event_timed::execute");
@@ -1085,18 +1096,19 @@ event_timed::execute(THD *thd, MEM_ROOT
running= true;
VOID(pthread_mutex_unlock(&this->LOCK_running));
- // TODO Andrey : make this as member variable and delete in destructor
-
- if (!sphead && (ret= compile(thd, mem_root)))
- goto done;
-
DBUG_PRINT("info", ("master_access=%d db_access=%d",
thd->security_ctx->master_access,
thd->security_ctx->db_access));
- change_security_context(thd, &save_ctx);
-
+ change_security_context(thd, &security_ctx, &save_ctx);
DBUG_PRINT("info", ("master_access=%d db_access=%d",
thd->security_ctx->master_access,
thd->security_ctx->db_access));
- if (mysql_change_db(thd, dbname.str, 0))
+
+ if (!sphead && (ret= compile(thd, mem_root)))
+ goto done;
+ /* Now we are sure we have valid this->sphead so we can copy the context */
+ sphead->m_security_ctx= security_ctx;
+ thd->db= dbname.str;
+ thd->db_length= dbname.length;
+ if (!check_access(thd, EVENT_ACL,dbname.str, 0, 0, 0,is_schema_db(dbname.str)))
{
List<Item> empty_item_list;
empty_item_list.empty();
@@ -1109,16 +1121,20 @@ event_timed::execute(THD *thd, MEM_ROOT
ret= -99;
}
restore_security_context(thd, save_ctx);
-
DBUG_PRINT("info", ("master_access=%d db_access=%d",
thd->security_ctx->master_access,
thd->security_ctx->db_access));
+ thd->db= 0;
VOID(pthread_mutex_lock(&this->LOCK_running));
running= false;
VOID(pthread_mutex_unlock(&this->LOCK_running));
done:
- // Don't cache sphead if allocated on another mem_root
+ /*
+ 1. Don't cache sphead if allocated on another mem_root
+ 2. Don't call security_ctx.destroy() because this will free our dbname.str
+ name.str and definer.str
+ */
if (mem_root && sphead)
{
delete sphead;
@@ -1143,20 +1159,22 @@ done:
1 - Error (generates error too)
*/
bool
-event_timed::change_security_context(THD *thd, Security_context **backup)
+event_timed::change_security_context(THD *thd, Security_context *s_ctx,
+ Security_context **backup)
{
DBUG_ENTER("event_timed::change_security_context");
DBUG_PRINT("info",("%s@%s@%s",definer_user.str,definer_host.str, dbname.str));
#ifndef NO_EMBEDDED_ACCESS_CHECKS
+ s_ctx->init();
*backup= 0;
- if (acl_getroot_no_password(&sphead->m_security_ctx, definer_user.str,
- definer_host.str, definer_host.str, dbname.str))
+ if (acl_getroot_no_password(s_ctx, definer_user.str, definer_host.str,
+ definer_host.str, dbname.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= &sphead->m_security_ctx;
+ thd->security_ctx= s_ctx;
#endif
DBUG_RETURN(FALSE);
}
| Thread |
|---|
| • bk commit into 5.1 tree (andrey:1.2115) BUG#16406 | ahristov | 16 Feb |