From: Jon Olav Hauglid Date: June 21 2011 7:57am Subject: bzr commit into mysql-trunk branch (jon.hauglid:3224) Bug#12661349 List-Archive: http://lists.mysql.com/commits/139548 X-Bug: 12661349 Message-Id: <201106210757.p5L7vsFJ014867@acsmt357.oracle.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1283836419955256886==" --===============1283836419955256886== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///export/home/x/mysql-trunk-bug12661349/ based on revid:dmitry.lenev@stripped 3224 Jon Olav Hauglid 2011-06-21 Bug#12661349 Assert in protocol::end_statement The triggered assert checks that either OK or an error is sent to the client after a command has been processed by the server. It was triggered in this case if the client used binary protocol and the connection was killed during prepare. On release builds, the consequence of the bug was that OK was sent to the client even if the prepare failed. When processing a SQL command, a check towards end of processing makes sure to report KILL_QUERY error to the client if the connection/command was killed. This check was however not done for binary protocol processing (COM_STMT_PREPARE in this case). This patch fixes the problem by making sure that the KILL_QUERY error is sent to the client in these cases as well. Test case added to ps.test. modified: mysql-test/r/ps.result mysql-test/t/ps.test sql/sql_class.h sql/sql_parse.cc === modified file 'mysql-test/r/ps.result' --- a/mysql-test/r/ps.result 2011-03-22 12:06:52 +0000 +++ b/mysql-test/r/ps.result 2011-06-21 07:57:31 +0000 @@ -3721,3 +3721,17 @@ FROM (SELECT 1 UNION SELECT 2) t; 2 # # End of 5.5 tests. +# +# Bug#12661349 assert in protocol::end_statement +# +# Note: This test case should be run with --ps-protocol +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (col1 INT); +# Connection con1 +# Connection default +KILL QUERY ; +# Connection con1 +SELECT * FROM t1; +ERROR 70100: Query execution was interrupted +# Connection default +DROP TABLE t1; === modified file 'mysql-test/t/ps.test' --- a/mysql-test/t/ps.test 2011-03-22 12:06:52 +0000 +++ b/mysql-test/t/ps.test 2011-06-21 07:57:31 +0000 @@ -3328,3 +3328,37 @@ FROM (SELECT 1 UNION SELECT 2) t; --echo # End of 5.5 tests. ########################################################################### + + +--echo # +--echo # Bug#12661349 assert in protocol::end_statement +--echo # + +--echo # Note: This test case should be run with --ps-protocol + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (col1 INT); + +--echo # Connection con1 +connect(con1, localhost, root); +let $con1_id= `SELECT CONNECTION_ID()`; + +--echo # Connection default +connection default; +--replace_result $con1_id +eval KILL QUERY $con1_id; + +--echo # Connection con1 +connection con1; +# Here the server asserts when running with "--ps-protocol" +--error ER_QUERY_INTERRUPTED +SELECT * FROM t1; +disconnect con1; +--source include/wait_until_disconnected.inc + +--echo # Connection default +connection default; +DROP TABLE t1; === modified file 'sql/sql_class.h' --- a/sql/sql_class.h 2011-06-16 16:06:32 +0000 +++ b/sql/sql_class.h 2011-06-21 07:57:31 +0000 @@ -2891,7 +2891,7 @@ public: inline void send_kill_message() const { int err= killed_errno(); - if (err) + if (err && !get_stmt_da()->is_set()) { if ((err == KILL_CONNECTION) && !shutdown_in_progress) err = KILL_QUERY; === modified file 'sql/sql_parse.cc' --- a/sql/sql_parse.cc 2011-06-16 16:06:32 +0000 +++ b/sql/sql_parse.cc 2011-06-21 07:57:31 +0000 @@ -1527,6 +1527,8 @@ bool dispatch_command(enum enum_server_c /* Finalize server status flags after executing a command. */ thd->update_server_status(); + if (thd->killed) + thd->send_kill_message(); thd->protocol->end_statement(); query_cache_end_of_result(thd); @@ -4531,10 +4533,7 @@ finish: { /* report error issued during command execution */ if (thd->killed_errno()) - { - if (! thd->get_stmt_da()->is_set()) - thd->send_kill_message(); - } + thd->send_kill_message(); if (thd->killed == THD::KILL_QUERY || thd->killed == THD::KILL_BAD_DATA) { thd->killed= THD::NOT_KILLED; --===============1283836419955256886== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/jon.hauglid@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: jon.hauglid@stripped # target_branch: file:///export/home/x/mysql-trunk-bug12661349/ # testament_sha1: 4d2ea979e8efb49df33cc4958678d94fc9fdb186 # timestamp: 2011-06-21 09:57:42 +0200 # source_branch: file:///export/home/x/mysql-5.5/ # base_revision_id: dmitry.lenev@stripped\ # etqnkczu8doethhl # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWXNo4lgABBbfgFAQfXf//39/ /uD////wYAoPr1e62K8lAdbhbe7gCgAUrpUgcJU1NBNMRkwKaeoaYmgADT1NA09Rpo9QACSRNTDC mI0p6T0EPUekAHqAANAAaANU1P0GiUZPanqjCNDQ9RgBGg0YEaGjQYCRIQITExGpk0D1M0g2UNA0 0yDQDJo0HAMIwmmIYBAMgBhGmTJhGAhoJJCaaaAQ0NAIyTJop4TJAMj0aagD0nqLVJoapV222D3j +EKNanXw2kmYYVZb8PwwaXcWF5LksV66PtsL88os9kQ3sRQ+Vjq+zo47a3jZz9dIU3uBfOgpHpS3 UXydUV8hndajyNr+X26NLccNkypEFWgx+uABzQlyggRKys7gaAyg2xtjDp0JXTt3JyM843ZzlR02 opKNxHK6RbSOpsRovEXkAkqOA+2eoeMeSVodYma7jns8R4QpM9mn03uC/GxmzEoOFxUdVdGOTwyk EYsaJzUCixrKiC2LiHUiwRnYUxqpgCOJK5qBI93WAo2ZySAaRHBEhl6WaKK4kKU4K3WB9D8x5IBo 1X+ocsHWNGNtsSynNieTJzAyRigpQe+7L2CuRxuFC0sLmVsADUotb9UAoxBGsbbGMY28aha3g7+Y 9FdCjXHs4OQs1wNS6kj64a5pFB3OMjYRDxSDcfeekxtXO4F/FBQDG5T5tApLJmKkuoN1aI8LurXw rhsf0wekitXoVFiKSCWsKCEQ5g3SgEVN8AfiEGfYDwwgJEds6j1FCYqkSCxMO9QrLVWgM5cQNNCk pjIcTmiIz1I0cfZxuqp3vMDUyGWwcrsDMoeC3TiibBJILy0E/EuL91SQW1h7oZqrrStU3rlfTI1Y cFzw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