Bug #21557 entries in the general query log truncated at 1000 characters.
Submitted: 10 Aug 2006 3:01 Modified: 23 Oct 2007 0:18
Reporter: Hsing-Tsu Lai Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Logging Severity:S2 (Serious)
Version:5.1.11 OS:Any (NA)
Assigned to: Davi Arnaut CPU Architecture:Any
Tags: 5.1 regression, bfsm_2007_10_18

[10 Aug 2006 3:01] Hsing-Tsu Lai
Description:
See details at
http://forums.mysql.com/read.php?35,105413,105413#msg-105413

How to repeat:
See above
[10 Aug 2006 3:06] Dean Ellis
Verified in 5.1.12-bk, though it's not 1000 bytes:

Breakpoint 1, Log_to_csv_event_handler::log_general (this=0x199ea10,
    event_time=1155179330,
    user_host=0x4410a2d0 "dellis[dellis] @ localhost []", user_host_len=29,
    thread_id=2, command_type=0xb2cd95 "Query", command_type_len=5,
    sql_text=0x44109ed0 "select 1 a union all select 1 a union all select 1 a union all select 1 a union all select 1 a union all select 1 a union all select 1 a union all select 1 a union all select 1 a union all select 1 a "...,
    sql_text_len=1022, client_cs=0xf02fa0) at log.cc:306
[15 Aug 2006 21:59] J Rabbit
I just thought I'd add, the main impact of this is it is no longer possible to cut & paste queries from the log to EXPLAIN them making it much harder to diagnose performance issues as a DBA.
[18 Jan 2007 19:05] Konstantin Osipov
Suggested fix: push down the formatting of the SQL text from LOGGER::general_log_print to the specific log handler. In this case, when using a file, we can bypass any intermediate buffers and format the message at the same time when writing it into the file (by means of  fprintf).
Alternatively, we could have another general_log_print function that doesn't perform any formatting and writes the given message directly to the file.
[10 Aug 2007 11:13] Cyril SCETBON
I'm using the last beta version (5.1.20) and got the same behaviour. 
Can we force the write of the long queries ?
[19 Sep 2007 20:22] Harrison Fisk
Both the mysql.slow_log and mysql.general_log have a mediumtext type for the argument or sql_text.  

Why would it be necessary to truncate to 1022 characters for either file or log table?  

Seems like the correct fix would be to log the full query in all cases.
[15 Oct 2007 13:01] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/35559

ChangeSet@1.2599, 2007-10-15 11:01:18-03:00, davi@moksha.com.br +8 -0
  Bug#21557 entries in the general query log truncated at 1000 characters.
  
  The general log write function (general_log_print) uses printf style
  arguments which need to be pre-processed, meaning that the all arguments
  are copied to a single buffer and the problem is that the buffer size is
  constant (1022 characters) but queries can be much larger then this.
  
  The solution is to introduce a new log write function that accepts a
  buffer and it's length as arguments. The function is to be used when
  a formatted output is not required, which is the case for almost all
  query write-to-log calls.
[15 Oct 2007 18:57] Konstantin Osipov
Marc shall review and give final approval of the patch.
[16 Oct 2007 11:06] Valeriy Kravchuk
This bug will be discussed by our Bugs Fix Priorities Steering Committee on October 18th, 2007.
[18 Oct 2007 14:49] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/35850

ChangeSet@1.2599, 2007-10-18 12:47:48-03:00, davi@moksha.com.br +9 -0
  Bug#21557 entries in the general query log truncated at 1000 characters.
  
  The general log write function (general_log_print) uses printf style
  arguments which need to be pre-processed, meaning that the all arguments
  are copied to a single buffer and the problem is that the buffer size is
  constant (1022 characters) but queries can be much larger then this.
  
  The solution is to introduce a new log write function that accepts a
  buffer and it's length as arguments. The function is to be used when
  a formatted output is not required, which is the case for almost all
  query write-to-log calls.
  
  This is a incompatible change with respect to the log format of prepared
  statements.
[18 Oct 2007 17:51] Davi Arnaut
Pushed into mysql-5.1-runtime
[19 Oct 2007 18:53] Bugs System
Pushed into 5.1.23-beta
[23 Oct 2007 0:18] Paul DuBois
Noted in 5.1.23 changelog.