mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fix for bug#12127 triggers do not show in info_schema before they are used if set to the database(2nd version)
use db name of table which trigger belongs to instead of thd->db name during trigger body parsing
This commit is contained in:
@ -520,6 +520,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
|
||||
char path_buff[FN_REFLEN];
|
||||
LEX_STRING path;
|
||||
File_parser *parser;
|
||||
LEX_STRING save_db;
|
||||
|
||||
DBUG_ENTER("Table_triggers_list::check_n_load");
|
||||
|
||||
@ -581,6 +582,10 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
|
||||
|
||||
thd->lex= &lex;
|
||||
|
||||
save_db.str= thd->db;
|
||||
save_db.length= thd->db_length;
|
||||
thd->db_length= strlen(db);
|
||||
thd->db= (char *) db;
|
||||
while ((trg_create_str= it++))
|
||||
{
|
||||
lex_start(thd, (uchar*)trg_create_str->str, trg_create_str->length);
|
||||
@ -623,6 +628,8 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
|
||||
|
||||
lex_end(&lex);
|
||||
}
|
||||
thd->db= save_db.str;
|
||||
thd->db_length= save_db.length;
|
||||
thd->lex= old_lex;
|
||||
|
||||
DBUG_RETURN(0);
|
||||
@ -631,6 +638,8 @@ err_with_lex_cleanup:
|
||||
// QQ: anything else ?
|
||||
lex_end(&lex);
|
||||
thd->lex= old_lex;
|
||||
thd->db= save_db.str;
|
||||
thd->db_length= save_db.length;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user