Commit 8e13cd1a authored by Alexey Kopytov's avatar Alexey Kopytov

Automerge of mysql-5.1-bugteam into mysql-trunk-merge.

parents 641d39a3 181a29f2
...@@ -229,5 +229,4 @@ a: b ...@@ -229,5 +229,4 @@ a: b
</row> </row>
</resultset> </resultset>
drop table t1; drop table t1;
End of 5.0 tests
End of tests
...@@ -510,4 +510,60 @@ DROP USER mysqltest_u1@localhost; ...@@ -510,4 +510,60 @@ DROP USER mysqltest_u1@localhost;
DROP PROCEDURE p_suid; DROP PROCEDURE p_suid;
DROP FUNCTION f_suid; DROP FUNCTION f_suid;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #48872 : Privileges for stored functions ignored if function name
# is mixed case
#
CREATE DATABASE B48872;
USE B48872;
CREATE TABLE `TestTab` (id INT);
INSERT INTO `TestTab` VALUES (1),(2);
CREATE FUNCTION `f_Test`() RETURNS INT RETURN 123;
CREATE FUNCTION `f_Test_denied`() RETURNS INT RETURN 123;
CREATE USER 'tester';
CREATE USER 'Tester';
GRANT SELECT ON TABLE `TestTab` TO 'tester';
GRANT EXECUTE ON FUNCTION `f_Test` TO 'tester';
GRANT EXECUTE ON FUNCTION `f_Test_denied` TO 'Tester';
SELECT f_Test();
f_Test()
123
SELECT * FROM TestTab;
id
1
2
SELECT * FROM TestTab;
id
1
2
SELECT `f_Test`();
`f_Test`()
123
SELECT `F_TEST`();
`F_TEST`()
123
SELECT f_Test();
f_Test()
123
SELECT F_TEST();
F_TEST()
123
SELECT * FROM TestTab;
SELECT `f_Test`();
SELECT `F_TEST`();
SELECT f_Test();
SELECT F_TEST();
SELECT `f_Test_denied`();
`f_Test_denied`()
123
SELECT `F_TEST_DENIED`();
`F_TEST_DENIED`()
123
DROP TABLE `TestTab`;
DROP FUNCTION `f_Test`;
DROP FUNCTION `f_Test_denied`;
USE test;
DROP USER 'tester';
DROP USER 'Tester';
DROP DATABASE B48872;
End of 5.0 tests. End of 5.0 tests.
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
create table t1(a int not null auto_increment, b int, primary key(a) );
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
select * from t1;
a b
1 10
2 15
select * from t1;
a b
1 10
2 15
drop table t1;
...@@ -476,4 +476,30 @@ master-bin.000001 # Table_map # # table_id: # (mysqltest1.with_select) ...@@ -476,4 +476,30 @@ master-bin.000001 # Table_map # # table_id: # (mysqltest1.with_select)
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # COMMIT
DROP DATABASE mysqltest1; DROP DATABASE mysqltest1;
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE TEMPORARY TABLE t7(c1 INT);
CREATE TABLE t5(c1 INT);
CREATE TABLE t4(c1 INT);
CREATE VIEW bug48506_t1 AS SELECT 1;
CREATE VIEW bug48506_t2 AS SELECT * FROM t4;
CREATE VIEW bug48506_t3 AS SELECT t5.c1 AS A, t4.c1 AS B FROM t5, t4;
CREATE TABLE bug48506_t4(c1 INT);
DROP VIEW bug48506_t1, bug48506_t2, bug48506_t3;
DROP TABLE bug48506_t4;
CREATE TABLE IF NOT EXISTS bug48506_t1 LIKE t7;
CREATE TABLE IF NOT EXISTS bug48506_t2 LIKE t7;
CREATE TABLE IF NOT EXISTS bug48506_t3 LIKE t7;
CREATE TABLE IF NOT EXISTS bug48506_t4 LIKE t7;
SHOW TABLES LIKE 'bug48506%';
Tables_in_test (bug48506%)
bug48506_t4
DROP VIEW IF EXISTS bug48506_t1, bug48506_t2, bug48506_t3;
DROP TEMPORARY TABLES t7;
DROP TABLES t4, t5;
DROP TABLES IF EXISTS bug48506_t4;
end of the tests end of the tests
--secure-file-priv=$MYSQLTEST_VARDIR/std_data_master_link
ln -s $MYSQLTEST_VARDIR/std_data $MYSQLTEST_VARDIR/std_data_master_link
--slave-load-tmpdir=$MYSQLTEST_VARDIR/std_data_slave_link
ln -s $MYSQLTEST_VARDIR/std_data $MYSQLTEST_VARDIR/std_data_slave_link
#
# BUG#43913
# This test verifies if loading data infile will work fine
# if the path of the load data file is a symbolic link.
#
--source include/master-slave.inc
--source include/have_binlog_format_statement.inc
create table t1(a int not null auto_increment, b int, primary key(a) );
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
select * from t1;
sync_slave_with_master;
connection slave;
select * from t1;
connection master;
drop table t1;
sync_slave_with_master;
...@@ -292,4 +292,40 @@ connection master; ...@@ -292,4 +292,40 @@ connection master;
DROP DATABASE mysqltest1; DROP DATABASE mysqltest1;
sync_slave_with_master; sync_slave_with_master;
#
# BUG#48506: crash in CREATE TABLE <existing_view> IF NOT EXISTS LIKE
# <tmp_tbl> with RBL
#
source include/master-slave-reset.inc;
connection master;
CREATE TEMPORARY TABLE t7(c1 INT);
CREATE TABLE t5(c1 INT);
CREATE TABLE t4(c1 INT);
CREATE VIEW bug48506_t1 AS SELECT 1;
CREATE VIEW bug48506_t2 AS SELECT * FROM t4;
CREATE VIEW bug48506_t3 AS SELECT t5.c1 AS A, t4.c1 AS B FROM t5, t4;
CREATE TABLE bug48506_t4(c1 INT);
--disable_warnings
sync_slave_with_master;
DROP VIEW bug48506_t1, bug48506_t2, bug48506_t3;
DROP TABLE bug48506_t4;
connection master;
CREATE TABLE IF NOT EXISTS bug48506_t1 LIKE t7;
CREATE TABLE IF NOT EXISTS bug48506_t2 LIKE t7;
CREATE TABLE IF NOT EXISTS bug48506_t3 LIKE t7;
CREATE TABLE IF NOT EXISTS bug48506_t4 LIKE t7;
--enable_warnings
sync_slave_with_master;
SHOW TABLES LIKE 'bug48506%';
connection master;
DROP VIEW IF EXISTS bug48506_t1, bug48506_t2, bug48506_t3;
DROP TEMPORARY TABLES t7;
DROP TABLES t4, t5;
DROP TABLES IF EXISTS bug48506_t4;
source include/master-slave-end.inc;
--echo end of the tests --echo end of the tests
# Embedded server doesn't support external clients
--source include/not_embedded.inc
--echo # --echo #
--echo # Bug#47671 - wrong character-set after upgrade from 5.1.34 to 5.1.39 --echo # Bug#47671 - wrong character-set after upgrade from 5.1.34 to 5.1.39
--echo # --echo #
--echo # Extract only charset information from 'status' command output using regex --echo # Extract only charset information from 'status' command output using regex
--replace_regex /.*mysql.*// /Connection.*// /Current.*// /SSL.*// /Using.*// /Server version.*// /Protocol.*// /UNIX.*// /Uptime.*// /Threads.*// --replace_regex /.*mysql.*// /Connection.*// /Current.*// /SSL.*// /Using.*// /Server version.*// /Protocol.*// /UNIX.*// /Uptime.*// /Threads.*// /TCP.*//
--exec $MYSQL -u root test -e "status"; --exec $MYSQL -e "status";
...@@ -385,10 +385,16 @@ drop tables t1, t2; ...@@ -385,10 +385,16 @@ drop tables t1, t2;
# #
# Bug #27884: mysql --html does not quote HTML special characters in output # Bug #27884: mysql --html does not quote HTML special characters in output
# #
--exec $MYSQL --html test -e "select '< & >' as '<'" --write_file $MYSQLTEST_VARDIR/tmp/bug27884.sql
SELECT '< & >' AS `<`;
EOF
--exec $MYSQL --html test < $MYSQLTEST_VARDIR/tmp/bug27884.sql
remove_file $MYSQLTEST_VARDIR/tmp/bug27884.sql;
# #
# Bug #27884: mysql client + null byte # Bug #28203: mysql client + null byte
# #
create table t1 (a char(5)); create table t1 (a char(5));
insert into t1 values ('\0b\0'); insert into t1 values ('\0b\0');
...@@ -401,5 +407,5 @@ insert into t1 values ('\0b\0'); ...@@ -401,5 +407,5 @@ insert into t1 values ('\0b\0');
--exec $MYSQL --xml test -e "select a from t1" --exec $MYSQL --xml test -e "select a from t1"
drop table t1; drop table t1;
--echo
--echo End of tests --echo End of 5.0 tests
...@@ -865,6 +865,65 @@ DROP PROCEDURE p_suid; ...@@ -865,6 +865,65 @@ DROP PROCEDURE p_suid;
DROP FUNCTION f_suid; DROP FUNCTION f_suid;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug #48872 : Privileges for stored functions ignored if function name
--echo # is mixed case
--echo #
CREATE DATABASE B48872;
USE B48872;
CREATE TABLE `TestTab` (id INT);
INSERT INTO `TestTab` VALUES (1),(2);
CREATE FUNCTION `f_Test`() RETURNS INT RETURN 123;
CREATE FUNCTION `f_Test_denied`() RETURNS INT RETURN 123;
CREATE USER 'tester';
CREATE USER 'Tester';
GRANT SELECT ON TABLE `TestTab` TO 'tester';
GRANT EXECUTE ON FUNCTION `f_Test` TO 'tester';
GRANT EXECUTE ON FUNCTION `f_Test_denied` TO 'Tester';
SELECT f_Test();
SELECT * FROM TestTab;
CONNECT (con_tester,localhost,tester,,B48872);
CONNECT (con_tester_denied,localhost,Tester,,B48872);
CONNECTION con_tester;
SELECT * FROM TestTab;
SELECT `f_Test`();
SELECT `F_TEST`();
SELECT f_Test();
SELECT F_TEST();
CONNECTION con_tester_denied;
--disable_result_log
--error ER_TABLEACCESS_DENIED_ERROR
SELECT * FROM TestTab;
--error ER_PROCACCESS_DENIED_ERROR
SELECT `f_Test`();
--error ER_PROCACCESS_DENIED_ERROR
SELECT `F_TEST`();
--error ER_PROCACCESS_DENIED_ERROR
SELECT f_Test();
--error ER_PROCACCESS_DENIED_ERROR
SELECT F_TEST();
--enable_result_log
SELECT `f_Test_denied`();
SELECT `F_TEST_DENIED`();
CONNECTION default;
DISCONNECT con_tester;
DISCONNECT con_tester_denied;
DROP TABLE `TestTab`;
DROP FUNCTION `f_Test`;
DROP FUNCTION `f_Test_denied`;
USE test;
DROP USER 'tester';
DROP USER 'Tester';
DROP DATABASE B48872;
--echo End of 5.0 tests. --echo End of 5.0 tests.
# Wait till all disconnects are completed # Wait till all disconnects are completed
......
...@@ -103,11 +103,11 @@ static const char cur_dir_name[]= {FN_CURLIB, 0}; ...@@ -103,11 +103,11 @@ static const char cur_dir_name[]= {FN_CURLIB, 0};
int my_sync_dir(const char *dir_name, myf my_flags) int my_sync_dir(const char *dir_name, myf my_flags)
{ {
#ifdef NEED_EXPLICIT_SYNC_DIR #ifdef NEED_EXPLICIT_SYNC_DIR
DBUG_ENTER("my_sync_dir");
DBUG_PRINT("my",("Dir: '%s' my_flags: %d", dir_name, my_flags));
File dir_fd; File dir_fd;
int res= 0; int res= 0;
const char *correct_dir_name; const char *correct_dir_name;
DBUG_ENTER("my_sync_dir");
DBUG_PRINT("my",("Dir: '%s' my_flags: %d", dir_name, my_flags));
/* Sometimes the path does not contain an explicit directory */ /* Sometimes the path does not contain an explicit directory */
correct_dir_name= (dir_name[0] == 0) ? cur_dir_name : dir_name; correct_dir_name= (dir_name[0] == 0) ? cur_dir_name : dir_name;
/* /*
......
...@@ -105,7 +105,8 @@ int init_relay_log_info(Relay_log_info* rli, ...@@ -105,7 +105,8 @@ int init_relay_log_info(Relay_log_info* rli,
rli->tables_to_lock_count= 0; rli->tables_to_lock_count= 0;
char pattern[FN_REFLEN]; char pattern[FN_REFLEN];
if (fn_format(pattern, PREFIX_SQL_LOAD, slave_load_tmpdir, "", (void) my_realpath(pattern, slave_load_tmpdir, 0);
if (fn_format(pattern, PREFIX_SQL_LOAD, pattern, "",
MY_SAFE_PATH | MY_RETURN_REAL_PATH) == NullS) MY_SAFE_PATH | MY_RETURN_REAL_PATH) == NullS)
{ {
pthread_mutex_unlock(&rli->data_lock); pthread_mutex_unlock(&rli->data_lock);
......
...@@ -2444,14 +2444,17 @@ static GRANT_NAME *name_hash_search(HASH *name_hash, ...@@ -2444,14 +2444,17 @@ static GRANT_NAME *name_hash_search(HASH *name_hash,
const char *host,const char* ip, const char *host,const char* ip,
const char *db, const char *db,
const char *user, const char *tname, const char *user, const char *tname,
bool exact) bool exact, bool name_tolower)
{ {
char helping [NAME_LEN*2+USERNAME_LENGTH+3]; char helping [NAME_LEN*2+USERNAME_LENGTH+3], *name_ptr;
uint len; uint len;
GRANT_NAME *grant_name,*found=0; GRANT_NAME *grant_name,*found=0;
HASH_SEARCH_STATE state; HASH_SEARCH_STATE state;
len = (uint) (strmov(strmov(strmov(helping,user)+1,db)+1,tname)-helping)+ 1; name_ptr= strmov(strmov(helping, user) + 1, db) + 1;
len = (uint) (strmov(name_ptr, tname) - helping) + 1;
if (name_tolower)
my_casedn_str(files_charset_info, name_ptr);
for (grant_name= (GRANT_NAME*) hash_first(name_hash, (uchar*) helping, for (grant_name= (GRANT_NAME*) hash_first(name_hash, (uchar*) helping,
len, &state); len, &state);
grant_name ; grant_name ;
...@@ -2484,7 +2487,7 @@ routine_hash_search(const char *host, const char *ip, const char *db, ...@@ -2484,7 +2487,7 @@ routine_hash_search(const char *host, const char *ip, const char *db,
{ {
return (GRANT_TABLE*) return (GRANT_TABLE*)
name_hash_search(proc ? &proc_priv_hash : &func_priv_hash, name_hash_search(proc ? &proc_priv_hash : &func_priv_hash,
host, ip, db, user, tname, exact); host, ip, db, user, tname, exact, TRUE);
} }
...@@ -2493,7 +2496,7 @@ table_hash_search(const char *host, const char *ip, const char *db, ...@@ -2493,7 +2496,7 @@ table_hash_search(const char *host, const char *ip, const char *db,
const char *user, const char *tname, bool exact) const char *user, const char *tname, bool exact)
{ {
return (GRANT_TABLE*) name_hash_search(&column_priv_hash, host, ip, db, return (GRANT_TABLE*) name_hash_search(&column_priv_hash, host, ip, db,
user, tname, exact); user, tname, exact, FALSE);
} }
......
...@@ -304,7 +304,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -304,7 +304,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
else else
{ {
(void) fn_format(name, ex->file_name, mysql_real_data_home, "", (void) fn_format(name, ex->file_name, mysql_real_data_home, "",
MY_RELATIVE_PATH | MY_UNPACK_FILENAME); MY_RELATIVE_PATH | MY_UNPACK_FILENAME |
MY_RETURN_REAL_PATH);
#if !defined(__WIN__) && ! defined(__NETWARE__) #if !defined(__WIN__) && ! defined(__NETWARE__)
MY_STAT stat_info; MY_STAT stat_info;
if (!my_stat(name,&stat_info,MYF(MY_WME))) if (!my_stat(name,&stat_info,MYF(MY_WME)))
...@@ -347,13 +348,17 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -347,13 +348,17 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
DBUG_ASSERT(FALSE); DBUG_ASSERT(FALSE);
#endif #endif
} }
else if (opt_secure_file_priv && else if (opt_secure_file_priv)
strncmp(opt_secure_file_priv, name, strlen(opt_secure_file_priv))) {
char secure_file_real_path[FN_REFLEN];
(void) my_realpath(secure_file_real_path, opt_secure_file_priv, 0);
if (strncmp(secure_file_real_path, name, strlen(secure_file_real_path)))
{ {
/* Read only allowed from within dir specified by secure_file_priv */ /* Read only allowed from within dir specified by secure_file_priv */
my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv"); my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
}
} }
if ((file=my_open(name,O_RDONLY,MYF(MY_WME))) < 0) if ((file=my_open(name,O_RDONLY,MYF(MY_WME))) < 0)
......
...@@ -5419,6 +5419,13 @@ goto binlog; ...@@ -5419,6 +5419,13 @@ goto binlog;
} }
VOID(pthread_mutex_unlock(&LOCK_open)); VOID(pthread_mutex_unlock(&LOCK_open));
/*
The condition avoids a crash as described in BUG#48506. Other
binlogging problems related to CREATE TABLE IF NOT EXISTS LIKE
when the existing object is a view will be solved by BUG 47442.
*/
if (!table->view)
{
IF_DBUG(int result=) IF_DBUG(int result=)
store_create_info(thd, table, &query, store_create_info(thd, table, &query,
create_info, FALSE /* show_database */); create_info, FALSE /* show_database */);
...@@ -5426,6 +5433,7 @@ goto binlog; ...@@ -5426,6 +5433,7 @@ goto binlog;
DBUG_ASSERT(result == 0); // store_create_info() always return 0 DBUG_ASSERT(result == 0); // store_create_info() always return 0
write_bin_log(thd, TRUE, query.ptr(), query.length()); write_bin_log(thd, TRUE, query.ptr(), query.length());
} }
}
else // Case 1 else // Case 1
write_bin_log(thd, TRUE, thd->query(), thd->query_length()); write_bin_log(thd, TRUE, thd->query(), thd->query_length());
} }
......
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