summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2006-06-07 16:17:56 +0400
committerunknown <evgen@moonbone.local>2006-06-07 16:17:56 +0400
commit683ebcd101f4f33d4fd04bd44b0344353fe282a1 (patch)
treea8601a9a3f0ee78987d909ec51a4d5eb43282497
parent63d6336465c13c010977c04a037468e55b68e9e0 (diff)
downloadmariadb-git-683ebcd101f4f33d4fd04bd44b0344353fe282a1.tar.gz
Fixed bug#19789: REPLACE was allowed for a VIEW with CHECK OPTION enabled.
The st_lex::which_check_option_applicable() function controls for which statements WITH CHECK OPTION clause should be taken into account. REPLACE and REPLACE_SELECT wasn't in the list which results in allowing REPLACE to insert wrong rows in a such view. The st_lex::which_check_option_applicable() now includes REPLACE and REPLACE_SELECT in the list of statements for which WITH CHECK OPTION clause is applicable. mysql-test/t/replace.test: Added test case for bug#19789: REPLACE was allowed for a VIEW with CHECK OPTION enabled. mysql-test/r/replace.result: Added test case for bug#19789: REPLACE was allowed for a VIEW with CHECK OPTION enabled. sql/sql_lex.h: Fixed bug#19789: REPLACE was allowed for a VIEW with CHECK OPTION enabled. The st_lex::which_check_option_applicable() now includes REPLACE and REPLACE_SELECT in the list of statements for which WITH CHECK OPTION clause is applicable.
-rw-r--r--mysql-test/r/replace.result6
-rw-r--r--mysql-test/t/replace.test10
-rw-r--r--sql/sql_lex.h2
3 files changed, 18 insertions, 0 deletions
diff --git a/mysql-test/r/replace.result b/mysql-test/r/replace.result
index a7d59fcfa62..5a5e4571ba9 100644
--- a/mysql-test/r/replace.result
+++ b/mysql-test/r/replace.result
@@ -24,3 +24,9 @@ a b
63 default_value
127 last
drop table t1;
+CREATE TABLE t1 (f1 INT);
+CREATE VIEW v1 AS SELECT f1 FROM t1 WHERE f1 = 0 WITH CHECK OPTION;
+REPLACE INTO v1 (f1) VALUES (1);
+ERROR HY000: CHECK OPTION failed 'test.v1'
+DROP TABLE t1;
+DROP VIEW v1;
diff --git a/mysql-test/t/replace.test b/mysql-test/t/replace.test
index 10703eaafb8..269854fb180 100644
--- a/mysql-test/t/replace.test
+++ b/mysql-test/t/replace.test
@@ -35,3 +35,13 @@ select * from t1;
drop table t1;
# End of 4.1 tests
+
+#
+# Bug#19789: REPLACE was allowed for a VIEW with CHECK OPTION enabled.
+#
+CREATE TABLE t1 (f1 INT);
+CREATE VIEW v1 AS SELECT f1 FROM t1 WHERE f1 = 0 WITH CHECK OPTION;
+--error 1369
+REPLACE INTO v1 (f1) VALUES (1);
+DROP TABLE t1;
+DROP VIEW v1;
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 34e7ee969b6..306a726cab9 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -1000,6 +1000,8 @@ typedef struct st_lex
case SQLCOM_UPDATE_MULTI:
case SQLCOM_INSERT:
case SQLCOM_INSERT_SELECT:
+ case SQLCOM_REPLACE:
+ case SQLCOM_REPLACE_SELECT:
case SQLCOM_LOAD:
return TRUE;
default: