diff --git a/client/mysqltest.c b/client/mysqltest.c index d9f1f25e093..170819e9a1e 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -105,7 +105,7 @@ static my_bool cursor_protocol= 0, cursor_protocol_enabled= 0; static my_bool parsing_disabled= 0; static my_bool display_result_vertically= FALSE, display_metadata= FALSE; static my_bool disable_query_log= 0, disable_result_log= 0; -static my_bool disable_warnings= 0, disable_ps_warnings= 0; +static my_bool disable_warnings= 0; static my_bool disable_info= 1; static my_bool abort_on_error= 1; static my_bool is_windows= 0; @@ -264,7 +264,6 @@ enum enum_commands { Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG, Q_WAIT_FOR_SLAVE_TO_STOP, Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS, - Q_ENABLE_PS_WARNINGS, Q_DISABLE_PS_WARNINGS, Q_ENABLE_INFO, Q_DISABLE_INFO, Q_ENABLE_METADATA, Q_DISABLE_METADATA, Q_EXEC, Q_DELIMITER, @@ -328,8 +327,6 @@ const char *command_names[]= "wait_for_slave_to_stop", "enable_warnings", "disable_warnings", - "enable_ps_warnings", - "disable_ps_warnings", "enable_info", "disable_info", "enable_metadata", @@ -6056,8 +6053,6 @@ int main(int argc, char **argv) case Q_DISABLE_RESULT_LOG: disable_result_log=1; break; case Q_ENABLE_WARNINGS: disable_warnings=0; break; case Q_DISABLE_WARNINGS: disable_warnings=1; break; - case Q_ENABLE_PS_WARNINGS: disable_ps_warnings=0; break; - case Q_DISABLE_PS_WARNINGS: disable_ps_warnings=1; break; case Q_ENABLE_INFO: disable_info=0; break; case Q_DISABLE_INFO: disable_info=1; break; case Q_ENABLE_METADATA: display_metadata=1; break; diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index d4f9a4f0c56..07cc37fe6bc 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -181,12 +181,12 @@ date format datetime 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.123450 2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12 -10:20:10 %H:%i:%s 0000-00-00 00:00:00 -10:20:10 %h:%i:%s.%f 0000-00-00 00:00:00 -10:20:10 %T 0000-00-00 00:00:00 -10:20:10AM %h:%i:%s%p 0000-00-00 00:00:00 -10:20:10AM %r 0000-00-00 00:00:00 -10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 00:00:00 +10:20:10 %H:%i:%s 0000-00-00 10:20:10 +10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10 +10:20:10 %T 0000-00-00 10:20:10 +10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10 +10:20:10AM %r 0000-00-00 10:20:10 +10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.440000 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 15 September 2001 %d %M %Y 2001-09-15 00:00:00 15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 @@ -203,13 +203,6 @@ Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00 15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00 15-01-20 %d-%m-%y 2020-01-15 00:00:00 15-2001-1 %d-%Y-%c 2001-01-15 00:00:00 -Warnings: -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10.440000' select date,format,DATE(str_to_date(date, format)) as date2 from t1; date format date2 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 @@ -250,12 +243,12 @@ date format time 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450 2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12 -10:20:10 %H:%i:%s NULL -10:20:10 %h:%i:%s.%f NULL -10:20:10 %T NULL -10:20:10AM %h:%i:%s%p NULL -10:20:10AM %r NULL -10:20:10.44AM %h:%i:%s.%f%p NULL +10:20:10 %H:%i:%s 10:20:10 +10:20:10 %h:%i:%s.%f 10:20:10 +10:20:10 %T 10:20:10 +10:20:10AM %h:%i:%s%p 10:20:10 +10:20:10AM %r 10:20:10 +10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58 15 September 2001 %d %M %Y 00:00:00 15 SEPTEMB 2001 %d %M %Y 00:00:00 @@ -272,13 +265,6 @@ Tuesday 52 2001 %W %V %X 00:00:00 15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00 15-01-20 %d-%m-%y 00:00:00 15-2001-1 %d-%Y-%c 00:00:00 -Warnings: -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10.440000' select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1; date format time2 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12 @@ -288,12 +274,12 @@ date format time2 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450 2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12 -10:20:10 %H:%i:%s NULL -10:20:10 %h:%i:%s.%f NULL -10:20:10 %T NULL -10:20:10AM %h:%i:%s%p NULL -10:20:10AM %r NULL -10:20:10.44AM %h:%i:%s.%f%p NULL +10:20:10 %H:%i:%s 10:20:10 +10:20:10 %h:%i:%s.%f 10:20:10 +10:20:10 %T 10:20:10 +10:20:10AM %h:%i:%s%p 10:20:10 +10:20:10AM %r 10:20:10 +10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58 15 September 2001 %d %M %Y 00:00:00 15 SEPTEMB 2001 %d %M %Y 00:00:00 @@ -310,13 +296,6 @@ Tuesday 52 2001 %W %V %X 00:00:00 15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00 15-01-20 %d-%m-%y 00:00:00 15-2001-1 %d-%Y-%c 00:00:00 -Warnings: -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10.440000' select concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d')); concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d')) 2003-01-02 08:11:02.123456 diff --git a/mysql-test/r/rpl_ignore_table.result b/mysql-test/r/rpl_ignore_table.result index 356a9dcb2f8..28bb4a448e0 100644 --- a/mysql-test/r/rpl_ignore_table.result +++ b/mysql-test/r/rpl_ignore_table.result @@ -14,3 +14,106 @@ SELECT * FROM t4; a DROP TABLE t1; DROP TABLE t4; +**** Test case for BUG#25482 **** +**** Adding GRANTS on master **** +create table test.t1(a int); +create table test.t4(a int); +GRANT SELECT ON test.t1 TO mysqltest1@localhost; +GRANT INSERT ON test.t4 TO mysqltest2@localhost; +GRANT select, update, insert, references on t1 +to mysqltest2@localhost; +GRANT SELECT ON test.* TO mysqltest3@localhost; +GRANT INSERT ON test.t4 TO mysqltest3@localhost; +GRANT select(a), update(a), insert(a), references(a) on t4 +to mysqltest3@localhost; +create database mysqltest2; +create table mysqltest2.t2 (id int); +GRANT SELECT ON mysqltest2.t2 TO mysqltest4@localhost IDENTIFIED BY 'pass'; +insert into mysql.user (user, host) values ("mysqltest5", "somehost"); +GRANT SELECT ON *.* TO mysqltest6@localhost; +GRANT INSERT ON *.* TO mysqltest6@localhost; +GRANT INSERT ON test.* TO mysqltest6@localhost; +GRANT INSERT ON test.t1 TO mysqltest6@localhost; +show grants for mysqltest1@localhost; +Grants for mysqltest1@localhost +GRANT USAGE ON *.* TO 'mysqltest1'@'localhost' +GRANT SELECT ON `test`.`t1` TO 'mysqltest1'@'localhost' +show grants for mysqltest2@localhost; +Grants for mysqltest2@localhost +GRANT USAGE ON *.* TO 'mysqltest2'@'localhost' +GRANT SELECT, INSERT, UPDATE, REFERENCES ON `test`.`t1` TO 'mysqltest2'@'localhost' +GRANT INSERT ON `test`.`t4` TO 'mysqltest2'@'localhost' +show grants for mysqltest3@localhost; +Grants for mysqltest3@localhost +GRANT USAGE ON *.* TO 'mysqltest3'@'localhost' +GRANT SELECT ON `test`.* TO 'mysqltest3'@'localhost' +GRANT SELECT (a), INSERT, INSERT (a), UPDATE (a), REFERENCES (a) ON `test`.`t4` TO 'mysqltest3'@'localhost' +show grants for mysqltest4@localhost; +Grants for mysqltest4@localhost +GRANT USAGE ON *.* TO 'mysqltest4'@'localhost' IDENTIFIED BY PASSWORD '*196BDEDE2AE4F84CA44C47D54D78478C7E2BD7B7' +GRANT SELECT ON `mysqltest2`.`t2` TO 'mysqltest4'@'localhost' +show grants for mysqltest6@localhost; +Grants for mysqltest6@localhost +GRANT SELECT, INSERT ON *.* TO 'mysqltest6'@'localhost' +GRANT INSERT ON `test`.* TO 'mysqltest6'@'localhost' +GRANT INSERT ON `test`.`t1` TO 'mysqltest6'@'localhost' +flush privileges; +show grants for mysqltest5@somehost; +Grants for mysqltest5@somehost +GRANT USAGE ON *.* TO 'mysqltest5'@'somehost' +**** Checking grants on slave **** +show grants for mysqltest2@localhost; +Grants for mysqltest2@localhost +GRANT USAGE ON *.* TO 'mysqltest2'@'localhost' +GRANT INSERT ON `test`.`t4` TO 'mysqltest2'@'localhost' +show grants for mysqltest3@localhost; +Grants for mysqltest3@localhost +GRANT USAGE ON *.* TO 'mysqltest3'@'localhost' +GRANT SELECT ON `test`.* TO 'mysqltest3'@'localhost' +GRANT SELECT (a), INSERT, INSERT (a), UPDATE (a), REFERENCES (a) ON `test`.`t4` TO 'mysqltest3'@'localhost' +show grants for mysqltest4@localhost; +Grants for mysqltest4@localhost +GRANT USAGE ON *.* TO 'mysqltest4'@'localhost' IDENTIFIED BY PASSWORD '*196BDEDE2AE4F84CA44C47D54D78478C7E2BD7B7' +GRANT SELECT ON `mysqltest2`.`t2` TO 'mysqltest4'@'localhost' +show grants for mysqltest5@somehost; +Grants for mysqltest5@somehost +GRANT USAGE ON *.* TO 'mysqltest5'@'somehost' +show grants for mysqltest6@localhost; +Grants for mysqltest6@localhost +GRANT SELECT, INSERT ON *.* TO 'mysqltest6'@'localhost' +GRANT INSERT ON `test`.* TO 'mysqltest6'@'localhost' +show grants for mysqltest1@localhost; +ERROR 42000: There is no such grant defined for user 'mysqltest1' on host 'localhost' +**** Revoking grants on master **** +REVOKE SELECT ON test.t1 FROM mysqltest1@localhost; +REVOKE SELECT ON mysqltest2.t2 FROM mysqltest4@localhost; +REVOKE select(a) on t4 +from mysqltest3@localhost; +show grants for mysqltest1@localhost; +Grants for mysqltest1@localhost +GRANT USAGE ON *.* TO 'mysqltest1'@'localhost' +show grants for mysqltest3@localhost; +Grants for mysqltest3@localhost +GRANT USAGE ON *.* TO 'mysqltest3'@'localhost' +GRANT SELECT ON `test`.* TO 'mysqltest3'@'localhost' +GRANT INSERT, INSERT (a), UPDATE (a), REFERENCES (a) ON `test`.`t4` TO 'mysqltest3'@'localhost' +show grants for mysqltest4@localhost; +Grants for mysqltest4@localhost +GRANT USAGE ON *.* TO 'mysqltest4'@'localhost' IDENTIFIED BY PASSWORD '*196BDEDE2AE4F84CA44C47D54D78478C7E2BD7B7' +**** Checking grants on slave **** +show grants for mysqltest1@localhost; +ERROR 42000: There is no such grant defined for user 'mysqltest1' on host 'localhost' +show grants for mysqltest3@localhost; +Grants for mysqltest3@localhost +GRANT USAGE ON *.* TO 'mysqltest3'@'localhost' +GRANT SELECT ON `test`.* TO 'mysqltest3'@'localhost' +GRANT INSERT, INSERT (a), UPDATE (a), REFERENCES (a) ON `test`.`t4` TO 'mysqltest3'@'localhost' +show grants for mysqltest4@localhost; +Grants for mysqltest4@localhost +GRANT USAGE ON *.* TO 'mysqltest4'@'localhost' IDENTIFIED BY PASSWORD '*196BDEDE2AE4F84CA44C47D54D78478C7E2BD7B7' +drop table t1, t4, mysqltest2.t2; +drop database mysqltest2; +delete from mysql.user where user like "mysqltest%"; +delete from mysql.db where user like "mysqltest%"; +delete from mysql.tables_priv where user like "mysqltest%"; +delete from mysql.columns_priv where user like "mysqltest%"; diff --git a/mysql-test/t/rpl_ignore_table.test b/mysql-test/t/rpl_ignore_table.test index bc651779208..660921a94be 100644 --- a/mysql-test/t/rpl_ignore_table.test +++ b/mysql-test/t/rpl_ignore_table.test @@ -26,3 +26,101 @@ SELECT * FROM t4; connection master; DROP TABLE t1; DROP TABLE t4; + + +# +# Bug#25482 GRANT statements are not replicated if +# you use "replicate-ignore-table" +# + +--echo **** Test case for BUG#25482 **** +--echo **** Adding GRANTS on master **** + +connection master; +create table test.t1(a int); +create table test.t4(a int); + +# Simple user that should not replicate +GRANT SELECT ON test.t1 TO mysqltest1@localhost; + +# Partial replicate +GRANT INSERT ON test.t4 TO mysqltest2@localhost; +GRANT select, update, insert, references on t1 + to mysqltest2@localhost; + +# Partial replicate 2 +GRANT SELECT ON test.* TO mysqltest3@localhost; +GRANT INSERT ON test.t4 TO mysqltest3@localhost; +GRANT select(a), update(a), insert(a), references(a) on t4 + to mysqltest3@localhost; + +# Create another database and table +create database mysqltest2; +create table mysqltest2.t2 (id int); +# Create a grant that should replicate +GRANT SELECT ON mysqltest2.t2 TO mysqltest4@localhost IDENTIFIED BY 'pass'; + +# Create a grant manually +insert into mysql.user (user, host) values ("mysqltest5", "somehost"); + +# Partial replicate 3 with *.* +GRANT SELECT ON *.* TO mysqltest6@localhost; +GRANT INSERT ON *.* TO mysqltest6@localhost; +GRANT INSERT ON test.* TO mysqltest6@localhost; +GRANT INSERT ON test.t1 TO mysqltest6@localhost; + +show grants for mysqltest1@localhost; +show grants for mysqltest2@localhost; +show grants for mysqltest3@localhost; +show grants for mysqltest4@localhost; +show grants for mysqltest6@localhost; + +flush privileges; +show grants for mysqltest5@somehost; + + +sync_slave_with_master; + +--echo **** Checking grants on slave **** + +# Check that grants are replicated to slave +show grants for mysqltest2@localhost; +show grants for mysqltest3@localhost; +show grants for mysqltest4@localhost; +show grants for mysqltest5@somehost; +show grants for mysqltest6@localhost; + +# mysqltest1 should not be on slave +--error 1141 +show grants for mysqltest1@localhost; + +--echo **** Revoking grants on master **** +connection master; +REVOKE SELECT ON test.t1 FROM mysqltest1@localhost; +REVOKE SELECT ON mysqltest2.t2 FROM mysqltest4@localhost; +REVOKE select(a) on t4 + from mysqltest3@localhost; + +show grants for mysqltest1@localhost; +show grants for mysqltest3@localhost; +show grants for mysqltest4@localhost; + +sync_slave_with_master; + +--echo **** Checking grants on slave **** + +# mysqltest1 should not be on slave +--error 1141 +show grants for mysqltest1@localhost; +show grants for mysqltest3@localhost; +show grants for mysqltest4@localhost; + +# Cleanup +connection master; +drop table t1, t4, mysqltest2.t2; +drop database mysqltest2; +delete from mysql.user where user like "mysqltest%"; +delete from mysql.db where user like "mysqltest%"; +delete from mysql.tables_priv where user like "mysqltest%"; +delete from mysql.columns_priv where user like "mysqltest%"; +sync_slave_with_master; diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 77226da3dc8..8f3646e84eb 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -350,10 +350,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, l_time->year > 9999 || l_time->month > 12 || l_time->day > 31 || l_time->hour > 23 || l_time->minute > 59 || l_time->second > 59 || - (!(flags & TIME_FUZZY_DATE) && - (l_time->month == 0 || l_time->day == 0)) || - (l_time->year == 0 && l_time->month == 0 && l_time->day == 0 && - (l_time->hour != 0 || l_time->minute != 0 || l_time->second != 0))) + (!(flags & TIME_FUZZY_DATE) && (l_time->month == 0 || l_time->day == 0))) { /* Only give warning for a zero date if there is some garbage after */ if (!not_zero_date) /* If zero date */ diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index ee57a4d611c..b72caac46a0 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -5926,7 +5926,8 @@ opt_table: | table_ident { LEX *lex=Lex; - if (!lex->current_select->add_table_to_list(lex->thd, $1,NULL,0)) + if (!lex->current_select->add_table_to_list(lex->thd, $1,NULL, + TL_OPTION_UPDATING)) YYABORT; if (lex->grant == GLOBAL_ACLS) lex->grant = TABLE_ACLS & ~GRANT_ACL;