summaryrefslogtreecommitdiff
path: root/mysql-test/t/select_safe.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/select_safe.test')
-rw-r--r--mysql-test/t/select_safe.test32
1 files changed, 32 insertions, 0 deletions
diff --git a/mysql-test/t/select_safe.test b/mysql-test/t/select_safe.test
new file mode 100644
index 00000000000..e76b7558997
--- /dev/null
+++ b/mysql-test/t/select_safe.test
@@ -0,0 +1,32 @@
+#
+# test of safe selects
+#
+
+drop table if exists t1;
+SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=4, SQL_MAX_JOIN_SIZE=9;
+create table t1 (a int primary key, b char(20));
+insert into t1 values(1,"test");
+SELECT SQL_BUFFER_RESULT * from t1;
+update t1 set b="a" where a=1;
+delete from t1 where a=1;
+insert into t1 values(1,"test"),(2,"test2");
+SELECT SQL_BUFFER_RESULT * from t1;
+update t1 set b="a" where a=1;
+select 1 from t1,t1 as t2,t1 as t3,t1 as t4;
+
+# The following should give errors:
+!$1175 update t1 set b="a";
+!$1175 update t1 set b="a" where b="test";
+!$1175 delete from t1;
+!$1175 delete from t1 where b="test";
+!$1175 delete from t1 where a+0=1;
+!$1104 select 1 from t1,t1 as t2,t1 as t3,t1 as t4,t1 as t5;
+
+# The following should be ok:
+update t1 set b="a" limit 1;
+update t1 set b="a" where b="b" limit 2;
+delete from t1 where b="test" limit 1;
+delete from t1 where a+0=1 limit 2;
+drop table t1;
+
+SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, SQL_MAX_JOIN_SIZE=DEFAULT;