Bug #66891 how to create queries log for prepared statement in mysql
Submitted: 20 Sep 2012 13:56 Modified: 20 Oct 2012 20:10
Reporter: Devashish Chourey Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Tracing Severity:S3 (Non-critical)
Version:1 OS:Any
Assigned to: CPU Architecture:Any
Tags: how to create log queries for prepared statement in mysql.

[20 Sep 2012 13:56] Devashish Chourey
Description:
how to create log queries for prepared statement in mysql.

How to repeat:
For Prepared Statement unable to log "long_query_time" in mysql-slow.log file using below setting :
In file my.cnf, [mysqld] section - add:

log_slow_queries=/var/log/mysql/mysql-slow.log
# log queries that took more than 1 sec
long_query_time = 1

Suggested fix:
Please suggest how we can log long queries in log file.
[20 Sep 2012 20:10] Sveta Smirnova
Thank you for the report.

I either can not repeat described behavior or don't get what you mean.

Here is my slow query log content.

Version 5.5:

/home/sveta/src/mysql-5.5/sql/mysqld, Version: 5.5.29-debug-log (Source distribution). started with:
Tcp port: 13000  Unix socket: /home/sveta/src/mysql-5.5/mysql-test/var/tmp/mysqld.1.sock
Time                 Id Command    Argument
# Time: 120920 23:09:28
# User@Host: root[root] @ localhost []
# Query_time: 10.000216  Lock_time: 0.000000 Rows_sent: 1  Rows_examined: 0
use test;
SET timestamp=1348171768;
select sleep(10);
# Time: 120920 23:09:33
# User@Host: root[root] @ localhost []
# Query_time: 5.000210  Lock_time: 0.000000 Rows_sent: 1  Rows_examined: 0
SET timestamp=1348171773;
select sleep(5);

Version 5.1:

/home/sveta/src/mysql-5.1/sql/mysqld, Version: 5.1.67-debug-log (Source distribution). started with:
Tcp port: 13000  Unix socket: /home/sveta/src/mysql-5.1/mysql-test/var/tmp/mysqld.1.sock
Time                 Id Command    Argument
# Time: 120920 23:10:17
# User@Host: root[root] @ localhost []
# Query_time: 10.000517  Lock_time: 0.000000 Rows_sent: 1  Rows_examined: 0
use test;
SET timestamp=1348171817;
select sleep(10);
# Time: 120920 23:10:22
# User@Host: root[root] @ localhost []
# Query_time: 5.000447  Lock_time: 0.000000 Rows_sent: 1  Rows_examined: 0
SET timestamp=1348171822;
select sleep(5);

I prepared and executed this:

prepare p2 from 'select sleep(?)';
set @a=10;
execute p2 using @a;
set @a=5;
execute p2 using @a;

Please explain what is wrong here.
[21 Oct 2012 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".