Merge bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/home/dlenev/src/mysql-4.1-bg6765


sql/item_strfunc.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_db.cc:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_prepare.cc:
  Auto merged
sql/sql_show.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
This commit is contained in:
unknown 2004-12-09 13:33:12 +03:00
commit af07ef79d4
24 changed files with 88 additions and 31 deletions

View File

@ -1,4 +1,4 @@
drop table if exists t1; drop table if exists t1, t2;
create table t1 (ts timestamp); create table t1 (ts timestamp);
set time_zone='+00:00'; set time_zone='+00:00';
select unix_timestamp(utc_timestamp())-unix_timestamp(current_timestamp()); select unix_timestamp(utc_timestamp())-unix_timestamp(current_timestamp());
@ -256,18 +256,50 @@ delete from mysql.db where user like 'mysqltest\_%';
delete from mysql.tables_priv where user like 'mysqltest\_%'; delete from mysql.tables_priv where user like 'mysqltest\_%';
delete from mysql.columns_priv where user like 'mysqltest\_%'; delete from mysql.columns_priv where user like 'mysqltest\_%';
flush privileges; flush privileges;
grant usage on mysqltest.* to mysqltest_1@localhost; create table t1 (a int, b datetime);
create table t2 (c int, d datetime);
grant all privileges on test.* to mysqltest_1@localhost;
show grants for current_user(); show grants for current_user();
Grants for mysqltest_1@localhost Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost' GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
GRANT ALL PRIVILEGES ON `test`.* TO 'mysqltest_1'@'localhost'
set time_zone= '+00:00'; set time_zone= '+00:00';
set time_zone= 'Europe/Moscow'; set time_zone= 'Europe/Moscow';
select convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC'); select convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC');
convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC') convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC')
2004-10-21 15:00:00 2004-10-21 15:00:00
select convert_tz(b, 'Europe/Moscow', 'UTC') from t1;
convert_tz(b, 'Europe/Moscow', 'UTC')
update t1, t2 set t1.b = convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC')
where t1.a = t2.c and t2.d = (select max(d) from t2);
select * from mysql.time_zone_name; select * from mysql.time_zone_name;
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysql' ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysql'
select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name; select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name;
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysql' ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysql'
delete from mysql.user where user like 'mysqltest\_%'; delete from mysql.db where user like 'mysqltest\_%';
flush privileges; flush privileges;
grant all privileges on test.t1 to mysqltest_1@localhost;
grant all privileges on test.t2 to mysqltest_1@localhost;
show grants for current_user();
Grants for mysqltest_1@localhost
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
GRANT ALL PRIVILEGES ON `test`.`t2` TO 'mysqltest_1'@'localhost'
GRANT ALL PRIVILEGES ON `test`.`t1` TO 'mysqltest_1'@'localhost'
set time_zone= '+00:00';
set time_zone= 'Europe/Moscow';
select convert_tz('2004-11-31 12:00:00', 'Europe/Moscow', 'UTC');
convert_tz('2004-11-31 12:00:00', 'Europe/Moscow', 'UTC')
2004-12-01 09:00:00
select convert_tz(b, 'Europe/Moscow', 'UTC') from t1;
convert_tz(b, 'Europe/Moscow', 'UTC')
update t1, t2 set t1.b = convert_tz('2004-11-30 12:00:00', 'Europe/Moscow', 'UTC')
where t1.a = t2.c and t2.d = (select max(d) from t2);
select * from mysql.time_zone_name;
ERROR 42000: select command denied to user 'mysqltest_1'@'localhost' for table 'time_zone_name'
select Name, convert_tz('2004-11-30 12:00:00', Name, 'UTC') from mysql.time_zone_name;
ERROR 42000: select command denied to user 'mysqltest_1'@'localhost' for table 'time_zone_name'
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\_%';
flush privileges;
drop table t1, t2;

View File

@ -2,7 +2,7 @@
# Preparing playground # Preparing playground
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1, t2;
--enable_warnings --enable_warnings
@ -205,25 +205,64 @@ drop table t1;
# even for unprivileged users. # even for unprivileged users.
# #
# Let us prepare playground
delete from mysql.user where user like 'mysqltest\_%'; delete from mysql.user where user like 'mysqltest\_%';
delete from mysql.db where user like 'mysqltest\_%'; delete from mysql.db where user like 'mysqltest\_%';
delete from mysql.tables_priv where user like 'mysqltest\_%'; delete from mysql.tables_priv where user like 'mysqltest\_%';
delete from mysql.columns_priv where user like 'mysqltest\_%'; delete from mysql.columns_priv where user like 'mysqltest\_%';
flush privileges; flush privileges;
create table t1 (a int, b datetime);
create table t2 (c int, d datetime);
grant usage on mysqltest.* to mysqltest_1@localhost; grant all privileges on test.* to mysqltest_1@localhost;
connect (tzuser, localhost, mysqltest_1,,); connect (tzuser, localhost, mysqltest_1,,);
connection tzuser; connection tzuser;
show grants for current_user(); show grants for current_user();
set time_zone= '+00:00'; set time_zone= '+00:00';
set time_zone= 'Europe/Moscow'; set time_zone= 'Europe/Moscow';
select convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC'); select convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC');
select convert_tz(b, 'Europe/Moscow', 'UTC') from t1;
# Let us also check whenever multi-update works ok
update t1, t2 set t1.b = convert_tz('2004-10-21 19:00:00', 'Europe/Moscow', 'UTC')
where t1.a = t2.c and t2.d = (select max(d) from t2);
# But still these two statements should not work: # But still these two statements should not work:
--error 1044 --error 1044
select * from mysql.time_zone_name; select * from mysql.time_zone_name;
--error 1044 --error 1044
select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name; select Name, convert_tz('2004-10-21 19:00:00', Name, 'UTC') from mysql.time_zone_name;
#
# Test for bug #6765 "Implicit access to time zone description tables
# requires privileges for them if some table or column level grants
# present"
#
connection default;
# Let use some table-level grants instead of db-level
# to make life more interesting
delete from mysql.db where user like 'mysqltest\_%';
flush privileges;
grant all privileges on test.t1 to mysqltest_1@localhost;
grant all privileges on test.t2 to mysqltest_1@localhost;
# The test itself is almost the same as previous one
connect (tzuser2, localhost, mysqltest_1,,);
connection tzuser2;
show grants for current_user();
set time_zone= '+00:00';
set time_zone= 'Europe/Moscow';
select convert_tz('2004-11-31 12:00:00', 'Europe/Moscow', 'UTC');
select convert_tz(b, 'Europe/Moscow', 'UTC') from t1;
update t1, t2 set t1.b = convert_tz('2004-11-30 12:00:00', 'Europe/Moscow', 'UTC')
where t1.a = t2.c and t2.d = (select max(d) from t2);
# Again these two statements should not work (but with different errors):
--error 1142
select * from mysql.time_zone_name;
--error 1142
select Name, convert_tz('2004-11-30 12:00:00', Name, 'UTC') from mysql.time_zone_name;
# Clean-up
connection default; connection default;
delete from mysql.user where user like 'mysqltest\_%'; 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\_%';
flush privileges; flush privileges;
drop table t1, t2;

View File

@ -24,7 +24,6 @@
#include "mysql_priv.h" #include "mysql_priv.h"
#ifdef HAVE_SPATIAL #ifdef HAVE_SPATIAL
#include "sql_acl.h"
#include <m_ctype.h> #include <m_ctype.h>
void Item_geometry_func::fix_length_and_dec() void Item_geometry_func::fix_length_and_dec()

View File

@ -25,7 +25,6 @@
#endif #endif
#include "mysql_priv.h" #include "mysql_priv.h"
#include "sql_acl.h"
#include <m_ctype.h> #include <m_ctype.h>
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
#include <openssl/des.h> #include <openssl/des.h>

View File

@ -23,7 +23,6 @@
#endif #endif
#include "mysql_priv.h" #include "mysql_priv.h"
#include "sql_acl.h"
#include "sql_repl.h" #include "sql_repl.h"
#include "ha_innodb.h" // necessary to cut the binlog when crash recovery #include "ha_innodb.h" // necessary to cut the binlog when crash recovery

View File

@ -350,7 +350,6 @@ inline THD *_current_thd(void)
#include "sql_udf.h" #include "sql_udf.h"
class user_var_entry; class user_var_entry;
#include "item.h" #include "item.h"
#include "tztime.h"
typedef Comp_creator* (*chooser_compare_func_creator)(bool invert); typedef Comp_creator* (*chooser_compare_func_creator)(bool invert);
/* sql_parse.cc */ /* sql_parse.cc */
void free_items(Item *item); void free_items(Item *item);
@ -371,6 +370,8 @@ int create_table_precheck(THD *thd, TABLE_LIST *tables,
TABLE_LIST *create_table); TABLE_LIST *create_table);
Item *negate_expression(THD *thd, Item *expr); Item *negate_expression(THD *thd, Item *expr);
#include "sql_class.h" #include "sql_class.h"
#include "sql_acl.h"
#include "tztime.h"
#include "opt_range.h" #include "opt_range.h"
#ifdef HAVE_QUERY_CACHE #ifdef HAVE_QUERY_CACHE

View File

@ -17,7 +17,6 @@
#include "mysql_priv.h" #include "mysql_priv.h"
#include <m_ctype.h> #include <m_ctype.h>
#include <my_dir.h> #include <my_dir.h>
#include "sql_acl.h"
#include "slave.h" #include "slave.h"
#include "sql_repl.h" #include "sql_repl.h"
#include "repl_failsafe.h" #include "repl_failsafe.h"

View File

@ -20,7 +20,6 @@
#include "repl_failsafe.h" #include "repl_failsafe.h"
#include "sql_repl.h" #include "sql_repl.h"
#include "slave.h" #include "slave.h"
#include "sql_acl.h"
#include "log_event.h" #include "log_event.h"
#include <mysql.h> #include <mysql.h>

View File

@ -55,7 +55,6 @@
#include "mysql_priv.h" #include "mysql_priv.h"
#include <mysql.h> #include <mysql.h>
#include "slave.h" #include "slave.h"
#include "sql_acl.h"
#include <my_getopt.h> #include <my_getopt.h>
#include <thr_alarm.h> #include <thr_alarm.h>
#include <myisam.h> #include <myisam.h>

View File

@ -26,7 +26,6 @@
*/ */
#include "mysql_priv.h" #include "mysql_priv.h"
#include "sql_acl.h"
#include "hash_filo.h" #include "hash_filo.h"
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
#include "sql_repl.h" //for tables_ok() #include "sql_repl.h" //for tables_ok()

View File

@ -18,7 +18,6 @@
/* Basic functions needed by many modules */ /* Basic functions needed by many modules */
#include "mysql_priv.h" #include "mysql_priv.h"
#include "sql_acl.h"
#include "sql_select.h" #include "sql_select.h"
#include <m_ctype.h> #include <m_ctype.h>
#include <my_dir.h> #include <my_dir.h>

View File

@ -300,7 +300,6 @@ TODO list:
#include <m_ctype.h> #include <m_ctype.h>
#include <my_dir.h> #include <my_dir.h>
#include <hash.h> #include <hash.h>
#include "sql_acl.h"
#include "ha_myisammrg.h" #include "ha_myisammrg.h"
#ifndef MASTER #ifndef MASTER
#include "../srclib/myisammrg/myrg_def.h" #include "../srclib/myisammrg/myrg_def.h"

View File

@ -27,7 +27,6 @@
#endif #endif
#include "mysql_priv.h" #include "mysql_priv.h"
#include "sql_acl.h"
#include <m_ctype.h> #include <m_ctype.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <thr_alarm.h> #include <thr_alarm.h>

View File

@ -19,7 +19,6 @@
#include "mysql_priv.h" #include "mysql_priv.h"
#include <mysys_err.h> #include <mysys_err.h>
#include "sql_acl.h"
#include <my_dir.h> #include <my_dir.h>
#include <m_ctype.h> #include <m_ctype.h>
#ifdef __WIN__ #ifdef __WIN__

View File

@ -23,7 +23,6 @@
#include "mysql_priv.h" #include "mysql_priv.h"
#include "sql_select.h" #include "sql_select.h"
#include "sql_acl.h"
static int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *s, static int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *s,
TABLE_LIST *t); TABLE_LIST *t);

View File

@ -18,7 +18,6 @@
/* Execute DO statement */ /* Execute DO statement */
#include "mysql_priv.h" #include "mysql_priv.h"
#include "sql_acl.h"
int mysql_do(THD *thd, List<Item> &values) int mysql_do(THD *thd, List<Item> &values)
{ {

View File

@ -18,7 +18,6 @@
/* Insert of records */ /* Insert of records */
#include "mysql_priv.h" #include "mysql_priv.h"
#include "sql_acl.h"
static int check_null_fields(THD *thd,TABLE *entry); static int check_null_fields(THD *thd,TABLE *entry);
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY

View File

@ -15,7 +15,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "mysql_priv.h" #include "mysql_priv.h"
#include "sql_acl.h"
#include "sql_repl.h" #include "sql_repl.h"
#include "repl_failsafe.h" #include "repl_failsafe.h"
#include <m_ctype.h> #include <m_ctype.h>
@ -3591,7 +3590,7 @@ error:
/* /*
Check grants for commands which work only with one table and all other Check grants for commands which work only with one table and all other
tables belong to subselects. tables belonging to subselects or implicitly opened tables.
SYNOPSIS SYNOPSIS
check_one_table_access() check_one_table_access()
@ -3613,7 +3612,7 @@ int check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables)
if (grant_option && check_grant(thd, privilege, tables, 0, 1, 0)) if (grant_option && check_grant(thd, privilege, tables, 0, 1, 0))
return 1; return 1;
/* Check rights on tables of subselect (if exists) */ /* Check rights on tables of subselects and implictly opened tables */
TABLE_LIST *subselects_tables; TABLE_LIST *subselects_tables;
if ((subselects_tables= tables->next)) if ((subselects_tables= tables->next))
{ {
@ -5202,7 +5201,10 @@ int multi_update_precheck(THD *thd, TABLE_LIST *tables)
DBUG_PRINT("info",("Checking sub query list")); DBUG_PRINT("info",("Checking sub query list"));
for (table= tables; table; table= table->next) for (table= tables; table; table= table->next)
{ {
if (table->table_in_update_from_clause) if (my_tz_check_n_skip_implicit_tables(&table,
lex->time_zone_tables_used))
continue;
else if (table->table_in_update_from_clause)
{ {
/* /*
If we check table by local TABLE_LIST copy then we should copy If we check table by local TABLE_LIST copy then we should copy

View File

@ -68,7 +68,6 @@ Long data handling:
***********************************************************************/ ***********************************************************************/
#include "mysql_priv.h" #include "mysql_priv.h"
#include "sql_acl.h"
#include "sql_select.h" // for JOIN #include "sql_select.h" // for JOIN
#include <m_ctype.h> // for isspace() #include <m_ctype.h> // for isspace()
#ifdef EMBEDDED_LIBRARY #ifdef EMBEDDED_LIBRARY

View File

@ -18,7 +18,6 @@
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
#include "sql_repl.h" #include "sql_repl.h"
#include "sql_acl.h"
#include "log_event.h" #include "log_event.h"
#include <my_dir.h> #include <my_dir.h>

View File

@ -19,7 +19,6 @@
#include "mysql_priv.h" #include "mysql_priv.h"
#include "sql_select.h" // For select_describe #include "sql_select.h" // For select_describe
#include "sql_acl.h"
#include "repl_failsafe.h" #include "repl_failsafe.h"
#include <my_dir.h> #include <my_dir.h>

View File

@ -21,7 +21,6 @@
*/ */
#include "mysql_priv.h" #include "mysql_priv.h"
#include "sql_acl.h"
#include "sql_select.h" #include "sql_select.h"
static bool safe_update_on_fly(JOIN_TAB *join_tab, List<Item> *fields); static bool safe_update_on_fly(JOIN_TAB *join_tab, List<Item> *fields);

View File

@ -32,7 +32,6 @@
#define Select Lex->current_select #define Select Lex->current_select
#include "mysql_priv.h" #include "mysql_priv.h"
#include "slave.h" #include "slave.h"
#include "sql_acl.h"
#include "lex_symbol.h" #include "lex_symbol.h"
#include "item_create.h" #include "item_create.h"
#include <myisam.h> #include <myisam.h>

View File

@ -66,8 +66,8 @@ extern void my_tz_free();
/* /*
Check if we have pointer to the beggining of list of implictly used Check if we have pointer to the begining of list of implicitly used time
time zone tables and fast-forward to its end. zone tables, set SELECT_ACL for them and fast-forward to its end.
SYNOPSIS SYNOPSIS
my_tz_check_n_skip_implicit_tables() my_tz_check_n_skip_implicit_tables()
@ -87,6 +87,8 @@ inline bool my_tz_check_n_skip_implicit_tables(TABLE_LIST **table,
{ {
if (*table == tz_tables) if (*table == tz_tables)
{ {
for (int i= 0; i < 4; i++)
(*table)[i].grant.privilege= SELECT_ACL;
(*table)+= 3; (*table)+= 3;
return TRUE; return TRUE;
} }