error message interception (Bug#4598)

error handling of view initialization fixed (Bug#4599)


include/mysqld_error.h:
  new error message
mysql-test/r/view.result:
  changing of underlaying table test
mysql-test/t/view.test:
  changing of underlaying table test
sql/share/czech/errmsg.txt:
  new error message
sql/share/danish/errmsg.txt:
  new error message
sql/share/dutch/errmsg.txt:
  new error message
sql/share/english/errmsg.txt:
  new error message
sql/share/estonian/errmsg.txt:
  new error message
sql/share/french/errmsg.txt:
  new error message
sql/share/german/errmsg.txt:
  new error message
sql/share/greek/errmsg.txt:
  new error message
sql/share/hungarian/errmsg.txt:
  new error message
sql/share/italian/errmsg.txt:
  new error message
sql/share/japanese/errmsg.txt:
  new error message
sql/share/korean/errmsg.txt:
  new error message
sql/share/norwegian-ny/errmsg.txt:
  new error message
sql/share/norwegian/errmsg.txt:
  new error message
sql/share/polish/errmsg.txt:
  new error message
sql/share/portuguese/errmsg.txt:
  new error message
sql/share/romanian/errmsg.txt:
  new error message
sql/share/russian/errmsg.txt:
  new error message
sql/share/serbian/errmsg.txt:
  new error message
sql/share/slovak/errmsg.txt:
  new error message
sql/share/spanish/errmsg.txt:
  new error message
sql/share/swedish/errmsg.txt:
  new error message
sql/share/ukrainian/errmsg.txt:
  new error message
sql/sql_base.cc:
  error message interception
  error handling fixed
sql/sql_view.cc:
  comment fixed
  error message interception
sql/table.cc:
  error message interception
sql/table.h:
  error message interception
This commit is contained in:
unknown 2004-07-21 04:26:20 +03:00
parent d3b2b84294
commit b01e2f6ddc
30 changed files with 85 additions and 4 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -359,3 +359,4 @@ character-set=koi8r
"View SELECT и список полей view имеют разное количество столбцов"
"Алгоритм слияния view не может быть использован сейчас (алгоритм будет неопеределенным)"
"Обновляемый view не содержит ключа использованной в нем таблиц(ы)"
"View '%-.64s.%-.64s' ссылается на несуществующие таблицы или слолбцы"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -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)"

View File

@ -362,3 +362,4 @@ character-set=koi8u
"View SELECT ╕ перел╕к стовбц╕в view мають р╕зну к╕льк╕сть сковбц╕в"
"Алгоритм зливання view не може бути використаний зараз (алгоритм буде невизначений)"
"View, що оновлюеться, не м╕стить повного ключа таблиц╕(ь), що викор╕стана в ньюому"
"View '%-.64s.%-.64s' посила╓тся на не╕снуюч╕ таблиц╕ або стовбц╕"

View File

@ -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)
{

View File

@ -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

View File

@ -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);
}

View File

@ -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 */