From: Tor Didriksen Date: October 6 2010 11:44am Subject: bzr commit into mysql-next-mr-bugfixing branch (tor.didriksen:3319) WL#5208 List-Archive: http://lists.mysql.com/commits/120109 Message-Id: <20101006114444.77361379F@atum07.norway.sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1056184942144533687==" --===============1056184942144533687== 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:mattias.jonsson@stripped 3319 Tor Didriksen 2010-10-06 WL#5208 Add --explain-protocol to mysql/MTR This is a simplified version, compared to the original 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-28 15:30:47 +0000 +++ b/client/mysqltest.cc 2010-10-06 11:44:39 +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, @@ -6166,6 +6167,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, @@ -7638,6 +7642,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 @@ -8036,6 +8069,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'", @@ -8058,6 +8092,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) @@ -8292,6 +8327,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-28 15:17:29 +0000 +++ b/mysql-test/mysql-test-run.pl 2010-10-06 11:44:39 +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 @@ -852,6 +853,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, @@ -5039,6 +5041,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"); @@ -5465,6 +5472,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 --===============1056184942144533687== 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\ # 49hwxxcdfplya5uc # target_branch: file:///export/home/didrik/repo/next-mr-bf-wl5208-\ # explain/ # testament_sha1: dedbfea8e4081dc752c2aab5bef4ef6c5f94a2ea # timestamp: 2010-10-06 13:44:44 +0200 # base_revision_id: mattias.jonsson@stripped\ # xoa68wy2b5fixyg8 # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWXYJl/QAA4t/gFIwEAB99/// f6ff5L////pgCC6Xd2+73WACe9677Gvfc43e3j2WdL1CRUCZT1GJPaRPaZU9T9JNNNPahhENDQNA PSeo0aAkoJkMjRogTRkE9UyaGgeoAAAAAaDKE8qn4lPCnlPU0A0DQABoAAAGjQAJEhNJiJiniKfq eVH6UPYRTZNT1DIaPUAaAGgDaopk8kjaMpmU0yHqZNDEA0AAAAAAJJCnoJk0J6aU9E/KaNT00maT QGg0aMnqAAZGkijYHtYEBvM/xYGqynhIm5NmKFPPr8PX8Cfie1Mkx/9D2GbBNb5xuMLSS376cb9/ 6wCIoWVycp5ckW47JOe4RyxODbxUoSUKS1vxsIRpGDS15P79O25HvfeovbkUul9ztMh4hg2gbnSk uODsSLsk46x77KWsbqmiiDEU8u2VbntZO+AhkNsMkvZ4rowB6jhq4croqvBgwOdYKExVbImPjSC/ bUTTJLbZlasovXKDRYgk7xUK0Q0PZbdoPpAJ5RtzZDKj0e1191nb5NkuW/k87ifSPn1e70N2olgO SERFJLHrfMMhGMJsxCanVsxNv9QYKq7g3o8uNWBkzW2s5K3m7uwemREQtKLiAKwYLU12+VIqi2R9 RcKVC1UqtCs8QEqCduRWctEmB6dHQLkfECLjLSqJMivXGVuki1yGkgW/JAxMchmphA0LKWl8QMOj TBnBm9mZqbspCCnBWpqaQOyBKEKSitqm6xg3FKNQqqEhWFshc4hyLEQIUxcL4xIIgIg0VnPXAlgm AfTYjQc/hKwBkp33KttTNn+w842GIDZ1/rDOQM0VcHRV4/Gy/Vi9GenHMs5Ykx4zM2sFsrmb22qn MTWIUzUysHNNdf+VFwhfwGnvXPLsT4FlmjFMJ7JXZYG2CJHYsSXVq2xTnNNxerPFrVIpThZz5Y2k uDcgOY3LAecMtcG3Fc734Xq1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