summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-10-30 19:04:54 +0100
committerSergei Golubchik <serg@mariadb.org>2018-11-12 09:27:41 +0100
commit68889c8dfa4a1f580a611c174d0ef807cb87bbad (patch)
tree39d12de3916d77fbb8878c04e15a4e5c3f18ea21
parent89ac4b3bf82aee9cd6bde87e0fe2c5f7ad87154b (diff)
downloadmariadb-git-bb-10.4-ps.tar.gz
Make mysqltest to use --ps-protocol morebb-10.4-ps
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 mysqltest.cc: * make sure run_query_stmt() doesn't crash if there's no active connection (in wait_until_connected_again.inc) 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 the correct metadata when creating a column for ANALYZE SELECT. The actual value is always FLOAT(4,2), but the column was created as FLOAT(4,10), so --ps and text protocols were using different number of decimals. 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() sql_show.cc: * check grants for SHOW CREATE VIEW here, not in mysql_execute_command sql_tvc.cc: * allocate Type_holder and items in the correct arena 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.
-rw-r--r--client/mysqltest.cc60
-rw-r--r--include/wsrep.h6
-rw-r--r--mysql-test/main/kill_processlist-6619.test2
-rw-r--r--mysql-test/main/log_tables.test2
-rw-r--r--mysql-test/main/mysql_client_test.result8
-rw-r--r--mysql-test/main/old-mode.test3
-rw-r--r--mysql-test/main/partition.result2
-rw-r--r--mysql-test/main/partition.test2
-rw-r--r--mysql-test/main/show_check.test12
-rw-r--r--mysql-test/main/show_explain_ps.result7
-rw-r--r--mysql-test/main/show_explain_ps.test17
-rw-r--r--mysql-test/main/sp-ucs2.result34
-rw-r--r--mysql-test/main/sp-ucs2.test16
-rw-r--r--mysql-test/main/sp.result2
-rw-r--r--mysql-test/main/sp.test2
-rw-r--r--mysql-test/main/sp_notembedded.result2
-rw-r--r--mysql-test/main/sp_notembedded.test2
-rw-r--r--mysql-test/main/sp_trans.result2
-rw-r--r--mysql-test/main/sp_trans.test2
-rw-r--r--mysql-test/main/subselect_sj_mat.test2
-rw-r--r--mysql-test/main/temp_table.test2
-rw-r--r--mysql-test/main/tmp_table_count-7586.test4
-rw-r--r--mysql-test/main/userstat.result12
-rw-r--r--mysql-test/main/userstat.test7
-rw-r--r--mysql-test/main/view.result5
-rw-r--r--mysql-test/main/view.test6
-rw-r--r--mysql-test/suite/funcs_1/datadict/processlist_priv.inc13
-rw-r--r--mysql-test/suite/funcs_1/datadict/processlist_val.inc7
-rw-r--r--mysql-test/suite/handler/ps.test2
-rw-r--r--mysql-test/suite/innodb/t/innodb-corrupted-table.test1
-rw-r--r--mysql-test/suite/sys_vars/t/max_prepared_stmt_count_func.test2
-rw-r--r--mysql-test/suite/sys_vars/t/sql_buffer_result_func.test10
-rw-r--r--mysql-test/suite/vcol/t/wrong_arena.test2
-rw-r--r--sql/sql_acl.cc81
-rw-r--r--sql/sql_acl.h2
-rw-r--r--sql/sql_class.cc14
-rw-r--r--sql/sql_class.h4
-rw-r--r--sql/sql_parse.cc62
-rw-r--r--sql/sql_prepare.cc23
-rw-r--r--sql/sql_show.cc52
-rw-r--r--sql/sql_tvc.cc10
-rw-r--r--sql/sql_view.cc9
42 files changed, 323 insertions, 192 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 38e89236896..5c80058e5db 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -8304,6 +8304,12 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command,
DBUG_ENTER("run_query_stmt");
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
*/
@@ -8841,18 +8847,56 @@ void init_re(void)
*/
const char *ps_re_str =
"^("
- "[[:space:]]*REPLACE[[:space:]]|"
- "[[:space:]]*INSERT[[:space:]]|"
- "[[:space:]]*UPDATE[[:space:]]|"
- "[[:space:]]*DELETE[[:space:]]|"
- "[[:space:]]*SELECT[[:space:]]|"
+ "[[:space:]]*ALTER[[:space:]]+SEQUENCE[[:space:]]|"
+ "[[:space:]]*ALTER[[:space:]]+TABLE[[:space:]]|"
+ "[[:space:]]*ALTER[[:space:]]+USER[[:space:]]|"
+ "[[:space:]]*ANALYZE[[: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:]]+USER[[:space:]]|"
+ "[[:space:]]*CREATE[[:space:]]+VIEW[[:space:]]|"
+ "[[:space:]]*DELETE[[: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:]]*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:]]*DELETE[[:space:]]+MULTI[[:space:]]|"
- "[[:space:]]*UPDATE[[:space:]]+MULTI[[:space:]]|"
- "[[:space:]]*INSERT[[:space:]]+SELECT[[:space:]])";
+ "[[:space:]]*SHOW[[:space:]]|"
+ "[[:space:]]*SHUTDOWN[[:space:]]|"
+ "[[:space:]]*SLAVE[[:space:]]|"
+ "[[:space:]]*TRUNCATE[[:space:]]|"
+ "[[:space:]]*UNINSTALL[[:space:]]+|"
+ "[[:space:]]*UPDATE[[:space:]]"
+ ")";
/*
Filter for queries that can be run using the
diff --git a/include/wsrep.h b/include/wsrep.h
index e2aefe80eb3..d9784582367 100644
--- a/include/wsrep.h
+++ b/include/wsrep.h
@@ -51,8 +51,8 @@
#define WSREP_ERROR(...) WSREP_LOG(sql_print_error, ##__VA_ARGS__)
#define WSREP_SYNC_WAIT(thd_, before_) \
- { if (WSREP_CLIENT(thd_) && \
- wsrep_sync_wait(thd_, before_)) goto error; }
+ do { if (WSREP_CLIENT(thd_) && \
+ wsrep_sync_wait(thd_, before_)) goto error; } while(0)
#else
#define IF_WSREP(A,B) B
@@ -65,7 +65,7 @@
#define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_)
#define WSREP_TO_ISOLATION_END
#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_)
-#define WSREP_SYNC_WAIT(thd_, before_)
+#define WSREP_SYNC_WAIT(thd_, before_) do { } while(0)
#endif /* WITH_WSREP */
diff --git a/mysql-test/main/kill_processlist-6619.test b/mysql-test/main/kill_processlist-6619.test
index d984924f9db..c272e68a877 100644
--- a/mysql-test/main/kill_processlist-6619.test
+++ b/mysql-test/main/kill_processlist-6619.test
@@ -6,6 +6,7 @@
--connect (con1,localhost,root,,)
--let $con_id = `SELECT CONNECTION_ID()`
+--replace_result Execute Query
--replace_column 1 # 3 # 6 # 7 #
SHOW PROCESSLIST;
SET DEBUG_SYNC='before_execute_sql_command SIGNAL ready WAIT_FOR go';
@@ -29,5 +30,6 @@ let $wait_condition=
WHERE info is NULL;
--source include/wait_condition.inc
+--replace_result Execute Query
--replace_column 1 # 3 # 6 # 7 #
SHOW PROCESSLIST;
diff --git a/mysql-test/main/log_tables.test b/mysql-test/main/log_tables.test
index a4158ba6a24..f822ec8d758 100644
--- a/mysql-test/main/log_tables.test
+++ b/mysql-test/main/log_tables.test
@@ -855,7 +855,9 @@ SET GLOBAL slow_query_log = @old_slow_query_log;
#
select CONNECTION_ID() into @thread_id;
+--disable_ps_protocol
truncate table mysql.general_log;
+--enable_ps_protocol
set global general_log = on;
--disable_result_log
set @lparam = "000 001 002 003 004 005 006 007 008 009"
diff --git a/mysql-test/main/mysql_client_test.result b/mysql-test/main/mysql_client_test.result
index 6f65979517b..6ecf03946ab 100644
--- a/mysql-test/main/mysql_client_test.result
+++ b/mysql-test/main/mysql_client_test.result
@@ -149,7 +149,7 @@ ANALYZE number of fields: 13
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
- - 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
+ - 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 12: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
@@ -178,7 +178,7 @@ ANALYZE INSERT number of fields: 13
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
- - 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
+ - 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 12: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
@@ -207,7 +207,7 @@ ANALYZE UPDATE number of fields: 13
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
- - 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
+ - 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 12: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
@@ -236,7 +236,7 @@ ANALYZE DELETE number of fields: 13
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
- - 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
+ - 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 12: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
diff --git a/mysql-test/main/old-mode.test b/mysql-test/main/old-mode.test
index d7e8ce8ee55..e092ee78a2e 100644
--- a/mysql-test/main/old-mode.test
+++ b/mysql-test/main/old-mode.test
@@ -22,7 +22,8 @@ drop table t1,t2;
--replace_column 1 <Id> 3 <Host> 6 <Time> 7 <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/
SHOW PROCESSLIST;
diff --git a/mysql-test/main/partition.result b/mysql-test/main/partition.result
index fd76da09d78..54031942c2e 100644
--- a/mysql-test/main/partition.result
+++ b/mysql-test/main/partition.result
@@ -1321,7 +1321,7 @@ partition p2 values in (1));
end//
call p()//
drop procedure p//
-drop table t1;
+drop table t1//
create procedure p ()
begin
create table t1 (a int not null,b int not null,c int not null,primary key (a,b))
diff --git a/mysql-test/main/partition.test b/mysql-test/main/partition.test
index 7b7d1457426..487c7616622 100644
--- a/mysql-test/main/partition.test
+++ b/mysql-test/main/partition.test
@@ -1198,7 +1198,7 @@ end//
call p()//
drop procedure p//
-drop table t1;
+drop table t1//
create procedure p ()
begin
diff --git a/mysql-test/main/show_check.test b/mysql-test/main/show_check.test
index b6885b1fcaf..b6c37d391bf 100644
--- a/mysql-test/main/show_check.test
+++ b/mysql-test/main/show_check.test
@@ -47,7 +47,9 @@ insert into t1 values (5,5,5);
check table t1 changed;
check table t1 medium;
check table t1 extended;
+--disable_ps_protocol
show index from t1;
+--enable_ps_protocol
--disable_metadata
--error ER_DUP_ENTRY
insert into t1 values (5,5,5);
@@ -409,7 +411,9 @@ CREATE TABLE t1(
PRIMARY KEY(field1(1000))
);
--enable_metadata
+--disable_ps_protocol
show index from t1;
+--enable_ps_protocol
--disable_metadata
drop table t1;
@@ -707,11 +711,13 @@ set names utf8;
--echo ----------------------------------------------------------------
+--disable_ps_protocol
SHOW CHARACTER SET LIKE 'utf8';
--echo ----------------------------------------------------------------
SHOW COLLATION LIKE 'latin1_bin';
+--enable_ps_protocol
--echo ----------------------------------------------------------------
@@ -727,7 +733,9 @@ SHOW CREATE TABLE t1;
--echo ----------------------------------------------------------------
+--disable_ps_protocol
SHOW INDEX FROM t1;
+--enable_ps_protocol
--echo ----------------------------------------------------------------
@@ -774,8 +782,10 @@ SHOW COLUMNS FROM t1;
--echo ----------------------------------------------------------------
+--disable_ps_protocol
--replace_column 6 #
SHOW TRIGGERS LIKE 't1';
+--enable_ps_protocol
--echo ----------------------------------------------------------------
@@ -1364,9 +1374,11 @@ let $wait_timeout= 10;
let $wait_condition= SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%GET_LOCK%' AND ID != CONNECTION_ID();
--source include/wait_condition.inc
--replace_column 1 ### 3 ### 6 ### 7 ###
+--replace_result "Execute" "Query"
SHOW PROCESSLIST;
SET NAMES utf8;
--replace_column 1 ### 3 ### 6 ### 7 ###
+--replace_result "Execute" "Query"
SHOW PROCESSLIST;
SELECT RELEASE_LOCK('t');
--connection con1
diff --git a/mysql-test/main/show_explain_ps.result b/mysql-test/main/show_explain_ps.result
index fae432e830e..69ee2cab31d 100644
--- a/mysql-test/main/show_explain_ps.result
+++ b/mysql-test/main/show_explain_ps.result
@@ -31,12 +31,11 @@ count(*)
set debug_dbug='';
select event_name
from
-performance_schema.events_stages_history_long
+performance_schema.events_stages_history_long join
+performance_schema.threads using (thread_id)
where
event_name like '%show explain' and
-thread_id in(select thread_id
-from performance_schema.events_statements_history_long
-where EVENT_NAME='statement/sql/show_explain');
+processlist_id=$thr1;
event_name
stage/sql/Show explain
drop table t0;
diff --git a/mysql-test/main/show_explain_ps.test b/mysql-test/main/show_explain_ps.test
index b43cd559e09..5b08290c5e0 100644
--- a/mysql-test/main/show_explain_ps.test
+++ b/mysql-test/main/show_explain_ps.test
@@ -44,17 +44,18 @@ send select count(*) from t0 where a < 100000;
connection default;
--source include/wait_condition.inc
evalp show explain for $thr2;
+
connection con1;
reap;
set debug_dbug='';
-select event_name
-from
-performance_schema.events_stages_history_long
-where
- event_name like '%show explain' and
- thread_id in(select thread_id
- from performance_schema.events_statements_history_long
- where EVENT_NAME='statement/sql/show_explain');
+evalp select event_name
+ from
+ performance_schema.events_stages_history_long join
+ performance_schema.threads using (thread_id)
+ where
+ event_name like '%show explain' and
+ processlist_id=$thr1;
+
drop table t0;
diff --git a/mysql-test/main/sp-ucs2.result b/mysql-test/main/sp-ucs2.result
index b8cc5dfd73d..ca448efa535 100644
--- a/mysql-test/main/sp-ucs2.result
+++ b/mysql-test/main/sp-ucs2.result
@@ -32,61 +32,55 @@ RETURNS VARCHAR(64) UNICODE BINARY
BEGIN
RETURN '';
END|
-SHOW CREATE FUNCTION f;
-DROP FUNCTION f;
+SHOW CREATE FUNCTION f|
+Function sql_mode Create Function character_set_client collation_connection Database Collation
+f STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,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()
RETURNS VARCHAR(64) BINARY UNICODE
BEGIN
RETURN '';
END|
+SHOW CREATE FUNCTION f|
Function sql_mode Create Function character_set_client collation_connection Database Collation
f STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,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;
-#
-# Testing keywords ASCII + BINARY
-#
+DROP FUNCTION f|
CREATE FUNCTION f()
RETURNS VARCHAR(64) ASCII BINARY
BEGIN
RETURN '';
END|
+SHOW CREATE FUNCTION f|
Function sql_mode Create Function character_set_client collation_connection Database Collation
-f STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` FUNCTION `f`() RETURNS varchar(64) CHARSET ucs2 COLLATE ucs2_bin
+f STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,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
-SHOW CREATE FUNCTION f;
-DROP FUNCTION f;
+DROP FUNCTION f|
CREATE FUNCTION f()
RETURNS VARCHAR(64) BINARY ASCII
BEGIN
RETURN '';
END|
+SHOW CREATE FUNCTION f|
Function sql_mode Create Function character_set_client collation_connection Database Collation
f STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,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
-SHOW CREATE FUNCTION f;
-DROP FUNCTION f;
-#
-# Testing COLLATE in OUT parameter
-#
+DROP FUNCTION f|
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)
BEGIN
SET f2= f1;
SET f2= concat(collation(f1), ' ', collation(f2));
END|
-Function sql_mode Create Function character_set_client collation_connection Database Collation
-f STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,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()
RETURNS VARCHAR(64) CHARACTER SET ucs2
BEGIN
diff --git a/mysql-test/main/sp-ucs2.test b/mysql-test/main/sp-ucs2.test
index 3532169e5a1..a1aec8071b4 100644
--- a/mysql-test/main/sp-ucs2.test
+++ b/mysql-test/main/sp-ucs2.test
@@ -52,16 +52,16 @@ CREATE FUNCTION f()
BEGIN
RETURN '';
END|
-SHOW CREATE FUNCTION f;
-DROP FUNCTION f;
+SHOW CREATE FUNCTION f|
+DROP FUNCTION f|
CREATE FUNCTION f()
RETURNS VARCHAR(64) BINARY UNICODE
BEGIN
RETURN '';
END|
-SHOW CREATE FUNCTION f;
-DROP FUNCTION f;
+SHOW CREATE FUNCTION f|
+DROP FUNCTION f|
#
@@ -72,16 +72,16 @@ CREATE FUNCTION f()
BEGIN
RETURN '';
END|
-SHOW CREATE FUNCTION f;
-DROP FUNCTION f;
+SHOW CREATE FUNCTION f|
+DROP FUNCTION f|
CREATE FUNCTION f()
RETURNS VARCHAR(64) BINARY ASCII
BEGIN
RETURN '';
END|
-SHOW CREATE FUNCTION f;
-DROP FUNCTION f;
+SHOW CREATE FUNCTION f|
+DROP FUNCTION f|
#
# Testing COLLATE in OUT parameter
diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result
index 16b0b1d60e5..9b4d3039c89 100644
--- a/mysql-test/main/sp.result
+++ b/mysql-test/main/sp.result
@@ -6766,7 +6766,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist
create table t1 (a integer)$
call p1$
a
-alter table t1 add b integer;
+alter table t1 add b integer$
call p1$
a
drop table t1;
diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test
index 4f520f321c5..d2c587a6d54 100644
--- a/mysql-test/main/sp.test
+++ b/mysql-test/main/sp.test
@@ -8041,7 +8041,7 @@ create procedure p1() begin select * from t1; end$
call p1$
create table t1 (a integer)$
call p1$
-alter table t1 add b integer;
+alter table t1 add b integer$
call p1$
delimiter ;$
diff --git a/mysql-test/main/sp_notembedded.result b/mysql-test/main/sp_notembedded.result
index 860f82ebd93..81fb63af949 100644
--- a/mysql-test/main/sp_notembedded.result
+++ b/mysql-test/main/sp_notembedded.result
@@ -74,7 +74,7 @@ select res;
end|
create table t3 (a int)|
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)
begin
if level < lim then
diff --git a/mysql-test/main/sp_notembedded.test b/mysql-test/main/sp_notembedded.test
index 64f1daeaeb9..1f033d8d725 100644
--- a/mysql-test/main/sp_notembedded.test
+++ b/mysql-test/main/sp_notembedded.test
@@ -118,7 +118,7 @@ end|
# a procedure which use tables and recursion
create table t3 (a int)|
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)
begin
if level < lim then
diff --git a/mysql-test/main/sp_trans.result b/mysql-test/main/sp_trans.result
index dad1aa7c0ff..cee2a7e5188 100644
--- a/mysql-test/main/sp_trans.result
+++ b/mysql-test/main/sp_trans.result
@@ -642,7 +642,7 @@ TRUNCATE TABLE t1;
END|
LOCK TABLES t1 WRITE|
CALL p1()|
-FLUSH TABLES;
+FLUSH TABLES|
UNLOCK TABLES|
CALL p1()|
DROP PROCEDURE p1|
diff --git a/mysql-test/main/sp_trans.test b/mysql-test/main/sp_trans.test
index a9759b99269..7d6faba9789 100644
--- a/mysql-test/main/sp_trans.test
+++ b/mysql-test/main/sp_trans.test
@@ -689,7 +689,7 @@ END|
LOCK TABLES t1 WRITE|
CALL p1()|
-FLUSH TABLES;
+FLUSH TABLES|
UNLOCK TABLES|
CALL p1()|
diff --git a/mysql-test/main/subselect_sj_mat.test b/mysql-test/main/subselect_sj_mat.test
index 7b8179bba38..bc627911a2e 100644
--- a/mysql-test/main/subselect_sj_mat.test
+++ b/mysql-test/main/subselect_sj_mat.test
@@ -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);
flush status;
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';
+--enable_ps_protocol
DROP TABLE t1,t2,t3;
--echo #
diff --git a/mysql-test/main/temp_table.test b/mysql-test/main/temp_table.test
index a528e27b890..a1e61b31a82 100644
--- a/mysql-test/main/temp_table.test
+++ b/mysql-test/main/temp_table.test
@@ -115,8 +115,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');
flush status;
+--disable_ps_protocol
select * from t1 group by d;
show status like "created_tmp%tables";
+--enable_ps_protocol
drop table t1;
# Fix for BUG#8921: Check that temporary table is ingored by view commands.
diff --git a/mysql-test/main/tmp_table_count-7586.test b/mysql-test/main/tmp_table_count-7586.test
index e7bac127815..8bfb0e7c5cf 100644
--- a/mysql-test/main/tmp_table_count-7586.test
+++ b/mysql-test/main/tmp_table_count-7586.test
@@ -9,12 +9,16 @@ create view v2 as select a from t2;
flush status;
select * from v2;
+--disable_ps_protocol
show status like '%Created_tmp%';
+--enable_ps_protocol
explain select * from v2;
select * from (select * from t2) T1;
+--disable_ps_protocol
show status like '%Created_tmp%';
+--enable_ps_protocol
explain select * from (select * from t2) T1;
diff --git a/mysql-test/main/userstat.result b/mysql-test/main/userstat.result
index 2c8a3d3e97d..b3178aefeaf 100644
--- a/mysql-test/main/userstat.result
+++ b/mysql-test/main/userstat.result
@@ -148,7 +148,7 @@ show table_statistics;
Table_schema Table_name Rows_read Rows_changed Rows_changed_x_#indexes
show index_statistics;
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_SSL_CONNECTIONS 1
CONCURRENT_CONNECTIONS 0
@@ -159,14 +159,13 @@ ROWS_INSERTED 7
ROWS_UPDATED 5
SELECT_COMMANDS 4
UPDATE_COMMANDS 11
-OTHER_COMMANDS 7
COMMIT_TRANSACTIONS 19
ROLLBACK_TRANSACTIONS 2
DENIED_CONNECTIONS 0
LOST_CONNECTIONS 0
ACCESS_DENIED 0
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_SSL_CONNECTIONS 1
CONCURRENT_CONNECTIONS 0
@@ -177,13 +176,18 @@ ROWS_INSERTED 7
ROWS_UPDATED 5
SELECT_COMMANDS 4
UPDATE_COMMANDS 11
-OTHER_COMMANDS 7
COMMIT_TRANSACTIONS 19
ROLLBACK_TRANSACTIONS 2
DENIED_CONNECTIONS 0
LOST_CONNECTIONS 0
ACCESS_DENIED 0
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 index_statistics;
select * from information_schema.index_statistics;
diff --git a/mysql-test/main/userstat.test b/mysql-test/main/userstat.test
index 9ce3a32c442..547138cfeaa 100644
--- a/mysql-test/main/userstat.test
+++ b/mysql-test/main/userstat.test
@@ -73,8 +73,11 @@ select * from information_schema.index_statistics;
select * from information_schema.table_statistics;
show table_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, 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.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.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 index_statistics;
select * from information_schema.index_statistics;
diff --git a/mysql-test/main/view.result b/mysql-test/main/view.result
index fcd3fc202e0..b6bd4d01d72 100644
--- a/mysql-test/main/view.result
+++ b/mysql-test/main/view.result
@@ -2210,11 +2210,6 @@ create table t1(f1 char(1));
create view v1 as select * from t1;
select * from (select f1 as f2, f1 as f3 from v1) v where v.f2='a';
f2 f3
-show status like "Created_tmp%";
-Variable_name Value
-Created_tmp_disk_tables 0
-Created_tmp_files 0
-Created_tmp_tables 1
drop view v1;
drop table t1;
set @@optimizer_switch=@tmp;
diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test
index 658cd09ae6f..513517737ba 100644
--- a/mysql-test/main/view.test
+++ b/mysql-test/main/view.test
@@ -2054,6 +2054,7 @@ flush status;
create table t1(f1 char(1));
create view v1 as select * from t1;
select * from (select f1 as f2, f1 as f3 from v1) v where v.f2='a';
+--replace_result $PS_PROTOCOL 0
show status like "Created_tmp%";
drop view v1;
drop table t1;
@@ -2063,7 +2064,6 @@ set @@optimizer_switch='derived_merge=OFF';
create table t1(f1 char(1));
create view v1 as select * from t1;
select * from (select f1 as f2, f1 as f3 from v1) v where v.f2='a';
-show status like "Created_tmp%";
drop view v1;
drop table t1;
set @@optimizer_switch=@tmp;
@@ -2369,6 +2369,7 @@ DROP TABLE t1;
# Bug#15943 mysql_next_result hangs on invalid SHOW CREATE VIEW
#
+disable_ps_protocol;
delimiter //;
drop table if exists t1;
drop view if exists v1;
@@ -2379,6 +2380,7 @@ show create view v1;
drop view v1;
//
delimiter ;//
+enable_ps_protocol;
#
@@ -3889,7 +3891,9 @@ CREATE VIEW v1 AS SELECT f1() FROM t1;
let $MYSQLD_DATADIR= `SELECT @@datadir`;
copy_file std_data/bug48449.frm $MYSQLD_DATADIR/test/v2.frm;
+enable_prepare_warnings;
SHOW CREATE VIEW v1;
+disable_prepare_warnings;
DROP VIEW v1,v2;
DROP TABLE t1,t2;
diff --git a/mysql-test/suite/funcs_1/datadict/processlist_priv.inc b/mysql-test/suite/funcs_1/datadict/processlist_priv.inc
index ae46dfd31c8..99a4340c571 100644
--- a/mysql-test/suite/funcs_1/datadict/processlist_priv.inc
+++ b/mysql-test/suite/funcs_1/datadict/processlist_priv.inc
@@ -156,6 +156,7 @@ WHERE DB = 'information_schema' AND COMMAND = 'Sleep' AND USER = 'ddicttestuser1
--source include/wait_condition.inc
--replace_result ENGINE=MyISAM "" ENGINE=Aria "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" ""
eval SHOW CREATE TABLE $table;
+--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
eval SHOW $table;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID
@@ -176,6 +177,7 @@ connection con100;
# but "ddicttestuser1" must not see anything of the root session.
--replace_result ENGINE=MyISAM "" ENGINE=Aria "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" ""
eval SHOW CREATE TABLE $table;
+--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
eval SHOW $table;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID
@@ -202,6 +204,7 @@ GRANT PROCESS ON *.* TO ddicttestuser1@'localhost' IDENTIFIED BY 'ddictpass';
--echo ####################################################################################
connection con100;
SHOW GRANTS;
+--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID
@@ -214,6 +217,7 @@ SELECT * FROM information_schema.processlist;
--echo ####################################################################################
connect (con101,localhost,ddicttestuser1,ddictpass,information_schema);
SHOW GRANTS;
+--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID
@@ -237,6 +241,7 @@ GRANT PROCESS ON *.* TO ''@'localhost';
--echo ####################################################################################
connect (anonymous1,localhost,"''",,information_schema);
SHOW GRANTS;
+--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID
@@ -259,6 +264,7 @@ connect (con102,localhost,ddicttestuser1,ddictpass,information_schema);
--echo ddicttestuser1 are visible.
--echo ####################################################################################
SHOW GRANTS;
+--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID
@@ -284,6 +290,7 @@ SHOW GRANTS FOR ''@'localhost';
if ($fixed_bug_30395)
{
# 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
SHOW processlist;
}
@@ -306,6 +313,7 @@ connect (con103,localhost,ddicttestuser1,ddictpass,information_schema);
--echo Only the processes of ddicttestuser1 user are visible.
--echo ####################################################################################
SHOW GRANTS FOR 'ddicttestuser1'@'localhost';
+--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID
@@ -328,6 +336,7 @@ connect (con104,localhost,ddicttestuser1,ddictpass,information_schema);
--echo Only the processes of ddicttestuser1 are visible.
--echo ####################################################################################
SHOW GRANTS FOR 'ddicttestuser1'@'localhost';
+--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID
@@ -375,6 +384,7 @@ connect (con200,localhost,ddicttestuser2,ddictpass,information_schema);
--echo ddicttestuser2 has now the PROCESS privilege and sees all connections
--echo ####################################################################################
SHOW GRANTS FOR 'ddicttestuser2'@'localhost';
+--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 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 ####################################################################################
SHOW GRANTS;
+--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID
@@ -419,6 +430,7 @@ connect (con107,localhost,ddicttestuser1,ddictpass,information_schema);
SHOW GRANTS FOR 'ddicttestuser1'@'localhost';
--error ER_ACCESS_DENIED_ERROR
GRANT PROCESS ON *.* TO 'ddicttestuser2'@'localhost';
+--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 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 ####################################################################################
SHOW GRANTS FOR 'ddicttestuser1'@'localhost';
+--replace_result Execute Query
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS
SHOW processlist;
--replace_column 1 ID 3 HOST_NAME 6 TIME 9 TIME_MS 13 MEMORY 14 MAX_MEMORY 15 ROWS 16 QUERY_ID 18 TID
diff --git a/mysql-test/suite/funcs_1/datadict/processlist_val.inc b/mysql-test/suite/funcs_1/datadict/processlist_val.inc
index 24f3eb76a1c..fa6ed4049d6 100644
--- a/mysql-test/suite/funcs_1/datadict/processlist_val.inc
+++ b/mysql-test/suite/funcs_1/datadict/processlist_val.inc
@@ -94,6 +94,7 @@ echo
# 1. Just dump what we get
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <MAX_MEMORY> 15 <ROWS> 16 <QUERY_ID> 18 <TID>
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>
SHOW FULL PROCESSLIST;
#
@@ -161,6 +162,7 @@ let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
# 1. Just dump what we get
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 7 <STATE> 9 <TIME_MS> 13 <MEMORY> 14 <MAX_MEMORY> 15 <ROWS> 16 <QUERY_ID> 18 <TID>
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+--replace_result Execute Query
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
SHOW FULL PROCESSLIST;
#
@@ -203,6 +205,7 @@ echo
connection con1;
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <MAX_MEMORY> 15 <ROWS> 16 <QUERY_ID> 18 <TID>
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+--replace_result Execute Query
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
SHOW FULL PROCESSLIST;
@@ -228,6 +231,7 @@ connection con2;
# Just dump what we get
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <MAX_MEMORY> 15 <ROWS> 16 <QUERY_ID> 18 <TID>
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+--replace_result Execute Query
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
SHOW FULL PROCESSLIST;
#
@@ -279,6 +283,7 @@ WHERE ID = @test_user_con2_id AND Command IN('Query','Execute')
# 1. Just dump what we get
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME> 9 <TIME_MS> 13 <MEMORY> 14 <MAX_MEMORY> 15 <ROWS> 16 <QUERY_ID> 18 <TID>
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+--replace_result Execute Query
--replace_column 1 <ID> 3 <HOST_NAME> 6 <TIME>
SHOW FULL PROCESSLIST;
#
@@ -385,8 +390,10 @@ echo
;
--replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE> 9 <TIME_MS> 13 <MEMORY> 14 <MAX_MEMORY> 15 <ROWS> 16 <QUERY_ID> 18 <TID>
SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST;
+--replace_result Execute Query
--replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE>
SHOW FULL PROCESSLIST;
+--replace_result Execute Query
--replace_column 1 <ID> 3 <HOST_NAME> 5 <COMMAND> 6 <TIME> 7 <STATE>
SHOW PROCESSLIST;
UNLOCK TABLES;
diff --git a/mysql-test/suite/handler/ps.test b/mysql-test/suite/handler/ps.test
index 68091190c85..783d862435e 100644
--- a/mysql-test/suite/handler/ps.test
+++ b/mysql-test/suite/handler/ps.test
@@ -7,5 +7,7 @@ flush status;
handler handler_a read first;
# handler...read must be prepared in --ps-protocol mode
--replace_result $PS_PROTOCOL OK
+--disable_ps_protocol
show status like 'Com_stmt_prepare%';
+--enable_ps_protocol
drop table t1;
diff --git a/mysql-test/suite/innodb/t/innodb-corrupted-table.test b/mysql-test/suite/innodb/t/innodb-corrupted-table.test
index 5d8e2bd1eda..d1384d20c7b 100644
--- a/mysql-test/suite/innodb/t/innodb-corrupted-table.test
+++ b/mysql-test/suite/innodb/t/innodb-corrupted-table.test
@@ -34,6 +34,7 @@ alter table t1 add primary key (pk);
--enable_reconnect
--source include/wait_until_connected_again.inc
+--enable_prepare_warnings
show create table t1;
select * from t1;
alter table t1 add j int;
diff --git a/mysql-test/suite/sys_vars/t/max_prepared_stmt_count_func.test b/mysql-test/suite/sys_vars/t/max_prepared_stmt_count_func.test
index 6617c4ad2ea..c37fc7ab114 100644
--- a/mysql-test/suite/sys_vars/t/max_prepared_stmt_count_func.test
+++ b/mysql-test/suite/sys_vars/t/max_prepared_stmt_count_func.test
@@ -19,7 +19,7 @@
# option_mysqld_max_prepared_stmt_count #
# #
################################################################################
-
+--source include/no_protocol.inc
--echo ** Setup **
--echo
diff --git a/mysql-test/suite/sys_vars/t/sql_buffer_result_func.test b/mysql-test/suite/sys_vars/t/sql_buffer_result_func.test
index 0f6084b65f6..380f2568b9c 100644
--- a/mysql-test/suite/sys_vars/t/sql_buffer_result_func.test
+++ b/mysql-test/suite/sys_vars/t/sql_buffer_result_func.test
@@ -46,17 +46,23 @@ INSERT INTO t1 VALUES('aa','bb');
SET SESSION sql_buffer_result = 1;
+--disable_ps_protocol
SHOW STATUS LIKE 'Created_tmp_tables';
+--enable_ps_protocol
--echo Expected value : 0.
SELECT * FROM t1;
+--disable_ps_protocol
SHOW STATUS LIKE 'Created_tmp_tables';
+--enable_ps_protocol
--echo Expected value : 1.
SELECT * FROM t1;
+--disable_ps_protocol
SHOW STATUS LIKE 'Created_tmp_tables';
+--enable_ps_protocol
--echo Expected value : 2.
--echo '#--------------------FN_DYNVARS_156_02-------------------------#'
@@ -66,12 +72,16 @@ SHOW STATUS LIKE 'Created_tmp_tables';
SET SESSION sql_buffer_result = 0;
+--disable_ps_protocol
SHOW STATUS LIKE 'Created_tmp_tables';
+--enable_ps_protocol
--echo Expected value : 2.
SELECT * FROM t1;
+--disable_ps_protocol
SHOW STATUS LIKE 'Created_tmp_tables';
+--enable_ps_protocol
--echo Expected value : 2.
--echo '#--------------------FN_DYNVARS_156_03-------------------------#'
diff --git a/mysql-test/suite/vcol/t/wrong_arena.test b/mysql-test/suite/vcol/t/wrong_arena.test
index 3d65dac9219..8ac1af5c36b 100644
--- a/mysql-test/suite/vcol/t/wrong_arena.test
+++ b/mysql-test/suite/vcol/t/wrong_arena.test
@@ -14,7 +14,9 @@ create table t1 (a datetime,
# other issues
e int as ((a,1) in ((1,1),(2,1),(NULL,1))) # cmp_item_row::alloc_comparators()
);
+enable_prepare_warnings;
show create table t1;
+disable_prepare_warnings;
connect con1, localhost, root;
disable_warnings;
insert t1 (a) values ('2010-10-10 10:10:10');
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 19d742691e1..0e0349edb28 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -8262,59 +8262,70 @@ static bool print_grants_for_role(THD *thd, ACL_ROLE * role)
}
-/** checks privileges for SHOW GRANTS and SHOW CREATE USER
+/** get the user/host/role name for SHOW GRANTS and SHOW CREATE USER
@note that in case of SHOW CREATE USER the parser guarantees
that a role can never happen here, so *rolename will never
be assigned to
*/
-static bool check_show_access(THD *thd, LEX_USER *lex_user,
- const char **username,
- const char **hostname, const char **rolename)
+bool get_show_user(THD *thd, LEX_USER *lex_user, const char **username,
+ const char **hostname, const char **rolename)
{
- DBUG_ENTER("check_show_access");
+ DBUG_ENTER("get_show_user");
+ Security_context *sctx= thd->security_ctx;
if (lex_user->user.str == current_user.str)
{
- *username= thd->security_ctx->priv_user;
- *hostname= thd->security_ctx->priv_host;
+ *username= sctx->priv_user;
+ *hostname= sctx->priv_host;
+ DBUG_RETURN(false);
}
- else if (lex_user->user.str == current_role.str)
+ if (lex_user->user.str == current_role.str)
{
- *rolename= thd->security_ctx->priv_role;
+ *rolename= sctx->priv_role;
+ DBUG_RETURN(false);
}
- else if (lex_user->user.str == current_user_and_current_role.str)
+ 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;
+ *username= sctx->priv_user;
+ *hostname= sctx->priv_host;
+ *rolename= sctx->priv_role;
+ DBUG_RETURN(false);
}
- else
+
+ if (!(lex_user= get_current_user(thd, lex_user)))
{
- Security_context *sctx= thd->security_ctx;
- bool do_check_access;
+ *username= *rolename= NULL;
+ DBUG_RETURN(false);
+ }
- lex_user= get_current_user(thd, lex_user);
- if (!lex_user)
- DBUG_RETURN(TRUE);
+ if (lex_user->is_role())
+ {
+ *rolename= lex_user->user.str;
+ DBUG_RETURN(strcmp(*rolename, sctx->priv_role));
+ }
- 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);
- }
+ *username= lex_user->user.str;
+ *hostname= lex_user->host.str;
+ DBUG_RETURN(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_RETURN(FALSE);
+/** checks privileges for SHOW GRANTS and SHOW CREATE USER
+*/
+static bool check_show_access(THD *thd, LEX_USER *lex_user,
+ const char **username, const char **hostname,
+ const char **rolename)
+{
+ DBUG_ENTER("check_show_access");
+ bool do_check_access=
+ get_show_user(thd, lex_user, username, hostname, rolename);
+
+ if (!*username && !*rolename)
+ DBUG_RETURN(1);
+
+ DBUG_RETURN(do_check_access &&
+ check_access(thd, SELECT_ACL, "mysql", 0, 0, 1, 0));
}
bool mysql_show_create_user(THD *thd, LEX_USER *lex_user)
diff --git a/sql/sql_acl.h b/sql/sql_acl.h
index 6da7d4d5db4..5c4a4d09e6d 100644
--- a/sql/sql_acl.h
+++ b/sql/sql_acl.h
@@ -258,6 +258,8 @@ void mysql_show_grants_get_fields(THD *thd, List<Item> *fields,
const char *name, size_t length);
bool mysql_show_grants(THD *thd, LEX_USER *user);
bool mysql_show_create_user(THD *thd, LEX_USER *user);
+bool get_show_user(THD *thd, LEX_USER *lex_user, const char **username,
+ const char **hostname, const char **rolename);
int fill_schema_enabled_roles(THD *thd, TABLE_LIST *tables, COND *cond);
int fill_schema_applicable_roles(THD *thd, TABLE_LIST *tables, COND *cond);
void get_privilege_desc(char *to, uint max_length, ulong access);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index a4ecdfb1297..1bc0bac99c8 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -2584,17 +2584,15 @@ CHANGED_TABLE_LIST* THD::changed_table_dup(const char *key, size_t key_length)
}
-void THD::prepare_explain_fields(select_result *result,
- List<Item> *field_list,
- uint8 explain_flags,
- bool is_analyze)
+int THD::prepare_explain_fields(select_result *result, List<Item> *field_list,
+ uint8 explain_flags, bool is_analyze)
{
if (lex->explain_json)
make_explain_json_field_list(*field_list, is_analyze);
else
make_explain_field_list(*field_list, explain_flags, is_analyze);
- result->prepare(*field_list, NULL);
+ return result->prepare(*field_list, NULL);
}
@@ -2604,8 +2602,8 @@ int THD::send_explain_fields(select_result *result,
{
List<Item> field_list;
int rc;
- prepare_explain_fields(result, &field_list, explain_flags, is_analyze);
- rc= result->send_result_set_metadata(field_list,
+ rc= prepare_explain_fields(result, &field_list, explain_flags, is_analyze)
+ || result->send_result_set_metadata(field_list,
Protocol::SEND_NUM_ROWS |
Protocol::SEND_EOF);
return(rc);
@@ -2683,7 +2681,7 @@ void THD::make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
if (is_analyze)
{
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);
item->maybe_null=1;
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 70781296d1b..c8818424853 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -3792,8 +3792,8 @@ public:
void add_changed_table(TABLE *table);
void add_changed_table(const char *key, size_t key_length);
CHANGED_TABLE_LIST * changed_table_dup(const char *key, size_t key_length);
- void prepare_explain_fields(select_result *result, List<Item> *field_list,
- uint8 explain_flags, bool is_analyze);
+ int prepare_explain_fields(select_result *result, List<Item> *field_list,
+ uint8 explain_flags, bool is_analyze);
int send_explain_fields(select_result *result, uint8 explain_flags,
bool is_analyze);
void make_explain_field_list(List<Item> &field_list, uint8 explain_flags,
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 8d93233783f..ef45ef7943c 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3745,12 +3745,14 @@ mysql_execute_command(THD *thd)
case SQLCOM_SHOW_PROFILE:
case SQLCOM_SELECT:
{
-#ifdef WITH_WSREP
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
- WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW)
-#endif /* WITH_WSREP */
+ {
+ 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;
@@ -4491,48 +4493,7 @@ end_with_restore_list:
DBUG_PRINT("debug", ("lex->only_view: %d, table: %s.%s",
lex->table_type == TABLE_TYPE_VIEW,
first_table->db.str, first_table->table_name.str));
- if (lex->table_type == TABLE_TYPE_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.str);
- 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 (thd->open_temporary_tables(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.str);
- goto error;
- }
- }
-
- /* Access is granted. Execute the command. */
res= mysqld_show_create(thd, first_table);
break;
#endif
@@ -4885,7 +4846,7 @@ end_with_restore_list:
case SQLCOM_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);
if (WSREP_CLIENT(thd) &&
wsrep_sync_wait(thd, WSREP_SYNC_WAIT_BEFORE_UPDATE_DELETE))
@@ -4916,16 +4877,15 @@ end_with_restore_list:
}
else
{
- if (!(sel_result= lex->result) &&
- !(sel_result= new (thd->mem_root) select_send(thd)))
- return 1;
+ if (!lex->result && !(sel_result= new (thd->mem_root) select_send(thd)))
+ goto error;
}
}
res = mysql_delete(thd, all_tables,
select_lex->where, &select_lex->order_list,
unit->select_limit_cnt, select_lex->options,
- sel_result);
+ lex->result ? lex->result : sel_result);
if (replaced_protocol)
{
@@ -7089,7 +7049,7 @@ static bool check_show_access(THD *thd, TABLE_LIST *table)
Check_grant will grant access if there is any column privileges on
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 */
close_thread_tables(thd);
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 8a627662206..4b27c502d88 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1901,8 +1901,19 @@ static int mysql_test_show_grants(Prepared_statement *stmt)
DBUG_ENTER("mysql_test_show_grants");
THD *thd= stmt->thd;
List<Item> fields;
+ char buff[1024];
+ const char *username= NULL, *hostname= NULL, *rolename= NULL, *end;
- mysql_show_grants_get_fields(thd, &fields, STRING_WITH_LEN("Grants for"));
+ get_show_user(thd, thd->lex->grant_user, &username, &hostname, &rolename);
+
+ if (username)
+ end= strxmov(buff,"Grants for ",username,"@",hostname, NullS);
+ else if (rolename)
+ end= strxmov(buff,"Grants for ",rolename, NullS);
+ else
+ DBUG_RETURN(1);
+
+ mysql_show_grants_get_fields(thd, &fields, buff, end - buff);
DBUG_RETURN(send_stmt_metadata(thd, stmt, &fields));
}
#endif /*NO_EMBEDDED_ACCESS_CHECKS*/
@@ -1926,7 +1937,7 @@ static int mysql_test_show_slave_status(Prepared_statement *stmt)
THD *thd= stmt->thd;
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));
}
@@ -2466,6 +2477,7 @@ static bool check_prepared_statement(Prepared_statement *stmt)
case SQLCOM_CREATE_INDEX:
case SQLCOM_DROP_INDEX:
case SQLCOM_ROLLBACK:
+ case SQLCOM_ROLLBACK_TO_SAVEPOINT:
case SQLCOM_TRUNCATE:
case SQLCOM_DROP_VIEW:
case SQLCOM_REPAIR:
@@ -2495,6 +2507,7 @@ static bool check_prepared_statement(Prepared_statement *stmt)
case SQLCOM_GRANT:
case SQLCOM_GRANT_ROLE:
case SQLCOM_REVOKE:
+ case SQLCOM_REVOKE_ALL:
case SQLCOM_REVOKE_ROLE:
case SQLCOM_KILL:
case SQLCOM_COMPOUND:
@@ -2527,9 +2540,9 @@ static bool check_prepared_statement(Prepared_statement *stmt)
!(lex->result= new (stmt->mem_root) select_send(thd)))
DBUG_RETURN(TRUE);
List<Item> field_list;
- thd->prepare_explain_fields(lex->result, &field_list,
- lex->describe, lex->analyze_stmt);
- res= send_prep_stmt(stmt, lex->result->field_count(field_list)) ||
+ res= thd->prepare_explain_fields(lex->result, &field_list,
+ lex->describe, lex->analyze_stmt) ||
+ send_prep_stmt(stmt, lex->result->field_count(field_list)) ||
lex->result->send_result_set_metadata(field_list,
Protocol::SEND_EOF);
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index b98f8aabdc1..8d3ae958b0f 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1238,13 +1238,55 @@ mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list,
List<Item> *field_list, String *buffer)
{
bool error= TRUE;
+ LEX *lex= thd->lex;
MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("mysqld_show_create_get_fields");
DBUG_PRINT("enter",("db: %s table: %s",table_list->db.str,
table_list->table_name.str));
+ if (lex->table_type == TABLE_TYPE_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.str);
+ 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 (thd->open_temporary_tables(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.str);
+ goto exit;
+ }
+ }
+
/* We want to preserve the tree for views. */
- thd->lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
+ lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
{
/*
@@ -1259,20 +1301,20 @@ mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list,
bool open_error=
open_tables(thd, &table_list, &counter,
MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL) ||
- mysql_handle_derived(thd->lex, DT_INIT | DT_PREPARE);
+ mysql_handle_derived(lex, DT_INIT | DT_PREPARE);
thd->pop_internal_handler();
if (unlikely(open_error && (thd->killed || thd->is_error())))
goto exit;
}
/* TODO: add environment variables show when it become possible */
- if (thd->lex->table_type == TABLE_TYPE_VIEW && !table_list->view)
+ if (lex->table_type == TABLE_TYPE_VIEW && !table_list->view)
{
my_error(ER_WRONG_OBJECT, MYF(0),
table_list->db.str, table_list->table_name.str, "VIEW");
goto exit;
}
- else if (thd->lex->table_type == TABLE_TYPE_SEQUENCE &&
+ else if (lex->table_type == TABLE_TYPE_SEQUENCE &&
table_list->table->s->table_type != TABLE_TYPE_SEQUENCE)
{
my_error(ER_NOT_SEQUENCE, MYF(0),
@@ -1287,7 +1329,7 @@ mysqld_show_create_get_fields(THD *thd, TABLE_LIST *table_list,
if ((table_list->view ?
show_create_view(thd, table_list, buffer) :
- thd->lex->table_type == TABLE_TYPE_SEQUENCE ?
+ lex->table_type == TABLE_TYPE_SEQUENCE ?
show_create_sequence(thd, table_list, buffer) :
show_create_table(thd, table_list, buffer, NULL, WITHOUT_DB_NAME)))
goto exit;
diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc
index 0e4caae7a2f..71a749dd4a8 100644
--- a/sql/sql_tvc.cc
+++ b/sql/sql_tvc.cc
@@ -230,16 +230,16 @@ bool table_value_constr::prepare(THD *thd, SELECT_LEX *sl,
if (fix_fields_for_tvc(thd, li))
DBUG_RETURN(true);
- if (!(holders= new (thd->mem_root)
- Type_holder[cnt]) ||
- join_type_handlers_for_tvc(thd, li, holders,
- cnt) ||
+ if (!(holders= new (thd->stmt_arena->mem_root) Type_holder[cnt]) ||
+ join_type_handlers_for_tvc(thd, li, holders, cnt) ||
get_type_attributes_for_tvc(thd, li, holders,
lists_of_values.elements, cnt))
DBUG_RETURN(true);
List_iterator_fast<Item> it(*first_elem);
Item *item;
+ Query_arena *arena, backup;
+ arena= thd->activate_stmt_arena_if_needed(&backup);
sl->item_list.empty();
for (uint pos= 0; (item= it++); pos++)
@@ -253,6 +253,8 @@ bool table_value_constr::prepare(THD *thd, SELECT_LEX *sl,
holders[pos].get_maybe_null());
sl->item_list.push_back(new_holder);
}
+ if (arena)
+ thd->restore_active_arena(arena, &backup);
if (unlikely(thd->is_fatal_error))
DBUG_RETURN(true); // out of memory
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index f2fc4b6bf75..31d53111e0a 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -329,12 +329,11 @@ bool create_view_precheck(THD *thd, TABLE_LIST *tables, TABLE_LIST *view,
{
if (!tbl->table_in_first_from_clause)
{
- if (check_access(thd, SELECT_ACL, tbl->db.str,
- &tbl->grant.privilege,
- &tbl->grant.m_internal,
- 0, 0) ||
- check_grant(thd, SELECT_ACL, tbl, FALSE, 1, FALSE))
+ if (check_single_table_access(thd, SELECT_ACL, tbl, FALSE))
+ {
+ tbl->hide_view_error(thd);
goto err;
+ }
}
}
}