From: Jon Olav Hauglid Date: June 20 2011 1:55pm Subject: bzr commit into mysql-trunk branch (jon.hauglid:3224) Bug#12661349 List-Archive: http://lists.mysql.com/commits/139529 X-Bug: 12661349 Message-Id: <201106201355.p5KDtiJ7005655@acsmt358.oracle.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6244492457345756477==" --===============6244492457345756477== 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-20 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-20 13:55:21 +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-20 13:55:21 +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-20 13:55:21 +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-20 13:55:21 +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_errno()) + 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; --===============6244492457345756477== 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: 039b4d3dc22e29a25c7fa5c5c0f8171f2de30e79 # timestamp: 2011-06-20 15:55:33 +0200 # source_branch: file:///export/home/x/mysql-5.5/ # base_revision_id: dmitry.lenev@stripped\ # etqnkczu8doethhl # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWaeN5ksABCzfgFAQfXf//39/ /uD////wYAoPt7r3rZbUqgKwVsaDqgBkJXTBcNEU9U200o8NGqaPIT2VA0ABkAAaNAANRRp6jIGj I2poAyAA0NAyAAGQAkpTxomUDCKeU0eoaMJ6gB6jI00NAADQJERCaGgNFGUep6m0n4qabTSPUyPU HqDIDRo9QcAwjCaYhgEAyAGEaZMmEYCGgkkJoNAQ0NAEYo0yU80RDI2U8p6agD0nqJKnyVYXVGge 7fgw6/ZgfEbkILNH3ew1Mq4WsN7qGyiTOQnz0xZ7IhuYih9FbpdHRwyk8bZV5ThPc4F9JicelRtO uFiSlwmsjCUnmgvRjH6GUT7zSKlBIgDPaoAIfIsg4jlLvLToDqDaDbG2MPd1JX0yc1JPFSOelJq6 7orMcx3e+wJUazwtNMBQYApyDcH1c5gwauvUoLQ5XWOPN4BgMrQ+rj9OXhmjDHEmDk4sP6tqxy9E yEadSKUUCi5s/UP6WR3HbXzntjKyOIHaYNlcW3U4QjOXQ+ATgVwdQMvBmiiUSE6cEnVh9T+o8oAa NN3iOV7q2jGyxM/NYrnyzSJWyiRiXXeLg4tu2FmOpq77Nixd3cFI8Ncu+lY0gjsG2xjGNvWoXY8O fybz6LrCxrtNHcreyBouiacIaqkiY5uNRrIh6Eg2n4ngYWLl+aCAMbVTyaBgCnK6jBUroDdGiPC3 o10K4an87HpIkrkKuZFpRLcFSlgdIPq8lgIvfaE6w1VimASDxIc4F1z8nnPDMYUkQCwcECRYmGck tZRFFQ7c9ExGoJxh62YyOFryiNxoZDLUOVdpkaIvQq2Iq4KJBaTMf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