Commit 9e9f2636 authored by unknown's avatar unknown

Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-5.1-opt

into  mysql.com:/home/hf/work/16813/my51-16813

parents 68ecb0ce 5db08aa9
...@@ -2956,4 +2956,14 @@ View Create View ...@@ -2956,4 +2956,14 @@ View Create View
v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`pk` AS `pk` from (`t1` join `t2` on(((`t2`.`fk` = `t1`.`pk`) and (`t2`.`ver` = (select max(`t`.`ver`) AS `MAX(t.ver)` from `t2` `t` where (`t`.`org` = `t2`.`org`)))))) v1 CREATE ALGORITHM=MERGE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`pk` AS `pk` from (`t1` join `t2` on(((`t2`.`fk` = `t1`.`pk`) and (`t2`.`ver` = (select max(`t`.`ver`) AS `MAX(t.ver)` from `t2` `t` where (`t`.`org` = `t2`.`org`))))))
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1, t2; DROP TABLE t1, t2;
CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, val INT UNSIGNED NOT NULL);
CREATE VIEW v1 AS SELECT id, val FROM t1 WHERE val >= 1 AND val <= 5 WITH CHECK OPTION;
INSERT INTO v1 (val) VALUES (2);
INSERT INTO v1 (val) VALUES (4);
INSERT INTO v1 (val) VALUES (6);
ERROR HY000: CHECK OPTION failed 'test.v1'
UPDATE v1 SET val=6 WHERE id=2;
ERROR HY000: CHECK OPTION failed 'test.v1'
DROP VIEW v1;
DROP TABLE t1;
End of 5.0 tests. End of 5.0 tests.
...@@ -2856,7 +2856,6 @@ EXPLAIN SELECT * FROM v1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1); ...@@ -2856,7 +2856,6 @@ 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 # Bug #5505: Wrong error message on INSERT into a view
# #
create table t1 (s1 int); create table t1 (s1 int);
...@@ -2884,4 +2883,19 @@ SHOW CREATE VIEW v1; ...@@ -2884,4 +2883,19 @@ SHOW CREATE VIEW v1;
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1, t2; DROP TABLE t1, t2;
#
# Bug #16813 (WITH CHECK OPTION doesn't work with UPDATE)
#
CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, val INT UNSIGNED NOT NULL);
CREATE VIEW v1 AS SELECT id, val FROM t1 WHERE val >= 1 AND val <= 5 WITH CHECK OPTION;
INSERT INTO v1 (val) VALUES (2);
INSERT INTO v1 (val) VALUES (4);
-- error 1369
INSERT INTO v1 (val) VALUES (6);
-- error 1369
UPDATE v1 SET val=6 WHERE id=2;
DROP VIEW v1;
DROP TABLE t1;
--echo End of 5.0 tests. --echo End of 5.0 tests.
...@@ -2773,12 +2773,13 @@ bool st_table_list::prep_where(THD *thd, Item **conds, ...@@ -2773,12 +2773,13 @@ bool st_table_list::prep_where(THD *thd, Item **conds,
this expression will not be moved to WHERE condition (i.e. will this expression will not be moved to WHERE condition (i.e. will
be clean correctly for PS/SP) be clean correctly for PS/SP)
*/ */
tbl->on_expr= and_conds(tbl->on_expr, where); tbl->on_expr= and_conds(tbl->on_expr,
where->copy_andor_structure(thd));
break; break;
} }
} }
if (tbl == 0) if (tbl == 0)
*conds= and_conds(*conds, where); *conds= and_conds(*conds, where->copy_andor_structure(thd));
if (arena) if (arena)
thd->restore_active_arena(arena, &backup); thd->restore_active_arena(arena, &backup);
where_processed= TRUE; where_processed= 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