mirror of
https://github.com/MariaDB/server.git
synced 2025-10-12 12:25:37 +03:00
UPDATE FOR PERIOD OF: don't crash on multi-table views
This commit is contained in:
@@ -288,6 +288,10 @@ id log
|
||||
create or replace view v as select * from t;
|
||||
delete from v for portion of p from '2000-01-01' to '2018-01-01';
|
||||
ERROR 42S02: 'v' is a view
|
||||
# View can't be used
|
||||
create or replace view v as select t.* from t, t as t1;
|
||||
delete from v for portion of p from '2000-01-01' to '2018-01-01';
|
||||
ERROR 42S02: 'v' is a view
|
||||
# auto_increment field overflow
|
||||
create or replace table t (id tinyint auto_increment primary key,
|
||||
s date, e date, period for apptime(s,e));
|
||||
|
@@ -200,6 +200,14 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
|
||||
set t.id= t.id + 5' at line 1
|
||||
update t1 set x= (select id from t for portion of apptime from '2000-01-01' to '2018-01-01');
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'portion of apptime from '2000-01-01' to '2018-01-01')' at line 1
|
||||
# single-table views
|
||||
create or replace view v1 as select * from t where id<10;
|
||||
update v1 for portion of apptime from '2000-01-01' to '2018-01-01' set id= id + 5;
|
||||
ERROR 42S02: 'v1' is a view
|
||||
# multi-table views
|
||||
create or replace view v1 as select * from t, t1 where x=id;
|
||||
update v1 for portion of apptime from '2000-01-01' to '2018-01-01' set id= id + 5;
|
||||
ERROR 42S02: 'v1' is a view
|
||||
# SQL16: 14.14 <update statement: searched>, Syntax Rules, 7)a) iii-iv)
|
||||
# Let FROMVAL be <point in time 1>. FROMVAL shall not generally contain a
|
||||
# reference to a column of T or a <routine invocation>
|
||||
|
@@ -131,6 +131,10 @@ create or replace view v as select * from t;
|
||||
--error ER_IT_IS_A_VIEW
|
||||
delete from v for portion of p from '2000-01-01' to '2018-01-01';
|
||||
|
||||
--echo # View can't be used
|
||||
create or replace view v as select t.* from t, t as t1;
|
||||
--error ER_IT_IS_A_VIEW
|
||||
delete from v for portion of p from '2000-01-01' to '2018-01-01';
|
||||
|
||||
--echo # auto_increment field overflow
|
||||
create or replace table t (id tinyint auto_increment primary key,
|
||||
|
@@ -87,6 +87,16 @@ update t for portion of apptime from '2000-01-01' to '2018-01-01', t1
|
||||
--error ER_PARSE_ERROR
|
||||
update t1 set x= (select id from t for portion of apptime from '2000-01-01' to '2018-01-01');
|
||||
|
||||
--echo # single-table views
|
||||
create or replace view v1 as select * from t where id<10;
|
||||
--error ER_IT_IS_A_VIEW
|
||||
update v1 for portion of apptime from '2000-01-01' to '2018-01-01' set id= id + 5;
|
||||
|
||||
--echo # multi-table views
|
||||
create or replace view v1 as select * from t, t1 where x=id;
|
||||
--error ER_IT_IS_A_VIEW
|
||||
update v1 for portion of apptime from '2000-01-01' to '2018-01-01' set id= id + 5;
|
||||
|
||||
--echo # SQL16: 14.14 <update statement: searched>, Syntax Rules, 7)a) iii-iv)
|
||||
--echo # Let FROMVAL be <point in time 1>. FROMVAL shall not generally contain a
|
||||
--echo # reference to a column of T or a <routine invocation>
|
||||
|
@@ -384,6 +384,12 @@ int mysql_update(THD *thd,
|
||||
if (mysql_handle_derived(thd->lex, DT_INIT))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
if (table_list->has_period() && table_list->is_view_or_derived())
|
||||
{
|
||||
my_error(ER_IT_IS_A_VIEW, MYF(0), table_list->table_name.str);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
if (((update_source_table=unique_table(thd, table_list,
|
||||
table_list->next_global, 0)) ||
|
||||
table_list->is_multitable()))
|
||||
@@ -1337,12 +1343,6 @@ bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
|
||||
|
||||
if (table_list->has_period())
|
||||
{
|
||||
if (table_list->is_view_or_derived())
|
||||
{
|
||||
my_error(ER_IT_IS_A_VIEW, MYF(0), table_list->table_name.str);
|
||||
DBUG_RETURN(true);
|
||||
}
|
||||
|
||||
*conds= select_lex->period_setup_conds(thd, table_list, *conds);
|
||||
if (!*conds)
|
||||
DBUG_RETURN(true);
|
||||
|
Reference in New Issue
Block a user