Commit 8a2aa354 authored by hartmut@mysql.com/linux.site's avatar hartmut@mysql.com/linux.site

Merge hholzgraefe@bk-internal.mysql.com:/home/bk/mysql-5.0-maint

into  mysql.com:/home/hartmut/projects/mysql/dev/5.0-bug14995
parents 73c77c00 dee4105c
......@@ -867,6 +867,81 @@ insert into mysql.user select * from t2;
flush privileges;
drop table t2;
drop table t1;
CREATE DATABASE mysqltest3;
use mysqltest3;
CREATE TABLE t_nn (c1 INT);
CREATE VIEW v_nn AS SELECT * FROM t_nn;
CREATE DATABASE mysqltest2;
use mysqltest2;
CREATE TABLE t_nn (c1 INT);
CREATE VIEW v_nn AS SELECT * FROM t_nn;
CREATE VIEW v_yn AS SELECT * FROM t_nn;
CREATE VIEW v_gy AS SELECT * FROM t_nn;
CREATE VIEW v_ny AS SELECT * FROM t_nn;
CREATE VIEW v_yy AS SELECT * FROM t_nn WHERE c1=55;
GRANT SHOW VIEW ON mysqltest2.v_ny TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
GRANT SELECT ON mysqltest2.v_yn TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
GRANT SELECT ON mysqltest2.* TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
GRANT SHOW VIEW,SELECT ON mysqltest2.v_yy TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
SHOW CREATE VIEW mysqltest2.v_nn;
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v_nn'
SHOW CREATE TABLE mysqltest2.v_nn;
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v_nn'
SHOW CREATE VIEW mysqltest2.v_yn;
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v_yn'
SHOW CREATE TABLE mysqltest2.v_yn;
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v_yn'
SHOW CREATE TABLE mysqltest2.v_ny;
View Create View
v_ny CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_ny` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn`
SHOW CREATE VIEW mysqltest2.v_ny;
View Create View
v_ny CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_ny` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn`
SHOW CREATE TABLE mysqltest3.t_nn;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't_nn'
SHOW CREATE VIEW mysqltest3.t_nn;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't_nn'
SHOW CREATE VIEW mysqltest3.v_nn;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v_nn'
SHOW CREATE TABLE mysqltest3.v_nn;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v_nn'
SHOW CREATE TABLE mysqltest2.t_nn;
Table Create Table
t_nn CREATE TABLE `t_nn` (
`c1` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SHOW CREATE VIEW mysqltest2.t_nn;
ERROR HY000: 'mysqltest2.t_nn' is not VIEW
SHOW CREATE VIEW mysqltest2.v_yy;
View Create View
v_yy CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_yy` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn` where (`mysqltest2`.`t_nn`.`c1` = 55)
SHOW CREATE TABLE mysqltest2.v_yy;
View Create View
v_yy CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_yy` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn` where (`mysqltest2`.`t_nn`.`c1` = 55)
SHOW CREATE TABLE mysqltest2.v_nn;
View Create View
v_nn CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_nn` AS select `t_nn`.`c1` AS `c1` from `t_nn`
SHOW CREATE VIEW mysqltest2.v_nn;
View Create View
v_nn CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_nn` AS select `t_nn`.`c1` AS `c1` from `t_nn`
SHOW CREATE TABLE mysqltest2.t_nn;
Table Create Table
t_nn CREATE TABLE `t_nn` (
`c1` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
SHOW CREATE VIEW mysqltest2.t_nn;
ERROR HY000: 'mysqltest2.t_nn' is not VIEW
DROP VIEW mysqltest2.v_nn;
DROP VIEW mysqltest2.v_yn;
DROP VIEW mysqltest2.v_ny;
DROP VIEW mysqltest2.v_yy;
DROP TABLE mysqltest2.t_nn;
DROP DATABASE mysqltest2;
DROP VIEW mysqltest3.v_nn;
DROP TABLE mysqltest3.t_nn;
DROP DATABASE mysqltest3;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost';
DROP USER 'mysqltest_1'@'localhost';
create user mysqltest1_thisisreallytoolong;
ERROR HY000: Operation CREATE USER failed for 'mysqltest1_thisisreallytoolong'@'%'
End of 5.0 tests
......@@ -680,6 +680,133 @@ drop table t2;
drop table t1;
#
# Bug#20214: Incorrect error when user calls SHOW CREATE VIEW on non
# privileged view
#
connection master;
CREATE DATABASE mysqltest3;
use mysqltest3;
CREATE TABLE t_nn (c1 INT);
CREATE VIEW v_nn AS SELECT * FROM t_nn;
CREATE DATABASE mysqltest2;
use mysqltest2;
CREATE TABLE t_nn (c1 INT);
CREATE VIEW v_nn AS SELECT * FROM t_nn;
CREATE VIEW v_yn AS SELECT * FROM t_nn;
CREATE VIEW v_gy AS SELECT * FROM t_nn;
CREATE VIEW v_ny AS SELECT * FROM t_nn;
CREATE VIEW v_yy AS SELECT * FROM t_nn WHERE c1=55;
GRANT SHOW VIEW ON mysqltest2.v_ny TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
GRANT SELECT ON mysqltest2.v_yn TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
GRANT SELECT ON mysqltest2.* TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
GRANT SHOW VIEW,SELECT ON mysqltest2.v_yy TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
connect (mysqltest_1, localhost, mysqltest_1, mysqltest_1,);
# fail because of missing SHOW VIEW (have generic SELECT)
--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE VIEW mysqltest2.v_nn;
--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE TABLE mysqltest2.v_nn;
# fail because of missing SHOW VIEW
--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE VIEW mysqltest2.v_yn;
--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE TABLE mysqltest2.v_yn;
# succeed (despite of missing SELECT, having SHOW VIEW bails us out)
SHOW CREATE TABLE mysqltest2.v_ny;
# succeed (despite of missing SELECT, having SHOW VIEW bails us out)
SHOW CREATE VIEW mysqltest2.v_ny;
# fail because of missing (specific or generic) SELECT
--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE TABLE mysqltest3.t_nn;
# fail because of missing (specific or generic) SELECT (not because it's not a view!)
--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE VIEW mysqltest3.t_nn;
# fail because of missing missing (specific or generic) SELECT (and SHOW VIEW)
--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE VIEW mysqltest3.v_nn;
--error ER_TABLEACCESS_DENIED_ERROR
SHOW CREATE TABLE mysqltest3.v_nn;
# succeed thanks to generic SELECT
SHOW CREATE TABLE mysqltest2.t_nn;
# fail because it's not a view! (have generic SELECT though)
--error ER_WRONG_OBJECT
SHOW CREATE VIEW mysqltest2.t_nn;
# succeed, have SELECT and SHOW VIEW
SHOW CREATE VIEW mysqltest2.v_yy;
# succeed, have SELECT and SHOW VIEW
SHOW CREATE TABLE mysqltest2.v_yy;
#clean-up
connection master;
# succeed, we're root
SHOW CREATE TABLE mysqltest2.v_nn;
SHOW CREATE VIEW mysqltest2.v_nn;
SHOW CREATE TABLE mysqltest2.t_nn;
# fail because it's not a view!
--error ER_WRONG_OBJECT
SHOW CREATE VIEW mysqltest2.t_nn;
DROP VIEW mysqltest2.v_nn;
DROP VIEW mysqltest2.v_yn;
DROP VIEW mysqltest2.v_ny;
DROP VIEW mysqltest2.v_yy;
DROP TABLE mysqltest2.t_nn;
DROP DATABASE mysqltest2;
DROP VIEW mysqltest3.v_nn;
DROP TABLE mysqltest3.t_nn;
DROP DATABASE mysqltest3;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost';
DROP USER 'mysqltest_1'@'localhost';
#
# Bug #10668: CREATE USER does not enforce username length limit
#
......
......@@ -8,8 +8,8 @@
# server or run mysql-test-run --debug mysql_client_test and check
# var/log/mysql_client_test.trace
--disable_result_log
--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M
--exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test.log 2>&1
--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.log 2>&1
# End of 4.1 tests
echo ok;
......
......@@ -122,6 +122,7 @@ static void client_disconnect();
void die(const char *file, int line, const char *expr)
{
fprintf(stderr, "%s:%d: check failed: '%s'\n", file, line, expr);
fflush(NULL);
abort();
}
......@@ -14914,7 +14915,7 @@ static void test_bug17667()
{ "insert into bug17667 (c) values ('5 NULs=\0\0\0\0\0')", 48 },
{ "/* NUL=\0 with comment */ insert into bug17667 (c) values ('encore')", 67 },
{ "drop table bug17667", 19 },
{ NULL, 0 } };
{ NULL, 0 } };
struct buffer_and_length *statement_cursor;
FILE *log_file;
......@@ -14929,11 +14930,14 @@ static void test_bug17667()
myquery(rc);
}
sleep(1); /* The server may need time to flush the data to the log. */
/* Make sure the server has written the logs to disk before reading it */
rc= mysql_query(mysql, "flush logs");
myquery(rc);
master_log_filename = (char *) malloc(strlen(opt_vardir) + strlen("/log/master.log") + 1);
strcpy(master_log_filename, opt_vardir);
strcat(master_log_filename, "/log/master.log");
printf("Opening '%s'\n", master_log_filename);
log_file= fopen(master_log_filename, "r");
free(master_log_filename);
......@@ -14941,18 +14945,30 @@ static void test_bug17667()
for (statement_cursor= statements; statement_cursor->buffer != NULL;
statement_cursor++) {
char line_buffer[MAX_TEST_QUERY_LENGTH*2];
/* more than enough room for the query and some marginalia. */
char line_buffer[MAX_TEST_QUERY_LENGTH*2];
/* more than enough room for the query and some marginalia. */
do {
memset(line_buffer, '/', MAX_TEST_QUERY_LENGTH*2);
DIE_UNLESS(fgets(line_buffer, MAX_TEST_QUERY_LENGTH*2, log_file) !=
NULL);
/* If we reach EOF before finishing the statement list, then we failed. */
if(fgets(line_buffer, MAX_TEST_QUERY_LENGTH*2, log_file) == NULL)
{
/* If fgets returned NULL, it indicates either error or EOF */
if (feof(log_file))
DIE("Found EOF before all statements where found");
else
{
fprintf(stderr, "Got error %d while reading from file\n",
ferror(log_file));
DIE("Read error");
}
}
} while (my_memmem(line_buffer, MAX_TEST_QUERY_LENGTH*2,
statement_cursor->buffer, statement_cursor->length) == NULL);
printf("Found statement starting with \"%s\"\n",
statement_cursor->buffer);
}
printf("success. All queries found intact in the log.\n");
......
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