mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
Fixed bug#5505: Wrong error message on INSERT into a view
On an INSERT into an updatable but non-insertable view an error message was issued stating the view being not updatable. This can lead to a confusion of a user. A new error message is introduced. Is is showed when a user tries to insert into a non-insertable view. sql/sql_base.cc: Fixed bug#5505: Wrong error message on INSERT into a view The update_non_unique_table_error() function now issues proper error for an INSERT. sql/sql_insert.cc: Fixed bug#5505: Wrong error message on INSERT into a view Issue the ER_NON_INSERTABLE_TABLE error instead of the ER_NON_UPDATABLE_TABLE on insert into a view. sql/sql_view.cc: Fixed bug#5505: Wrong error message on INSERT into a view Issue the ER_NON_INSERTABLE_TABLE error instead of the ER_NON_UPDATABLE_TABLE on insert into a view. mysql-test/r/view.result: Added the test case for bug#5505: Wrong error message on INSERT into a view Corrected a few test cases after fixing bug#5505 mysql-test/t/view.test: Added the test case for bug#5505: Wrong error message on INSERT into a view Corrected a few test cases after fixing bug#5505 sql/share/errmsg.txt: Fixed bug#5505: Wrong error message on INSERT into a view Added the ER_NON_INSERTABLE_TABLE error definition.
This commit is contained in:
parent
665ebc05d0
commit
d332c37c58
6 changed files with 49 additions and 24 deletions
|
@ -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 algorithm=temptable view v5 (x,y,z) as select c, b, a from t1;
|
||||
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);
|
||||
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);
|
||||
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 (z,y,x) values (50,6,-100);
|
||||
insert into v2 values (5,40);
|
||||
|
@ -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 algorithm=temptable view v5 (x,y,z) as select c, b, a from t1;
|
||||
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;
|
||||
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;
|
||||
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 (z,y,x) select a+20,b+2,-100 from t2;
|
||||
insert into v2 select b+1, a+10 from t2;
|
||||
|
@ -1352,14 +1352,14 @@ drop table t1;
|
|||
create table t1 (s1 smallint);
|
||||
create view v1 as select * from t1 where 20 < (select (s1) from t1);
|
||||
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 v3 as select * from t1 where 20 < (select (s1) from v2);
|
||||
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);
|
||||
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 table t1;
|
||||
create table t1 (a int);
|
||||
|
@ -2911,7 +2911,7 @@ INSERT INTO v2 VALUES (0);
|
|||
RETURN 0;
|
||||
END |
|
||||
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 f2;
|
||||
DROP VIEW v1, v2;
|
||||
|
@ -2935,4 +2935,11 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||
2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
|
||||
DROP VIEW v1;
|
||||
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;
|
||||
End of 5.0 tests.
|
||||
|
|
|
@ -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 algorithm=temptable view v5 (x,y,z) as select c, b, a from t1;
|
||||
# try insert to VIEW with fields duplicate
|
||||
-- error 1288
|
||||
-- error 1470
|
||||
insert into v3 values (-60,4,30);
|
||||
# try insert to VIEW with expression in SELECT list
|
||||
-- error 1288
|
||||
-- error 1470
|
||||
insert into v4 values (-60,4,30);
|
||||
# try insert to VIEW using temporary table algorithm
|
||||
-- error 1288
|
||||
-- error 1470
|
||||
insert into v5 values (-60,4,30);
|
||||
insert into v1 values (-60,4,30);
|
||||
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;
|
|||
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;
|
||||
# try insert to VIEW with fields duplicate
|
||||
-- error 1288
|
||||
-- error 1470
|
||||
insert into v3 select c, b, a from t2;
|
||||
# try insert to VIEW with expression in SELECT list
|
||||
-- error 1288
|
||||
-- error 1470
|
||||
insert into v4 select c, b, a from t2;
|
||||
# try insert to VIEW using temporary table algorithm
|
||||
-- error 1288
|
||||
-- error 1470
|
||||
insert into v5 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;
|
||||
|
@ -1249,14 +1249,14 @@ drop table t1;
|
|||
#
|
||||
create table t1 (s1 smallint);
|
||||
create view v1 as select * from t1 where 20 < (select (s1) from t1);
|
||||
-- error 1288
|
||||
-- error 1470
|
||||
insert into v1 values (30);
|
||||
create view v2 as select * from t1;
|
||||
create view v3 as select * from t1 where 20 < (select (s1) from v2);
|
||||
-- error 1288
|
||||
-- error 1470
|
||||
insert into v3 values (30);
|
||||
create view v4 as select * from v2 where 20 < (select (s1) from t1);
|
||||
-- error 1288
|
||||
-- error 1470
|
||||
insert into v4 values (30);
|
||||
drop view v4, v3, v2, v1;
|
||||
drop table t1;
|
||||
|
@ -2825,7 +2825,7 @@ BEGIN
|
|||
END |
|
||||
delimiter ;|
|
||||
|
||||
--error ER_NON_UPDATABLE_TABLE
|
||||
--error ER_NON_INSERTABLE_TABLE
|
||||
SELECT f2();
|
||||
|
||||
DROP FUNCTION f1;
|
||||
|
@ -2850,4 +2850,16 @@ EXPLAIN SELECT * FROM v1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1);
|
|||
|
||||
DROP VIEW v1;
|
||||
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 1470
|
||||
insert into v1 values (1,1);
|
||||
update v1 set a = 5;
|
||||
drop view v1;
|
||||
drop table t1;
|
||||
|
||||
--echo End of 5.0 tests.
|
||||
|
|
|
@ -5629,3 +5629,6 @@ ER_HOSTNAME
|
|||
eng "host name"
|
||||
ER_WRONG_STRING_LENGTH
|
||||
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"
|
||||
|
||||
|
|
|
@ -902,8 +902,11 @@ void update_non_unique_table_error(TABLE_LIST *update,
|
|||
*/
|
||||
if (update->view)
|
||||
{
|
||||
/* Issue the ER_NON_INSERTABLE_TABLE error for an INSERT */
|
||||
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
|
||||
my_error(ER_VIEW_PREVENT_UPDATE, MYF(0),
|
||||
(duplicate->view ? duplicate->alias : update->alias),
|
||||
|
|
|
@ -111,7 +111,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ static int check_insert_fields(THD *thd, TABLE_LIST *table_list,
|
|||
(table_list->view &&
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1574,7 +1574,7 @@ bool insert_view_fields(THD *thd, List<Item> *list, TABLE_LIST *view)
|
|||
list->push_back(fld);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue