MDEV-15945 --ps-protocol does not test some queries

Make mysqltest to use --ps-protocol more

use prepared statements for everything that server supports
with the exception of CALL (for now).

Fix discovered test failures and bugs.

tests:
* PROCESSLIST shows Execute state, not Query
* SHOW STATUS increments status variables more than in text protocol
* multi-statements should be avoided (see tests with a wrong delimiter)
* performance_schema events have different names in --ps-protocol
* --enable_prepare_warnings

mysqltest.cc:
* make sure run_query_stmt() doesn't crash if there's
  no active connection (in wait_until_connected_again.inc)
* prepare all statements that server supports

protocol.h
* Protocol_discard::send_result_set_metadata() should not send
  anything to the client.

sql_acl.cc:
* extract the functionality of getting the user for SHOW GRANTS
  from check_show_access(), so that mysql_test_show_grants() could
  generate the correct column names in the prepare step

sql_class.cc:
* result->prepare() can fail, don't ignore its return value
* use correct number of decimals for EXPLAIN columns

sql_parse.cc:
* discard profiling for SHOW PROFILE. In text protocol it's done in
  prepare_schema_table(), but in --ps it is called on prepare only,
  so nothing was discarding profiling during execute.
* move the permission checking code for SHOW CREATE VIEW to
  mysqld_show_create_get_fields(), so that it would be called during
  prepare step too.
* only set sel_result when it was created here and needs to be
  destroyed in the same block. Avoid destroying lex->result.
* use the correct number of tables in check_show_access(). Saying
  "as many as possible" doesn't work when first_not_own_table isn't
  set yet.

sql_prepare.cc:
* use correct user name for SHOW GRANTS columns
* don't ignore verbose flag for SHOW SLAVE STATUS
* support preparing REVOKE ALL and ROLLBACK TO SAVEPOINT
* don't ignore errors from thd->prepare_explain_fields()
* use select_send result for sending ANALYZE and EXPLAIN, but don't
  overwrite lex->result, because it might be needed to issue execute-time
  errors (select_dumpvar - too many rows)

sql_show.cc:
* check grants for SHOW CREATE VIEW here, not in mysql_execute_command

sql_view.cc:
* use the correct function to check privileges. Old code was doing
  check_access() for thd->security_ctx, which is invoker's sctx,
  not definer's sctx. Hide various view related errors from the invoker.

sql_yacc.yy:
* initialize lex->select_lex for LOAD, otherwise it'll contain garbage
  data that happen to fail tests with views in --ps (but not otherwise).
This commit is contained in:
Sergei Golubchik 2019-03-10 23:59:50 +01:00
parent 22f1cf9292
commit a62e9a83c0
38 changed files with 314 additions and 186 deletions

View File

@ -8219,6 +8219,12 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command,
DBUG_ENTER("run_query_stmt"); DBUG_ENTER("run_query_stmt");
DBUG_PRINT("query", ("'%-.60s'", query)); DBUG_PRINT("query", ("'%-.60s'", query));
if (!mysql)
{
handle_no_active_connection(command, cn, ds);
DBUG_VOID_RETURN;
}
/* /*
Init a new stmt if it's not already one created for this connection Init a new stmt if it's not already one created for this connection
*/ */
@ -8744,18 +8750,56 @@ void init_re(void)
*/ */
const char *ps_re_str = const char *ps_re_str =
"^(" "^("
"[[:space:]]*REPLACE[[:space:]]|" "[[:space:]]*ALTER[[:space:]]+SEQUENCE[[:space:]]|"
"[[:space:]]*INSERT[[:space:]]|" "[[:space:]]*ALTER[[:space:]]+TABLE[[:space:]]|"
"[[:space:]]*UPDATE[[:space:]]|" "[[:space:]]*ALTER[[:space:]]+USER[[:space:]]|"
"[[:space:]]*DELETE[[:space:]]|" "[[:space:]]*ANALYZE[[:space:]]|"
"[[:space:]]*SELECT[[:space:]]|" "[[:space:]]*ASSIGN[[:space:]]|"
//"[[:space:]]*CALL[[:space:]]|" // XXX run_query_stmt doesn't read multiple result sets
"[[:space:]]*CHANGE[[:space:]]|"
"[[:space:]]*CHECKSUM[[:space:]]|"
"[[:space:]]*COMMIT[[:space:]]|"
"[[:space:]]*COMPOUND[[:space:]]|"
"[[:space:]]*CREATE[[:space:]]+DATABASE[[:space:]]|"
"[[:space:]]*CREATE[[:space:]]+INDEX[[:space:]]|"
"[[:space:]]*CREATE[[:space:]]+ROLE[[:space:]]|"
"[[:space:]]*CREATE[[:space:]]+SEQUENCE[[:space:]]|"
"[[:space:]]*CREATE[[:space:]]+TABLE[[:space:]]|" "[[:space:]]*CREATE[[:space:]]+TABLE[[:space:]]|"
"[[:space:]]*CREATE[[:space:]]+USER[[:space:]]|"
"[[:space:]]*CREATE[[:space:]]+VIEW[[:space:]]|"
"[[:space:]]*DELETE[[:space:]]|"
"[[:space:]]*DO[[:space:]]|" "[[:space:]]*DO[[:space:]]|"
"[[:space:]]*DROP[[:space:]]+DATABASE[[:space:]]|"
"[[:space:]]*DROP[[:space:]]+INDEX[[:space:]]|"
"[[:space:]]*DROP[[:space:]]+ROLE[[:space:]]|"
"[[:space:]]*DROP[[:space:]]+SEQUENCE[[:space:]]|"
"[[:space:]]*DROP[[:space:]]+TABLE[[:space:]]|"
"[[:space:]]*DROP[[:space:]]+USER[[:space:]]|"
"[[:space:]]*DROP[[:space:]]+VIEW[[:space:]]|"
"[[:space:]]*FLUSH[[:space:]]|"
"[[:space:]]*GRANT[[:space:]]|"
"[[:space:]]*HANDLER[[:space:]]+.*[[:space:]]+READ[[:space:]]|" "[[:space:]]*HANDLER[[:space:]]+.*[[:space:]]+READ[[:space:]]|"
"[[:space:]]*INSERT[[:space:]]|"
"[[:space:]]*INSTALL[[:space:]]+|"
"[[:space:]]*KILL[[:space:]]|"
"[[:space:]]*OPTIMIZE[[:space:]]|"
"[[:space:]]*PRELOAD[[:space:]]|"
"[[:space:]]*RENAME[[:space:]]+TABLE[[:space:]]|"
"[[:space:]]*RENAME[[:space:]]+USER[[:space:]]|"
"[[:space:]]*REPAIR[[:space:]]|"
"[[:space:]]*REPLACE[[:space:]]|"
"[[:space:]]*RESET[[:space:]]|"
"[[:space:]]*REVOKE[[:space:]]|"
"[[:space:]]*ROLLBACK[[:space:]]|"
"[[:space:]]*SELECT[[:space:]]|"
"[[:space:]]*SET[[:space:]]+OPTION[[:space:]]|" "[[:space:]]*SET[[:space:]]+OPTION[[:space:]]|"
"[[:space:]]*DELETE[[:space:]]+MULTI[[:space:]]|" "[[:space:]]*SHOW[[:space:]]|"
"[[:space:]]*UPDATE[[:space:]]+MULTI[[:space:]]|" "[[:space:]]*SHUTDOWN[[:space:]]|"
"[[:space:]]*INSERT[[:space:]]+SELECT[[:space:]])"; "[[:space:]]*SLAVE[[:space:]]|"
"[[:space:]]*TRUNCATE[[:space:]]|"
"[[:space:]]*UNINSTALL[[:space:]]+|"
"[[:space:]]*UPDATE[[:space:]]"
")";
/* /*
Filter for queries that can be run using the Filter for queries that can be run using the

View File

@ -1318,7 +1318,7 @@ partition p2 values in (1));
end// end//
call p()// call p()//
drop procedure p// drop procedure p//
drop table t1; drop table t1//
create procedure p () create procedure p ()
begin begin
create table t1 (a int not null,b int not null,c int not null,primary key (a,b)) create table t1 (a int not null,b int not null,c int not null,primary key (a,b))

View File

@ -32,61 +32,55 @@ RETURNS VARCHAR(64) UNICODE BINARY
BEGIN BEGIN
RETURN ''; RETURN '';
END| END|
SHOW CREATE FUNCTION f; SHOW CREATE FUNCTION f|
DROP FUNCTION f; Function sql_mode Create Function character_set_client collation_connection Database Collation
f NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET ucs2 COLLATE ucs2_bin
BEGIN
RETURN '';
END latin1 latin1_swedish_ci latin1_swedish_ci
DROP FUNCTION f|
CREATE FUNCTION f() CREATE FUNCTION f()
RETURNS VARCHAR(64) BINARY UNICODE RETURNS VARCHAR(64) BINARY UNICODE
BEGIN BEGIN
RETURN ''; RETURN '';
END| END|
SHOW CREATE FUNCTION f|
Function sql_mode Create Function character_set_client collation_connection Database Collation Function sql_mode Create Function character_set_client collation_connection Database Collation
f NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET ucs2 COLLATE ucs2_bin f NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET ucs2 COLLATE ucs2_bin
BEGIN BEGIN
RETURN ''; RETURN '';
END latin1 latin1_swedish_ci latin1_swedish_ci END latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE FUNCTION f; DROP FUNCTION f|
DROP FUNCTION f;
#
# Testing keywords ASCII + BINARY
#
CREATE FUNCTION f() CREATE FUNCTION f()
RETURNS VARCHAR(64) ASCII BINARY RETURNS VARCHAR(64) ASCII BINARY
BEGIN BEGIN
RETURN ''; RETURN '';
END| END|
Function sql_mode Create Function character_set_client collation_connection Database Collation SHOW CREATE FUNCTION f|
f NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET ucs2 COLLATE ucs2_bin
BEGIN
RETURN '';
END latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE FUNCTION f;
DROP FUNCTION f;
CREATE FUNCTION f()
RETURNS VARCHAR(64) BINARY ASCII
BEGIN
RETURN '';
END|
Function sql_mode Create Function character_set_client collation_connection Database Collation Function sql_mode Create Function character_set_client collation_connection Database Collation
f NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET latin1 COLLATE latin1_bin f NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET latin1 COLLATE latin1_bin
BEGIN BEGIN
RETURN ''; RETURN '';
END latin1 latin1_swedish_ci latin1_swedish_ci END latin1 latin1_swedish_ci latin1_swedish_ci
SHOW CREATE FUNCTION f; DROP FUNCTION f|
DROP FUNCTION f; CREATE FUNCTION f()
# RETURNS VARCHAR(64) BINARY ASCII
# Testing COLLATE in OUT parameter BEGIN
# RETURN '';
END|
SHOW CREATE FUNCTION f|
Function sql_mode Create Function character_set_client collation_connection Database Collation
f NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET latin1 COLLATE latin1_bin
BEGIN
RETURN '';
END latin1 latin1_swedish_ci latin1_swedish_ci
DROP FUNCTION f|
CREATE PROCEDURE p1(IN f1 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_czech_ci, CREATE PROCEDURE p1(IN f1 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_czech_ci,
OUT f2 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_polish_ci) OUT f2 VARCHAR(64) CHARACTER SET ucs2 COLLATE ucs2_polish_ci)
BEGIN BEGIN
SET f2= f1; SET f2= f1;
SET f2= concat(collation(f1), ' ', collation(f2)); SET f2= concat(collation(f1), ' ', collation(f2));
END| END|
Function sql_mode Create Function character_set_client collation_connection Database Collation
f NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET latin1 COLLATE latin1_bin
BEGIN
RETURN '';
END latin1 latin1_swedish_ci latin1_swedish_ci
CREATE FUNCTION f1() CREATE FUNCTION f1()
RETURNS VARCHAR(64) CHARACTER SET ucs2 RETURNS VARCHAR(64) CHARACTER SET ucs2
BEGIN BEGIN

View File

@ -6790,7 +6790,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist
create table t1 (a integer)$ create table t1 (a integer)$
call p1$ call p1$
a a
alter table t1 add b integer; alter table t1 add b integer$
call p1$ call p1$
a a
drop table t1; drop table t1;

View File

@ -72,7 +72,7 @@ select res;
end| end|
create table t3 (a int)| create table t3 (a int)|
insert into t3 values (0)| insert into t3 values (0)|
create view v1 as select a from t3; create view v1 as select a from t3|
create procedure bug10100pt(level int, lim int) create procedure bug10100pt(level int, lim int)
begin begin
if level < lim then if level < lim then

View File

@ -640,7 +640,7 @@ TRUNCATE TABLE t1;
END| END|
LOCK TABLES t1 WRITE| LOCK TABLES t1 WRITE|
CALL p1()| CALL p1()|
FLUSH TABLES; FLUSH TABLES|
UNLOCK TABLES| UNLOCK TABLES|
CALL p1()| CALL p1()|
DROP PROCEDURE p1| DROP PROCEDURE p1|

View File

@ -142,7 +142,7 @@ show table_statistics;
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
show index_statistics; show index_statistics;
Table_schema Table_name Index_name Rows_read Table_schema Table_name Index_name Rows_read
select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics;; select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics;;
TOTAL_CONNECTIONS 2 TOTAL_CONNECTIONS 2
TOTAL_SSL_CONNECTIONS 1 TOTAL_SSL_CONNECTIONS 1
CONCURRENT_CONNECTIONS 0 CONCURRENT_CONNECTIONS 0
@ -153,14 +153,13 @@ ROWS_INSERTED 7
ROWS_UPDATED 5 ROWS_UPDATED 5
SELECT_COMMANDS 4 SELECT_COMMANDS 4
UPDATE_COMMANDS 11 UPDATE_COMMANDS 11
OTHER_COMMANDS 7
COMMIT_TRANSACTIONS 19 COMMIT_TRANSACTIONS 19
ROLLBACK_TRANSACTIONS 2 ROLLBACK_TRANSACTIONS 2
DENIED_CONNECTIONS 0 DENIED_CONNECTIONS 0
LOST_CONNECTIONS 0 LOST_CONNECTIONS 0
ACCESS_DENIED 0 ACCESS_DENIED 0
EMPTY_QUERIES 1 EMPTY_QUERIES 1
select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.user_statistics;; select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.user_statistics;;
TOTAL_CONNECTIONS 2 TOTAL_CONNECTIONS 2
TOTAL_SSL_CONNECTIONS 1 TOTAL_SSL_CONNECTIONS 1
CONCURRENT_CONNECTIONS 0 CONCURRENT_CONNECTIONS 0
@ -171,13 +170,18 @@ ROWS_INSERTED 7
ROWS_UPDATED 5 ROWS_UPDATED 5
SELECT_COMMANDS 4 SELECT_COMMANDS 4
UPDATE_COMMANDS 11 UPDATE_COMMANDS 11
OTHER_COMMANDS 7
COMMIT_TRANSACTIONS 19 COMMIT_TRANSACTIONS 19
ROLLBACK_TRANSACTIONS 2 ROLLBACK_TRANSACTIONS 2
DENIED_CONNECTIONS 0 DENIED_CONNECTIONS 0
LOST_CONNECTIONS 0 LOST_CONNECTIONS 0
ACCESS_DENIED 0 ACCESS_DENIED 0
EMPTY_QUERIES 1 EMPTY_QUERIES 1
select OTHER_COMMANDS IN (7,8) from information_schema.client_statistics;
OTHER_COMMANDS IN (7,8)
1
select OTHER_COMMANDS IN (7,8) from information_schema.user_statistics;
OTHER_COMMANDS IN (7,8)
1
flush table_statistics; flush table_statistics;
flush index_statistics; flush index_statistics;
select * from information_schema.index_statistics; select * from information_schema.index_statistics;

View File

@ -156,6 +156,7 @@ WHERE DB = 'information_schema' AND COMMAND = 'Sleep' AND USER = 'ddicttestuser1
--source include/wait_condition.inc --source include/wait_condition.inc
--replace_result ENGINE=MyISAM "" ENGINE=Aria "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" "" --replace_result ENGINE=MyISAM "" ENGINE=Aria "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" ""
eval SHOW CREATE TABLE $table; eval SHOW CREATE TABLE $table;
--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
eval SHOW $table; eval SHOW $table;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID
@ -176,6 +177,7 @@ connection con100;
# but "ddicttestuser1" must not see anything of the root session. # but "ddicttestuser1" must not see anything of the root session.
--replace_result ENGINE=MyISAM "" ENGINE=Aria "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" "" --replace_result ENGINE=MyISAM "" ENGINE=Aria "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" ""
eval SHOW CREATE TABLE $table; eval SHOW CREATE TABLE $table;
--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
eval SHOW $table; eval SHOW $table;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID
@ -202,6 +204,7 @@ GRANT PROCESS ON *.* TO ddicttestuser1@'localhost' IDENTIFIED BY 'ddictpass';
--echo #################################################################################### --echo ####################################################################################
connection con100; connection con100;
SHOW GRANTS; SHOW GRANTS;
--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist; SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID
@ -214,6 +217,7 @@ SELECT * FROM information_schema.processlist;
--echo #################################################################################### --echo ####################################################################################
connect (con101,localhost,ddicttestuser1,ddictpass,information_schema); connect (con101,localhost,ddicttestuser1,ddictpass,information_schema);
SHOW GRANTS; SHOW GRANTS;
--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist; SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID
@ -237,6 +241,7 @@ GRANT PROCESS ON *.* TO ''@'localhost';
--echo #################################################################################### --echo ####################################################################################
connect (anonymous1,localhost,"''",,information_schema); connect (anonymous1,localhost,"''",,information_schema);
SHOW GRANTS; SHOW GRANTS;
--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist; SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID
@ -259,6 +264,7 @@ connect (con102,localhost,ddicttestuser1,ddictpass,information_schema);
--echo ddicttestuser1 are visible. --echo ddicttestuser1 are visible.
--echo #################################################################################### --echo ####################################################################################
SHOW GRANTS; SHOW GRANTS;
--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist; SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID
@ -284,6 +290,7 @@ SHOW GRANTS FOR ''@'localhost';
if ($fixed_bug_30395) if ($fixed_bug_30395)
{ {
# Bug#30395 strange results after REVOKE PROCESS ON *.* FROM ... # Bug#30395 strange results after REVOKE PROCESS ON *.* FROM ...
--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist; SHOW processlist;
} }
@ -306,6 +313,7 @@ connect (con103,localhost,ddicttestuser1,ddictpass,information_schema);
--echo Only the processes of ddicttestuser1 user are visible. --echo Only the processes of ddicttestuser1 user are visible.
--echo #################################################################################### --echo ####################################################################################
SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; SHOW GRANTS FOR 'ddicttestuser1'@'localhost';
--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist; SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID
@ -328,6 +336,7 @@ connect (con104,localhost,ddicttestuser1,ddictpass,information_schema);
--echo Only the processes of ddicttestuser1 are visible. --echo Only the processes of ddicttestuser1 are visible.
--echo #################################################################################### --echo ####################################################################################
SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; SHOW GRANTS FOR 'ddicttestuser1'@'localhost';
--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist; SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID
@ -375,6 +384,7 @@ connect (con200,localhost,ddicttestuser2,ddictpass,information_schema);
--echo ddicttestuser2 has now the PROCESS privilege and sees all connections --echo ddicttestuser2 has now the PROCESS privilege and sees all connections
--echo #################################################################################### --echo ####################################################################################
SHOW GRANTS FOR 'ddicttestuser2'@'localhost'; SHOW GRANTS FOR 'ddicttestuser2'@'localhost';
--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist; SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID
@ -396,6 +406,7 @@ connect (con201,localhost,ddicttestuser2,ddictpass,information_schema);
--echo ddicttestuser2 has no more the PROCESS privilege and can only see own connects --echo ddicttestuser2 has no more the PROCESS privilege and can only see own connects
--echo #################################################################################### --echo ####################################################################################
SHOW GRANTS; SHOW GRANTS;
--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist; SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID
@ -419,6 +430,7 @@ connect (con107,localhost,ddicttestuser1,ddictpass,information_schema);
SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; SHOW GRANTS FOR 'ddicttestuser1'@'localhost';
--error ER_ACCESS_DENIED_ERROR --error ER_ACCESS_DENIED_ERROR
GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost'; GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost';
--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist; SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID
@ -443,6 +455,7 @@ connect (con108,localhost,ddicttestuser1,ddictpass,information_schema);
--echo Therefore the missing SELECT privilege does not affect SELECTs on PROCESSLIST. --echo Therefore the missing SELECT privilege does not affect SELECTs on PROCESSLIST.
--echo #################################################################################### --echo ####################################################################################
SHOW GRANTS FOR 'ddicttestuser1'@'localhost'; SHOW GRANTS FOR 'ddicttestuser1'@'localhost';
--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist; SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID --replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 ROWS 15 QUERY_ID 17 TID

View File

@ -94,6 +94,7 @@ echo
# 1. Just dump what we get # 1. Just dump what we get
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID> --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID>
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
--replace_result Execute Query
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS>
SHOW FULL PROCESSLIST; SHOW FULL PROCESSLIST;
# #
@ -167,6 +168,7 @@ let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
# 1. Just dump what we get # 1. Just dump what we get
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 7 <STATE> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID> --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 7 <STATE> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID>
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
--replace_result Execute Query
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
SHOW FULL PROCESSLIST; SHOW FULL PROCESSLIST;
# #
@ -212,6 +214,7 @@ echo
connection con1; connection con1;
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID> --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID>
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
--replace_result Execute Query
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
SHOW FULL PROCESSLIST; SHOW FULL PROCESSLIST;
@ -246,6 +249,7 @@ connection con2;
# Just dump what we get # Just dump what we get
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID> --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID>
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
--replace_result Execute Query
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
SHOW FULL PROCESSLIST; SHOW FULL PROCESSLIST;
# #
@ -306,6 +310,7 @@ WHERE ID = @test_user_con2_id AND Command IN('Query','Execute')
# 1. Just dump what we get # 1. Just dump what we get
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID> --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID>
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
--replace_result Execute Query
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> --replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
SHOW FULL PROCESSLIST; SHOW FULL PROCESSLIST;
# #
@ -436,8 +441,10 @@ echo
; ;
--replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID> --replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE> 9 <TIME_MS> 13 <MEMORY> 14 <ROWS> 15 <QUERY_ID> 17 <TID>
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST; SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
--replace_result Execute Query
--replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE> --replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE>
SHOW FULL PROCESSLIST; SHOW FULL PROCESSLIST;
--replace_result Execute Query
--replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE> --replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE>
SHOW PROCESSLIST; SHOW PROCESSLIST;
UNLOCK TABLES; UNLOCK TABLES;

View File

@ -7,5 +7,7 @@ flush status;
handler handler_a read first; handler handler_a read first;
# handler...read must be prepared in --ps-protocol mode # handler...read must be prepared in --ps-protocol mode
--replace_result $PS_PROTOCOL OK --replace_result $PS_PROTOCOL OK
--disable_ps_protocol
show status like 'Com_stmt_prepare%'; show status like 'Com_stmt_prepare%';
--enable_ps_protocol
drop table t1; drop table t1;

View File

@ -34,6 +34,7 @@ alter table t1 add primary key (pk);
--enable_reconnect --enable_reconnect
--source include/wait_until_connected_again.inc --source include/wait_until_connected_again.inc
--enable_prepare_warnings
show create table t1; show create table t1;
select * from t1; select * from t1;
alter table t1 add j int; alter table t1 add j int;

View File

@ -19,7 +19,7 @@
# option_mysqld_max_prepared_stmt_count # # option_mysqld_max_prepared_stmt_count #
# # # #
################################################################################ ################################################################################
--source include/no_protocol.inc
--echo ** Setup ** --echo ** Setup **
--echo --echo

View File

@ -46,17 +46,23 @@ INSERT INTO t1 VALUES('aa','bb');
SET SESSION sql_buffer_result = 1; SET SESSION sql_buffer_result = 1;
--disable_ps_protocol
SHOW STATUS LIKE 'Created_tmp_tables'; SHOW STATUS LIKE 'Created_tmp_tables';
--enable_ps_protocol
--echo Expected value : 0. --echo Expected value : 0.
SELECT * FROM t1; SELECT * FROM t1;
--disable_ps_protocol
SHOW STATUS LIKE 'Created_tmp_tables'; SHOW STATUS LIKE 'Created_tmp_tables';
--enable_ps_protocol
--echo Expected value : 1. --echo Expected value : 1.
SELECT * FROM t1; SELECT * FROM t1;
--disable_ps_protocol
SHOW STATUS LIKE 'Created_tmp_tables'; SHOW STATUS LIKE 'Created_tmp_tables';
--enable_ps_protocol
--echo Expected value : 2. --echo Expected value : 2.
--echo '#--------------------FN_DYNVARS_156_02-------------------------#' --echo '#--------------------FN_DYNVARS_156_02-------------------------#'
@ -66,12 +72,16 @@ SHOW STATUS LIKE 'Created_tmp_tables';
SET SESSION sql_buffer_result = 0; SET SESSION sql_buffer_result = 0;
--disable_ps_protocol
SHOW STATUS LIKE 'Created_tmp_tables'; SHOW STATUS LIKE 'Created_tmp_tables';
--enable_ps_protocol
--echo Expected value : 2. --echo Expected value : 2.
SELECT * FROM t1; SELECT * FROM t1;
--disable_ps_protocol
SHOW STATUS LIKE 'Created_tmp_tables'; SHOW STATUS LIKE 'Created_tmp_tables';
--enable_ps_protocol
--echo Expected value : 2. --echo Expected value : 2.
--echo '#--------------------FN_DYNVARS_156_03-------------------------#' --echo '#--------------------FN_DYNVARS_156_03-------------------------#'

View File

@ -14,7 +14,9 @@ create table t1 (a datetime,
# other issues # other issues
e int as ((a,1) in ((1,1),(2,1),(NULL,1))) # cmp_item_row::alloc_comparators() e int as ((a,1) in ((1,1),(2,1),(NULL,1))) # cmp_item_row::alloc_comparators()
); );
enable_prepare_warnings;
show create table t1; show create table t1;
disable_prepare_warnings;
connect con1, localhost, root; connect con1, localhost, root;
insert t1 (a) values ('2010-10-10 10:10:10'); insert t1 (a) values ('2010-10-10 10:10:10');
select * from t1; select * from t1;

View File

@ -7,6 +7,7 @@
--enable_connect_log --enable_connect_log
--connect (con1,localhost,root,,) --connect (con1,localhost,root,,)
--let $con_id = `SELECT CONNECTION_ID()` --let $con_id = `SELECT CONNECTION_ID()`
--replace_result Execute Query
--replace_column 1 # 3 # 6 # 7 # --replace_column 1 # 3 # 6 # 7 #
SHOW PROCESSLIST; SHOW PROCESSLIST;
SET DEBUG_SYNC='before_execute_sql_command SIGNAL ready WAIT_FOR go'; SET DEBUG_SYNC='before_execute_sql_command SIGNAL ready WAIT_FOR go';
@ -30,5 +31,6 @@ let $wait_condition=
WHERE info is NULL; WHERE info is NULL;
--source include/wait_condition.inc --source include/wait_condition.inc
--replace_result Execute Query
--replace_column 1 # 3 # 6 # 7 # --replace_column 1 # 3 # 6 # 7 #
SHOW PROCESSLIST; SHOW PROCESSLIST;

View File

@ -855,7 +855,9 @@ SET GLOBAL slow_query_log = @old_slow_query_log;
# #
select CONNECTION_ID() into @thread_id; select CONNECTION_ID() into @thread_id;
--disable_ps_protocol
truncate table mysql.general_log; truncate table mysql.general_log;
--enable_ps_protocol
set global general_log = on; set global general_log = on;
--disable_result_log --disable_result_log
set @lparam = "000 001 002 003 004 005 006 007 008 009" set @lparam = "000 001 002 003 004 005 006 007 008 009"

View File

@ -22,7 +22,8 @@ drop table t1,t2;
--replace_column 1 <Id> 3 <Host> 6 <Time> 7 <State> --replace_column 1 <Id> 3 <Host> 6 <Time> 7 <State>
# Embedded server is hardcoded to show "Writing to net" as STATE. # Embedded server is hardcoded to show "Writing to net" as STATE.
--replace_result "Writing to net" "NULL" # ps-protocol will have Execute not Query
--replace_result "Writing to net" "NULL" "Execute" "Query"
--replace_regex /localhost[:0-9]*/localhost/ --replace_regex /localhost[:0-9]*/localhost/
SHOW PROCESSLIST; SHOW PROCESSLIST;

View File

@ -1197,7 +1197,7 @@ end//
call p()// call p()//
drop procedure p// drop procedure p//
drop table t1; drop table t1//
create procedure p () create procedure p ()
begin begin

View File

@ -47,7 +47,9 @@ insert into t1 values (5,5,5);
check table t1 changed; check table t1 changed;
check table t1 medium; check table t1 medium;
check table t1 extended; check table t1 extended;
--disable_ps_protocol
show index from t1; show index from t1;
--enable_ps_protocol
--disable_metadata --disable_metadata
--error ER_DUP_ENTRY --error ER_DUP_ENTRY
insert into t1 values (5,5,5); insert into t1 values (5,5,5);
@ -72,7 +74,9 @@ drop table t1;
show variables like "wait_timeout%"; show variables like "wait_timeout%";
show variables like "WAIT_timeout%"; show variables like "WAIT_timeout%";
show variables like "this_doesn't_exists%"; show variables like "this_doesn't_exists%";
--disable_ps_protocol
show table status from test like "this_doesn't_exists%"; show table status from test like "this_doesn't_exists%";
--enable_ps_protocol
show databases; show databases;
show databases like "test%"; show databases like "test%";
--disable_metadata --disable_metadata
@ -409,7 +413,9 @@ CREATE TABLE t1(
PRIMARY KEY(field1(1000)) PRIMARY KEY(field1(1000))
); );
--enable_metadata --enable_metadata
--disable_ps_protocol
show index from t1; show index from t1;
--enable_ps_protocol
--disable_metadata --disable_metadata
drop table t1; drop table t1;
@ -707,11 +713,15 @@ set names utf8;
--echo ---------------------------------------------------------------- --echo ----------------------------------------------------------------
--disable_ps_protocol
SHOW CHARACTER SET LIKE 'utf8'; SHOW CHARACTER SET LIKE 'utf8';
--enable_ps_protocol
--echo ---------------------------------------------------------------- --echo ----------------------------------------------------------------
--disable_ps_protocol
SHOW COLLATION LIKE 'latin1_bin'; SHOW COLLATION LIKE 'latin1_bin';
--enable_ps_protocol
--echo ---------------------------------------------------------------- --echo ----------------------------------------------------------------
@ -727,7 +737,9 @@ SHOW CREATE TABLE t1;
--echo ---------------------------------------------------------------- --echo ----------------------------------------------------------------
--disable_ps_protocol
SHOW INDEX FROM t1; SHOW INDEX FROM t1;
--enable_ps_protocol
--echo ---------------------------------------------------------------- --echo ----------------------------------------------------------------
@ -774,7 +786,9 @@ SHOW COLUMNS FROM t1;
--echo ---------------------------------------------------------------- --echo ----------------------------------------------------------------
--disable_ps_protocol
SHOW TRIGGERS LIKE 't1'; SHOW TRIGGERS LIKE 't1';
--enable_ps_protocol
--echo ---------------------------------------------------------------- --echo ----------------------------------------------------------------
@ -1343,9 +1357,11 @@ let $wait_timeout= 10;
let $wait_condition= SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%GET_LOCK%' AND ID != CONNECTION_ID(); let $wait_condition= SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%GET_LOCK%' AND ID != CONNECTION_ID();
--source include/wait_condition.inc --source include/wait_condition.inc
--replace_column 1 ### 3 ### 6 ### 7 ### --replace_column 1 ### 3 ### 6 ### 7 ###
--replace_result "Execute" "Query"
SHOW PROCESSLIST; SHOW PROCESSLIST;
SET NAMES utf8; SET NAMES utf8;
--replace_column 1 ### 3 ### 6 ### 7 ### --replace_column 1 ### 3 ### 6 ### 7 ###
--replace_result "Execute" "Query"
SHOW PROCESSLIST; SHOW PROCESSLIST;
SELECT RELEASE_LOCK('t'); SELECT RELEASE_LOCK('t');
--connection con1 --connection con1

View File

@ -52,16 +52,16 @@ CREATE FUNCTION f()
BEGIN BEGIN
RETURN ''; RETURN '';
END| END|
SHOW CREATE FUNCTION f; SHOW CREATE FUNCTION f|
DROP FUNCTION f; DROP FUNCTION f|
CREATE FUNCTION f() CREATE FUNCTION f()
RETURNS VARCHAR(64) BINARY UNICODE RETURNS VARCHAR(64) BINARY UNICODE
BEGIN BEGIN
RETURN ''; RETURN '';
END| END|
SHOW CREATE FUNCTION f; SHOW CREATE FUNCTION f|
DROP FUNCTION f; DROP FUNCTION f|
# #
@ -72,16 +72,16 @@ CREATE FUNCTION f()
BEGIN BEGIN
RETURN ''; RETURN '';
END| END|
SHOW CREATE FUNCTION f; SHOW CREATE FUNCTION f|
DROP FUNCTION f; DROP FUNCTION f|
CREATE FUNCTION f() CREATE FUNCTION f()
RETURNS VARCHAR(64) BINARY ASCII RETURNS VARCHAR(64) BINARY ASCII
BEGIN BEGIN
RETURN ''; RETURN '';
END| END|
SHOW CREATE FUNCTION f; SHOW CREATE FUNCTION f|
DROP FUNCTION f; DROP FUNCTION f|
# #
# Testing COLLATE in OUT parameter # Testing COLLATE in OUT parameter

View File

@ -8057,7 +8057,7 @@ create procedure p1() begin select * from t1; end$
call p1$ call p1$
create table t1 (a integer)$ create table t1 (a integer)$
call p1$ call p1$
alter table t1 add b integer; alter table t1 add b integer$
call p1$ call p1$
delimiter ;$ delimiter ;$

View File

@ -116,7 +116,7 @@ end|
# a procedure which use tables and recursion # a procedure which use tables and recursion
create table t3 (a int)| create table t3 (a int)|
insert into t3 values (0)| insert into t3 values (0)|
create view v1 as select a from t3; create view v1 as select a from t3|
create procedure bug10100pt(level int, lim int) create procedure bug10100pt(level int, lim int)
begin begin
if level < lim then if level < lim then

View File

@ -689,7 +689,7 @@ END|
LOCK TABLES t1 WRITE| LOCK TABLES t1 WRITE|
CALL p1()| CALL p1()|
FLUSH TABLES; FLUSH TABLES|
UNLOCK TABLES| UNLOCK TABLES|
CALL p1()| CALL p1()|

View File

@ -1570,7 +1570,9 @@ INSERT INTO t2 values(1),(2);
EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT * FROM t2 GROUP BY a HAVING a > 1); EXPLAIN SELECT * FROM t1 WHERE a IN (SELECT * FROM t2 GROUP BY a HAVING a > 1);
flush status; flush status;
CREATE TABLE t3 SELECT * FROM t1 WHERE a IN (SELECT * FROM t2 GROUP BY a HAVING a > 1); CREATE TABLE t3 SELECT * FROM t1 WHERE a IN (SELECT * FROM t2 GROUP BY a HAVING a > 1);
--disable_ps_protocol
SHOW STATUS LIKE 'Created_tmp_tables'; SHOW STATUS LIKE 'Created_tmp_tables';
--enable_ps_protocol
DROP TABLE t1,t2,t3; DROP TABLE t1,t2,t3;
--echo # --echo #

View File

@ -114,8 +114,10 @@ CREATE TABLE t1 (
INSERT INTO t1 VALUES ('2002-10-24 14:50:32'),('2002-10-24 14:50:33'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40'); INSERT INTO t1 VALUES ('2002-10-24 14:50:32'),('2002-10-24 14:50:33'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:34'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:35'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:36'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:37'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:38'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:39'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40'),('2002-10-24 14:50:40');
flush status; flush status;
--disable_ps_protocol
select * from t1 group by d; select * from t1 group by d;
show status like "created_tmp%tables"; show status like "created_tmp%tables";
--enable_ps_protocol
drop table t1; drop table t1;
# Fix for BUG#8921: Check that temporary table is ingored by view commands. # Fix for BUG#8921: Check that temporary table is ingored by view commands.

View File

@ -9,12 +9,16 @@ create view v2 as select a from t2;
flush status; flush status;
select * from v2; select * from v2;
--disable_ps_protocol
show status like '%Created_tmp%'; show status like '%Created_tmp%';
--enable_ps_protocol
explain select * from v2; explain select * from v2;
select * from (select * from t2) T1; select * from (select * from t2) T1;
--disable_ps_protocol
show status like '%Created_tmp%'; show status like '%Created_tmp%';
--enable_ps_protocol
explain select * from (select * from t2) T1; explain select * from (select * from t2) T1;

View File

@ -73,8 +73,11 @@ select * from information_schema.index_statistics;
select * from information_schema.table_statistics; select * from information_schema.table_statistics;
show table_statistics; show table_statistics;
show index_statistics; show index_statistics;
--query_vertical select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics; --query_vertical select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.client_statistics;
--query_vertical select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, OTHER_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.user_statistics; --query_vertical select TOTAL_CONNECTIONS, TOTAL_SSL_CONNECTIONS, CONCURRENT_CONNECTIONS, ROWS_READ, ROWS_SENT, ROWS_DELETED, ROWS_INSERTED, ROWS_UPDATED, SELECT_COMMANDS, UPDATE_COMMANDS, COMMIT_TRANSACTIONS, ROLLBACK_TRANSACTIONS, DENIED_CONNECTIONS, LOST_CONNECTIONS, ACCESS_DENIED, EMPTY_QUERIES from information_schema.user_statistics;
# different values in --ps-protocol
select OTHER_COMMANDS IN (7,8) from information_schema.client_statistics;
select OTHER_COMMANDS IN (7,8) from information_schema.user_statistics;
flush table_statistics; flush table_statistics;
flush index_statistics; flush index_statistics;
select * from information_schema.index_statistics; select * from information_schema.index_statistics;

View File

@ -2437,6 +2437,7 @@ DROP TABLE t1;
# Bug#15943 mysql_next_result hangs on invalid SHOW CREATE VIEW # Bug#15943 mysql_next_result hangs on invalid SHOW CREATE VIEW
# #
--disable_ps_protocol
delimiter //; delimiter //;
drop table if exists t1; drop table if exists t1;
drop view if exists v1; drop view if exists v1;
@ -2447,6 +2448,7 @@ show create view v1;
drop view v1; drop view v1;
// //
delimiter ;// delimiter ;//
--enable_ps_protocol
# #
@ -3957,7 +3959,9 @@ CREATE VIEW v1 AS SELECT f1() FROM t1;
let $MYSQLD_DATADIR= `SELECT @@datadir`; let $MYSQLD_DATADIR= `SELECT @@datadir`;
copy_file std_data/bug48449.frm $MYSQLD_DATADIR/test/v2.frm; copy_file std_data/bug48449.frm $MYSQLD_DATADIR/test/v2.frm;
enable_prepare_warnings;
SHOW CREATE VIEW v1; SHOW CREATE VIEW v1;
disable_prepare_warnings;
DROP VIEW v1,v2; DROP VIEW v1,v2;
DROP TABLE t1,t2; DROP TABLE t1,t2;

View File

@ -230,13 +230,8 @@ class Protocol_discard : public Protocol_text
{ {
public: public:
Protocol_discard(THD *thd_arg) : Protocol_text(thd_arg) {} Protocol_discard(THD *thd_arg) : Protocol_text(thd_arg) {}
virtual bool send_result_set_metadata(List<Item> *list, uint flags)
{
// Don't pas Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF flags
return Protocol_text::send_result_set_metadata(list, 0);
}
bool write() { return 0; } bool write() { return 0; }
bool send_result_set_metadata(List<Item> *, uint) { return 0; }
bool send_eof(uint, uint) { return 0; } bool send_eof(uint, uint) { return 0; }
void prepare_for_resend() { IF_DBUG(field_pos= 0,); } void prepare_for_resend() { IF_DBUG(field_pos= 0,); }

View File

@ -7776,6 +7776,51 @@ void mysql_show_grants_get_fields(THD *thd, List<Item> *fields,
fields->push_back(field, thd->mem_root); fields->push_back(field, thd->mem_root);
} }
bool get_show_user(THD *thd, LEX_USER *lex_user, const char **username,
const char **hostname, const char **rolename)
{
if (lex_user->user.str == current_user.str)
{
*username= thd->security_ctx->priv_user;
*hostname= thd->security_ctx->priv_host;
return 0;
}
if (lex_user->user.str == current_role.str)
{
*rolename= thd->security_ctx->priv_role;
return 0;
}
if (lex_user->user.str == current_user_and_current_role.str)
{
*username= thd->security_ctx->priv_user;
*hostname= thd->security_ctx->priv_host;
*rolename= thd->security_ctx->priv_role;
return 0;
}
Security_context *sctx= thd->security_ctx;
bool do_check_access;
if (!(lex_user= get_current_user(thd, lex_user)))
return 1;
if (lex_user->is_role())
{
*rolename= lex_user->user.str;
do_check_access= strcmp(*rolename, sctx->priv_role);
}
else
{
*username= lex_user->user.str;
*hostname= lex_user->host.str;
do_check_access= strcmp(*username, sctx->priv_user) ||
strcmp(*hostname, sctx->priv_host);
}
if (do_check_access && check_access(thd, SELECT_ACL, "mysql", 0, 0, 1, 0))
return 1;
return 0;
}
/* /*
SHOW GRANTS; Send grants for a user to the client SHOW GRANTS; Send grants for a user to the client
@ -7791,9 +7836,9 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user)
ACL_ROLE *acl_role= NULL; ACL_ROLE *acl_role= NULL;
char buff[1024]; char buff[1024];
Protocol *protocol= thd->protocol; Protocol *protocol= thd->protocol;
char *username= NULL; const char *username= NULL;
char *hostname= NULL; const char *hostname= NULL;
char *rolename= NULL; const char *rolename= NULL;
DBUG_ENTER("mysql_show_grants"); DBUG_ENTER("mysql_show_grants");
if (!initialized) if (!initialized)
@ -7802,46 +7847,9 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user)
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
if (lex_user->user.str == current_user.str) if (get_show_user(thd, lex_user, &username, &hostname, &rolename))
{ DBUG_RETURN(TRUE);
username= thd->security_ctx->priv_user;
hostname= thd->security_ctx->priv_host;
}
else if (lex_user->user.str == current_role.str)
{
rolename= thd->security_ctx->priv_role;
}
else if (lex_user->user.str == current_user_and_current_role.str)
{
username= thd->security_ctx->priv_user;
hostname= thd->security_ctx->priv_host;
rolename= thd->security_ctx->priv_role;
}
else
{
Security_context *sctx= thd->security_ctx;
bool do_check_access;
lex_user= get_current_user(thd, lex_user);
if (!lex_user)
DBUG_RETURN(TRUE);
if (lex_user->is_role())
{
rolename= lex_user->user.str;
do_check_access= strcmp(rolename, sctx->priv_role);
}
else
{
username= lex_user->user.str;
hostname= lex_user->host.str;
do_check_access= strcmp(username, sctx->priv_user) ||
strcmp(hostname, sctx->priv_host);
}
if (do_check_access && check_access(thd, SELECT_ACL, "mysql", 0, 0, 1, 0))
DBUG_RETURN(TRUE);
}
DBUG_ASSERT(rolename || username); DBUG_ASSERT(rolename || username);
List<Item> field_list; List<Item> field_list;

View File

@ -241,6 +241,8 @@ ulong get_table_grant(THD *thd, TABLE_LIST *table);
ulong get_column_grant(THD *thd, GRANT_INFO *grant, ulong get_column_grant(THD *thd, GRANT_INFO *grant,
const char *db_name, const char *table_name, const char *db_name, const char *table_name,
const char *field_name); const char *field_name);
bool get_show_user(THD *thd, LEX_USER *lex_user, const char **username,
const char **hostname, const char **rolename);
void mysql_show_grants_get_fields(THD *thd, List<Item> *fields, void mysql_show_grants_get_fields(THD *thd, List<Item> *fields,
const char *name); const char *name);
bool mysql_show_grants(THD *thd, LEX_USER *user); bool mysql_show_grants(THD *thd, LEX_USER *user);

View File

@ -2405,17 +2405,15 @@ CHANGED_TABLE_LIST* THD::changed_table_dup(const char *key, long key_length)
} }
void THD::prepare_explain_fields(select_result *result, int THD::prepare_explain_fields(select_result *result, List<Item> *field_list,
List<Item> *field_list, uint8 explain_flags, bool is_analyze)
uint8 explain_flags,
bool is_analyze)
{ {
if (lex->explain_json) if (lex->explain_json)
make_explain_json_field_list(*field_list, is_analyze); make_explain_json_field_list(*field_list, is_analyze);
else else
make_explain_field_list(*field_list, explain_flags, is_analyze); make_explain_field_list(*field_list, explain_flags, is_analyze);
result->prepare(*field_list, NULL); return result->prepare(*field_list, NULL);
} }
@ -2425,11 +2423,10 @@ int THD::send_explain_fields(select_result *result,
{ {
List<Item> field_list; List<Item> field_list;
int rc; int rc;
prepare_explain_fields(result, &field_list, explain_flags, is_analyze); rc= prepare_explain_fields(result, &field_list, explain_flags, is_analyze) ||
rc= result->send_result_set_metadata(field_list, result->send_result_set_metadata(field_list, Protocol::SEND_NUM_ROWS |
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
Protocol::SEND_EOF); return rc;
return(rc);
} }
@ -2504,7 +2501,7 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
if (is_analyze) if (is_analyze)
{ {
field_list.push_back(item= new (mem_root) field_list.push_back(item= new (mem_root)
Item_float(this, "r_rows", 0.1234, 10, 4), Item_float(this, "r_rows", 0.1234, 2, 4),
mem_root); mem_root);
item->maybe_null=1; item->maybe_null=1;
} }

View File

@ -3331,8 +3331,8 @@ public:
void add_changed_table(TABLE *table); void add_changed_table(TABLE *table);
void add_changed_table(const char *key, long key_length); void add_changed_table(const char *key, long key_length);
CHANGED_TABLE_LIST * changed_table_dup(const char *key, long key_length); CHANGED_TABLE_LIST * changed_table_dup(const char *key, long key_length);
void prepare_explain_fields(select_result *result, List<Item> *field_list, int prepare_explain_fields(select_result *result, List<Item> *field_list,
uint8 explain_flags, bool is_analyze); uint8 explain_flags, bool is_analyze);
int send_explain_fields(select_result *result, uint8 explain_flags, int send_explain_fields(select_result *result, uint8 explain_flags,
bool is_analyze); bool is_analyze);
void make_explain_field_list(List<Item> &field_list, uint8 explain_flags, void make_explain_field_list(List<Item> &field_list, uint8 explain_flags,

View File

@ -3007,7 +3007,11 @@ mysql_execute_command(THD *thd)
if (lex->sql_command == SQLCOM_SELECT) if (lex->sql_command == SQLCOM_SELECT)
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ); WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_READ);
else else
{
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW);
if (lex->sql_command == SQLCOM_SHOW_PROFILE)
thd->profiling.discard_current_query();
}
thd->status_var.last_query_cost= 0.0; thd->status_var.last_query_cost= 0.0;
@ -3723,49 +3727,6 @@ end_with_restore_list:
DBUG_PRINT("debug", ("lex->only_view: %d, table: %s.%s", DBUG_PRINT("debug", ("lex->only_view: %d, table: %s.%s",
lex->only_view, lex->only_view,
first_table->db, first_table->table_name)); first_table->db, first_table->table_name));
if (lex->only_view)
{
if (check_table_access(thd, SELECT_ACL, first_table, FALSE, 1, FALSE))
{
DBUG_PRINT("debug", ("check_table_access failed"));
my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
"SHOW", thd->security_ctx->priv_user,
thd->security_ctx->host_or_ip, first_table->alias);
goto error;
}
DBUG_PRINT("debug", ("check_table_access succeeded"));
/* Ignore temporary tables if this is "SHOW CREATE VIEW" */
first_table->open_type= OT_BASE_ONLY;
}
else
{
/*
Temporary tables should be opened for SHOW CREATE TABLE, but not
for SHOW CREATE VIEW.
*/
if (open_temporary_tables(thd, all_tables))
goto error;
/*
The fact that check_some_access() returned FALSE does not mean that
access is granted. We need to check if first_table->grant.privilege
contains any table-specific privilege.
*/
DBUG_PRINT("debug", ("first_table->grant.privilege: %lx",
first_table->grant.privilege));
if (check_some_access(thd, SHOW_CREATE_TABLE_ACLS, first_table) ||
(first_table->grant.privilege & SHOW_CREATE_TABLE_ACLS) == 0)
{
my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
"SHOW", thd->security_ctx->priv_user,
thd->security_ctx->host_or_ip, first_table->alias);
goto error;
}
}
/* Access is granted. Execute the command. */
res= mysqld_show_create(thd, first_table); res= mysqld_show_create(thd, first_table);
break; break;
#endif #endif
@ -4116,7 +4077,7 @@ end_with_restore_list:
case SQLCOM_DELETE: case SQLCOM_DELETE:
{ {
WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE); WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE);
select_result *sel_result=lex->result; select_result *sel_result= NULL;
DBUG_ASSERT(first_table == all_tables && first_table != 0); DBUG_ASSERT(first_table == all_tables && first_table != 0);
if (WSREP_CLIENT(thd) && if (WSREP_CLIENT(thd) &&
wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE)) wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE))
@ -4147,16 +4108,15 @@ end_with_restore_list:
} }
else else
{ {
if (!(sel_result= lex->result) && if (!lex->result && !(sel_result= new (thd->mem_root) select_send(thd)))
!(sel_result= new (thd->mem_root) select_send(thd))) goto error;
return 1;
} }
} }
res = mysql_delete(thd, all_tables, res = mysql_delete(thd, all_tables,
select_lex->where, &select_lex->order_list, select_lex->where, &select_lex->order_list,
unit->select_limit_cnt, select_lex->options, unit->select_limit_cnt, select_lex->options,
sel_result); lex->result ? lex->result : sel_result);
if (replaced_protocol) if (replaced_protocol)
{ {
@ -6517,7 +6477,7 @@ static bool check_show_access(THD *thd, TABLE_LIST *table)
Check_grant will grant access if there is any column privileges on Check_grant will grant access if there is any column privileges on
all of the tables thanks to the fourth parameter (bool show_table). all of the tables thanks to the fourth parameter (bool show_table).
*/ */
if (check_grant(thd, SELECT_ACL, dst_table, TRUE, UINT_MAX, FALSE)) if (check_grant(thd, SELECT_ACL, dst_table, TRUE, 1, FALSE))
return TRUE; /* Access denied */ return TRUE; /* Access denied */
close_thread_tables(thd); close_thread_tables(thd);

View File

@ -1883,9 +1883,20 @@ static int mysql_test_show_grants(Prepared_statement *stmt)
DBUG_ENTER("mysql_test_show_grants"); DBUG_ENTER("mysql_test_show_grants");
THD *thd= stmt->thd; THD *thd= stmt->thd;
List<Item> fields; List<Item> fields;
char buff[1024];
const char *username= NULL, *hostname= NULL, *rolename= NULL;
mysql_show_grants_get_fields(thd, &fields, "Grants for"); if (get_show_user(thd, thd->lex->grant_user, &username, &hostname, &rolename))
DBUG_RETURN(1);
if (username)
strxmov(buff,"Grants for ",username,"@",hostname, NullS);
else if (rolename)
strxmov(buff,"Grants for ",rolename, NullS);
else
DBUG_RETURN(1);
mysql_show_grants_get_fields(thd, &fields, buff);
DBUG_RETURN(send_stmt_metadata(thd, stmt, &fields)); DBUG_RETURN(send_stmt_metadata(thd, stmt, &fields));
} }
#endif /*NO_EMBEDDED_ACCESS_CHECKS*/ #endif /*NO_EMBEDDED_ACCESS_CHECKS*/
@ -1909,7 +1920,7 @@ static int mysql_test_show_slave_status(Prepared_statement *stmt)
THD *thd= stmt->thd; THD *thd= stmt->thd;
List<Item> fields; List<Item> fields;
show_master_info_get_fields(thd, &fields, 0, 0); show_master_info_get_fields(thd, &fields, thd->lex->verbose, 0);
DBUG_RETURN(send_stmt_metadata(thd, stmt, &fields)); DBUG_RETURN(send_stmt_metadata(thd, stmt, &fields));
} }
@ -2424,6 +2435,7 @@ static bool check_prepared_statement(Prepared_statement *stmt)
case SQLCOM_CREATE_INDEX: case SQLCOM_CREATE_INDEX:
case SQLCOM_DROP_INDEX: case SQLCOM_DROP_INDEX:
case SQLCOM_ROLLBACK: case SQLCOM_ROLLBACK:
case SQLCOM_ROLLBACK_TO_SAVEPOINT:
case SQLCOM_TRUNCATE: case SQLCOM_TRUNCATE:
case SQLCOM_DROP_VIEW: case SQLCOM_DROP_VIEW:
case SQLCOM_REPAIR: case SQLCOM_REPAIR:
@ -2452,6 +2464,7 @@ static bool check_prepared_statement(Prepared_statement *stmt)
case SQLCOM_GRANT: case SQLCOM_GRANT:
case SQLCOM_GRANT_ROLE: case SQLCOM_GRANT_ROLE:
case SQLCOM_REVOKE: case SQLCOM_REVOKE:
case SQLCOM_REVOKE_ALL:
case SQLCOM_REVOKE_ROLE: case SQLCOM_REVOKE_ROLE:
case SQLCOM_KILL: case SQLCOM_KILL:
case SQLCOM_COMPOUND: case SQLCOM_COMPOUND:
@ -2480,14 +2493,12 @@ static bool check_prepared_statement(Prepared_statement *stmt)
{ {
if (lex->describe || lex->analyze_stmt) if (lex->describe || lex->analyze_stmt)
{ {
if (!lex->result && select_send result(thd);
!(lex->result= new (stmt->mem_root) select_send(thd)))
DBUG_RETURN(TRUE);
List<Item> field_list; List<Item> field_list;
thd->prepare_explain_fields(lex->result, &field_list, res= thd->prepare_explain_fields(&result, &field_list,
lex->describe, lex->analyze_stmt); lex->describe, lex->analyze_stmt) ||
res= send_prep_stmt(stmt, lex->result->field_count(field_list)) || send_prep_stmt(stmt, result.field_count(field_list)) ||
lex->result->send_result_set_metadata(field_list, result.send_result_set_metadata(field_list,
Protocol::SEND_EOF); Protocol::SEND_EOF);
} }
else else

View File

@ -1148,6 +1148,48 @@ mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list,
DBUG_PRINT("enter",("db: %s table: %s",table_list->db, DBUG_PRINT("enter",("db: %s table: %s",table_list->db,
table_list->table_name)); table_list->table_name));
if (lex->only_view)
{
if (check_table_access(thd, SELECT_ACL, table_list, FALSE, 1, FALSE))
{
DBUG_PRINT("debug", ("check_table_access failed"));
my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
"SHOW", thd->security_ctx->priv_user,
thd->security_ctx->host_or_ip, table_list->alias);
goto exit;
}
DBUG_PRINT("debug", ("check_table_access succeeded"));
/* Ignore temporary tables if this is "SHOW CREATE VIEW" */
table_list->open_type= OT_BASE_ONLY;
}
else
{
/*
Temporary tables should be opened for SHOW CREATE TABLE, but not
for SHOW CREATE VIEW.
*/
if (open_temporary_tables(thd, table_list))
goto exit;
/*
The fact that check_some_access() returned FALSE does not mean that
access is granted. We need to check if table_list->grant.privilege
contains any table-specific privilege.
*/
DBUG_PRINT("debug", ("table_list->grant.privilege: %lx",
table_list->grant.privilege));
if (check_some_access(thd, SHOW_CREATE_TABLE_ACLS, table_list) ||
(table_list->grant.privilege & SHOW_CREATE_TABLE_ACLS) == 0)
{
my_error(ER_TABLEACCESS_DENIED_ERROR, MYF(0),
"SHOW", thd->security_ctx->priv_user,
thd->security_ctx->host_or_ip, table_list->alias);
goto exit;
}
}
/* Access is granted. Execute the command. */
/* We want to preserve the tree for views. */ /* We want to preserve the tree for views. */
lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW; lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;

View File

@ -330,12 +330,11 @@ bool create_view_precheck(THD *thd, TABLE_LIST *tables, TABLE_LIST *view,
{ {
if (!tbl->table_in_first_from_clause) if (!tbl->table_in_first_from_clause)
{ {
if (check_access(thd, SELECT_ACL, tbl->db, if (check_single_table_access(thd, SELECT_ACL, tbl, FALSE))
&tbl->grant.privilege, {
&tbl->grant.m_internal, tbl->hide_view_error(thd);
0, 0) ||
check_grant(thd, SELECT_ACL, tbl, FALSE, 1, FALSE))
goto err; goto err;
}
} }
} }
} }

View File

@ -12994,6 +12994,7 @@ load:
LOAD data_or_xml LOAD data_or_xml
{ {
LEX *lex= thd->lex; LEX *lex= thd->lex;
mysql_init_select(lex);
if (lex->sphead) if (lex->sphead)
{ {