diff options
author | Sergei Golubchik <serg@mariadb.org> | 2019-03-15 20:00:28 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2019-03-15 21:00:41 +0100 |
commit | 0508d327aef520d3131ff8a85ed610337149fffc (patch) | |
tree | 7e04769f49b4aded9053adcad442fe00eb487d98 /sql/sql_prepare.cc | |
parent | bb8c82c66abddf796e8d44f817518e5ab38ae6e4 (diff) | |
parent | 34db9958e28c325b0f708f78b7ff029de810d5ea (diff) | |
download | mariadb-git-0508d327aef520d3131ff8a85ed610337149fffc.tar.gz |
Merge branch '10.1' into 10.2
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r-- | sql/sql_prepare.cc | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 272d6615028..f99dc237cd0 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1957,9 +1957,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; - 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)); } #endif /*NO_EMBEDDED_ACCESS_CHECKS*/ @@ -1983,7 +1994,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)); } @@ -2499,6 +2510,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: @@ -2527,6 +2539,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: @@ -2550,8 +2563,26 @@ static bool check_prepared_statement(Prepared_statement *stmt) break; } if (res == 0) - DBUG_RETURN(stmt->is_sql_prepare() ? - FALSE : (send_prep_stmt(stmt, 0) || thd->protocol->flush())); + { + if (!stmt->is_sql_prepare()) + { + if (lex->describe || lex->analyze_stmt) + { + select_send result(thd); + List<Item> 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 + res= send_prep_stmt(stmt, 0); + if (!res) + thd->protocol->flush(); + } + DBUG_RETURN(FALSE); + } error: DBUG_RETURN(TRUE); } |