Commit d3612560 authored by unknown's avatar unknown

Merge dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.0-opt

into  dl145s.mysql.com:/data/bk/team_tree_merge/MERGE/mysql-5.1-opt


mysql-test/r/view.result:
  Auto merged
mysql-test/t/view.test:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_view.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
parents d5ea425a 669d8a6f
...@@ -472,11 +472,11 @@ create view v3 (x,y,z) as select b, a, b from t1; ...@@ -472,11 +472,11 @@ create view v3 (x,y,z) as select b, a, b from t1;
create view v4 (x,y,z) as select c+1, b, a from t1; create view v4 (x,y,z) as select c+1, b, a from t1;
create algorithm=temptable view v5 (x,y,z) as select c, b, a from t1; create algorithm=temptable view v5 (x,y,z) as select c, b, a from t1;
insert into v3 values (-60,4,30); insert into v3 values (-60,4,30);
ERROR HY000: The target table v3 of the INSERT is not updatable ERROR HY000: The target table v3 of the INSERT is not insertable-into
insert into v4 values (-60,4,30); insert into v4 values (-60,4,30);
ERROR HY000: The target table v4 of the INSERT is not updatable ERROR HY000: The target table v4 of the INSERT is not insertable-into
insert into v5 values (-60,4,30); insert into v5 values (-60,4,30);
ERROR HY000: The target table v5 of the INSERT is not updatable ERROR HY000: The target table v5 of the INSERT is not insertable-into
insert into v1 values (-60,4,30); insert into v1 values (-60,4,30);
insert into v1 (z,y,x) values (50,6,-100); insert into v1 (z,y,x) values (50,6,-100);
insert into v2 values (5,40); insert into v2 values (5,40);
...@@ -499,11 +499,11 @@ create view v3 (x,y,z) as select b, a, b from t1; ...@@ -499,11 +499,11 @@ create view v3 (x,y,z) as select b, a, b from t1;
create view v4 (x,y,z) as select c+1, b, a from t1; create view v4 (x,y,z) as select c+1, b, a from t1;
create algorithm=temptable view v5 (x,y,z) as select c, b, a from t1; create algorithm=temptable view v5 (x,y,z) as select c, b, a from t1;
insert into v3 select c, b, a from t2; insert into v3 select c, b, a from t2;
ERROR HY000: The target table v3 of the INSERT is not updatable ERROR HY000: The target table v3 of the INSERT is not insertable-into
insert into v4 select c, b, a from t2; insert into v4 select c, b, a from t2;
ERROR HY000: The target table v4 of the INSERT is not updatable ERROR HY000: The target table v4 of the INSERT is not insertable-into
insert into v5 select c, b, a from t2; insert into v5 select c, b, a from t2;
ERROR HY000: The target table v5 of the INSERT is not updatable ERROR HY000: The target table v5 of the INSERT is not insertable-into
insert into v1 select c, b, a from t2; insert into v1 select c, b, a from t2;
insert into v1 (z,y,x) select a+20,b+2,-100 from t2; insert into v1 (z,y,x) select a+20,b+2,-100 from t2;
insert into v2 select b+1, a+10 from t2; insert into v2 select b+1, a+10 from t2;
...@@ -1352,14 +1352,14 @@ drop table t1; ...@@ -1352,14 +1352,14 @@ drop table t1;
create table t1 (s1 smallint); create table t1 (s1 smallint);
create view v1 as select * from t1 where 20 < (select (s1) from t1); create view v1 as select * from t1 where 20 < (select (s1) from t1);
insert into v1 values (30); insert into v1 values (30);
ERROR HY000: The target table v1 of the INSERT is not updatable ERROR HY000: The target table v1 of the INSERT is not insertable-into
create view v2 as select * from t1; create view v2 as select * from t1;
create view v3 as select * from t1 where 20 < (select (s1) from v2); create view v3 as select * from t1 where 20 < (select (s1) from v2);
insert into v3 values (30); insert into v3 values (30);
ERROR HY000: The target table v3 of the INSERT is not updatable ERROR HY000: The target table v3 of the INSERT is not insertable-into
create view v4 as select * from v2 where 20 < (select (s1) from t1); create view v4 as select * from v2 where 20 < (select (s1) from t1);
insert into v4 values (30); insert into v4 values (30);
ERROR HY000: The target table v4 of the INSERT is not updatable ERROR HY000: The target table v4 of the INSERT is not insertable-into
drop view v4, v3, v2, v1; drop view v4, v3, v2, v1;
drop table t1; drop table t1;
create table t1 (a int); create table t1 (a int);
...@@ -2911,7 +2911,7 @@ INSERT INTO v2 VALUES (0); ...@@ -2911,7 +2911,7 @@ INSERT INTO v2 VALUES (0);
RETURN 0; RETURN 0;
END | END |
SELECT f2(); SELECT f2();
ERROR HY000: The target table v2 of the INSERT is not updatable ERROR HY000: The target table v2 of the INSERT is not insertable-into
DROP FUNCTION f1; DROP FUNCTION f1;
DROP FUNCTION f2; DROP FUNCTION f2;
DROP VIEW v1, v2; DROP VIEW v1, v2;
...@@ -2935,6 +2935,13 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -2935,6 +2935,13 @@ id select_type table type possible_keys key key_len ref rows Extra
2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
create table t1 (s1 int);
create view v1 as select s1 as a, s1 as b from t1;
insert into v1 values (1,1);
ERROR HY000: The target table v1 of the INSERT is not insertable-into
update v1 set a = 5;
drop view v1;
drop table t1;
CREATE TABLE t1(pk int PRIMARY KEY); CREATE TABLE t1(pk int PRIMARY KEY);
CREATE TABLE t2(pk int PRIMARY KEY, fk int, ver int, org int); CREATE TABLE t2(pk int PRIMARY KEY, fk int, ver int, org int);
CREATE ALGORITHM=MERGE VIEW v1 AS CREATE ALGORITHM=MERGE VIEW v1 AS
......
...@@ -347,13 +347,13 @@ create view v3 (x,y,z) as select b, a, b from t1; ...@@ -347,13 +347,13 @@ create view v3 (x,y,z) as select b, a, b from t1;
create view v4 (x,y,z) as select c+1, b, a from t1; create view v4 (x,y,z) as select c+1, b, a from t1;
create algorithm=temptable view v5 (x,y,z) as select c, b, a from t1; create algorithm=temptable view v5 (x,y,z) as select c, b, a from t1;
# try insert to VIEW with fields duplicate # try insert to VIEW with fields duplicate
-- error 1288 -- error 1471
insert into v3 values (-60,4,30); insert into v3 values (-60,4,30);
# try insert to VIEW with expression in SELECT list # try insert to VIEW with expression in SELECT list
-- error 1288 -- error 1471
insert into v4 values (-60,4,30); insert into v4 values (-60,4,30);
# try insert to VIEW using temporary table algorithm # try insert to VIEW using temporary table algorithm
-- error 1288 -- error 1471
insert into v5 values (-60,4,30); insert into v5 values (-60,4,30);
insert into v1 values (-60,4,30); insert into v1 values (-60,4,30);
insert into v1 (z,y,x) values (50,6,-100); insert into v1 (z,y,x) values (50,6,-100);
...@@ -375,13 +375,13 @@ create view v3 (x,y,z) as select b, a, b from t1; ...@@ -375,13 +375,13 @@ create view v3 (x,y,z) as select b, a, b from t1;
create view v4 (x,y,z) as select c+1, b, a from t1; create view v4 (x,y,z) as select c+1, b, a from t1;
create algorithm=temptable view v5 (x,y,z) as select c, b, a from t1; create algorithm=temptable view v5 (x,y,z) as select c, b, a from t1;
# try insert to VIEW with fields duplicate # try insert to VIEW with fields duplicate
-- error 1288 -- error 1471
insert into v3 select c, b, a from t2; insert into v3 select c, b, a from t2;
# try insert to VIEW with expression in SELECT list # try insert to VIEW with expression in SELECT list
-- error 1288 -- error 1471
insert into v4 select c, b, a from t2; insert into v4 select c, b, a from t2;
# try insert to VIEW using temporary table algorithm # try insert to VIEW using temporary table algorithm
-- error 1288 -- error 1471
insert into v5 select c, b, a from t2; insert into v5 select c, b, a from t2;
insert into v1 select c, b, a from t2; insert into v1 select c, b, a from t2;
insert into v1 (z,y,x) select a+20,b+2,-100 from t2; insert into v1 (z,y,x) select a+20,b+2,-100 from t2;
...@@ -1249,14 +1249,14 @@ drop table t1; ...@@ -1249,14 +1249,14 @@ drop table t1;
# #
create table t1 (s1 smallint); create table t1 (s1 smallint);
create view v1 as select * from t1 where 20 < (select (s1) from t1); create view v1 as select * from t1 where 20 < (select (s1) from t1);
-- error 1288 -- error 1471
insert into v1 values (30); insert into v1 values (30);
create view v2 as select * from t1; create view v2 as select * from t1;
create view v3 as select * from t1 where 20 < (select (s1) from v2); create view v3 as select * from t1 where 20 < (select (s1) from v2);
-- error 1288 -- error 1471
insert into v3 values (30); insert into v3 values (30);
create view v4 as select * from v2 where 20 < (select (s1) from t1); create view v4 as select * from v2 where 20 < (select (s1) from t1);
-- error 1288 -- error 1471
insert into v4 values (30); insert into v4 values (30);
drop view v4, v3, v2, v1; drop view v4, v3, v2, v1;
drop table t1; drop table t1;
...@@ -2830,7 +2830,7 @@ BEGIN ...@@ -2830,7 +2830,7 @@ BEGIN
END | END |
delimiter ;| delimiter ;|
--error ER_NON_UPDATABLE_TABLE --error ER_NON_INSERTABLE_TABLE
SELECT f2(); SELECT f2();
DROP FUNCTION f1; DROP FUNCTION f1;
...@@ -2856,6 +2856,17 @@ EXPLAIN SELECT * FROM v1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1); ...@@ -2856,6 +2856,17 @@ EXPLAIN SELECT * FROM v1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1);
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #5505: Wrong error message on INSERT into a view
#
create table t1 (s1 int);
create view v1 as select s1 as a, s1 as b from t1;
--error 1471
insert into v1 values (1,1);
update v1 set a = 5;
drop view v1;
drop table t1;
# #
# Bug #21646: view qith a subquery in ON expression # Bug #21646: view qith a subquery in ON expression
# #
......
...@@ -5986,6 +5986,8 @@ ER_HOSTNAME ...@@ -5986,6 +5986,8 @@ ER_HOSTNAME
eng "host name" eng "host name"
ER_WRONG_STRING_LENGTH ER_WRONG_STRING_LENGTH
eng "String '%-.70s' is too long for %s (should be no longer than %d)" eng "String '%-.70s' is too long for %s (should be no longer than %d)"
ER_NON_INSERTABLE_TABLE
eng "The target table %-.100s of the %s is not insertable-into"
ER_UNSUPORTED_LOG_ENGINE ER_UNSUPORTED_LOG_ENGINE
eng "This storage engine cannot be used for log tables"" eng "This storage engine cannot be used for log tables""
ER_BAD_LOG_STATEMENT ER_BAD_LOG_STATEMENT
......
...@@ -1461,8 +1461,11 @@ void update_non_unique_table_error(TABLE_LIST *update, ...@@ -1461,8 +1461,11 @@ void update_non_unique_table_error(TABLE_LIST *update,
*/ */
if (update->view) if (update->view)
{ {
/* Issue the ER_NON_INSERTABLE_TABLE error for an INSERT */
if (update->view == duplicate->view) if (update->view == duplicate->view)
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), update->alias, operation); my_error(!strncmp(operation, "INSERT", 6) ?
ER_NON_INSERTABLE_TABLE : ER_NON_UPDATABLE_TABLE, MYF(0),
update->alias, operation);
else else
my_error(ER_VIEW_PREVENT_UPDATE, MYF(0), my_error(ER_VIEW_PREVENT_UPDATE, MYF(0),
(duplicate->view ? duplicate->alias : update->alias), (duplicate->view ? duplicate->alias : update->alias),
......
...@@ -112,7 +112,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list, ...@@ -112,7 +112,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
if (!table_list->updatable) if (!table_list->updatable)
{ {
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "INSERT"); my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias, "INSERT");
return -1; return -1;
} }
...@@ -228,7 +228,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list, ...@@ -228,7 +228,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
(table_list->view && (table_list->view &&
check_view_insertability(thd, table_list))) check_view_insertability(thd, table_list)))
{ {
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "INSERT"); my_error(ER_NON_INSERTABLE_TABLE, MYF(0), table_list->alias, "INSERT");
return -1; return -1;
} }
......
...@@ -1603,7 +1603,7 @@ bool insert_view_fields(THD *thd, List<Item> *list, TABLE_LIST *view) ...@@ -1603,7 +1603,7 @@ bool insert_view_fields(THD *thd, List<Item> *list, TABLE_LIST *view)
list->push_back(fld); list->push_back(fld);
else else
{ {
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), view->alias, "INSERT"); my_error(ER_NON_INSERTABLE_TABLE, MYF(0), view->alias, "INSERT");
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment