Below is the list of changes that have just been committed into a local
5.0 repository of bell. When bell 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.1910 05/08/23 23:17:36 bell@stripped +13 -0
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-5.0
into sanja.is.com.ua:/home/bell/mysql/bk/work-bug3-5.0
sql/table.h
1.110 05/08/23 23:17:32 bell@stripped +0 -0
merge
sql/sql_insert.cc
1.171 05/08/23 23:17:32 bell@stripped +1 -7
merge
sql/share/errmsg.txt
1.41 05/08/23 23:17:32 bell@stripped +2 -2
merge
mysql-test/t/view.test
1.100 05/08/23 23:17:32 bell@stripped +0 -1
merge
mysql-test/r/view.result
1.106 05/08/23 23:17:32 bell@stripped +0 -0
merge
sql/table.cc
1.184 05/08/23 23:05:20 bell@stripped +0 -0
Auto merged
sql/sql_view.cc
1.61 05/08/23 23:05:20 bell@stripped +0 -0
Auto merged
sql/sql_update.cc
1.167 05/08/23 23:05:20 bell@stripped +0 -0
Auto merged
sql/sql_parse.cc
1.473 05/08/23 23:05:20 bell@stripped +0 -0
Auto merged
sql/sql_delete.cc
1.157 05/08/23 23:05:19 bell@stripped +0 -0
Auto merged
sql/sql_base.cc
1.291 05/08/23 23:05:19 bell@stripped +0 -0
Auto merged
sql/mysql_priv.h
1.343 05/08/23 23:05:19 bell@stripped +0 -0
Auto merged
BitKeeper/etc/config
1.20 05/08/23 23:05:19 bell@stripped +0 -1
Auto merged
# 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: bell
# Host: sanja.is.com.ua
# Root: /home/bell/mysql/bk/work-bug3-5.0/RESYNC
--- 1.342/sql/mysql_priv.h 2005-08-16 12:18:28 +03:00
+++ 1.343/sql/mysql_priv.h 2005-08-23 23:05:19 +03:00
@@ -895,6 +895,9 @@
void add_join_natural(TABLE_LIST *a,TABLE_LIST *b,List<String> *using_fields);
bool add_proc_to_list(THD *thd, Item *item);
TABLE *unlink_open_table(THD *thd,TABLE *list,TABLE *find);
+void update_non_unique_table_error(TABLE_LIST *update,
+ const char *operation,
+ TABLE_LIST *duplicate);
SQL_SELECT *make_select(TABLE *head, table_map const_tables,
table_map read_tables, COND *conds,
--- 1.290/sql/sql_base.cc 2005-08-23 18:15:46 +03:00
+++ 1.291/sql/sql_base.cc 2005-08-23 23:05:19 +03:00
@@ -774,6 +774,60 @@
}
+/*
+ Issue correct error message in case we found 2 duplicate tables which
+ prevent some update operation
+
+ SYNOPSIS
+ update_non_unique_table_error()
+ update table which we try to update
+ operation name of update operation
+ duplicate duplicate table which we found
+
+ NOTE:
+ here we hide view underlying tables if we have them
+*/
+
+void update_non_unique_table_error(TABLE_LIST *update,
+ const char *operation,
+ TABLE_LIST *duplicate)
+{
+ update= update->top_table();
+ duplicate= duplicate->top_table();
+ if (!update->view || !duplicate->view ||
+ update->view == duplicate->view ||
+ update->view_name.length != duplicate->view_name.length ||
+ update->view_db.length != duplicate->view_db.length ||
+ my_strcasecmp(table_alias_charset,
+ update->view_name.str, duplicate->view_name.str) != 0 ||
+ my_strcasecmp(table_alias_charset,
+ update->view_db.str, duplicate->view_db.str) != 0)
+ {
+ /*
+ it is not the same view repeated (but it can be parts of the same copy
+ of view), so we have to hide underlying tables.
+ */
+ if (update->view)
+ {
+ if (update->view == duplicate->view)
+ my_error(ER_NON_UPDATABLE_TABLE, MYF(0), update->alias, operation);
+ else
+ my_error(ER_VIEW_PREVENT_UPDATE, MYF(0),
+ (duplicate->view ? duplicate->alias : update->alias),
+ operation, update->alias);
+ return;
+ }
+ if (duplicate->view)
+ {
+ my_error(ER_VIEW_PREVENT_UPDATE, MYF(0), duplicate->alias, operation,
+ update->alias);
+ return;
+ }
+ }
+ my_error(ER_UPDATE_TABLE_USED, MYF(0), update->alias);
+}
+
+
TABLE **find_temporary_table(THD *thd, const char *db, const char *table_name)
{
char key[MAX_DBKEY_LENGTH];
@@ -4153,9 +4207,7 @@
{
TABLE *table= table_list->table;
if (first_select_table &&
- (table_list->belong_to_view ?
- table_list->belong_to_view :
- table_list) == first_select_table)
+ table_list->top_table() == first_select_table)
{
/* new counting for SELECT of INSERT ... SELECT command */
first_select_table= 0;
--- 1.156/sql/sql_delete.cc 2005-08-15 18:31:01 +03:00
+++ 1.157/sql/sql_delete.cc 2005-08-23 23:05:19 +03:00
@@ -312,10 +312,13 @@
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "DELETE");
DBUG_RETURN(TRUE);
}
- if (unique_table(table_list, table_list->next_global))
{
- my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
- DBUG_RETURN(TRUE);
+ TABLE_LIST *duplicate;
+ if ((duplicate= unique_table(table_list, table_list->next_global)))
+ {
+ update_non_unique_table_error(table_list, "DELETE", duplicate);
+ DBUG_RETURN(TRUE);
+ }
}
select_lex->fix_prepare_information(thd, conds);
DBUG_RETURN(FALSE);
@@ -398,11 +401,15 @@
Check that table from which we delete is not used somewhere
inside subqueries/view.
*/
- if (unique_table(target_tbl->correspondent_table, lex->query_tables))
{
- my_error(ER_UPDATE_TABLE_USED, MYF(0),
- target_tbl->correspondent_table->table_name);
- DBUG_RETURN(TRUE);
+ TABLE_LIST *duplicate;
+ if ((duplicate= unique_table(target_tbl->correspondent_table,
+ lex->query_tables)))
+ {
+ update_non_unique_table_error(target_tbl->correspondent_table,
+ "DELETE", duplicate);
+ DBUG_RETURN(TRUE);
+ }
}
}
DBUG_RETURN(FALSE);
--- 1.170/sql/sql_insert.cc 2005-08-18 03:12:33 +03:00
+++ 1.171/sql/sql_insert.cc 2005-08-23 23:17:32 +03:00
@@ -917,9 +917,10 @@
if (!select_insert)
{
Item *fake_conds= 0;
- if (unique_table(table_list, table_list->next_global))
+ TABLE_LIST *duplicate;
+ if ((duplicate= unique_table(table_list, table_list->next_global)))
{
- my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
+ update_non_unique_table_error(table_list, "INSERT", duplicate);
DBUG_RETURN(TRUE);
}
select_lex->fix_prepare_information(thd, &fake_conds);
--- 1.472/sql/sql_parse.cc 2005-08-22 01:13:18 +03:00
+++ 1.473/sql/sql_parse.cc 2005-08-23 23:05:20 +03:00
@@ -2854,12 +2854,15 @@
Is table which we are changing used somewhere in other parts
of query
*/
- if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) &&
- unique_table(create_table, select_tables))
+ if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE))
{
- my_error(ER_UPDATE_TABLE_USED, MYF(0), create_table->table_name);
- res= 1;
- goto end_with_restart_wait;
+ TABLE_LIST *duplicate;
+ if ((duplicate= unique_table(create_table, select_tables)))
+ {
+ update_non_unique_table_error(create_table, "CREATE", duplicate);
+ res= 1;
+ goto end_with_restart_wait;
+ }
}
/* If we create merge table, we have to test tables in merge, too */
if (lex->create_info.used_fields & HA_CREATE_USED_UNION)
@@ -2869,9 +2872,10 @@
tab;
tab= tab->next_local)
{
- if (unique_table(tab, select_tables))
+ TABLE_LIST *duplicate;
+ if ((duplicate= unique_table(tab, select_tables)))
{
- my_error(ER_UPDATE_TABLE_USED, MYF(0), tab->table_name);
+ update_non_unique_table_error(tab, "CREATE", duplicate);
res= 1;
goto end_with_restart_wait;
}
--- 1.166/sql/sql_update.cc 2005-08-15 18:31:01 +03:00
+++ 1.167/sql/sql_update.cc 2005-08-23 23:05:20 +03:00
@@ -566,10 +566,14 @@
DBUG_RETURN(TRUE);
/* Check that we are not using table that we are updating in a sub select */
- if (unique_table(table_list, table_list->next_global))
{
- my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
- DBUG_RETURN(TRUE);
+ TABLE_LIST *duplicate;
+ if ((duplicate= unique_table(table_list, table_list->next_global)))
+ {
+ update_non_unique_table_error(table_list, "UPDATE", duplicate);
+ my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
+ DBUG_RETURN(TRUE);
+ }
}
select_lex->fix_prepare_information(thd, conds);
DBUG_RETURN(FALSE);
@@ -779,7 +783,7 @@
{
TABLE *table= tl->table;
TABLE_LIST *tlist;
- if (!(tlist= tl->belong_to_view ? tl->belong_to_view : tl)->derived)
+ if (!(tlist= tl->top_table())->derived)
{
tlist->grant.want_privilege=
(SELECT_ACL & ~tlist->grant.privilege);
@@ -788,11 +792,14 @@
DBUG_PRINT("info", ("table: %s want_privilege: %u", tl->alias,
(uint) table->grant.want_privilege));
if (tl->lock_type != TL_READ &&
- tl->lock_type != TL_READ_NO_INSERT &&
- unique_table(tl, table_list))
+ tl->lock_type != TL_READ_NO_INSERT)
{
- my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
- DBUG_RETURN(TRUE);
+ TABLE_LIST *duplicate;
+ if ((duplicate= unique_table(tl, table_list)))
+ {
+ update_non_unique_table_error(table_list, "UPDATE", duplicate);
+ DBUG_RETURN(TRUE);
+ }
}
}
--- 1.183/sql/table.cc 2005-08-23 18:15:46 +03:00
+++ 1.184/sql/table.cc 2005-08-23 23:05:20 +03:00
@@ -2056,7 +2056,7 @@
{
if (check_option && check_option->val_int() == 0)
{
- TABLE_LIST *view= (belong_to_view ? belong_to_view : this);
+ TABLE_LIST *view= top_table();
if (ignore_failure)
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
--- 1.109/sql/table.h 2005-08-23 18:15:46 +03:00
+++ 1.110/sql/table.h 2005-08-23 23:17:32 +03:00
@@ -602,6 +602,8 @@
st_table_list *first_leaf_for_name_resolution();
st_table_list *last_leaf_for_name_resolution();
bool is_leaf_for_name_resolution();
+ inline st_table_list *top_table()
+ { return belong_to_view ? belong_to_view : this; }
inline bool prepare_check_option(THD *thd)
{
bool res= FALSE;
--- 1.40/sql/share/errmsg.txt 2005-08-23 08:15:00 +03:00
+++ 1.41/sql/share/errmsg.txt 2005-08-23 23:17:32 +03:00
@@ -5399,3 +5399,5 @@
eng "Datetime function: %-.32s field overflow"
ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
eng "Can't update table '%-.64s' in stored function/trigger because it is already used by statement which invoked this stored function/trigger."
+ER_VIEW_PREVENT_UPDATE
+ eng "The definition of table '%-.64s' prevents operation %s on table '%-.64s'."
--- 1.105/mysql-test/r/view.result 2005-08-19 01:16:59 +03:00
+++ 1.106/mysql-test/r/view.result 2005-08-23 23:17:32 +03:00
@@ -875,29 +875,29 @@
create view v2 as select * from v1;
create view v3 as select v2.col1 from v2,t2 where v2.col1 = t2.col1;
update v2 set col1 = (select max(col1) from v1);
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'v2'.
update v2 set col1 = (select max(col1) from t1);
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 'v2'.
update v2 set col1 = (select max(col1) from v2);
ERROR HY000: You can't specify target table 'v2' for update in FROM clause
update v2,t2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1;
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'v2'.
update t1,t2 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't1'.
update v1,t2 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1;
ERROR HY000: You can't specify target table 'v1' for update in FROM clause
update t2,v2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't2'.
update t2,t1 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't2'.
update t2,v1 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't2'.
update v2,t2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1;
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 'v2'.
update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
ERROR HY000: You can't specify target table 't1' for update in FROM clause
update v1,t2 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 'v1' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'v1'.
update t2,v2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1;
ERROR HY000: You can't specify target table 't2' for update in FROM clause
update t2,t1 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
@@ -907,73 +907,73 @@
update v2,t2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1;
ERROR HY000: You can't specify target table 'v2' for update in FROM clause
update t1,t2 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 't1'.
update v1,t2 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 'v1' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 'v1'.
update t2,v2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 't2'.
update t2,t1 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 't2'.
update t2,v1 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 't2'.
update v3 set v3.col1 = (select max(col1) from v1);
-ERROR HY000: You can't specify target table 'v3' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'v3'.
update v3 set v3.col1 = (select max(col1) from t1);
-ERROR HY000: You can't specify target table 'v3' for update in FROM clause
+ERROR HY000: The definition of table 'v3' prevents operation UPDATE on table 'v3'.
update v3 set v3.col1 = (select max(col1) from v2);
-ERROR HY000: You can't specify target table 'v3' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 'v3'.
update v3 set v3.col1 = (select max(col1) from v3);
ERROR HY000: You can't specify target table 'v3' for update in FROM clause
delete from v2 where col1 = (select max(col1) from v1);
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'v2'.
delete from v2 where col1 = (select max(col1) from t1);
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation DELETE on table 'v2'.
delete from v2 where col1 = (select max(col1) from v2);
ERROR HY000: You can't specify target table 'v2' for update in FROM clause
delete v2 from v2,t2 where (select max(col1) from v1) > 0 and v2.col1 = t2.col1;
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'v2'.
delete t1 from t1,t2 where (select max(col1) from v1) > 0 and t1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 't1'.
delete v1 from v1,t2 where (select max(col1) from v1) > 0 and v1.col1 = t2.col1;
ERROR HY000: You can't specify target table 'v1' for update in FROM clause
delete v2 from v2,t2 where (select max(col1) from t1) > 0 and v2.col1 = t2.col1;
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation DELETE on table 'v2'.
delete t1 from t1,t2 where (select max(col1) from t1) > 0 and t1.col1 = t2.col1;
ERROR HY000: You can't specify target table 't1' for update in FROM clause
delete v1 from v1,t2 where (select max(col1) from t1) > 0 and v1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 'v1' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'v1'.
delete v2 from v2,t2 where (select max(col1) from v2) > 0 and v2.col1 = t2.col1;
ERROR HY000: You can't specify target table 'v2' for update in FROM clause
delete t1 from t1,t2 where (select max(col1) from v2) > 0 and t1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation DELETE on table 't1'.
delete v1 from v1,t2 where (select max(col1) from v2) > 0 and v1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 'v1' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation DELETE on table 'v1'.
insert into v2 values ((select max(col1) from v1));
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'v2'.
insert into t1 values ((select max(col1) from v1));
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 't1'.
insert into v2 values ((select max(col1) from v1));
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'v2'.
insert into v2 values ((select max(col1) from t1));
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v2'.
insert into t1 values ((select max(col1) from t1));
ERROR HY000: You can't specify target table 't1' for update in FROM clause
insert into v2 values ((select max(col1) from t1));
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v2'.
insert into v2 values ((select max(col1) from v2));
ERROR HY000: You can't specify target table 'v2' for update in FROM clause
insert into t1 values ((select max(col1) from v2));
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 't1'.
insert into v2 values ((select max(col1) from v2));
ERROR HY000: You can't specify target table 'v2' for update in FROM clause
insert into v3 (col1) values ((select max(col1) from v1));
-ERROR HY000: You can't specify target table 'v3' for update in FROM clause
+ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'v3'.
insert into v3 (col1) values ((select max(col1) from t1));
-ERROR HY000: You can't specify target table 'v3' for update in FROM clause
+ERROR HY000: The definition of table 'v3' prevents operation INSERT on table 'v3'.
insert into v3 (col1) values ((select max(col1) from v2));
-ERROR HY000: You can't specify target table 'v3' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v3'.
insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2));
-ERROR HY000: You can't specify target table 'v3' for update in FROM clause
+ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v3'.
insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2));
insert into mysql.time_zone values ('', (select CONVERT_TZ('20050101000000','UTC','MET') from t2));
ERROR 23000: Column 'Use_leap_seconds' cannot be null
@@ -1332,7 +1332,7 @@
ERROR HY000: The target table v3 of the INSERT is not updatable
create view v4 as select * from v2 where 20 < (select (s1) from t1);
insert into v4 values (30);
-ERROR HY000: You can't specify target table 'v4' for update in FROM clause
+ERROR HY000: The target table v4 of the INSERT is not updatable
drop view v4, v3, v2, v1;
drop table t1;
create table t1 (a int);
@@ -1935,6 +1935,16 @@
SUBSTRING_INDEX("dkjhgd:kjhdjh", ":", 1)
dkjhgd
drop view v1;
+create table t1 (f59 int, f60 int, f61 int);
+insert into t1 values (19,41,32);
+create view v1 as select f59, f60 from t1 where f59 in
+(select f59 from t1);
+update v1 set f60=2345;
+ERROR HY000: The target table v1 of the UPDATE is not updatable
+update t1 set f60=(select max(f60) from v1);
+ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't1'.
+drop view v1;
+drop table t1;
create table t1 (s1 int);
create view v1 as select var_samp(s1) from t1;
show create view v1;
--- 1.99/mysql-test/t/view.test 2005-08-19 01:18:21 +03:00
+++ 1.100/mysql-test/t/view.test 2005-08-23 23:17:32 +03:00
@@ -827,29 +827,29 @@
create view v1 as select * from t1;
create view v2 as select * from v1;
create view v3 as select v2.col1 from v2,t2 where v2.col1 = t2.col1;
--- error 1093
+-- error 1423
update v2 set col1 = (select max(col1) from v1);
--- error 1093
+-- error 1423
update v2 set col1 = (select max(col1) from t1);
-- error 1093
update v2 set col1 = (select max(col1) from v2);
--- error 1093
+-- error 1423
update v2,t2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1;
--- error 1093
+-- error 1423
update t1,t2 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1;
-- error 1093
update v1,t2 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1;
--- error 1093
+-- error 1423
update t2,v2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1;
--- error 1093
+-- error 1423
update t2,t1 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1;
--- error 1093
+-- error 1423
update t2,v1 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1;
--- error 1093
+-- error 1423
update v2,t2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1;
-- error 1093
update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
--- error 1093
+-- error 1423
update v1,t2 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1;
-- error 1093
update t2,v2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1;
@@ -859,74 +859,74 @@
update t2,v1 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1;
-- error 1093
update v2,t2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1;
--- error 1093
+-- error 1423
update t1,t2 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1;
--- error 1093
+-- error 1423
update v1,t2 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1;
--- error 1093
+-- error 1423
update t2,v2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1;
--- error 1093
+-- error 1423
update t2,t1 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1;
--- error 1093
+-- error 1423
update t2,v1 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1;
--- error 1093
+-- error 1423
update v3 set v3.col1 = (select max(col1) from v1);
--- error 1093
+-- error 1423
update v3 set v3.col1 = (select max(col1) from t1);
--- error 1093
+-- error 1423
update v3 set v3.col1 = (select max(col1) from v2);
-- error 1093
update v3 set v3.col1 = (select max(col1) from v3);
--- error 1093
+-- error 1423
delete from v2 where col1 = (select max(col1) from v1);
--- error 1093
+-- error 1423
delete from v2 where col1 = (select max(col1) from t1);
-- error 1093
delete from v2 where col1 = (select max(col1) from v2);
--- error 1093
+-- error 1423
delete v2 from v2,t2 where (select max(col1) from v1) > 0 and v2.col1 = t2.col1;
--- error 1093
+-- error 1423
delete t1 from t1,t2 where (select max(col1) from v1) > 0 and t1.col1 = t2.col1;
-- error 1093
delete v1 from v1,t2 where (select max(col1) from v1) > 0 and v1.col1 = t2.col1;
--- error 1093
+-- error 1423
delete v2 from v2,t2 where (select max(col1) from t1) > 0 and v2.col1 = t2.col1;
-- error 1093
delete t1 from t1,t2 where (select max(col1) from t1) > 0 and t1.col1 = t2.col1;
--- error 1093
+-- error 1423
delete v1 from v1,t2 where (select max(col1) from t1) > 0 and v1.col1 = t2.col1;
-- error 1093
delete v2 from v2,t2 where (select max(col1) from v2) > 0 and v2.col1 = t2.col1;
--- error 1093
+-- error 1423
delete t1 from t1,t2 where (select max(col1) from v2) > 0 and t1.col1 = t2.col1;
--- error 1093
+-- error 1423
delete v1 from v1,t2 where (select max(col1) from v2) > 0 and v1.col1 = t2.col1;
--- error 1093
+-- error 1423
insert into v2 values ((select max(col1) from v1));
--- error 1093
+-- error 1423
insert into t1 values ((select max(col1) from v1));
--- error 1093
+-- error 1423
insert into v2 values ((select max(col1) from v1));
--- error 1093
+-- error 1423
insert into v2 values ((select max(col1) from t1));
-- error 1093
insert into t1 values ((select max(col1) from t1));
--- error 1093
+-- error 1423
insert into v2 values ((select max(col1) from t1));
-- error 1093
insert into v2 values ((select max(col1) from v2));
--- error 1093
+-- error 1423
insert into t1 values ((select max(col1) from v2));
-- error 1093
insert into v2 values ((select max(col1) from v2));
--- error 1093
+-- error 1423
insert into v3 (col1) values ((select max(col1) from v1));
--- error 1093
+-- error 1423
insert into v3 (col1) values ((select max(col1) from t1));
--- error 1093
+-- error 1423
insert into v3 (col1) values ((select max(col1) from v2));
#check with TZ tables in list
--- error 1093
+-- error 1423
insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2));
insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2));
-- error 1048
@@ -1242,7 +1242,7 @@
-- error 1288
insert into v3 values (30);
create view v4 as select * from v2 where 20 < (select (s1) from t1);
--- error 1093
+-- error 1288
insert into v4 values (30);
drop view v4, v3, v2, v1;
drop table t1;
@@ -1759,6 +1759,20 @@
CREATE VIEW v1 AS SELECT SUBSTRING_INDEX("dkjhgd:kjhdjh", ":", 1);
SELECT * FROM v1;
drop view v1;
+
+#
+# hide underlying tables names in case of imposibility to update (BUG#10773)
+#
+create table t1 (f59 int, f60 int, f61 int);
+insert into t1 values (19,41,32);
+create view v1 as select f59, f60 from t1 where f59 in
+ (select f59 from t1);
+-- error 1288
+update v1 set f60=2345;
+-- error 1423
+update t1 set f60=(select max(f60) from v1);
+drop view v1;
+drop table t1;
#
# Using var_samp with view (BUG#10651)
--- 1.60/sql/sql_view.cc 2005-08-22 01:13:18 +03:00
+++ 1.61/sql/sql_view.cc 2005-08-23 23:05:20 +03:00
@@ -763,9 +763,7 @@
}
if (!res && !thd->is_fatal_error)
{
- TABLE_LIST *top_view= (table->belong_to_view ?
- table->belong_to_view :
- table);
+ TABLE_LIST *top_view= table->top_table();
TABLE_LIST *view_tables= lex->query_tables;
TABLE_LIST *view_tables_tail= 0;
TABLE_LIST *tbl;
@@ -1134,8 +1132,7 @@
thd->lex->select_lex.select_limit == 0)
DBUG_RETURN(FALSE); /* it is normal table or query without LIMIT */
table= view->table;
- if (view->belong_to_view)
- view= view->belong_to_view;
+ view= view->top_table();
trans= view->field_translation;
key_info_end= (key_info= table->key_info)+ table->s->keys;
| Thread |
|---|
| • bk commit into 5.0 tree (bell:1.1910) | sanja | 23 Aug |