mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Merge bk-internal.mysql.com:/home/bk/mysql-5.1-marvel
into mysql.com:/home/my/mysql-5.1 client/mysqladmin.cc: Auto merged client/mysqlbinlog.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_view.cc: Auto merged
This commit is contained in:
@@ -60,5 +60,5 @@ enum options_client
|
|||||||
OPT_SLAP_AUTO_GENERATE_SQL_LOAD_TYPE, OPT_SLAP_AUTO_GENERATE_WRITE_NUM,
|
OPT_SLAP_AUTO_GENERATE_SQL_LOAD_TYPE, OPT_SLAP_AUTO_GENERATE_WRITE_NUM,
|
||||||
OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT, OPT_SERVER_ID,
|
OPT_MYSQL_REPLACE_INTO, OPT_BASE64_OUTPUT, OPT_SERVER_ID,
|
||||||
OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
|
OPT_FIX_TABLE_NAMES, OPT_FIX_DB_NAMES, OPT_SSL_VERIFY_SERVER_CERT,
|
||||||
OPT_DEBUG_INFO, OPT_COLUMN_TYPES
|
OPT_DEBUG_INFO, OPT_COLUMN_TYPES, OPT_ERROR_LOG_FILE
|
||||||
};
|
};
|
||||||
|
@@ -885,14 +885,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
opt_nopager= 1;
|
opt_nopager= 1;
|
||||||
break;
|
break;
|
||||||
case OPT_MYSQL_PROTOCOL:
|
case OPT_MYSQL_PROTOCOL:
|
||||||
{
|
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
|
||||||
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
|
opt->name);
|
||||||
{
|
|
||||||
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'A':
|
case 'A':
|
||||||
opt_rehash= 0;
|
opt_rehash= 0;
|
||||||
|
@@ -287,15 +287,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case OPT_MYSQL_PROTOCOL:
|
case OPT_MYSQL_PROTOCOL:
|
||||||
{
|
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
|
||||||
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
|
opt->name);
|
||||||
{
|
|
||||||
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
usage();
|
usage();
|
||||||
|
@@ -946,14 +946,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
remote_opt= 1;
|
remote_opt= 1;
|
||||||
break;
|
break;
|
||||||
case OPT_MYSQL_PROTOCOL:
|
case OPT_MYSQL_PROTOCOL:
|
||||||
{
|
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
|
||||||
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
|
opt->name);
|
||||||
{
|
|
||||||
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case OPT_START_DATETIME:
|
case OPT_START_DATETIME:
|
||||||
start_datetime= convert_str_to_timestamp(start_datetime_str);
|
start_datetime= convert_str_to_timestamp(start_datetime_str);
|
||||||
break;
|
break;
|
||||||
|
@@ -310,15 +310,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
break;
|
break;
|
||||||
case 'V': print_version(); exit(0);
|
case 'V': print_version(); exit(0);
|
||||||
case OPT_MYSQL_PROTOCOL:
|
case OPT_MYSQL_PROTOCOL:
|
||||||
{
|
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
|
||||||
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
|
opt->name);
|
||||||
{
|
|
||||||
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -109,7 +109,8 @@ static char *opt_password=0,*current_user=0,
|
|||||||
*lines_terminated=0, *enclosed=0, *opt_enclosed=0, *escaped=0,
|
*lines_terminated=0, *enclosed=0, *opt_enclosed=0, *escaped=0,
|
||||||
*where=0, *order_by=0,
|
*where=0, *order_by=0,
|
||||||
*opt_compatible_mode_str= 0,
|
*opt_compatible_mode_str= 0,
|
||||||
*err_ptr= 0;
|
*err_ptr= 0,
|
||||||
|
*log_error_file= NULL;
|
||||||
static char **defaults_argv= 0;
|
static char **defaults_argv= 0;
|
||||||
static char compatible_mode_normal_str[255];
|
static char compatible_mode_normal_str[255];
|
||||||
static ulong opt_compatible_mode= 0;
|
static ulong opt_compatible_mode= 0;
|
||||||
@@ -120,7 +121,9 @@ static my_string opt_mysql_unix_port=0;
|
|||||||
static int first_error=0;
|
static int first_error=0;
|
||||||
static DYNAMIC_STRING extended_row;
|
static DYNAMIC_STRING extended_row;
|
||||||
#include <sslopt-vars.h>
|
#include <sslopt-vars.h>
|
||||||
FILE *md_result_file= 0;
|
FILE *md_result_file= 0;
|
||||||
|
FILE *stderror_file=0;
|
||||||
|
|
||||||
#ifdef HAVE_SMEM
|
#ifdef HAVE_SMEM
|
||||||
static char *shared_memory_base_name=0;
|
static char *shared_memory_base_name=0;
|
||||||
#endif
|
#endif
|
||||||
@@ -307,6 +310,9 @@ static struct my_option my_long_options[] =
|
|||||||
0, 0, 0, 0, 0, 0},
|
0, 0, 0, 0, 0, 0},
|
||||||
{"lock-tables", 'l', "Lock all tables for read.", (gptr*) &lock_tables,
|
{"lock-tables", 'l', "Lock all tables for read.", (gptr*) &lock_tables,
|
||||||
(gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
|
(gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
|
||||||
|
{"log-error", OPT_ERROR_LOG_FILE, "Append warnings and errors to given file.",
|
||||||
|
(gptr*) &log_error_file, (gptr*) &log_error_file, 0, GET_STR,
|
||||||
|
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
|
||||||
{"master-data", OPT_MASTER_DATA,
|
{"master-data", OPT_MASTER_DATA,
|
||||||
"This causes the binary log position and filename to be appended to the "
|
"This causes the binary log position and filename to be appended to the "
|
||||||
"output. If equal to 1, will print it as a CHANGE MASTER command; if equal"
|
"output. If equal to 1, will print it as a CHANGE MASTER command; if equal"
|
||||||
@@ -790,14 +796,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (int) OPT_MYSQL_PROTOCOL:
|
case (int) OPT_MYSQL_PROTOCOL:
|
||||||
{
|
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
|
||||||
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
|
opt->name);
|
||||||
{
|
break;
|
||||||
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -4118,6 +4119,16 @@ int main(int argc, char **argv)
|
|||||||
free_resources(0);
|
free_resources(0);
|
||||||
exit(exit_code);
|
exit(exit_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (log_error_file)
|
||||||
|
{
|
||||||
|
if(!(stderror_file= freopen(log_error_file, "a+", stderr)))
|
||||||
|
{
|
||||||
|
free_resources(0);
|
||||||
|
exit(EX_MYSQLERR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (connect_to_db(current_host, current_user, opt_password))
|
if (connect_to_db(current_host, current_user, opt_password))
|
||||||
{
|
{
|
||||||
free_resources(0);
|
free_resources(0);
|
||||||
@@ -4181,5 +4192,9 @@ err:
|
|||||||
if (!path)
|
if (!path)
|
||||||
write_footer(md_result_file);
|
write_footer(md_result_file);
|
||||||
free_resources();
|
free_resources();
|
||||||
|
|
||||||
|
if (stderror_file)
|
||||||
|
fclose(stderror_file);
|
||||||
|
|
||||||
return(first_error);
|
return(first_error);
|
||||||
} /* main */
|
} /* main */
|
||||||
|
@@ -231,14 +231,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case OPT_MYSQL_PROTOCOL:
|
case OPT_MYSQL_PROTOCOL:
|
||||||
{
|
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
|
||||||
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
|
opt->name);
|
||||||
{
|
|
||||||
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case '#':
|
case '#':
|
||||||
DBUG_PUSH(argument ? argument : "d:t:o");
|
DBUG_PUSH(argument ? argument : "d:t:o");
|
||||||
break;
|
break;
|
||||||
|
@@ -287,14 +287,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case OPT_MYSQL_PROTOCOL:
|
case OPT_MYSQL_PROTOCOL:
|
||||||
{
|
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
|
||||||
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
|
opt->name);
|
||||||
{
|
|
||||||
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case '#':
|
case '#':
|
||||||
DBUG_PUSH(argument ? argument : "d:t:o");
|
DBUG_PUSH(argument ? argument : "d:t:o");
|
||||||
break;
|
break;
|
||||||
|
@@ -568,14 +568,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case OPT_MYSQL_PROTOCOL:
|
case OPT_MYSQL_PROTOCOL:
|
||||||
{
|
opt_protocol= find_type_or_exit(argument, &sql_protocol_typelib,
|
||||||
if ((opt_protocol= find_type(argument, &sql_protocol_typelib,0)) <= 0)
|
opt->name);
|
||||||
{
|
break;
|
||||||
fprintf(stderr, "Unknown option to protocol: %s\n", argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case '#':
|
case '#':
|
||||||
DBUG_PUSH(argument ? argument : default_dbug_option);
|
DBUG_PUSH(argument ? argument : default_dbug_option);
|
||||||
break;
|
break;
|
||||||
|
@@ -26,6 +26,8 @@ typedef struct st_typelib { /* Different types saved here */
|
|||||||
unsigned int *type_lengths;
|
unsigned int *type_lengths;
|
||||||
} TYPELIB;
|
} TYPELIB;
|
||||||
|
|
||||||
|
extern int find_type_or_exit(const char *x, TYPELIB *typelib,
|
||||||
|
const char *option);
|
||||||
extern int find_type(char *x,TYPELIB *typelib,unsigned int full_name);
|
extern int find_type(char *x,TYPELIB *typelib,unsigned int full_name);
|
||||||
extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
|
extern void make_type(char *to,unsigned int nr,TYPELIB *typelib);
|
||||||
extern const char *get_type(TYPELIB *typelib,unsigned int nr);
|
extern const char *get_type(TYPELIB *typelib,unsigned int nr);
|
||||||
|
@@ -117,16 +117,82 @@ use testdb_1;
|
|||||||
create table t1 (f1 char(4));
|
create table t1 (f1 char(4));
|
||||||
create view v1 as select f1 from t1;
|
create view v1 as select f1 from t1;
|
||||||
grant insert on v1 to testdb_2@localhost;
|
grant insert on v1 to testdb_2@localhost;
|
||||||
|
create view v5 as select f1 from t1;
|
||||||
|
grant show view on v5 to testdb_2@localhost;
|
||||||
|
create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1;
|
||||||
|
ERROR 42000: Access denied; you need the SUPER privilege for this operation
|
||||||
|
use testdb_1;
|
||||||
|
create view v6 as select f1 from t1;
|
||||||
|
grant show view on v6 to testdb_2@localhost;
|
||||||
|
create table t2 (f1 char(4));
|
||||||
|
create definer=`no_such_user`@`no_such_host` view v7 as select * from t2;
|
||||||
|
Warnings:
|
||||||
|
Note 1449 There is no 'no_such_user'@'no_such_host' registered
|
||||||
|
show fields from testdb_1.v6;
|
||||||
|
Field Type Null Key Default Extra
|
||||||
|
f1 char(4) YES NULL
|
||||||
|
show create view testdb_1.v6;
|
||||||
|
View Create View
|
||||||
|
v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v6` AS select `t1`.`f1` AS `f1` from `t1`
|
||||||
|
show create view testdb_1.v7;
|
||||||
|
View Create View
|
||||||
|
v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2`
|
||||||
|
Warnings:
|
||||||
|
Warning 1356 View 'testdb_1.v7' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||||
|
show fields from testdb_1.v7;
|
||||||
|
Field Type Null Key Default Extra
|
||||||
|
f1 null YES NULL
|
||||||
|
Warnings:
|
||||||
|
Note 1449 There is no 'no_such_user'@'no_such_host' registered
|
||||||
create table t3 (f1 char(4), f2 char(4));
|
create table t3 (f1 char(4), f2 char(4));
|
||||||
create view v3 as select f1,f2 from t3;
|
create view v3 as select f1,f2 from t3;
|
||||||
grant insert(f1), insert(f2) on v3 to testdb_2@localhost;
|
grant insert(f1), insert(f2) on v3 to testdb_2@localhost;
|
||||||
create view v2 as select f1 from testdb_1.v1;
|
create view v2 as select f1 from testdb_1.v1;
|
||||||
create view v4 as select f1,f2 from testdb_1.v3;
|
create view v4 as select f1,f2 from testdb_1.v3;
|
||||||
|
show fields from testdb_1.v5;
|
||||||
|
Field Type Null Key Default Extra
|
||||||
|
f1 char(4) YES NULL
|
||||||
|
show create view testdb_1.v5;
|
||||||
|
View Create View
|
||||||
|
v5 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_1`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v5` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1`
|
||||||
|
show fields from testdb_1.v6;
|
||||||
|
Field Type Null Key Default Extra
|
||||||
|
f1 char(4) YES NULL
|
||||||
|
show create view testdb_1.v6;
|
||||||
|
View Create View
|
||||||
|
v6 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `testdb_1`.`v6` AS select `testdb_1`.`t1`.`f1` AS `f1` from `testdb_1`.`t1`
|
||||||
|
show fields from testdb_1.v7;
|
||||||
|
Field Type Null Key Default Extra
|
||||||
|
f1 null YES NULL
|
||||||
|
Warnings:
|
||||||
|
Note 1449 There is no 'no_such_user'@'no_such_host' registered
|
||||||
|
show create view testdb_1.v7;
|
||||||
|
View Create View
|
||||||
|
v7 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such_user`@`no_such_host` SQL SECURITY DEFINER VIEW `v7` AS select `testdb_1`.`t2`.`f1` AS `f1` from `t2`
|
||||||
|
Warnings:
|
||||||
|
Warning 1356 View 'testdb_1.v7' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||||
revoke insert(f1) on v3 from testdb_2@localhost;
|
revoke insert(f1) on v3 from testdb_2@localhost;
|
||||||
|
revoke show view on v5 from testdb_2@localhost;
|
||||||
|
use testdb_1;
|
||||||
|
revoke show view on v6 from testdb_2@localhost;
|
||||||
|
show fields from testdb_1.v5;
|
||||||
|
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v5'
|
||||||
|
show create view testdb_1.v5;
|
||||||
|
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v5'
|
||||||
|
show fields from testdb_1.v6;
|
||||||
|
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v6'
|
||||||
|
show create view testdb_1.v6;
|
||||||
|
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v6'
|
||||||
|
show fields from testdb_1.v7;
|
||||||
|
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v7'
|
||||||
|
show create view testdb_1.v7;
|
||||||
|
ERROR 42000: SELECT command denied to user 'testdb_2'@'localhost' for table 'v7'
|
||||||
show create view v4;
|
show create view v4;
|
||||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
||||||
show fields from v4;
|
show fields from v4;
|
||||||
ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
|
Field Type Null Key Default Extra
|
||||||
|
f1 null YES NULL
|
||||||
|
f2 char(4) YES NULL
|
||||||
show fields from v2;
|
show fields from v2;
|
||||||
Field Type Null Key Default Extra
|
Field Type Null Key Default Extra
|
||||||
f1 char(4) YES NULL
|
f1 char(4) YES NULL
|
||||||
@@ -151,7 +217,8 @@ where a.table_name = 'testdb_1.v1';
|
|||||||
view_definition
|
view_definition
|
||||||
select * from v2;
|
select * from v2;
|
||||||
ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
|
||||||
drop view testdb_1.v1,v2, testdb_1.v3, v4;
|
use test;
|
||||||
|
drop view testdb_1.v1, v2, testdb_1.v3, v4;
|
||||||
drop database testdb_1;
|
drop database testdb_1;
|
||||||
drop user testdb_1@localhost;
|
drop user testdb_1@localhost;
|
||||||
drop user testdb_2@localhost;
|
drop user testdb_2@localhost;
|
||||||
|
@@ -7,3 +7,4 @@ SOCKET
|
|||||||
ERROR 2047 (HY000): Wrong or unknown protocol
|
ERROR 2047 (HY000): Wrong or unknown protocol
|
||||||
ERROR 2047 (HY000): Wrong or unknown protocol
|
ERROR 2047 (HY000): Wrong or unknown protocol
|
||||||
Unknown option to protocol: NullS
|
Unknown option to protocol: NullS
|
||||||
|
Alternatives are: 'TCP','SOCKET','PIPE','MEMORY'
|
||||||
|
@@ -121,6 +121,28 @@ create table t1 (f1 char(4));
|
|||||||
create view v1 as select f1 from t1;
|
create view v1 as select f1 from t1;
|
||||||
grant insert on v1 to testdb_2@localhost;
|
grant insert on v1 to testdb_2@localhost;
|
||||||
|
|
||||||
|
create view v5 as select f1 from t1;
|
||||||
|
grant show view on v5 to testdb_2@localhost;
|
||||||
|
|
||||||
|
--error 1227
|
||||||
|
create definer=`no_such_user`@`no_such_host` view v6 as select f1 from t1;
|
||||||
|
|
||||||
|
connection default;
|
||||||
|
use testdb_1;
|
||||||
|
create view v6 as select f1 from t1;
|
||||||
|
grant show view on v6 to testdb_2@localhost;
|
||||||
|
|
||||||
|
create table t2 (f1 char(4));
|
||||||
|
create definer=`no_such_user`@`no_such_host` view v7 as select * from t2;
|
||||||
|
|
||||||
|
show fields from testdb_1.v6;
|
||||||
|
show create view testdb_1.v6;
|
||||||
|
|
||||||
|
show create view testdb_1.v7;
|
||||||
|
show fields from testdb_1.v7;
|
||||||
|
|
||||||
|
connection testdb_1;
|
||||||
|
|
||||||
create table t3 (f1 char(4), f2 char(4));
|
create table t3 (f1 char(4), f2 char(4));
|
||||||
create view v3 as select f1,f2 from t3;
|
create view v3 as select f1,f2 from t3;
|
||||||
grant insert(f1), insert(f2) on v3 to testdb_2@localhost;
|
grant insert(f1), insert(f2) on v3 to testdb_2@localhost;
|
||||||
@@ -129,13 +151,41 @@ connect (testdb_2,localhost,testdb_2,,test);
|
|||||||
create view v2 as select f1 from testdb_1.v1;
|
create view v2 as select f1 from testdb_1.v1;
|
||||||
create view v4 as select f1,f2 from testdb_1.v3;
|
create view v4 as select f1,f2 from testdb_1.v3;
|
||||||
|
|
||||||
|
show fields from testdb_1.v5;
|
||||||
|
show create view testdb_1.v5;
|
||||||
|
|
||||||
|
show fields from testdb_1.v6;
|
||||||
|
show create view testdb_1.v6;
|
||||||
|
|
||||||
connection testdb_1;
|
connection testdb_1;
|
||||||
|
show fields from testdb_1.v7;
|
||||||
|
show create view testdb_1.v7;
|
||||||
|
|
||||||
revoke insert(f1) on v3 from testdb_2@localhost;
|
revoke insert(f1) on v3 from testdb_2@localhost;
|
||||||
|
revoke show view on v5 from testdb_2@localhost;
|
||||||
|
connection default;
|
||||||
|
use testdb_1;
|
||||||
|
revoke show view on v6 from testdb_2@localhost;
|
||||||
connection testdb_2;
|
connection testdb_2;
|
||||||
|
|
||||||
|
--error 1142
|
||||||
|
show fields from testdb_1.v5;
|
||||||
|
--error 1142
|
||||||
|
show create view testdb_1.v5;
|
||||||
|
|
||||||
|
--error 1142
|
||||||
|
show fields from testdb_1.v6;
|
||||||
|
--error 1142
|
||||||
|
show create view testdb_1.v6;
|
||||||
|
|
||||||
|
--error 1142
|
||||||
|
show fields from testdb_1.v7;
|
||||||
|
--error 1142
|
||||||
|
show create view testdb_1.v7;
|
||||||
|
|
||||||
--error 1345
|
--error 1345
|
||||||
show create view v4;
|
show create view v4;
|
||||||
--error 1345
|
#--error 1345
|
||||||
show fields from v4;
|
show fields from v4;
|
||||||
|
|
||||||
show fields from v2;
|
show fields from v2;
|
||||||
@@ -155,7 +205,8 @@ where a.table_name = 'testdb_1.v1';
|
|||||||
select * from v2;
|
select * from v2;
|
||||||
|
|
||||||
connection default;
|
connection default;
|
||||||
drop view testdb_1.v1,v2, testdb_1.v3, v4;
|
use test;
|
||||||
|
drop view testdb_1.v1, v2, testdb_1.v3, v4;
|
||||||
drop database testdb_1;
|
drop database testdb_1;
|
||||||
drop user testdb_1@localhost;
|
drop user testdb_1@localhost;
|
||||||
drop user testdb_2@localhost;
|
drop user testdb_2@localhost;
|
||||||
|
@@ -20,6 +20,28 @@
|
|||||||
#include <m_ctype.h>
|
#include <m_ctype.h>
|
||||||
|
|
||||||
|
|
||||||
|
int find_type_or_exit(const char *x, TYPELIB *typelib, const char *option)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
const char **ptr;
|
||||||
|
|
||||||
|
if ((res= find_type((my_string) x, typelib, 2)) <= 0)
|
||||||
|
{
|
||||||
|
ptr= typelib->type_names;
|
||||||
|
if (!*x)
|
||||||
|
fprintf(stderr, "No option given to %s\n", option);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "Unknown option to %s: %s\n", option, x);
|
||||||
|
fprintf(stderr, "Alternatives are: '%s'", *ptr);
|
||||||
|
while (*++ptr)
|
||||||
|
fprintf(stderr, ",'%s'", *ptr);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Search after a string in a list of strings. Endspace in x is not compared.
|
Search after a string in a list of strings. Endspace in x is not compared.
|
||||||
|
|
||||||
|
118
sql/mysqld.cc
118
sql/mysqld.cc
@@ -737,6 +737,8 @@ pthread_handler_t handle_connections_shared_memory(void *arg);
|
|||||||
#endif
|
#endif
|
||||||
pthread_handler_t handle_slave(void *arg);
|
pthread_handler_t handle_slave(void *arg);
|
||||||
static ulong find_bit_type(const char *x, TYPELIB *bit_lib);
|
static ulong find_bit_type(const char *x, TYPELIB *bit_lib);
|
||||||
|
static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
|
||||||
|
const char *option);
|
||||||
static void clean_up(bool print_message);
|
static void clean_up(bool print_message);
|
||||||
static int test_if_case_insensitive(const char *dir_name);
|
static int test_if_case_insensitive(const char *dir_name);
|
||||||
|
|
||||||
@@ -7427,11 +7429,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
case (int) OPT_INIT_RPL_ROLE:
|
case (int) OPT_INIT_RPL_ROLE:
|
||||||
{
|
{
|
||||||
int role;
|
int role;
|
||||||
if ((role=find_type(argument, &rpl_role_typelib, 2)) <= 0)
|
role= find_type_or_exit(argument, &rpl_role_typelib, opt->name);
|
||||||
{
|
|
||||||
fprintf(stderr, "Unknown replication role: %s\n", argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
rpl_status = (role == 1) ? RPL_AUTH_MASTER : RPL_IDLE_SLAVE;
|
rpl_status = (role == 1) ? RPL_AUTH_MASTER : RPL_IDLE_SLAVE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -7487,17 +7485,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
case OPT_BINLOG_FORMAT:
|
case OPT_BINLOG_FORMAT:
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
if ((id= find_type(argument, &binlog_format_typelib, 2)) <= 0)
|
id= find_type_or_exit(argument, &binlog_format_typelib, opt->name);
|
||||||
{
|
|
||||||
fprintf(stderr,
|
|
||||||
"Unknown binary log format: '%s' "
|
|
||||||
"(should be one of '%s', '%s', '%s')\n",
|
|
||||||
argument,
|
|
||||||
binlog_format_names[BINLOG_FORMAT_STMT],
|
|
||||||
binlog_format_names[BINLOG_FORMAT_ROW],
|
|
||||||
binlog_format_names[BINLOG_FORMAT_MIXED]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
global_system_variables.binlog_format= opt_binlog_format_id= id - 1;
|
global_system_variables.binlog_format= opt_binlog_format_id= id - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -7557,13 +7545,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
log_output_str= argument;
|
log_output_str= argument;
|
||||||
if ((log_output_options=
|
log_output_options=
|
||||||
find_bit_type(argument, &log_output_typelib)) == ~(ulong) 0)
|
find_bit_type_or_exit(argument, &log_output_typelib, opt->name);
|
||||||
{
|
}
|
||||||
fprintf(stderr, "Unknown option to log-output: %s\n", argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -7577,10 +7561,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
type= 5 1 2 3 4
|
type= 5 1 2 3 4
|
||||||
(DISABLE ) - (OFF | ON) - (0 | 1)
|
(DISABLE ) - (OFF | ON) - (0 | 1)
|
||||||
*/
|
*/
|
||||||
switch ((type=find_type(argument, &Events::opt_typelib, 1))) {
|
type= find_type_or_exit(argument, &Events::opt_typelib, opt->name);
|
||||||
case 0:
|
switch (type) {
|
||||||
fprintf(stderr, "Unknown option to event-scheduler: %s\n",argument);
|
|
||||||
exit(1);
|
|
||||||
case 5: /* OPT_DISABLED */
|
case 5: /* OPT_DISABLED */
|
||||||
Events::opt_event_scheduler= Events::EVENTS_DISABLED;
|
Events::opt_event_scheduler= Events::EVENTS_DISABLED;
|
||||||
break;
|
break;
|
||||||
@@ -7730,11 +7712,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
if ((type=find_type(argument, &delay_key_write_typelib, 2)) <= 0)
|
type= find_type_or_exit(argument, &delay_key_write_typelib, opt->name);
|
||||||
{
|
|
||||||
fprintf(stderr,"Unknown delay_key_write type: %s\n",argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
delay_key_write_options= (uint) type-1;
|
delay_key_write_options= (uint) type-1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -7745,11 +7723,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
case OPT_TX_ISOLATION:
|
case OPT_TX_ISOLATION:
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
if ((type=find_type(argument, &tx_isolation_typelib, 2)) <= 0)
|
type= find_type_or_exit(argument, &tx_isolation_typelib, opt->name);
|
||||||
{
|
|
||||||
fprintf(stderr,"Unknown transaction isolation type: %s\n",argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
global_system_variables.tx_isolation= (type-1);
|
global_system_variables.tx_isolation= (type-1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -7790,16 +7764,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
break;
|
break;
|
||||||
case OPT_NDB_DISTRIBUTION:
|
case OPT_NDB_DISTRIBUTION:
|
||||||
int id;
|
int id;
|
||||||
if ((id= find_type(argument, &ndb_distribution_typelib, 2)) <= 0)
|
id= find_type_or_exit(argument, &ndb_distribution_typelib, opt->name);
|
||||||
{
|
|
||||||
fprintf(stderr,
|
|
||||||
"Unknown ndb distribution type: '%s' "
|
|
||||||
"(should be '%s' or '%s')\n",
|
|
||||||
argument,
|
|
||||||
ndb_distribution_names[ND_KEYHASH],
|
|
||||||
ndb_distribution_names[ND_LINHASH]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
opt_ndb_distribution_id= (enum ndb_distribution)(id-1);
|
opt_ndb_distribution_id= (enum ndb_distribution)(id-1);
|
||||||
break;
|
break;
|
||||||
case OPT_NDB_EXTRA_LOGGING:
|
case OPT_NDB_EXTRA_LOGGING:
|
||||||
@@ -7839,12 +7804,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
myisam_recover_options_str=argument;
|
myisam_recover_options_str=argument;
|
||||||
if ((myisam_recover_options=
|
myisam_recover_options=
|
||||||
find_bit_type(argument, &myisam_recover_typelib)) == ~(ulong) 0)
|
find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name);
|
||||||
{
|
|
||||||
fprintf(stderr, "Unknown option to myisam-recover: %s\n",argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ha_open_options|=HA_OPEN_ABORT_IF_CRASHED;
|
ha_open_options|=HA_OPEN_ABORT_IF_CRASHED;
|
||||||
break;
|
break;
|
||||||
@@ -7857,14 +7818,10 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
myisam_concurrent_insert= 0; /* --skip-concurrent-insert */
|
myisam_concurrent_insert= 0; /* --skip-concurrent-insert */
|
||||||
break;
|
break;
|
||||||
case OPT_TC_HEURISTIC_RECOVER:
|
case OPT_TC_HEURISTIC_RECOVER:
|
||||||
{
|
tc_heuristic_recover= find_type_or_exit(argument,
|
||||||
if ((tc_heuristic_recover=find_type(argument,
|
&tc_heuristic_recover_typelib,
|
||||||
&tc_heuristic_recover_typelib, 2)) <=0)
|
opt->name);
|
||||||
{
|
break;
|
||||||
fprintf(stderr, "Unknown option to tc-heuristic-recover: %s\n",argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case OPT_MYISAM_STATS_METHOD:
|
case OPT_MYISAM_STATS_METHOD:
|
||||||
{
|
{
|
||||||
ulong method_conv;
|
ulong method_conv;
|
||||||
@@ -7872,11 +7829,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
LINT_INIT(method_conv);
|
LINT_INIT(method_conv);
|
||||||
|
|
||||||
myisam_stats_method_str= argument;
|
myisam_stats_method_str= argument;
|
||||||
if ((method=find_type(argument, &myisam_stats_method_typelib, 2)) <= 0)
|
method= find_type_or_exit(argument, &myisam_stats_method_typelib,
|
||||||
{
|
opt->name);
|
||||||
fprintf(stderr, "Invalid value of myisam_stats_method: %s.\n", argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
switch (method-1) {
|
switch (method-1) {
|
||||||
case 2:
|
case 2:
|
||||||
method_conv= MI_STATS_METHOD_IGNORE_NULLS;
|
method_conv= MI_STATS_METHOD_IGNORE_NULLS;
|
||||||
@@ -7895,12 +7849,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||||||
case OPT_SQL_MODE:
|
case OPT_SQL_MODE:
|
||||||
{
|
{
|
||||||
sql_mode_str= argument;
|
sql_mode_str= argument;
|
||||||
if ((global_system_variables.sql_mode=
|
global_system_variables.sql_mode=
|
||||||
find_bit_type(argument, &sql_mode_typelib)) == ~(ulong) 0)
|
find_bit_type_or_exit(argument, &sql_mode_typelib, opt->name);
|
||||||
{
|
|
||||||
fprintf(stderr, "Unknown option to sql-mode: %s\n", argument);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
global_system_variables.sql_mode= fix_sql_mode(global_system_variables.
|
global_system_variables.sql_mode= fix_sql_mode(global_system_variables.
|
||||||
sql_mode);
|
sql_mode);
|
||||||
break;
|
break;
|
||||||
@@ -8208,6 +8158,30 @@ static void fix_paths(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ulong find_bit_type_or_exit(const char *x, TYPELIB *bit_lib,
|
||||||
|
const char *option)
|
||||||
|
{
|
||||||
|
ulong res;
|
||||||
|
|
||||||
|
const char **ptr;
|
||||||
|
|
||||||
|
if ((res= find_bit_type(x, bit_lib)) == ~(ulong) 0)
|
||||||
|
{
|
||||||
|
ptr= bit_lib->type_names;
|
||||||
|
if (!*x)
|
||||||
|
fprintf(stderr, "No option given to %s\n", option);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "Wrong option to %s. Option(s) given: %s\n", option, x);
|
||||||
|
fprintf(stderr, "Alternatives are: '%s'", *ptr);
|
||||||
|
while (*++ptr)
|
||||||
|
fprintf(stderr, ",'%s'", *ptr);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Return a bitfield from a string of substrings separated by ','
|
Return a bitfield from a string of substrings separated by ','
|
||||||
returns ~(ulong) 0 on error.
|
returns ~(ulong) 0 on error.
|
||||||
|
@@ -4490,14 +4490,35 @@ find_field_in_tables(THD *thd, Item_ident *item,
|
|||||||
{
|
{
|
||||||
Field *cur_field= find_field_in_table_ref(thd, cur_table, name, length,
|
Field *cur_field= find_field_in_table_ref(thd, cur_table, name, length,
|
||||||
item->name, db, table_name, ref,
|
item->name, db, table_name, ref,
|
||||||
check_privileges, allow_rowid,
|
check_privileges,
|
||||||
|
allow_rowid,
|
||||||
&(item->cached_field_index),
|
&(item->cached_field_index),
|
||||||
register_tree_change,
|
register_tree_change,
|
||||||
&actual_table);
|
&actual_table);
|
||||||
if (cur_field)
|
if (cur_field)
|
||||||
{
|
{
|
||||||
if (cur_field == WRONG_GRANT)
|
if (cur_field == WRONG_GRANT)
|
||||||
return (Field*) 0;
|
{
|
||||||
|
if (thd->lex->sql_command != SQLCOM_SHOW_FIELDS)
|
||||||
|
return (Field*) 0;
|
||||||
|
|
||||||
|
thd->clear_error();
|
||||||
|
cur_field= find_field_in_table_ref(thd, cur_table, name, length,
|
||||||
|
item->name, db, table_name, ref,
|
||||||
|
false,
|
||||||
|
allow_rowid,
|
||||||
|
&(item->cached_field_index),
|
||||||
|
register_tree_change,
|
||||||
|
&actual_table);
|
||||||
|
if (cur_field)
|
||||||
|
{
|
||||||
|
Field *nf=new Field_null(NULL,0,Field::NONE,
|
||||||
|
cur_field->field_name,
|
||||||
|
&my_charset_bin);
|
||||||
|
nf->init(cur_table->table);
|
||||||
|
cur_field= nf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Store the original table of the field, which may be different from
|
Store the original table of the field, which may be different from
|
||||||
@@ -4520,7 +4541,7 @@ find_field_in_tables(THD *thd, Item_ident *item,
|
|||||||
report_error == IGNORE_EXCEPT_NON_UNIQUE)
|
report_error == IGNORE_EXCEPT_NON_UNIQUE)
|
||||||
my_error(ER_NON_UNIQ_ERROR, MYF(0),
|
my_error(ER_NON_UNIQ_ERROR, MYF(0),
|
||||||
table_name ? item->full_name() : name, thd->where);
|
table_name ? item->full_name() : name, thd->where);
|
||||||
return (Field*) 0;
|
return (Field*) 0;
|
||||||
}
|
}
|
||||||
found= cur_field;
|
found= cur_field;
|
||||||
}
|
}
|
||||||
|
@@ -4460,7 +4460,10 @@ bool check_single_table_access(THD *thd, ulong privilege,
|
|||||||
goto deny;
|
goto deny;
|
||||||
|
|
||||||
/* Show only 1 table for check_grant */
|
/* Show only 1 table for check_grant */
|
||||||
if (grant_option && check_grant(thd, privilege, all_tables, 0, 1, 0))
|
if (grant_option &&
|
||||||
|
!(all_tables->belong_to_view &&
|
||||||
|
(thd->lex->sql_command == SQLCOM_SHOW_FIELDS)) &&
|
||||||
|
check_grant(thd, privilege, all_tables, 0, 1, 0))
|
||||||
goto deny;
|
goto deny;
|
||||||
|
|
||||||
thd->security_ctx= backup_ctx;
|
thd->security_ctx= backup_ctx;
|
||||||
|
@@ -1008,6 +1008,11 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
|
|||||||
CHARSET_INFO *save_cs= thd->variables.character_set_client;
|
CHARSET_INFO *save_cs= thd->variables.character_set_client;
|
||||||
thd->variables.character_set_client= system_charset_info;
|
thd->variables.character_set_client= system_charset_info;
|
||||||
res= MYSQLparse((void *)thd);
|
res= MYSQLparse((void *)thd);
|
||||||
|
|
||||||
|
if ((old_lex->sql_command == SQLCOM_SHOW_FIELDS) ||
|
||||||
|
(old_lex->sql_command == SQLCOM_SHOW_CREATE))
|
||||||
|
lex->sql_command= old_lex->sql_command;
|
||||||
|
|
||||||
thd->variables.character_set_client= save_cs;
|
thd->variables.character_set_client= save_cs;
|
||||||
thd->variables.sql_mode= save_mode;
|
thd->variables.sql_mode= save_mode;
|
||||||
}
|
}
|
||||||
@@ -1033,7 +1038,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!table->prelocking_placeholder &&
|
else if (!table->prelocking_placeholder &&
|
||||||
old_lex->sql_command == SQLCOM_SHOW_CREATE &&
|
(old_lex->sql_command == SQLCOM_SHOW_CREATE) &&
|
||||||
!table->belong_to_view)
|
!table->belong_to_view)
|
||||||
{
|
{
|
||||||
if (check_table_access(thd, SHOW_VIEW_ACL, table, 0))
|
if (check_table_access(thd, SHOW_VIEW_ACL, table, 0))
|
||||||
|
@@ -2961,7 +2961,7 @@ void st_table_list::hide_view_error(THD *thd)
|
|||||||
thd->net.last_errno == ER_NO_SUCH_TABLE)
|
thd->net.last_errno == ER_NO_SUCH_TABLE)
|
||||||
{
|
{
|
||||||
TABLE_LIST *top= top_table();
|
TABLE_LIST *top= top_table();
|
||||||
thd->clear_error();
|
thd->clear_error();
|
||||||
my_error(ER_VIEW_INVALID, MYF(0), top->view_db.str, top->view_name.str);
|
my_error(ER_VIEW_INVALID, MYF(0), top->view_db.str, top->view_name.str);
|
||||||
}
|
}
|
||||||
else if (thd->net.last_errno == ER_NO_DEFAULT_FOR_FIELD)
|
else if (thd->net.last_errno == ER_NO_DEFAULT_FOR_FIELD)
|
||||||
@@ -3317,7 +3317,8 @@ bool st_table_list::prepare_view_securety_context(THD *thd)
|
|||||||
definer.host.str,
|
definer.host.str,
|
||||||
thd->db))
|
thd->db))
|
||||||
{
|
{
|
||||||
if (thd->lex->sql_command == SQLCOM_SHOW_CREATE)
|
if ((thd->lex->sql_command == SQLCOM_SHOW_CREATE) ||
|
||||||
|
(thd->lex->sql_command == SQLCOM_SHOW_FIELDS))
|
||||||
{
|
{
|
||||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
|
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
|
||||||
ER_NO_SUCH_USER,
|
ER_NO_SUCH_USER,
|
||||||
|
Reference in New Issue
Block a user