summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <holyfoot/hf@deer.(none)>2006-09-29 12:17:33 +0500
committerunknown <holyfoot/hf@deer.(none)>2006-09-29 12:17:33 +0500
commit9314fabdd34605649f5062769de1163ea3899ee2 (patch)
tree34997e4bcb7206798d65258ba5ff7d118aae105a
parentd752b1a8da85f1d0ddc5b5e3e5bbe056e0e647e6 (diff)
parent5389cc169abd3853145d7bb1d0f6dbce214eacea (diff)
downloadmariadb-git-9314fabdd34605649f5062769de1163ea3899ee2.tar.gz
Merge mysql.com:/home/hf/work/16813/my50-16813
into mysql.com:/home/hf/work/16813/my51-16813 mysql-test/r/view.result: Auto merged mysql-test/t/view.test: Auto merged sql/table.cc: Auto merged
-rw-r--r--mysql-test/r/view.result10
-rw-r--r--mysql-test/t/view.test15
-rw-r--r--sql/table.cc5
3 files changed, 28 insertions, 2 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 5d009ed7840..7f0a028a0ae 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -2935,4 +2935,14 @@ 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(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.
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 7d1ddccba83..cfa93f8b06c 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -2855,4 +2855,19 @@ EXPLAIN SELECT * FROM v1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1);
DROP VIEW v1;
DROP TABLE t1;
+
+#
+# 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.
diff --git a/sql/table.cc b/sql/table.cc
index 834c2ed9c82..844720f04c4 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -2775,12 +2775,13 @@ bool st_table_list::prep_where(THD *thd, Item **conds,
this expression will not be moved to WHERE condition (i.e. will
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;
}
}
if (tbl == 0)
- *conds= and_conds(*conds, where);
+ *conds= and_conds(*conds, where->copy_andor_structure(thd));
if (arena)
thd->restore_active_arena(arena, &backup);
where_processed= TRUE;