diff options
author | Sergei Golubchik <serg@mariadb.org> | 2019-03-17 13:06:41 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2019-03-17 13:06:41 +0100 |
commit | b64fde8f38515dc39e019de26db7624cc0ea7046 (patch) | |
tree | 0478ea4c3ddeee290f6d381a47efa4f9aded9c0b /sql/sql_prepare.cc | |
parent | a89ee3cd154a67df2231f034fd8339f9225dbe64 (diff) | |
parent | 1f020299f816263e347c852eb2a494b5ef1cbf0d (diff) | |
download | mariadb-git-b64fde8f38515dc39e019de26db7624cc0ea7046.tar.gz |
Merge branch '10.2' into 10.3
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r-- | sql/sql_prepare.cc | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index d83e88a8d13..63fbc9e29f6 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1901,8 +1901,20 @@ 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")); + if (get_show_user(thd, thd->lex->grant_user, &username, &hostname, &rolename)) + DBUG_RETURN(1); + + 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, (uint)(end - buff)); DBUG_RETURN(send_stmt_metadata(thd, stmt, &fields)); } #endif /*NO_EMBEDDED_ACCESS_CHECKS*/ @@ -1926,7 +1938,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)); } @@ -2464,6 +2476,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: @@ -2483,6 +2496,7 @@ static bool check_prepared_statement(Prepared_statement *stmt) case SQLCOM_ALTER_DB_UPGRADE: case SQLCOM_CHECKSUM: case SQLCOM_CREATE_USER: + case SQLCOM_ALTER_USER: case SQLCOM_RENAME_USER: case SQLCOM_DROP_USER: case SQLCOM_CREATE_ROLE: @@ -2492,6 +2506,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: @@ -2520,14 +2535,12 @@ static bool check_prepared_statement(Prepared_statement *stmt) { if (lex->describe || lex->analyze_stmt) { - if (!lex->result && - !(lex->result= new (stmt->mem_root) select_send(thd))) - DBUG_RETURN(TRUE); + select_send result(thd); 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)) || - lex->result->send_result_set_metadata(field_list, + res= thd->prepare_explain_fields(&result, &field_list, + lex->describe, lex->analyze_stmt) || + send_prep_stmt(stmt, result.field_count(field_list)) || + result.send_result_set_metadata(field_list, Protocol::SEND_EOF); } else |