diff options
author | unknown <bell@sanja.is.com.ua> | 2004-08-16 23:15:31 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-08-16 23:15:31 +0300 |
commit | 3d67184d74eb30ccde88db31aff34dd0ae5a7242 (patch) | |
tree | 27a36ac2457c9101c8a9bebb198f606e2c765180 /mysql-test | |
parent | 81578bb40fc28d31b5b07ab8c80cd9176eab430a (diff) | |
download | mariadb-git-3d67184d74eb30ccde88db31aff34dd0ae5a7242.tar.gz |
resolve UPDATE fields belonged to VIEWs as Item_field (instead of Item_ref) in prepared statements, too (BUG#4999)
mysql-test/r/view.result:
Test of view updatebility in prepared statement
mysql-test/t/view.test:
Test of view updatebility in prepared statement
sql/sql_prepare.cc:
resolve UPDATE fields belonged to VIEWs as Item_field (instead of Item_ref) in prepared statements, too
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/view.result | 22 | ||||
-rw-r--r-- | mysql-test/t/view.test | 30 |
2 files changed, 52 insertions, 0 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index fe022c5fc77..c429c45c389 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1014,3 +1014,25 @@ p2 p4 drop view v1; drop table t1; +create table t1 (a int); +create view v1 as select a from t1; +insert into t1 values (1); +SET @v0 = '2'; +PREPARE stmt FROM 'UPDATE v1 SET a = ?'; +EXECUTE stmt USING @v0; +DEALLOCATE PREPARE stmt; +SET @v0 = '3'; +PREPARE stmt FROM 'insert into v1 values (?)'; +EXECUTE stmt USING @v0; +DEALLOCATE PREPARE stmt; +SET @v0 = '4'; +PREPARE stmt FROM 'insert into v1 (a) values (?)'; +EXECUTE stmt USING @v0; +DEALLOCATE PREPARE stmt; +select * from t1; +a +2 +3 +4 +drop view v1; +drop table t1; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index f9ff64e2e5b..cefbb599d27 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -943,3 +943,33 @@ select distinct first.col2 from t1 first where first.col2 in (select second.col2 select distinct first.col2 from v1 first where first.col2 in (select second.col2 from t1 second where second.col1<>first.col1); drop view v1; drop table t1; + +# +# Test of view updatebility in prepared statement +# +create table t1 (a int); +create view v1 as select a from t1; +insert into t1 values (1); + +#update +SET @v0 = '2'; +PREPARE stmt FROM 'UPDATE v1 SET a = ?'; +EXECUTE stmt USING @v0; +DEALLOCATE PREPARE stmt; + +#insert without field list +SET @v0 = '3'; +PREPARE stmt FROM 'insert into v1 values (?)'; +EXECUTE stmt USING @v0; +DEALLOCATE PREPARE stmt; + +#insert with field list +SET @v0 = '4'; +PREPARE stmt FROM 'insert into v1 (a) values (?)'; +EXECUTE stmt USING @v0; +DEALLOCATE PREPARE stmt; + +select * from t1; + +drop view v1; +drop table t1; |