SET STATEMENT incorrectly works on second prepared statement execution

Bug #1333650 reported by Oleksandr "Sanja" Byelkin on 2014-06-24
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Server
Status tracked in 5.7
5.5
Undecided
Unassigned
5.6
High
Unassigned
5.7
High
Unassigned

Bug Description

Here is a test suite:

set session binlog_format=mixed;
PREPARE stmt1 FROM 'set statement binlog_format=row for SELECT @@binlog_format';
execute stmt1;
execute stmt1;
deallocate prepare stmt1;

Result of the execution is:

set session binlog_format=mixed;
PREPARE stmt1 FROM 'set statement binlog_format=row for SELECT @@binlog_format';
execute stmt1;
@@binlog_format
ROW
execute stmt1;
@@binlog_format
MIXED
deallocate prepare stmt1;

I forgot to mention that it is 5.6 server

Thank you for the problem report. It's easy to confirm:

[openxs@centos ~]$ mysql -uroot test
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.17-66.0 Percona Server (GPL), Release 66.0, Revision 608

Copyright (c) 2009-2014 Percona LLC and/or its affiliates
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set session binlog_format=mixed;
Query OK, 0 rows affected (0.00 sec)

mysql> PREPARE stmt1 FROM 'set statement binlog_format=row for SELECT @@binlog_format';
Query OK, 0 rows affected (0.00 sec)
Statement prepared

mysql> execute stmt1;
+-----------------+
| @@binlog_format |
+-----------------+
| ROW |
+-----------------+
1 row in set (0.00 sec)

mysql> execute stmt1;
+-----------------+
| @@binlog_format |
+-----------------+
| MIXED |
+-----------------+
1 row in set (0.00 sec)

mysql> deallocate prepare stmt1;
Query OK, 0 rows affected (0.00 sec)

It is how to fix it:
    while ((var=(set_var *)it++))
    {
      var->var->stmt_update(thd);
    }

    //thd->lex->set_statement= false;
  }

tags: added: set-statement
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers