Commit 4bc6bd38 authored by bell@sanja.is.com.ua's avatar bell@sanja.is.com.ua

Merge

parents e2879722 5eb8404c
drop table if exists t1; drop table if exists t1;
drop database if exists mysqltest;
SET NAMES binary; SET NAMES binary;
delete from mysql.user where user='mysqltest_1'; delete from mysql.user where user='mysqltest_1';
delete from mysql.db where user='mysqltest_1'; delete from mysql.db where user='mysqltest_1';
...@@ -473,3 +474,115 @@ ERROR 42000: INSERT,CREATE command denied to user 'mysqltest_1'@'localhost' for ...@@ -473,3 +474,115 @@ ERROR 42000: INSERT,CREATE command denied to user 'mysqltest_1'@'localhost' for
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
delete from mysql.user where user=_binary'mysqltest_1'; delete from mysql.user where user=_binary'mysqltest_1';
drop database mysqltest; drop database mysqltest;
CREATE USER dummy@localhost;
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.dummytable (dummyfield INT);
CREATE VIEW mysqltest.dummyview AS SELECT dummyfield FROM mysqltest.dummytable;
GRANT ALL PRIVILEGES ON mysqltest.dummytable TO dummy@localhost;
GRANT ALL PRIVILEGES ON mysqltest.dummyview TO dummy@localhost;
SHOW GRANTS FOR dummy@localhost;
Grants for dummy@localhost
GRANT USAGE ON *.* TO 'dummy'@'localhost'
GRANT ALL PRIVILEGES ON `mysqltest`.`dummyview` TO 'dummy'@'localhost'
GRANT ALL PRIVILEGES ON `mysqltest`.`dummytable` TO 'dummy'@'localhost'
use INFORMATION_SCHEMA;
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
TABLE_SCHEMA TABLE_NAME PRIVILEGES
mysqltest dummytable ALTER, CREATE, CREATE VIEW, DELETE, DROP, INDEX, INSERT, REFERENCES, SELECT, SHOW VIEW, UPDATE
mysqltest dummyview ALTER, CREATE, CREATE VIEW, DELETE, DROP, INDEX, INSERT, REFERENCES, SELECT, SHOW VIEW, UPDATE
FLUSH PRIVILEGES;
SHOW GRANTS FOR dummy@localhost;
Grants for dummy@localhost
GRANT USAGE ON *.* TO 'dummy'@'localhost'
GRANT ALL PRIVILEGES ON `mysqltest`.`dummyview` TO 'dummy'@'localhost'
GRANT ALL PRIVILEGES ON `mysqltest`.`dummytable` TO 'dummy'@'localhost'
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
TABLE_SCHEMA TABLE_NAME PRIVILEGES
mysqltest dummytable ALTER, CREATE, CREATE VIEW, DELETE, DROP, INDEX, INSERT, REFERENCES, SELECT, SHOW VIEW, UPDATE
mysqltest dummyview ALTER, CREATE, CREATE VIEW, DELETE, DROP, INDEX, INSERT, REFERENCES, SELECT, SHOW VIEW, UPDATE
SHOW FIELDS FROM mysql.tables_priv;
Field Type Null Key Default Extra
Host char(60) NO PRI
Db char(64) NO PRI
User char(16) NO PRI
Table_name char(64) NO PRI
Grantor char(77) NO MUL
Timestamp timestamp YES CURRENT_TIMESTAMP
Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') NO
Column_priv set('Select','Insert','Update','References') NO
use test;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost;
DROP USER dummy@localhost;
DROP DATABASE mysqltest;
CREATE USER dummy@localhost;
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.dummytable (dummyfield INT);
CREATE VIEW mysqltest.dummyview AS SELECT dummyfield FROM mysqltest.dummytable;
GRANT CREATE VIEW ON mysqltest.dummytable TO dummy@localhost;
GRANT CREATE VIEW ON mysqltest.dummyview TO dummy@localhost;
SHOW GRANTS FOR dummy@localhost;
Grants for dummy@localhost
GRANT USAGE ON *.* TO 'dummy'@'localhost'
GRANT CREATE VIEW ON `mysqltest`.`dummyview` TO 'dummy'@'localhost'
GRANT CREATE VIEW ON `mysqltest`.`dummytable` TO 'dummy'@'localhost'
use INFORMATION_SCHEMA;
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
TABLE_SCHEMA TABLE_NAME PRIVILEGES
mysqltest dummytable CREATE VIEW
mysqltest dummyview CREATE VIEW
FLUSH PRIVILEGES;
SHOW GRANTS FOR dummy@localhost;
Grants for dummy@localhost
GRANT USAGE ON *.* TO 'dummy'@'localhost'
GRANT CREATE VIEW ON `mysqltest`.`dummyview` TO 'dummy'@'localhost'
GRANT CREATE VIEW ON `mysqltest`.`dummytable` TO 'dummy'@'localhost'
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
TABLE_SCHEMA TABLE_NAME PRIVILEGES
mysqltest dummytable CREATE VIEW
mysqltest dummyview CREATE VIEW
use test;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost;
DROP USER dummy@localhost;
DROP DATABASE mysqltest;
CREATE USER dummy@localhost;
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.dummytable (dummyfield INT);
CREATE VIEW mysqltest.dummyview AS SELECT dummyfield FROM mysqltest.dummytable;
GRANT SHOW VIEW ON mysqltest.dummytable TO dummy@localhost;
GRANT SHOW VIEW ON mysqltest.dummyview TO dummy@localhost;
SHOW GRANTS FOR dummy@localhost;
Grants for dummy@localhost
GRANT USAGE ON *.* TO 'dummy'@'localhost'
GRANT SHOW VIEW ON `mysqltest`.`dummyview` TO 'dummy'@'localhost'
GRANT SHOW VIEW ON `mysqltest`.`dummytable` TO 'dummy'@'localhost'
use INFORMATION_SCHEMA;
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
TABLE_SCHEMA TABLE_NAME PRIVILEGES
mysqltest dummytable SHOW VIEW
mysqltest dummyview SHOW VIEW
FLUSH PRIVILEGES;
SHOW GRANTS FOR dummy@localhost;
Grants for dummy@localhost
GRANT USAGE ON *.* TO 'dummy'@'localhost'
GRANT SHOW VIEW ON `mysqltest`.`dummyview` TO 'dummy'@'localhost'
GRANT SHOW VIEW ON `mysqltest`.`dummytable` TO 'dummy'@'localhost'
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
TABLE_SCHEMA TABLE_NAME PRIVILEGES
mysqltest dummytable SHOW VIEW
mysqltest dummyview SHOW VIEW
use test;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost;
DROP USER dummy@localhost;
DROP DATABASE mysqltest;
...@@ -128,7 +128,7 @@ tables_priv CREATE TABLE `tables_priv` ( ...@@ -128,7 +128,7 @@ tables_priv CREATE TABLE `tables_priv` (
`Table_name` char(64) collate utf8_bin NOT NULL default '', `Table_name` char(64) collate utf8_bin NOT NULL default '',
`Grantor` char(77) collate utf8_bin NOT NULL default '', `Grantor` char(77) collate utf8_bin NOT NULL default '',
`Timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `Timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`Table_priv` set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') character set utf8 NOT NULL default '', `Table_priv` set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') character set utf8 NOT NULL default '',
`Column_priv` set('Select','Insert','Update','References') character set utf8 NOT NULL default '', `Column_priv` set('Select','Insert','Update','References') character set utf8 NOT NULL default '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`), PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`),
KEY `Grantor` (`Grantor`) KEY `Grantor` (`Grantor`)
......
...@@ -1831,6 +1831,59 @@ select * from v1; ...@@ -1831,6 +1831,59 @@ select * from v1;
t t
01:00 01:00
drop view v1; drop view v1;
CREATE TABLE t1 (col1 time);
CREATE TABLE t2 (col1 time);
CREATE VIEW v1 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t1;
CREATE VIEW v2 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2;
CREATE VIEW v3 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t1;
CREATE VIEW v4 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2;
CREATE VIEW v5 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t1;
CREATE VIEW v6 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2;
DROP TABLE t1;
CHECK TABLE v1, v2, v3, v4, v5, v6;
Table Op Msg_type Msg_text
test.v1 check error View 'test.v1' references invalid table(s) or column(s) or function(s)
test.v2 check status OK
test.v3 check error View 'test.v3' references invalid table(s) or column(s) or function(s)
test.v4 check status OK
test.v5 check error View 'test.v5' references invalid table(s) or column(s) or function(s)
test.v6 check status OK
drop view v1, v2, v3, v4, v5, v6;
drop table t2;
CREATE TABLE t1 (col1 time);
CREATE TABLE t2 (col1 time);
CREATE TABLE t3 (col1 time);
create function f1 () returns int return (select max(col1) from t1);
create function f2 () returns int return (select max(col1) from t2);
CREATE VIEW v1 AS SELECT f1() FROM t3;
CREATE VIEW v2 AS SELECT f2() FROM t3;
CREATE VIEW v3 AS SELECT f1() FROM t3;
CREATE VIEW v4 AS SELECT f2() FROM t3;
CREATE VIEW v5 AS SELECT f1() FROM t3;
CREATE VIEW v6 AS SELECT f2() FROM t3;
drop function f1;
CHECK TABLE v1, v2, v3, v4, v5, v6;
Table Op Msg_type Msg_text
test.v1 check error View 'test.v1' references invalid table(s) or column(s) or function(s)
test.v2 check status OK
test.v3 check error View 'test.v3' references invalid table(s) or column(s) or function(s)
test.v4 check status OK
test.v5 check error View 'test.v5' references invalid table(s) or column(s) or function(s)
test.v6 check status OK
create function f1 () returns int return (select max(col1) from t1);
DROP TABLE t1;
CHECK TABLE v1, v2, v3, v4, v5, v6;
Table Op Msg_type Msg_text
test.v1 check error Table 'test.t1' doesn't exist
test.v2 check status OK
test.v3 check error Table 'test.t1' doesn't exist
test.v4 check status OK
test.v5 check error Table 'test.t1' doesn't exist
test.v6 check status OK
drop function f1;
drop function f2;
drop view v1, v2, v3, v4, v5, v6;
drop table t2,t3;
create table t1 (f1 date); create table t1 (f1 date);
insert into t1 values ('2005-01-01'),('2005-02-02'); insert into t1 values ('2005-01-01'),('2005-02-02');
create view v1 as select * from t1; create view v1 as select * from t1;
......
...@@ -284,7 +284,7 @@ create table mysqltest.v3 (b int); ...@@ -284,7 +284,7 @@ create table mysqltest.v3 (b int);
grant select(b) on mysqltest.v3 to mysqltest_1@localhost; grant select(b) on mysqltest.v3 to mysqltest_1@localhost;
drop table mysqltest.v3; drop table mysqltest.v3;
create view mysqltest.v3 as select b from mysqltest.t2; create view mysqltest.v3 as select b from mysqltest.t2;
ERROR 42000: CREATE VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v3' ERROR 42000: create view command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 'v3'
create view v4 as select b+1 from mysqltest.t2; create view v4 as select b+1 from mysqltest.t2;
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2' ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't2'
grant create view,update,select on test.* to mysqltest_1@localhost; grant create view,update,select on test.* to mysqltest_1@localhost;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
# Cleanup # Cleanup
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1;
drop database if exists mysqltest;
--enable_warnings --enable_warnings
connect (master,localhost,root,,); connect (master,localhost,root,,);
...@@ -403,3 +404,69 @@ connection root; ...@@ -403,3 +404,69 @@ connection root;
revoke all privileges on mysqltest.t1 from mysqltest_1@localhost; revoke all privileges on mysqltest.t1 from mysqltest_1@localhost;
delete from mysql.user where user=_binary'mysqltest_1'; delete from mysql.user where user=_binary'mysqltest_1';
drop database mysqltest; drop database mysqltest;
#
# check all new table priveleges
#
CREATE USER dummy@localhost;
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.dummytable (dummyfield INT);
CREATE VIEW mysqltest.dummyview AS SELECT dummyfield FROM mysqltest.dummytable;
GRANT ALL PRIVILEGES ON mysqltest.dummytable TO dummy@localhost;
GRANT ALL PRIVILEGES ON mysqltest.dummyview TO dummy@localhost;
SHOW GRANTS FOR dummy@localhost;
use INFORMATION_SCHEMA;
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
FLUSH PRIVILEGES;
SHOW GRANTS FOR dummy@localhost;
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
SHOW FIELDS FROM mysql.tables_priv;
use test;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost;
DROP USER dummy@localhost;
DROP DATABASE mysqltest;
# check view only privileges
CREATE USER dummy@localhost;
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.dummytable (dummyfield INT);
CREATE VIEW mysqltest.dummyview AS SELECT dummyfield FROM mysqltest.dummytable;
GRANT CREATE VIEW ON mysqltest.dummytable TO dummy@localhost;
GRANT CREATE VIEW ON mysqltest.dummyview TO dummy@localhost;
SHOW GRANTS FOR dummy@localhost;
use INFORMATION_SCHEMA;
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
FLUSH PRIVILEGES;
SHOW GRANTS FOR dummy@localhost;
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
use test;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost;
DROP USER dummy@localhost;
DROP DATABASE mysqltest;
CREATE USER dummy@localhost;
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.dummytable (dummyfield INT);
CREATE VIEW mysqltest.dummyview AS SELECT dummyfield FROM mysqltest.dummytable;
GRANT SHOW VIEW ON mysqltest.dummytable TO dummy@localhost;
GRANT SHOW VIEW ON mysqltest.dummyview TO dummy@localhost;
SHOW GRANTS FOR dummy@localhost;
use INFORMATION_SCHEMA;
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
FLUSH PRIVILEGES;
SHOW GRANTS FOR dummy@localhost;
SELECT TABLE_SCHEMA, TABLE_NAME, GROUP_CONCAT(PRIVILEGE_TYPE ORDER BY
PRIVILEGE_TYPE SEPARATOR ', ') AS PRIVILEGES FROM TABLE_PRIVILEGES WHERE GRANTEE
= '\'dummy\'@\'localhost\'' GROUP BY TABLE_SCHEMA, TABLE_NAME;
use test;
REVOKE ALL PRIVILEGES, GRANT OPTION FROM dummy@localhost;
DROP USER dummy@localhost;
DROP DATABASE mysqltest;
...@@ -1674,6 +1674,44 @@ create view v1 as SELECT TIME_FORMAT(SEC_TO_TIME(3600),'%H:%i') as t; ...@@ -1674,6 +1674,44 @@ create view v1 as SELECT TIME_FORMAT(SEC_TO_TIME(3600),'%H:%i') as t;
select * from v1; select * from v1;
drop view v1; drop view v1;
#
# checking views after some view with error (BUG#11337)
#
CREATE TABLE t1 (col1 time);
CREATE TABLE t2 (col1 time);
CREATE VIEW v1 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t1;
CREATE VIEW v2 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2;
CREATE VIEW v3 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t1;
CREATE VIEW v4 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2;
CREATE VIEW v5 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t1;
CREATE VIEW v6 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2;
DROP TABLE t1;
CHECK TABLE v1, v2, v3, v4, v5, v6;
drop view v1, v2, v3, v4, v5, v6;
drop table t2;
CREATE TABLE t1 (col1 time);
CREATE TABLE t2 (col1 time);
CREATE TABLE t3 (col1 time);
create function f1 () returns int return (select max(col1) from t1);
create function f2 () returns int return (select max(col1) from t2);
CREATE VIEW v1 AS SELECT f1() FROM t3;
CREATE VIEW v2 AS SELECT f2() FROM t3;
CREATE VIEW v3 AS SELECT f1() FROM t3;
CREATE VIEW v4 AS SELECT f2() FROM t3;
CREATE VIEW v5 AS SELECT f1() FROM t3;
CREATE VIEW v6 AS SELECT f2() FROM t3;
drop function f1;
CHECK TABLE v1, v2, v3, v4, v5, v6;
create function f1 () returns int return (select max(col1) from t1);
DROP TABLE t1;
# following will show underlying table until BUG#11555 fix
CHECK TABLE v1, v2, v3, v4, v5, v6;
drop function f1;
drop function f2;
drop view v1, v2, v3, v4, v5, v6;
drop table t2,t3;
# #
# bug #11325 Wrong date comparison in views # bug #11325 Wrong date comparison in views
# #
......
...@@ -360,7 +360,7 @@ create table mysqltest.v3 (b int); ...@@ -360,7 +360,7 @@ create table mysqltest.v3 (b int);
grant select(b) on mysqltest.v3 to mysqltest_1@localhost; grant select(b) on mysqltest.v3 to mysqltest_1@localhost;
drop table mysqltest.v3; drop table mysqltest.v3;
connection user1; connection user1;
-- error 1142 -- error 1143
create view mysqltest.v3 as select b from mysqltest.t2; create view mysqltest.v3 as select b from mysqltest.t2;
# Expression need select privileges # Expression need select privileges
......
...@@ -215,7 +215,7 @@ then ...@@ -215,7 +215,7 @@ then
c_t="$c_t Table_name char(64) binary DEFAULT '' NOT NULL," c_t="$c_t Table_name char(64) binary DEFAULT '' NOT NULL,"
c_t="$c_t Grantor char(77) DEFAULT '' NOT NULL," c_t="$c_t Grantor char(77) DEFAULT '' NOT NULL,"
c_t="$c_t Timestamp timestamp(14)," c_t="$c_t Timestamp timestamp(14),"
c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL," c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL,"
c_t="$c_t Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL," c_t="$c_t Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL,"
c_t="$c_t PRIMARY KEY (Host,Db,User,Table_name)," c_t="$c_t PRIMARY KEY (Host,Db,User,Table_name),"
c_t="$c_t KEY Grantor (Grantor)" c_t="$c_t KEY Grantor (Grantor)"
......
...@@ -260,6 +260,11 @@ ALTER TABLE db ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT ...@@ -260,6 +260,11 @@ ALTER TABLE db ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT
ALTER TABLE host ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; ALTER TABLE host ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
ALTER TABLE user ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; ALTER TABLE user ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv;
#
# Show/Create views table privileges (v5.0)
#
ALTER TABLE tables_priv MODIFY Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL;
# #
# Assign create/show view privileges to people who have create provileges # Assign create/show view privileges to people who have create provileges
# #
......
...@@ -106,8 +106,15 @@ ...@@ -106,8 +106,15 @@
(((A) & DB_CHUNK2) >> 6) | \ (((A) & DB_CHUNK2) >> 6) | \
(((A) & DB_CHUNK3) >> 9) | \ (((A) & DB_CHUNK3) >> 9) | \
(((A) & DB_CHUNK4) >> 2)) (((A) & DB_CHUNK4) >> 2))
#define fix_rights_for_table(A) (((A) & 63) | (((A) & ~63) << 4)) #define TBL_CHUNK0 DB_CHUNK0
#define get_rights_for_table(A) (((A) & 63) | (((A) & ~63) >> 4)) #define TBL_CHUNK1 DB_CHUNK1
#define TBL_CHUNK2 (CREATE_VIEW_ACL | SHOW_VIEW_ACL)
#define fix_rights_for_table(A) (((A) & TBL_CHUNK0) | \
(((A) << 4) & TBL_CHUNK1) | \
(((A) << 11) & TBL_CHUNK2))
#define get_rights_for_table(A) (((A) & TBL_CHUNK0) | \
(((A) & TBL_CHUNK1) >> 4) | \
(((A) & TBL_CHUNK2) >> 11))
#define fix_rights_for_column(A) (((A) & 7) | (((A) & ~7) << 8)) #define fix_rights_for_column(A) (((A) & 7) | (((A) & ~7) << 8))
#define get_rights_for_column(A) (((A) & 7) | ((A) >> 8)) #define get_rights_for_column(A) (((A) & 7) | ((A) >> 8))
#define fix_rights_for_procedure(A) ((((A) << 18) & EXECUTE_ACL) | \ #define fix_rights_for_procedure(A) ((((A) << 18) & EXECUTE_ACL) | \
......
...@@ -1943,6 +1943,45 @@ void st_lex::link_first_table_back(TABLE_LIST *first, ...@@ -1943,6 +1943,45 @@ void st_lex::link_first_table_back(TABLE_LIST *first,
} }
/*
cleanup lex for case when we open table by table for processing
SYNOPSIS
st_lex::cleanup_after_one_table_open()
*/
void st_lex::cleanup_after_one_table_open()
{
/*
thd->lex->derived_tables & additional units may be set if we open
a view. It is necessary to clear thd->lex->derived_tables flag
to prevent processing of derived tables during next open_and_lock_tables
if next table is a real table and cleanup & remove underlying units
NOTE: all units will be connected to thd->lex->select_lex, because we
have not UNION on most upper level.
*/
if (all_selects_list != &select_lex)
{
derived_tables= 0;
/* cleunup underlying units (units of VIEW) */
for (SELECT_LEX_UNIT *un= select_lex.first_inner_unit();
un;
un= un->next_unit())
un->cleanup();
/* reduce all selects list to default state */
all_selects_list= &select_lex;
/* remove underlying units (units of VIEW) subtree */
select_lex.cut_subtree();
}
time_zone_tables_used= 0;
if (spfuns.records)
my_hash_reset(&spfuns);
if (spprocs.records)
my_hash_reset(&spprocs);
}
/* /*
fix some structures at the end of preparation fix some structures at the end of preparation
......
...@@ -371,7 +371,6 @@ typedef class st_select_lex_node SELECT_LEX_NODE; ...@@ -371,7 +371,6 @@ typedef class st_select_lex_node SELECT_LEX_NODE;
SELECT_LEX_UNIT - unit of selects (UNION, INTERSECT, ...) group SELECT_LEX_UNIT - unit of selects (UNION, INTERSECT, ...) group
SELECT_LEXs SELECT_LEXs
*/ */
struct st_lex;
class THD; class THD;
class select_result; class select_result;
class JOIN; class JOIN;
...@@ -607,7 +606,13 @@ class st_select_lex: public st_select_lex_node ...@@ -607,7 +606,13 @@ class st_select_lex: public st_select_lex_node
order_list.first= 0; order_list.first= 0;
order_list.next= (byte**) &order_list.first; order_list.next= (byte**) &order_list.first;
} }
/*
This method created for reiniting LEX in mysql_admin_table() and can be
used only if you are going remove all SELECT_LEX & units except belonger
to LEX (LEX::unit & LEX::select, for other purposes there are
SELECT_LEX_UNIT::exclude_level & SELECT_LEX_UNIT::exclude_tree
*/
void cut_subtree() { slave= 0; }
bool test_limit(); bool test_limit();
friend void lex_start(THD *thd, uchar *buf, uint length); friend void lex_start(THD *thd, uchar *buf, uint length);
...@@ -920,7 +925,7 @@ typedef struct st_lex ...@@ -920,7 +925,7 @@ typedef struct st_lex
{ {
return ( query_tables_own_last ? *query_tables_own_last : 0); return ( query_tables_own_last ? *query_tables_own_last : 0);
} }
void cleanup_after_one_table_open();
} LEX; } LEX;
struct st_lex_local: public st_lex struct st_lex_local: public st_lex
......
...@@ -2103,6 +2103,7 @@ static int prepare_for_repair(THD* thd, TABLE_LIST *table_list, ...@@ -2103,6 +2103,7 @@ static int prepare_for_repair(THD* thd, TABLE_LIST *table_list,
} }
/* /*
RETURN VALUES RETURN VALUES
FALSE Message sent to net (admin operation went ok) FALSE Message sent to net (admin operation went ok)
...@@ -2122,10 +2123,12 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -2122,10 +2123,12 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
HA_CHECK_OPT *), HA_CHECK_OPT *),
int (view_operator_func)(THD *, TABLE_LIST*)) int (view_operator_func)(THD *, TABLE_LIST*))
{ {
TABLE_LIST *table, *next_global_table; TABLE_LIST *table, *save_next_global, *save_next_local;
SELECT_LEX *select= &thd->lex->select_lex;
List<Item> field_list; List<Item> field_list;
Item *item; Item *item;
Protocol *protocol= thd->protocol; Protocol *protocol= thd->protocol;
LEX *lex= thd->lex;
int result_code; int result_code;
DBUG_ENTER("mysql_admin_table"); DBUG_ENTER("mysql_admin_table");
...@@ -2152,12 +2155,25 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -2152,12 +2155,25 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
thd->open_options|= extra_open_options; thd->open_options|= extra_open_options;
table->lock_type= lock_type; table->lock_type= lock_type;
/* open only one table from local list of command */ /* open only one table from local list of command */
next_global_table= table->next_global; save_next_global= table->next_global;
table->next_global= 0; table->next_global= 0;
save_next_local= table->next_local;
table->next_local= 0;
select->table_list.first= (byte*)table;
/*
Time zone tables and SP tables can be add to lex->query_tables list,
so it have to be prepared.
TODO: Investigate if we can put extra tables into argument instead of
using lex->query_tables
*/
lex->query_tables= table;
lex->query_tables_last= &table->next_global;
lex->query_tables_own_last= 0;;
thd->no_warnings_for_error= no_warnings_for_error; thd->no_warnings_for_error= no_warnings_for_error;
open_and_lock_tables(thd, table); open_and_lock_tables(thd, table);
thd->no_warnings_for_error= 0; thd->no_warnings_for_error= 0;
table->next_global= next_global_table; table->next_global= save_next_global;
table->next_local= save_next_local;
/* if view are unsupported */ /* if view are unsupported */
if (table->view && view_operator_func == NULL) if (table->view && view_operator_func == NULL)
{ {
...@@ -2205,7 +2221,13 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -2205,7 +2221,13 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
err_msg= (const char *)buf; err_msg= (const char *)buf;
} }
protocol->store(err_msg, system_charset_info); protocol->store(err_msg, system_charset_info);
lex->cleanup_after_one_table_open();
thd->clear_error(); thd->clear_error();
/*
View opening can be interrupted in the middle of process so some
tables can be left opening
*/
close_thread_tables(thd);
if (protocol->write()) if (protocol->write())
goto err; goto err;
continue; continue;
...@@ -2274,6 +2296,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -2274,6 +2296,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
send_result: send_result:
lex->cleanup_after_one_table_open();
thd->clear_error(); // these errors shouldn't get client thd->clear_error(); // these errors shouldn't get client
protocol->prepare_for_resend(); protocol->prepare_for_resend();
protocol->store(table_name, system_charset_info); protocol->store(table_name, system_charset_info);
...@@ -2401,13 +2424,6 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -2401,13 +2424,6 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
} }
close_thread_tables(thd); close_thread_tables(thd);
table->table=0; // For query cache table->table=0; // For query cache
/*
thd->lex->derived_tables may be set to non zero value if we open
a view. It is necessary to clear thd->lex->derived_tables flag
to prevent processing of derived tables during next open_and_lock_tables
if next table is a real table.
*/
thd->lex->derived_tables= 0;
if (protocol->write()) if (protocol->write())
goto err; goto err;
} }
......
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