From: Tor Didriksen Date: October 1 2010 8:48am Subject: bzr commit into mysql-next-mr-bugfixing branch (tor.didriksen:3310) WL#5208 List-Archive: http://lists.mysql.com/commits/119605 Message-Id: <20101001084816.04131372C@atum07.norway.sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4817082321875575528==" --===============4817082321875575528== 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:luis.soares@stripped 3310 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-28 15:30:47 +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, @@ -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-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 @@ -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 --===============4817082321875575528== 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\ # 0khfs97qjqa9wlnk # target_branch: file:///export/home/didrik/repo/next-mr-bf-wl5208-\ # explain/ # testament_sha1: e2a9fa966a471398f30b7af1b725005767e117f4 # timestamp: 2010-10-01 10:48:15 +0200 # base_revision_id: luis.soares@stripped\ # k04pqy3nk9xf8vht # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWaw6Aj8AA59/gFIwEAB99/// f6ff5L////pgCC3vN23fd2+NKw5892p2177NdHvU1q26CSRATQA1HoTAp5QZNPaoPUbU02oPUaaP SaNqepoMkET0wmRqZJo0IaPUGgAyDQAAAGgymjQmTSaeoQNTxE2p6jRiMnqYgaAAeoAAkSJojRGm Kfqj0xENDaE000aAaNAANBpoDakmjSPIk9U80U9qaYkeU2oeiPUeoA0ANDQAAkkE0BMCNTExGUZT 1P0KaMnqAAeoAABEoWAGJ2PAyB6sl7OQM0XdQ9Np3Y9vYTeJqkqTDeDmZRhtLDByZxOIadOldU9O xACEUPhd23dy5I0e1k4NWmDOlluEBMB0trZKZMCw7mOT+9H5hPj6cywVPp3N/G4D6nbGDaBu1Klb jnSNalo9I87MzWh7N6cQXirPplXfelk7YCGQ2w1pdHMutgB3Gq7Vz34rXIyfqZYoduSRy7264cWh 4pRZ6GZu7MbO1gORwb7hUYlU3OZCNSCvEE1iOSy0Vi5Ainkyw5M882KjFfMpW0R8s8D/Q7jRI453 iJ0sq+z4hkhjC9wEjwvT+Nlt/qMmnarG+Pf0UY8KJt8K4onXz2RXLIWbbxqUB7Bai8afG8Vkjo1L ReXYQFpKzEgx0iV9tpDmaNFTyomh10ctD4JJzljqN0LTbTKyuoeipA4YOi5IehydkWTHImtnKJAX 9jjYZqZusxtTdKoAonTUrE1UgKlFclAlNRXY8BXVZVg5ol6PwFgjDijEtUNaCWsNtkwhCmjRd+5K OsCYRQyJ4x6XAj54/WwZmPsenPoVqCU+A17CBpIDx3QiAI/9Pm4BMTODzQLky7NDHKm6sM4IB4YM 6B87slsBdWyg1Kg5BPUCpATeKhgU0Vr/jiW6lEC5TmDW5odEWv5DfMLKCFGQui4Z2kPERO2kVNs1 KWoaFTlhrtBAQsC4792OfMquiKOaQIYcov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9eomlf6OG6n29BoZmG CujPqU6HWDHftqUneruVZlXyAZs9UwsiqnOUg2G/5wJ8COTu+dIy4mQwM2xkmV4cgzJpOUoBIXWp 0kb5LBCY7WCTlG33rV4TkcRdfVeBuxQYd166L8kllx6hBgebXGmlMszjAl61UkD2kpuFtfb6c3+P 4UPnCc4WZW25YIWeBsgBk0mbilVIYiZEkiJK8q1gUzMyROJknHhKaYVQCiNpMsoaxsRefUVuLwDY NSWbdHLcUkgtwW3ZDAwQrMThita4Zar68xA7lSF/hDC1WENbyuYEo6MKSw6an5XJkONsckcuxKcB NRRn4c+0lKvUwMhVHCxZgEtm8rZJQQuioo9gvWnqSpv1hi8Q41Hk2xPDUxKYQcLCNs+ZQcFTD9lB MpUsu2CpWeaWIYgTwjgYErimDHQ2Rp9GHgqohjQaN7ERJd5sbwyWUCYYKLYRFPVjuIFbhYscnykK ZRSjpNq2tfc53N2hG84AWG5xnrRhFbcqSHyVq+t4s7GLHfue0NasykxSnCqOCgVyDrmJdxCh2vx6 RkMyxBnWTnCI7qbfiVXh7klAEtC0DKC39QVpkcDMhzCk5LBZKcyULSBcRLNzQ/eQcBaddOdTLCp7 9BWtqDzLljFnalNnUQ/H0AprnmzUcfEb+UyVRJDgF7WRK7awaS8Oewa8ZHk4RdYdARzG43HGT06I Wlasvl60uWZmZeL/i7kinChIVh0BH4A= --===============4817082321875575528==--