diff options
author | unknown <dlenev@mysql.com> | 2005-12-21 15:02:34 +0300 |
---|---|---|
committer | unknown <dlenev@mysql.com> | 2005-12-21 15:02:34 +0300 |
commit | 9ae226fe41576390b48141205619223eb4cdde4b (patch) | |
tree | ab15b8ea4e5e9d944b887b22d0e8ebf8c157affe /sql/sql_trigger.cc | |
parent | 17b32e1a9116a1265e3be9ceed505ef2d7ea48ce (diff) | |
parent | 7402f669c6b84336769c8180e72f1da50194da74 (diff) | |
download | mariadb-git-9ae226fe41576390b48141205619223eb4cdde4b.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/dlenev/src/mysql-5.0-bg14836
Diffstat (limited to 'sql/sql_trigger.cc')
-rw-r--r-- | sql/sql_trigger.cc | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 779b044696e..13b79821a58 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -78,10 +78,6 @@ const char * const trigname_file_ext= ".TRN"; static File_option trigname_file_parameters[]= { { - /* - FIXME: Length specified for "trigger_table" key is erroneous, problem - caused by this are reported as BUG#14090 and should be fixed ASAP. - */ {STRING_WITH_LEN("trigger_table")}, offsetof(struct st_trigname, trigger_table), FILE_OPTIONS_ESTRING @@ -155,6 +151,17 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) But do we want this ? */ + /* + Note that once we will have check for TRIGGER privilege in place we won't + need second part of condition below, since check_access() function also + checks that db is specified. + */ + if (!thd->lex->spname->m_db.length || create && !tables->db_length) + { + my_error(ER_NO_DB_ERROR, MYF(0)); + DBUG_RETURN(TRUE); + } + if (!create && !(tables= add_table_for_trigger(thd, thd->lex->spname))) DBUG_RETURN(TRUE); @@ -285,6 +292,9 @@ end: definer. The caller is responsible to provide memory for storing LEX_STRING object. + NOTE + Assumes that trigger name is fully qualified. + RETURN VALUE False - success True - error @@ -307,9 +317,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, /* Trigger must be in the same schema as target table. */ - if (my_strcasecmp(table_alias_charset, table->s->db, - lex->spname->m_db.str ? lex->spname->m_db.str : - thd->db)) + if (my_strcasecmp(table_alias_charset, table->s->db, lex->spname->m_db.str)) { my_error(ER_TRG_IN_WRONG_SCHEMA, MYF(0)); return 1; @@ -1010,7 +1018,6 @@ bool Table_triggers_list::get_trigger_info(THD *thd, trg_event_type event, static TABLE_LIST *add_table_for_trigger(THD *thd, sp_name *trig) { - const char *db= !trig->m_db.str ? thd->db : trig->m_db.str; LEX *lex= thd->lex; char path_buff[FN_REFLEN]; LEX_STRING path; @@ -1018,7 +1025,7 @@ static TABLE_LIST *add_table_for_trigger(THD *thd, sp_name *trig) struct st_trigname trigname; DBUG_ENTER("add_table_for_trigger"); - strxnmov(path_buff, FN_REFLEN, mysql_data_home, "/", db, "/", + strxnmov(path_buff, FN_REFLEN, mysql_data_home, "/", trig->m_db.str, "/", trig->m_name.str, trigname_file_ext, NullS); path.length= unpack_filename(path_buff, path_buff); path.str= path_buff; @@ -1047,7 +1054,7 @@ static TABLE_LIST *add_table_for_trigger(THD *thd, sp_name *trig) /* We need to reset statement table list to be PS/SP friendly. */ lex->query_tables= 0; lex->query_tables_last= &lex->query_tables; - DBUG_RETURN(sp_add_to_query_tables(thd, lex, db, + DBUG_RETURN(sp_add_to_query_tables(thd, lex, trig->m_db.str, trigname.trigger_table.str, TL_WRITE)); } |