From 34f2f8ea41726d98e50752ff3453ebde70912c35 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 1 Jun 2012 17:53:59 +0200 Subject: [PATCH] MDEV-256 lp:995501 - mysqltest attempts to parse Perl code inside a block with false condition, gets confused and throws wrong errors --- client/mysqltest.cc | 11 +++++++---- mysql-test/r/mysqltest_256.result | 1 + mysql-test/t/mysqltest_256.test | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 mysql-test/r/mysqltest_256.result create mode 100644 mysql-test/t/mysqltest_256.test diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 68f076818dd..8f955ff586b 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -8259,8 +8259,12 @@ int main(int argc, char **argv) command->abort_on_error= (command->expected_errors.count == 0 && abort_on_error); - /* delimiter needs to be executed so we can continue to parse */ - ok_to_do= cur_block->ok || command->type == Q_DELIMITER; + /* + some commmands need to be executed or at least parsed unconditionally, + because they change the grammar. + */ + ok_to_do= cur_block->ok || command->type == Q_DELIMITER + || command->type == Q_PERL; /* Some commands need to be "done" the first time if they may get re-iterated over in a true context. This can only happen if there's @@ -8271,8 +8275,7 @@ int main(int argc, char **argv) if (command->type == Q_SOURCE || command->type == Q_ERROR || command->type == Q_WRITE_FILE || - command->type == Q_APPEND_FILE || - command->type == Q_PERL) + command->type == Q_APPEND_FILE) { for (struct st_block *stb= cur_block-1; stb >= block_stack; stb--) { diff --git a/mysql-test/r/mysqltest_256.result b/mysql-test/r/mysqltest_256.result new file mode 100644 index 00000000000..043c7208382 --- /dev/null +++ b/mysql-test/r/mysqltest_256.result @@ -0,0 +1 @@ +# Done diff --git a/mysql-test/t/mysqltest_256.test b/mysql-test/t/mysqltest_256.test new file mode 100644 index 00000000000..fd9447cd2d8 --- /dev/null +++ b/mysql-test/t/mysqltest_256.test @@ -0,0 +1,17 @@ +# +# MDEV-256 lp:995501 - mysqltest attempts to parse Perl code inside a block +# with false condition, gets confused and throws wrong errors +# + +let $run = 0; +if ($run) +{ + --perl + foreach (1) + { + print "In perl\n"; + } + EOF + SELECT 1; +} +--echo # Done