From: Tor Didriksen Date: September 13 2010 1:12pm Subject: bzr commit into mysql-next-mr-bugfixing branch (tor.didriksen:3286) WL#5208 List-Archive: http://lists.mysql.com/commits/118080 Message-Id: <20100913131242.85CF5354D@atum07.norway.sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8421331596224147790==" --===============8421331596224147790== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///export/home/didrik/repo/next-mr-bf-wl5208-explain/ based on revid:tor.didriksen@stripped 3286 Tor Didriksen 2010-09-13 WL#5208 Add --explain-protocol to mysql/MTR This is a simplified version, compared to the description in the worklog. We add a new --explain-protocol option, which makes mtr re-run all SELECT queries with 'EXPLAIN EXTENDED' prepended. @ client/mysqltest.cc Adds explain-protocol option. @ mysql-test/mysql-test-run.pl Adds explain-protocol option. modified: client/mysqltest.cc mysql-test/mysql-test-run.pl === modified file 'client/mysqltest.cc' --- a/client/mysqltest.cc 2010-09-08 07:10:51 +0000 +++ b/client/mysqltest.cc 2010-09-13 13:12:38 +0000 @@ -87,7 +87,7 @@ enum { OPT_PS_PROTOCOL=OPT_MAX_CLIENT_OPTION, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL, OPT_MAX_CONNECT_RETRIES, OPT_MAX_CONNECTIONS, OPT_MARK_PROGRESS, OPT_LOG_DIR, - OPT_TAIL_LINES, OPT_RESULT_FORMAT_VERSION + OPT_TAIL_LINES, OPT_RESULT_FORMAT_VERSION, OPT_EXPLAIN_PROTOCOL }; static int record= 0, opt_sleep= -1; @@ -107,6 +107,7 @@ static my_bool opt_mark_progress= 0; static my_bool ps_protocol= 0, ps_protocol_enabled= 0; static my_bool sp_protocol= 0, sp_protocol_enabled= 0; static my_bool view_protocol= 0, view_protocol_enabled= 0; +static my_bool explain_protocol= 0, explain_protocol_enabled= 0; static my_bool cursor_protocol= 0, cursor_protocol_enabled= 0; static my_bool parsing_disabled= 0; static my_bool display_result_vertically= FALSE, display_result_lower= FALSE, @@ -6158,6 +6159,9 @@ static struct my_option my_long_options[ {"view-protocol", OPT_VIEW_PROTOCOL, "Use views for select.", &view_protocol, &view_protocol, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"explain-protocol", OPT_EXPLAIN_PROTOCOL, "Explains all select.", + &explain_protocol, &explain_protocol, 0, + GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"connect_timeout", OPT_CONNECT_TIMEOUT, "Number of seconds before connection timeout.", &opt_connect_timeout, &opt_connect_timeout, 0, GET_UINT, REQUIRED_ARG, @@ -7630,6 +7634,35 @@ void run_query(struct st_connection *cn, DBUG_VOID_RETURN; } + +void run_explain(struct st_connection *cn, struct st_command *command, int flags) +{ + if (explain_protocol_enabled && + !command->expected_errors.count && + match_re(&view_re, command->query)) + { + st_command save_command= *command; + DYNAMIC_STRING query_str; + DYNAMIC_STRING ds_warning_messages; + + init_dynamic_string(&ds_warning_messages, "", 0, 2048); + init_dynamic_string(&query_str, "EXPLAIN EXTENDED ", 256, 256); + dynstr_append_mem(&query_str, command->query, + command->end - command->query); + command->query= query_str.str; + command->query_len= query_str.length; + command->end= strend(command->query); + + run_query(cn, command, flags); + + dynstr_free(&query_str); + dynstr_free(&ds_warning_messages); + + *command= save_command; + } +} + + /****************************************************************************/ /* Functions to detect different SQL statements @@ -8028,6 +8061,7 @@ int main(int argc, char **argv) var_set_int("$PS_PROTOCOL", ps_protocol); var_set_int("$SP_PROTOCOL", sp_protocol); var_set_int("$VIEW_PROTOCOL", view_protocol); + var_set_int("$EXPLAIN_PROTOCOL", explain_protocol); var_set_int("$CURSOR_PROTOCOL", cursor_protocol); DBUG_PRINT("info",("result_file: '%s'", @@ -8050,6 +8084,7 @@ int main(int argc, char **argv) ps_protocol_enabled= ps_protocol; sp_protocol_enabled= sp_protocol; view_protocol_enabled= view_protocol; + explain_protocol_enabled= explain_protocol; cursor_protocol_enabled= cursor_protocol; /* Cursor protcol implies ps protocol */ if (cursor_protocol_enabled) @@ -8282,6 +8317,7 @@ int main(int argc, char **argv) save_file[0]= 0; } run_query(cur_con, command, flags); + run_explain(cur_con, command, flags); command_executed++; command->last_argument= command->end; === modified file 'mysql-test/mysql-test-run.pl' --- a/mysql-test/mysql-test-run.pl 2010-09-01 13:46:08 +0000 +++ b/mysql-test/mysql-test-run.pl 2010-09-13 13:12:38 +0000 @@ -171,6 +171,7 @@ my $opt_ps_protocol; my $opt_sp_protocol; my $opt_cursor_protocol; my $opt_view_protocol; +my $opt_explain_protocol; our $opt_debug; our @opt_cases; # The test cases names in argv @@ -841,6 +842,7 @@ sub command_line_setup { 'ps-protocol' => \$opt_ps_protocol, 'sp-protocol' => \$opt_sp_protocol, 'view-protocol' => \$opt_view_protocol, + 'explain-protocol' => \$opt_explain_protocol, 'cursor-protocol' => \$opt_cursor_protocol, 'ssl|with-openssl' => \$opt_ssl, 'skip-ssl' => \$opt_skip_ssl, @@ -5022,6 +5024,11 @@ sub start_mysqltest ($) { mtr_add_arg($args, "--sp-protocol"); } + if ( $opt_explain_protocol ) + { + mtr_add_arg($args, "--explain-protocol"); + } + if ( $opt_view_protocol ) { mtr_add_arg($args, "--view-protocol"); @@ -5448,6 +5455,7 @@ Options to control what engine/variation cursor-protocol Use the cursor protocol between client and server (implies --ps-protocol) view-protocol Create a view to execute all non updating queries + explain-protocol Run 'EXPLAIN EXTENDED' on all SELECT queries sp-protocol Create a stored procedure to execute all queries compress Use the compressed protocol between client and server ssl Use ssl protocol between client and server --===============8421331596224147790== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/tor.didriksen@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: tor.didriksen@stripped\ # obpvblj5kb40ydvr # target_branch: file:///export/home/didrik/repo/next-mr-bf-wl5208-\ # explain/ # testament_sha1: ffae7b5d3e7884215f5b2cb3e7437a8a13a69626 # tim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