mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
error message interception (Bug#4598)
error handling of view initialization fixed (Bug#4599)
This commit is contained in:
@ -370,4 +370,5 @@
|
||||
#define ER_VIEW_WRONG_LIST 1351
|
||||
#define ER_WARN_VIEW_MERGE 1352
|
||||
#define ER_WARN_VIEW_WITHOUT_KEY 1353
|
||||
#define ER_ERROR_MESSAGES 354
|
||||
#define ER_VIEW_INVALID 1354
|
||||
#define ER_ERROR_MESSAGES 355
|
||||
|
@ -965,3 +965,13 @@ Field Type Null Key Default Extra
|
||||
col1 char(2) YES NULL
|
||||
drop view v1;
|
||||
drop table `t1a``b`;
|
||||
create table t1 (col1 char(5),col2 char(5));
|
||||
create view v1 as select * from t1;
|
||||
drop table t1;
|
||||
create table t1 (col1 char(5),newcol2 char(5));
|
||||
insert into v1 values('a','aa');
|
||||
ERROR HY000: View 'test.v1' references invalid table(s) or column(s)
|
||||
drop table t1;
|
||||
select * from v1;
|
||||
ERROR HY000: View 'test.v1' references invalid table(s) or column(s)
|
||||
drop view v1;
|
||||
|
@ -880,3 +880,17 @@ select * from v1;
|
||||
describe v1;
|
||||
drop view v1;
|
||||
drop table `t1a``b`;
|
||||
|
||||
#
|
||||
# Changing of underlaying table
|
||||
#
|
||||
create table t1 (col1 char(5),col2 char(5));
|
||||
create view v1 as select * from t1;
|
||||
drop table t1;
|
||||
create table t1 (col1 char(5),newcol2 char(5));
|
||||
-- error 1354
|
||||
insert into v1 values('a','aa');
|
||||
drop table t1;
|
||||
-- error 1354
|
||||
select * from v1;
|
||||
drop view v1;
|
||||
|
@ -366,3 +366,4 @@ character-set=latin2
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -360,3 +360,4 @@ character-set=latin1
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -368,3 +368,4 @@ character-set=latin1
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -357,3 +357,4 @@ character-set=latin1
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -362,3 +362,4 @@ character-set=latin7
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -357,3 +357,4 @@ character-set=latin1
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -369,3 +369,4 @@ character-set=latin1
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -357,3 +357,4 @@ character-set=greek
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -359,3 +359,4 @@ character-set=latin2
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -357,3 +357,4 @@ character-set=latin1
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -359,3 +359,4 @@ character-set=ujis
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -357,3 +357,4 @@ character-set=euckr
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -359,3 +359,4 @@ character-set=latin1
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -359,3 +359,4 @@ character-set=latin1
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -361,3 +361,4 @@ character-set=latin2
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -358,3 +358,4 @@ character-set=latin1
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -361,3 +361,4 @@ character-set=latin2
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -359,3 +359,4 @@ character-set=koi8r
|
||||
"View SELECT <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> view <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
|
||||
"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> view <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)"
|
||||
"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> view <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28>)"
|
||||
"View '%-.64s.%-.64s' <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
|
||||
|
@ -363,3 +363,4 @@ character-set=cp1250
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -365,3 +365,4 @@ character-set=latin2
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -359,3 +359,4 @@ character-set=latin1
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -357,3 +357,4 @@ character-set=latin1
|
||||
"View's SELECT and view's field list have different column counts"
|
||||
"View merge algorithm can't be used here for now (assumed undefined algorithm)"
|
||||
"View being update does not have complete key of underlying table in it"
|
||||
"View '%-.64s.%-.64s' references invalid table(s) or column(s)"
|
||||
|
@ -362,3 +362,4 @@ character-set=koi8u
|
||||
"View SELECT <20> <20><><EFBFBD><EFBFBD>̦<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>æ<EFBFBD> view <20><><EFBFBD><EFBFBD><EFBFBD> Ҧ<><D2A6><EFBFBD> ˦<><CBA6>˦<EFBFBD><CBA6><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>æ<EFBFBD>"
|
||||
"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> view <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)"
|
||||
"View, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><> ͦ<><CDA6><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>æ(<28>), <20><> <20><><EFBFBD><EFBFBD>Ҧ<EFBFBD><D2A6><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
|
||||
"View '%-.64s.%-.64s' <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20>Ŧ<EFBFBD><C5A6><EFBFBD><EFBFBD>ަ <20><><EFBFBD><EFBFBD><EFBFBD>æ <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>æ"
|
||||
|
@ -1505,6 +1505,13 @@ memory to write 'DELETE FROM `%s`.`%s`' to the binary log",db,name);
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
err:
|
||||
/* Hide "Table doesn't exist" errors if table belong to view */
|
||||
if (thd->net.last_errno == ER_NO_SUCH_TABLE && table_desc->belong_to_view)
|
||||
{
|
||||
TABLE_LIST * view= table_desc->belong_to_view;
|
||||
thd->clear_error();
|
||||
my_error(ER_VIEW_INVALID, MYF(0), view->view_db.str, view->view_name.str);
|
||||
}
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
@ -2511,8 +2518,8 @@ bool setup_tables(THD *thd, TABLE_LIST *tables, Item **conds)
|
||||
table->keys_in_use_for_query.subtract(map);
|
||||
}
|
||||
table->used_keys.intersect(table->keys_in_use_for_query);
|
||||
if (table_list->ancestor)
|
||||
table_list->setup_ancestor(thd, conds);
|
||||
if (table_list->ancestor && table_list->setup_ancestor(thd, conds))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (tablenr > MAX_TABLES)
|
||||
{
|
||||
|
@ -483,6 +483,10 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view,
|
||||
mysql_make_view()
|
||||
parser - parser object;
|
||||
table - TABLE_LIST structure for filling
|
||||
|
||||
RETURN
|
||||
TRUE OK
|
||||
FALSE error
|
||||
*/
|
||||
my_bool
|
||||
mysql_make_view(File_parser *parser, TABLE_LIST *table)
|
||||
@ -576,6 +580,9 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
|
||||
}
|
||||
if (!res && !thd->is_fatal_error)
|
||||
{
|
||||
TABLE_LIST *top_view= (table->belong_to_view ?
|
||||
table->belong_to_view :
|
||||
table);
|
||||
|
||||
/* move SP to main LEX */
|
||||
sp_merge_funs(old_lex, lex);
|
||||
@ -586,9 +593,12 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table)
|
||||
if ((table->next_global= lex->query_tables))
|
||||
table->next_global->prev_global= &table->next_global;
|
||||
|
||||
/* mark to avoid temporary table using */
|
||||
/* mark to avoid temporary table using and put view reference*/
|
||||
for (TABLE_LIST *tbl= table->next_global; tbl; tbl= tbl->next_global)
|
||||
{
|
||||
tbl->skip_temporary= 1;
|
||||
tbl->belong_to_view= top_view;
|
||||
}
|
||||
|
||||
/*
|
||||
check rights to run commands (EXPLAIN SELECT & SHOW CREATE) which show
|
||||
|
14
sql/table.cc
14
sql/table.cc
@ -1500,6 +1500,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
|
||||
{
|
||||
Item **transl;
|
||||
SELECT_LEX *select= &view->select_lex;
|
||||
SELECT_LEX *current_select_save= thd->lex->current_select;
|
||||
Item *item;
|
||||
List_iterator_fast<Item> it(select->item_list);
|
||||
uint i= 0;
|
||||
@ -1512,6 +1513,8 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
|
||||
|
||||
if (field_translation)
|
||||
{
|
||||
/* prevent look up in SELECTs tree */
|
||||
thd->lex->current_select= &thd->lex->select_lex;
|
||||
thd->set_query_id= 1;
|
||||
/* this view was prepared already on previous PS/SP execution */
|
||||
Item **end= field_translation + select->item_list.elements;
|
||||
@ -1536,6 +1539,9 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
|
||||
{
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
/* prevent look up in SELECTs tree */
|
||||
thd->lex->current_select= &thd->lex->select_lex;
|
||||
/*
|
||||
Resolve all view items against ancestor table.
|
||||
|
||||
@ -1590,10 +1596,18 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds)
|
||||
}
|
||||
|
||||
ok:
|
||||
thd->lex->current_select= current_select_save;
|
||||
thd->set_query_id= save_set_query_id;
|
||||
DBUG_RETURN(0);
|
||||
|
||||
err:
|
||||
/* Hide "Unknown column" error */
|
||||
if (thd->net.last_errno == ER_BAD_FIELD_ERROR)
|
||||
{
|
||||
thd->clear_error();
|
||||
my_error(ER_VIEW_INVALID, MYF(0), view_db.str, view_name.str);
|
||||
}
|
||||
thd->lex->current_select= current_select_save;
|
||||
thd->set_query_id= save_set_query_id;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
@ -205,6 +205,8 @@ typedef struct st_table_list
|
||||
Item **field_translation; /* array of VIEW fields */
|
||||
/* ancestor of this table (VIEW merge algorithm) */
|
||||
st_table_list *ancestor;
|
||||
/* most upper view this table belongs to */
|
||||
st_table_list *belong_to_view;
|
||||
Item *where; /* VIEW WHERE clause condition */
|
||||
LEX_STRING query; /* text of (CRETE/SELECT) statement */
|
||||
LEX_STRING md5; /* md5 of query tesxt */
|
||||
|
Reference in New Issue
Block a user