summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorEvgeny Potemkin <epotemkin@mysql.com>2008-09-10 12:44:38 +0400
committerEvgeny Potemkin <epotemkin@mysql.com>2008-09-10 12:44:38 +0400
commitc537134872e26914207645c2b469015c650fa1ba (patch)
tree9cba5f1cf3cc30ad8033dda4ea7de1f3c1094e53 /mysql-test
parentb3f4648edd68d644171dd433d120d1ec19fdd0d5 (diff)
parent3363e185e60d372e1ce01b9cf6adc59bce30d8b8 (diff)
downloadmariadb-git-c537134872e26914207645c2b469015c650fa1ba.tar.gz
Merge
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/include/grant_cache.inc2
-rw-r--r--mysql-test/r/create.result11
-rw-r--r--mysql-test/r/func_regexp.result12
-rw-r--r--mysql-test/r/grant2.result2
-rw-r--r--mysql-test/r/grant_cache_no_prot.result2
-rw-r--r--mysql-test/r/grant_cache_ps_prot.result2
-rw-r--r--mysql-test/r/type_datetime.result23
-rw-r--r--mysql-test/r/type_set.result10
-rw-r--r--mysql-test/r/view_grant.result39
-rw-r--r--mysql-test/suite/binlog/r/binlog_grant.result28
-rw-r--r--mysql-test/suite/binlog/t/binlog_grant.test60
-rw-r--r--mysql-test/t/create.test18
-rw-r--r--mysql-test/t/func_regexp.test10
-rw-r--r--mysql-test/t/grant2.test2
-rw-r--r--mysql-test/t/type_datetime.test16
-rw-r--r--mysql-test/t/type_set.test19
-rw-r--r--mysql-test/t/view_grant.test77
17 files changed, 328 insertions, 5 deletions
diff --git a/mysql-test/include/grant_cache.inc b/mysql-test/include/grant_cache.inc
index dd65d1ed726..501e115f0ee 100644
--- a/mysql-test/include/grant_cache.inc
+++ b/mysql-test/include/grant_cache.inc
@@ -136,7 +136,7 @@ connect (user3,localhost,mysqltest_3,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK);
connection user3;
select "user3";
--replace_result 127.0.0.1 localhost
---error ER_COLUMNACCESS_DENIED_ERROR
+--error ER_TABLEACCESS_DENIED_ERROR
select * from t1;
select a from t1;
--replace_result 127.0.0.1 localhost
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index 12bca922562..b8723a87661 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -1559,6 +1559,17 @@ SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 c1 1 c1 A NULL NULL NULL YES BTREE
DROP TABLE t1;
+CREATE TABLE t1 (a INTEGER AUTO_INCREMENT PRIMARY KEY, b INTEGER NOT NULL);
+INSERT IGNORE INTO t1 (b) VALUES (5);
+CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY)
+SELECT a FROM t1;
+CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY)
+SELECT a FROM t1;
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY)
+SELECT a FROM t1;
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+DROP TABLE t1, t2;
End of 5.0 tests
CREATE TABLE t1 (a int, b int);
insert into t1 values (1,1),(1,2);
diff --git a/mysql-test/r/func_regexp.result b/mysql-test/r/func_regexp.result
index b64f0b7f1c1..54aad23402f 100644
--- a/mysql-test/r/func_regexp.result
+++ b/mysql-test/r/func_regexp.result
@@ -114,6 +114,18 @@ End of 4.1 tests
SELECT 1 REGEXP NULL;
1 REGEXP NULL
NULL
+SELECT '' REGEXP BINARY NULL;
+'' REGEXP BINARY NULL
+NULL
+SELECT NULL REGEXP BINARY NULL;
+NULL REGEXP BINARY NULL
+NULL
+SELECT 'A' REGEXP BINARY NULL;
+'A' REGEXP BINARY NULL
+NULL
+SELECT "ABC" REGEXP BINARY NULL;
+"ABC" REGEXP BINARY NULL
+NULL
End of 5.0 tests
CREATE TABLE t1(a INT, b CHAR(4));
INSERT INTO t1 VALUES (1, '6.1'), (1, '7.0'), (1, '8.0');
diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result
index b94de265d0c..03c4ea042f6 100644
--- a/mysql-test/r/grant2.result
+++ b/mysql-test/r/grant2.result
@@ -434,7 +434,7 @@ USE db1;
SELECT c FROM t2;
ERROR 42000: SELECT command denied to user 'mysqltest1'@'localhost' for column 'c' in table 't2'
SELECT * FROM t2;
-ERROR 42000: SELECT command denied to user 'mysqltest1'@'localhost' for column 'c' in table 't2'
+ERROR 42000: SELECT command denied to user 'mysqltest1'@'localhost' for table 't2'
SELECT * FROM t1 JOIN t2 USING (b);
ERROR 42000: SELECT command denied to user 'mysqltest1'@'localhost' for column 'c' in table 't2'
DROP TABLE db1.t1, db1.t2;
diff --git a/mysql-test/r/grant_cache_no_prot.result b/mysql-test/r/grant_cache_no_prot.result
index 02360c4c325..cb9acaf540d 100644
--- a/mysql-test/r/grant_cache_no_prot.result
+++ b/mysql-test/r/grant_cache_no_prot.result
@@ -155,7 +155,7 @@ select "user3";
user3
user3
select * from t1;
-ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'b' in table 't1'
+ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 't1'
select a from t1;
a
1
diff --git a/mysql-test/r/grant_cache_ps_prot.result b/mysql-test/r/grant_cache_ps_prot.result
index 1e2cd1baa3a..cf1450f3b75 100644
--- a/mysql-test/r/grant_cache_ps_prot.result
+++ b/mysql-test/r/grant_cache_ps_prot.result
@@ -155,7 +155,7 @@ select "user3";
user3
user3
select * from t1;
-ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'b' in table 't1'
+ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 't1'
select a from t1;
a
1
diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result
index d485c468a39..6a692ed58e4 100644
--- a/mysql-test/r/type_datetime.result
+++ b/mysql-test/r/type_datetime.result
@@ -560,6 +560,29 @@ select * from t2
where id in (select id from t2 as x1 where (t2.cur_date is null));
id cur_date
drop table t1,t2;
+SELECT
+CAST('NULL' AS DATE) <=> CAST('2008-01-01' AS DATE) n1,
+CAST('2008-01-01' AS DATE) <=> CAST('NULL' AS DATE) n2,
+CAST('NULL' AS DATE) <=> CAST('NULL' AS DATE) n3,
+CAST('NULL' AS DATE) <> CAST('2008-01-01' AS DATE) n4,
+CAST('2008-01-01' AS DATE) <> CAST('NULL' AS DATE) n5,
+CAST('NULL' AS DATE) <> CAST('NULL' AS DATE) n6,
+CAST('NULL' AS DATE) < CAST('2008-01-01' AS DATE) n7,
+CAST('2008-01-01' AS DATE) < CAST('NULL' AS DATE) n8,
+CAST('NULL' AS DATE) < CAST('NULL' AS DATE) n9;
+n1 n2 n3 n4 n5 n6 n7 n8 n9
+0 0 1 NULL NULL NULL NULL NULL NULL
+Warnings:
+Warning 1292 Incorrect datetime value: 'NULL'
+Warning 1292 Incorrect datetime value: 'NULL'
+Warning 1292 Incorrect datetime value: 'NULL'
+Warning 1292 Incorrect datetime value: 'NULL'
+Warning 1292 Incorrect datetime value: 'NULL'
+Warning 1292 Incorrect datetime value: 'NULL'
+Warning 1292 Incorrect datetime value: 'NULL'
+Warning 1292 Incorrect datetime value: 'NULL'
+Warning 1292 Incorrect datetime value: 'NULL'
+Warning 1292 Incorrect datetime value: 'NULL'
End of 5.0 tests
set @org_mode=@@sql_mode;
create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03');
diff --git a/mysql-test/r/type_set.result b/mysql-test/r/type_set.result
index e36f21f2996..09531ec60d5 100644
--- a/mysql-test/r/type_set.result
+++ b/mysql-test/r/type_set.result
@@ -93,4 +93,14 @@ c
1,2,3
64
DROP TABLE t1;
+CREATE TABLE t1 (
+set_unique_utf8 set ('a','b','c','d','e','f','g','h','i','j','k','l',
+'m','n','o','p','q','r','s','t','u','v','w','x',
+'y','z') CHARACTER SET utf8,
+unique (set_unique_utf8)
+);
+INSERT INTO t1 ( set_unique_utf8 ) VALUES ( '' );
+INSERT INTO t1 ( set_unique_utf8 ) VALUES ( '' );
+ERROR 23000: Duplicate entry '' for key 'set_unique_utf8'
+DROP TABLE t1;
End of 5.0 tests
diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result
index 3585635d0f9..1821e50e294 100644
--- a/mysql-test/r/view_grant.result
+++ b/mysql-test/r/view_grant.result
@@ -957,3 +957,42 @@ Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function
DROP VIEW v1;
DROP TABLE t1;
End of 5.1 tests.
+CREATE USER mysqluser1@localhost;
+CREATE DATABASE mysqltest1;
+USE mysqltest1;
+CREATE TABLE t1 ( a INT, b INT );
+CREATE TABLE t2 ( a INT, b INT );
+CREATE VIEW v1 AS SELECT a, b FROM t1;
+GRANT SELECT( a ) ON v1 TO mysqluser1@localhost;
+GRANT UPDATE( b ) ON t2 TO mysqluser1@localhost;
+SELECT * FROM mysqltest1.v1;
+ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1'
+CREATE VIEW v1 AS SELECT * FROM mysqltest1.t2;
+ERROR 42000: ANY command denied to user 'mysqluser1'@'localhost' for table 't2'
+DROP TABLE t1, t2;
+DROP VIEW v1;
+DROP DATABASE mysqltest1;
+DROP USER mysqluser1@localhost;
+CREATE USER mysqluser1@localhost;
+CREATE DATABASE mysqltest1;
+USE mysqltest1;
+CREATE VIEW v1 AS SELECT * FROM information_schema.tables LIMIT 1;
+CREATE ALGORITHM = TEMPTABLE VIEW v2 AS SELECT 1 AS A;
+CREATE VIEW test.v3 AS SELECT 1 AS a;
+GRANT SELECT ON mysqltest1.* to mysqluser1@localhost;
+GRANT ALL ON test.* TO mysqluser1@localhost;
+PREPARE stmt_v1 FROM "SELECT * FROM mysqltest1.v1";
+PREPARE stmt_v2 FROM "SELECT * FROM mysqltest1.v2";
+REVOKE SELECT ON mysqltest1.* FROM mysqluser1@localhost;
+EXECUTE stmt_v1;
+ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v1'
+EXECUTE stmt_v2;
+ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 'v2'
+PREPARE stmt FROM "SELECT a FROM v3";
+EXECUTE stmt;
+a
+1
+DROP VIEW v1, v2;
+DROP DATABASE mysqltest1;
+DROP VIEW test.v3;
+DROP USER mysqluser1@localhost;
diff --git a/mysql-test/suite/binlog/r/binlog_grant.result b/mysql-test/suite/binlog/r/binlog_grant.result
new file mode 100644
index 00000000000..21ebb891103
--- /dev/null
+++ b/mysql-test/suite/binlog/r/binlog_grant.result
@@ -0,0 +1,28 @@
+reset master;
+set @saved_binlog_format = @@global.binlog_format;
+create user mysqltest_1@localhost;
+show grants for mysqltest_1@localhost;
+Grants for mysqltest_1@localhost
+GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
+**** Variable SQL_LOG_BIN ****
+[root]
+set global sql_log_bin = 1;
+ERROR HY000: Variable 'sql_log_bin' is a SESSION variable and can't be used with SET GLOBAL
+set session sql_log_bin = 1;
+[plain]
+set global sql_log_bin = 1;
+ERROR HY000: Variable 'sql_log_bin' is a SESSION variable and can't be used with SET GLOBAL
+set session sql_log_bin = 1;
+ERROR 42000: Access denied; you need the SUPER privilege for this operation
+**** Variable BINLOG_FORMAT ****
+[root]
+set global binlog_format = row;
+set session binlog_format = row;
+[plain]
+set global binlog_format = row;
+ERROR 42000: Access denied; you need the SUPER privilege for this operation
+set session binlog_format = row;
+ERROR 42000: Access denied; you need the SUPER privilege for this operation
+**** Clean up ****
+set global binlog_format = @saved_binlog_format;
+drop user mysqltest_1@localhost;
diff --git a/mysql-test/suite/binlog/t/binlog_grant.test b/mysql-test/suite/binlog/t/binlog_grant.test
new file mode 100644
index 00000000000..d36dcce4cc3
--- /dev/null
+++ b/mysql-test/suite/binlog/t/binlog_grant.test
@@ -0,0 +1,60 @@
+# Test grants for various objects (especially variables) related to
+# the binary log
+
+source include/have_log_bin.inc;
+
+connection default;
+--disable_warnings
+reset master;
+--enable_warnings
+
+set @saved_binlog_format = @@global.binlog_format;
+create user mysqltest_1@localhost;
+show grants for mysqltest_1@localhost;
+
+connect (plain,localhost,mysqltest_1,,test);
+connect (root,localhost,root,,test);
+
+# Testing setting both session and global SQL_LOG_BIN variable both as
+# root and as plain user.
+
+--echo **** Variable SQL_LOG_BIN ****
+
+connection root;
+--echo [root]
+--error ER_LOCAL_VARIABLE
+set global sql_log_bin = 1;
+set session sql_log_bin = 1;
+
+connection plain;
+--echo [plain]
+--error ER_LOCAL_VARIABLE
+set global sql_log_bin = 1;
+--error ER_SPECIFIC_ACCESS_DENIED_ERROR
+set session sql_log_bin = 1;
+
+
+# Testing setting both session and global BINLOG_FORMAT variable both
+# as root and as plain user.
+
+--echo **** Variable BINLOG_FORMAT ****
+
+connection root;
+--echo [root]
+set global binlog_format = row;
+set session binlog_format = row;
+
+connection plain;
+--echo [plain]
+--error ER_SPECIFIC_ACCESS_DENIED_ERROR
+set global binlog_format = row;
+--error ER_SPECIFIC_ACCESS_DENIED_ERROR
+set session binlog_format = row;
+
+--echo **** Clean up ****
+disconnect plain;
+disconnect root;
+
+connection default;
+set global binlog_format = @saved_binlog_format;
+drop user mysqltest_1@localhost;
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 847efb1315d..60d98fce490 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -1176,6 +1176,24 @@ SHOW INDEX FROM t1;
DROP TABLE t1;
+#
+# Bug#38821: Assert table->auto_increment_field_not_null failed in open_table()
+#
+CREATE TABLE t1 (a INTEGER AUTO_INCREMENT PRIMARY KEY, b INTEGER NOT NULL);
+INSERT IGNORE INTO t1 (b) VALUES (5);
+
+CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY)
+ SELECT a FROM t1;
+--error 1062
+CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY)
+ SELECT a FROM t1;
+--error 1062
+CREATE TABLE IF NOT EXISTS t2 (a INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY)
+ SELECT a FROM t1;
+
+DROP TABLE t1, t2;
+
+
--echo End of 5.0 tests
#
diff --git a/mysql-test/t/func_regexp.test b/mysql-test/t/func_regexp.test
index f3677b8f5b0..638e0bf08ee 100644
--- a/mysql-test/t/func_regexp.test
+++ b/mysql-test/t/func_regexp.test
@@ -64,6 +64,16 @@ drop table t1;
SELECT 1 REGEXP NULL;
+
+#
+# Bug #39021: SELECT REGEXP BINARY NULL never returns
+#
+
+SELECT '' REGEXP BINARY NULL;
+SELECT NULL REGEXP BINARY NULL;
+SELECT 'A' REGEXP BINARY NULL;
+SELECT "ABC" REGEXP BINARY NULL;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test
index 0f0c92e82eb..d91592f6bb6 100644
--- a/mysql-test/t/grant2.test
+++ b/mysql-test/t/grant2.test
@@ -605,7 +605,7 @@ connection conn1;
USE db1;
--error ER_COLUMNACCESS_DENIED_ERROR
SELECT c FROM t2;
---error ER_COLUMNACCESS_DENIED_ERROR
+--error ER_TABLEACCESS_DENIED_ERROR
SELECT * FROM t2;
--error ER_COLUMNACCESS_DENIED_ERROR
SELECT * FROM t1 JOIN t2 USING (b);
diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test
index 4fdd96b8729..eb1b7bde844 100644
--- a/mysql-test/t/type_datetime.test
+++ b/mysql-test/t/type_datetime.test
@@ -388,6 +388,22 @@ where id in (select id from t2 as x1 where (t2.cur_date is null));
drop table t1,t2;
+
+#
+# Bug #37526: asymertic operator <=> in trigger
+#
+SELECT
+ CAST('NULL' AS DATE) <=> CAST('2008-01-01' AS DATE) n1,
+ CAST('2008-01-01' AS DATE) <=> CAST('NULL' AS DATE) n2,
+ CAST('NULL' AS DATE) <=> CAST('NULL' AS DATE) n3,
+ CAST('NULL' AS DATE) <> CAST('2008-01-01' AS DATE) n4,
+ CAST('2008-01-01' AS DATE) <> CAST('NULL' AS DATE) n5,
+ CAST('NULL' AS DATE) <> CAST('NULL' AS DATE) n6,
+ CAST('NULL' AS DATE) < CAST('2008-01-01' AS DATE) n7,
+ CAST('2008-01-01' AS DATE) < CAST('NULL' AS DATE) n8,
+ CAST('NULL' AS DATE) < CAST('NULL' AS DATE) n9;
+
+
--echo End of 5.0 tests
#
# Test of storing datetime into date fields
diff --git a/mysql-test/t/type_set.test b/mysql-test/t/type_set.test
index e98555e137b..a851d116743 100644
--- a/mysql-test/t/type_set.test
+++ b/mysql-test/t/type_set.test
@@ -75,4 +75,23 @@ INSERT INTO t1 VALUES(9223372036854775808);
SELECT * FROM t1;
DROP TABLE t1;
+#
+# Bug #38701: Crash in String::append when inserting duplicate empty strings
+# an uft8 SET col
+#
+
+CREATE TABLE t1 (
+ set_unique_utf8 set ('a','b','c','d','e','f','g','h','i','j','k','l',
+ 'm','n','o','p','q','r','s','t','u','v','w','x',
+ 'y','z') CHARACTER SET utf8,
+ unique (set_unique_utf8)
+);
+
+INSERT INTO t1 ( set_unique_utf8 ) VALUES ( '' );
+--error ER_DUP_ENTRY
+INSERT INTO t1 ( set_unique_utf8 ) VALUES ( '' );
+
+DROP TABLE t1;
+
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test
index cbc66300173..4e8d97e4444 100644
--- a/mysql-test/t/view_grant.test
+++ b/mysql-test/t/view_grant.test
@@ -1219,3 +1219,80 @@ DROP VIEW v1;
DROP TABLE t1;
--echo End of 5.1 tests.
+
+#
+# Bug#36086: SELECT * from views don't check column grants
+#
+CREATE USER mysqluser1@localhost;
+CREATE DATABASE mysqltest1;
+
+USE mysqltest1;
+
+CREATE TABLE t1 ( a INT, b INT );
+CREATE TABLE t2 ( a INT, b INT );
+
+CREATE VIEW v1 AS SELECT a, b FROM t1;
+
+GRANT SELECT( a ) ON v1 TO mysqluser1@localhost;
+GRANT UPDATE( b ) ON t2 TO mysqluser1@localhost;
+
+--connect (connection1, localhost, mysqluser1, , test)
+
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT * FROM mysqltest1.v1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+CREATE VIEW v1 AS SELECT * FROM mysqltest1.t2;
+
+--disconnect connection1
+
+--connection default
+
+DROP TABLE t1, t2;
+DROP VIEW v1;
+DROP DATABASE mysqltest1;
+DROP USER mysqluser1@localhost;
+
+#
+# Bug#35600: Security breach via view, I_S table and prepared
+# statement/stored procedure
+#
+CREATE USER mysqluser1@localhost;
+CREATE DATABASE mysqltest1;
+
+USE mysqltest1;
+
+CREATE VIEW v1 AS SELECT * FROM information_schema.tables LIMIT 1;
+CREATE ALGORITHM = TEMPTABLE VIEW v2 AS SELECT 1 AS A;
+
+CREATE VIEW test.v3 AS SELECT 1 AS a;
+
+--connection default
+GRANT SELECT ON mysqltest1.* to mysqluser1@localhost;
+GRANT ALL ON test.* TO mysqluser1@localhost;
+
+--connect (connection1, localhost, mysqluser1, , test)
+PREPARE stmt_v1 FROM "SELECT * FROM mysqltest1.v1";
+PREPARE stmt_v2 FROM "SELECT * FROM mysqltest1.v2";
+
+--connection default
+REVOKE SELECT ON mysqltest1.* FROM mysqluser1@localhost;
+
+--connection connection1
+
+--error ER_TABLEACCESS_DENIED_ERROR
+EXECUTE stmt_v1;
+--error ER_TABLEACCESS_DENIED_ERROR
+EXECUTE stmt_v2;
+--disconnect connection1
+
+--connect (connection2, localhost, mysqluser1,,)
+PREPARE stmt FROM "SELECT a FROM v3";
+EXECUTE stmt;
+--disconnect connection2
+
+--connection default
+DROP VIEW v1, v2;
+DROP DATABASE mysqltest1;
+DROP VIEW test.v3;
+DROP USER mysqluser1@localhost;